summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2016-02-05 20:09:18 -0500
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2016-02-05 20:09:18 -0500
commita97282bd712e8643a9a66016798025ccd0cf9a3e (patch)
tree5f82592b602762e46880974e360148644468a9ff
Add blink example.
-rw-r--r--blink/Makefile16
-rw-r--r--blink/blink.c15
2 files changed, 31 insertions, 0 deletions
diff --git a/blink/Makefile b/blink/Makefile
new file mode 100644
index 0000000..890a892
--- /dev/null
+++ b/blink/Makefile
@@ -0,0 +1,16 @@
+PROJECT=blink
+SOURCES=$(PROJECT).c
+MMCU=attiny85
+F_CPU = 1000000
+
+CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU)
+
+$(PROJECT).hex: $(PROJECT).out
+ avr-objcopy -O ihex $(PROJECT).out $(PROJECT).c.hex;\
+ avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out
+
+$(PROJECT).out: $(SOURCES)
+ avr-gcc $(CFLAGS) -I./ -o $(PROJECT).out $(SOURCES)
+
+program: $(PROJECT).hex
+ avrdude -p $(MMCU) -c avrisp -P /dev/ttyUSB0 -b 19200 -U flash:w:$(PROJECT).c.hex
diff --git a/blink/blink.c b/blink/blink.c
new file mode 100644
index 0000000..5006606
--- /dev/null
+++ b/blink/blink.c
@@ -0,0 +1,15 @@
+#include <avr/io.h>
+#include <util/delay.h>
+
+int main(void) {
+ DDRB |= _BV(PB1);
+ while (1) {
+ PORTB |= (1<<2);
+ PORTB &= ~(1<<3);
+ _delay_ms(500);
+ PORTB &= ~(1<<2);
+ PORTB |= (1<<3);
+ _delay_ms(500);
+ }
+ return 0;
+}