From 420b7d6591a89b8d3f4446ef19cef2c8548a4380 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 9 Mar 2019 12:50:49 +0100 Subject: [PATCH] Initial import --- .gitignore | 4 ++++ blink.c | 17 +++++++++++++++++ buildandupload.sh | 16 ++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 .gitignore create mode 100644 blink.c create mode 100755 buildandupload.sh 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