commit 420b7d6591a89b8d3f4446ef19cef2c8548a4380 Author: Jan Philipp Timme Date: Sat Mar 9 12:50:49 2019 +0100 Initial import diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..912a953 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.hex +*.elf +*.o + diff --git a/blink.c b/blink.c new file mode 100644 index 0000000..217b660 --- /dev/null +++ b/blink.c @@ -0,0 +1,17 @@ +#include + +#define F_CPU 20000000UL +#include + +int main() { + DDRB |= 1; + + while(1) { + PORTB |= 1; + _delay_ms(50); + PORTB &= ~1; + _delay_ms(950); + } + + return 1; +} diff --git a/buildandupload.sh b/buildandupload.sh new file mode 100755 index 0000000..36deca6 --- /dev/null +++ b/buildandupload.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Cleanup +rm -vf *.o *.elf *.hex + +# Compile +/home/jpt/arduino-1.8.8/hardware/tools/avr/bin/avr-gcc -c -mmcu=atmega328p blink.c + +# Link +/home/jpt/arduino-1.8.8/hardware/tools/avr/bin/avr-gcc -g -mmcu=atmega328p blink.o -o blink.elf + +# Convert hex +/home/jpt/arduino-1.8.8/hardware/tools/avr/bin/avr-objcopy -j .text -j .data -O ihex blink.elf blink.hex + +# Upload +avrdude -P /dev/ttyUSB0 -c arduino -p m328p -b 19200 -U flash:w:blink.hex