MPM controlled 16ch RGB LED dimmer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6KB

  1. # ############################
  2. PRG = rgb16mpm
  3. MCU_TARGET = atmega32
  4. # ############################
  5. BUILD_DIR = build
  6. SRC = $(wildcard *.c)
  7. OUTPUTS = .hex .bin _eeprom.hex _eeprom.bin
  8. CFLAGS = -Os -g -Wall -mmcu=$(MCU_TARGET)
  9. CFLAGS += -pipe -MMD -MP -MG -MF $(BUILD_DIR)/$(*D)/$(*F).d
  10. LDFLAGS = -Wl,-Map,$(BUILD_DIR)/$(*D)/$(*F).map,--cref
  11. CC = avr-gcc
  12. OBJCOPY = avr-objcopy
  13. OBJDUMP = avr-objdump
  14. SIZE = avr-size
  15. # ############################
  16. .PHONY: all clean install
  17. all: $(patsubst %,$(BUILD_DIR)/$(PRG)%, .elf $(OUTPUTS))
  18. @$(SIZE) -x -A $<
  19. .SECONDARY: $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
  20. $(BUILD_DIR)/%.elf: $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
  21. @echo " Linking file: $@"
  22. @$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
  23. @$(OBJDUMP) -h -S $@ > $(subst elf,lst,$@)
  24. $(BUILD_DIR)/%.o: %.c $(MAKEFILE_LIST)
  25. @echo " Building file: $<"
  26. @$(shell test -d $(BUILD_DIR)/$(*D) || mkdir -p $(BUILD_DIR)/$(*D))
  27. @$(CC) $(CFLAGS) -o $@ -c $<
  28. $(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf
  29. @$(OBJCOPY) -j .text -j .data -O ihex $< $@
  30. $(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
  31. @$(OBJCOPY) -j .text -j .data -O binary $< $@
  32. $(BUILD_DIR)/%_eeprom.hex: $(BUILD_DIR)/%.elf
  33. @$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
  34. $(BUILD_DIR)/%_eeprom.bin: $(BUILD_DIR)/%.elf
  35. @$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
  36. include $(shell find $(BUILD_DIR) -name \*.d 2> /dev/null)
  37. # ############################
  38. clean:
  39. rm -rf $(BUILD_DIR)
  40. install: $(BUILD_DIR)/$(PRG).hex
  41. # avrdude -p m32 -c dragon_isp -P usb -U flash:w:$(PRG).hex
  42. mpmboot -d /dev/ttyUSB0 -a 0x11 -w flash:$<