3 SRC=main.c logging.c pwm.c adc.c pwmled.c pattern.c buttons.c control.c \
10 AVRDUDE_PROGRAMMER=usbasp
12 CFLAGS=-Wall -Os -mmcu=$(MCU) -DUSE_LOGGING=1 -DF_CPU=1000000UL -std=gnu99
14 AVRDUDE_FLAGS= -p$(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
23 all: $(PROGRAM).hex $(PROGRAM).eep
25 program: $(PROGRAM).hex $(PROGRAM).eep
26 $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i -U eeprom:w:$(PROGRAM).eep:i
28 program_flash: $(PROGRAM).hex
29 $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i
31 program_eeprom: $(PROGRAM).eep
32 $(AVRDUDE) $(AVRDUDE_FLAGS) eeprom:w:$(PROGRAM).eep:i
35 $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:r:eeprom.raw:r
38 objdump: $(PROGRAM).elf
39 $(OBJDUMP) --disassemble $<
41 .PRECIOUS : $(OBJ) $(PROGRAM).elf
44 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
47 $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
48 --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
51 $(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
53 %.o: %.c lights.h Makefile
54 $(CC) -c $(CFLAGS) $< -o $@
56 %.s: %.c lights.h Makefile
57 $(CC) -S -c $(CFLAGS) $< -o $@
60 $(CC) -c $(CFLAGS) $< -o $@
63 rm -f $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf *.o *.s eeprom.raw
65 .PHONY: all clean dump_eeprom program program_flash program_eeprom objdump