diff --git a/templates/no-ide/.gitignore b/templates/no-ide/.gitignore new file mode 100644 index 0000000..a39790f --- /dev/null +++ b/templates/no-ide/.gitignore @@ -0,0 +1,3 @@ +*.o +*.elf +*.hex diff --git a/templates/no-ide/Makefile b/templates/no-ide/Makefile new file mode 100644 index 0000000..f2d9257 --- /dev/null +++ b/templates/no-ide/Makefile @@ -0,0 +1,27 @@ +baud=57600 +avrType=atmega328p +avrFreq=16000000 # 16 Mhz +programmerDev=/dev/ttyUSB0 +programmerType=arduino + +cflags=-DF_CPU=$(avrFreq) -mmcu=$(avrType) -Wall -Werror -Wextra -Os +objects=$(patsubst %.c,%.o,$(wildcard *.c)) + +.PHONY: flash clean + +all: main.hex + +%.o: %.c + avr-gcc $(cflags) -c $< -o $@ + +main.elf: $(objects) + avr-gcc $(cflags) -o $@ $^ + +main.hex: main.elf + avr-objcopy -j .text -j .data -O ihex $^ $@ + +flash: main.hex + avrdude -p$(avrType) -c$(programmerType) -P$(programmerDev) -b$(baud) -v -U flash:w:$< + +clean: + rm -f main.hex main.elf $(objects) diff --git a/templates/no-ide/README b/templates/no-ide/README new file mode 100644 index 0000000..1d5fb84 --- /dev/null +++ b/templates/no-ide/README @@ -0,0 +1,6 @@ +You don't need the Arduino IDE, you can simply use a Makefile and write your +C code as long as you have avr-gcc, avr-libc and avrdude installed! + +make # compile and generate main.hex +make flash # flash it to the Arduino nano + diff --git a/templates/no-ide/hello.c b/templates/no-ide/hello.c new file mode 100644 index 0000000..ec67b0c --- /dev/null +++ b/templates/no-ide/hello.c @@ -0,0 +1,14 @@ +#include +#include + +#define LED PORTB5 + +int main(void) { + DDRB |= (1 << LED); + for/*ever*/(;;) { + PORTB |= (1 << LED); + _delay_ms(100); + PORTB &= (0 << LED); + _delay_ms(100); + } +}