]> www.fi.muni.cz Git - bike-lights.git/commitdiff
Initial import
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 8 Jun 2012 14:00:09 +0000 (16:00 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Fri, 8 Jun 2012 14:00:09 +0000 (16:00 +0200)
.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
lights.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..15168b4
--- /dev/null
@@ -0,0 +1,4 @@
+*.eep
+*.hex
+*.elf
+*.o
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..227e395
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,52 @@
+
+
+PROGRAM=lights
+SRC=lights.c
+OBJ=$(SRC:.c=.o)
+
+MCU=attiny861a
+# AVRDUDE_MCU=$(MCU)
+AVRDUDE_MCU=attiny861
+AVRDUDE_PROGRAMMER=usbasp
+
+CFLAGS=-Os -mmcu=$(MCU)
+LDFLAGS=
+AVRDUDE_FLAGS= -p$(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
+
+FORMAT=ihex
+
+CC=avr-gcc
+OBJCOPY=avr-objcopy
+AVRDUDE=avrdude
+
+all: $(PROGRAM).hex $(PROGRAM).eep
+
+program: $(PROGRAM).hex $(PROGRAM).eep
+       $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i -U eeprom:w:$(PROGRAM).eep:i
+
+.PRECIOUS : $(OBJ) $(PROGRAM).elf
+
+%.hex: %.elf
+       $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+       $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+               --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+%.elf: $(OBJ)
+       $(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
+
+%.o: %.c
+       $(CC) -c $(CFLAGS) $< -o $@
+
+%.s: %.c
+       $(CC) -S -c $(CFLAGS) $< -o $@
+
+%.o: %.S
+       $(CC) -c $(CFLAGS) $< -o $@
+
+clean:
+       rm -f $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf *.o *.s
+
+.PHONY: all clean
+
diff --git a/lights.c b/lights.c
new file mode 100644 (file)
index 0000000..18eef18
--- /dev/null
+++ b/lights.c
@@ -0,0 +1,13 @@
+#include <avr/io.h>
+#include <util/delay.h>
+
+int main(void)
+{
+    DDRA |= _BV( PA0 );
+    while( 1 ) { 
+        PORTA |=  _BV( PA0 );
+        _delay_ms(2000);
+        PORTA &=~ _BV( PA0 );
+        _delay_ms(2000);
+    }
+}