3 SRC=main.c logging.c adc.c pwm.c tmr.c pwmled.c gpio.c ambient.c pattern.c \
4 buttons.c battery.c control.c
11 AVRDUDE_PROGRAMMER=usbasp
13 CFLAGS=-Wall -Os -mmcu=$(MCU) -DUSE_LOGGING=1 -DF_CPU=1000000UL -std=gnu99
15 AVRDUDE_FLAGS= -p$(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER)
24 all: $(PROGRAM).hex $(PROGRAM).eep
26 program: $(PROGRAM).hex $(PROGRAM).eep
27 $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i -U eeprom:w:$(PROGRAM).eep:i
29 program_flash: $(PROGRAM).hex
30 $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(PROGRAM).hex:i
32 program_eeprom: $(PROGRAM).eep
33 $(AVRDUDE) $(AVRDUDE_FLAGS) eeprom:w:$(PROGRAM).eep:i
36 $(AVRDUDE) $(AVRDUDE_FLAGS) -U eeprom:r:eeprom.raw:r
39 objdump: $(PROGRAM).elf
40 $(OBJDUMP) --disassemble $<
42 .PRECIOUS : $(OBJ) $(PROGRAM).elf
45 $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
48 $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
49 --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
52 $(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS)
54 %.o: %.c lights.h Makefile
55 $(CC) -c $(CFLAGS) $< -o $@
57 %.s: %.c lights.h Makefile
58 $(CC) -S -c $(CFLAGS) $< -o $@
61 $(CC) -c $(CFLAGS) $< -o $@
64 rm -f $(PROGRAM).hex $(PROGRAM).eep $(PROGRAM).elf *.o *.s eeprom.raw
66 .PHONY: all clean dump_eeprom program program_flash program_eeprom objdump