From a1a714dddda8f8746fef69f5f8c517f2ba7e9e2f Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Fri, 8 Jun 2012 16:00:09 +0200 Subject: [PATCH] Initial import --- .gitignore | 4 ++++ Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lights.c | 13 +++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 lights.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..15168b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.eep +*.hex +*.elf +*.o diff --git a/Makefile b/Makefile new file mode 100644 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 index 0000000..18eef18 --- /dev/null +++ b/lights.c @@ -0,0 +1,13 @@ +#include +#include + +int main(void) +{ + DDRA |= _BV( PA0 ); + while( 1 ) { + PORTA |= _BV( PA0 ); + _delay_ms(2000); + PORTA &=~ _BV( PA0 ); + _delay_ms(2000); + } +} -- 2.39.3