From 6bd429ede5c61419abe0319f0ee0f13f1cc2b70d Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 15 Sep 2022 01:01:08 +0200 Subject: [PATCH] init. works. --- Makefile | 25 +++++++++++++++++++++++++ README.md | 2 +- led.c | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 led.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5960bfe --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ + + + +MMCU=atmega32u4 +MMCU_DUDE=m32u4 +.PHONY: all clean + +all: flash + +compile: + avr-gcc -g -Os -mmcu=$(MMCU) -c led.c + +link: compile + avr-gcc -g -mmcu=$(MMCU) -o led.elf led.o + +assemble: link + avr-objcopy -j .text -j .data -O ihex led.elf led.hex + +flash: assemble + avrdude -p $(MMCU_DUDE) -c stk500 -P /dev/cu.usbserial-1220 -U flash:w:led.hex:i + +clean: + rm *.o + rm *.elf + rm *.hex diff --git a/README.md b/README.md index 76c765b..139597f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# 32u4-seq + diff --git a/led.c b/led.c new file mode 100644 index 0000000..0071928 --- /dev/null +++ b/led.c @@ -0,0 +1,18 @@ +#ifndef F_CPU +#define F_CPU 16000000UL // or whatever may be your frequency +#endif + +#include +//#include +#include // for _delay_ms() + +int main(void) { + DDRD = 0xff; + while (1) { + PORTD = 0xff; + _delay_ms(100); + + PORTD = 0x00; + _delay_ms(100); + } +}