AVR based RC5 decoder (subwoofer-switch)
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.
 
 

54 lines
1.8 KiB

  1. CC := avr-gcc
  2. LD := avr-ld
  3. OBJCOPY := avr-objcopy
  4. OBJDUMP := avr-objdump
  5. SIZE := avr-size
  6. TARGET = rc5switch
  7. SOURCE = $(wildcard *.c)
  8. BUILD_DIR = build
  9. AVRDUDE_PROG := -c avr910 -b 115200 -P /dev/ispprog
  10. #AVRDUDE_PROG := -c dragon_isp -P usb
  11. MCU = attiny24
  12. AVRDUDE_MCU=t24
  13. # no self programming, 2.7V BOD, 8MHz internal RC Osz.
  14. AVRDUDE_FUSES=lfuse:w:0xc2:m hfuse:w:0xdd:m efuse:w:0xff:m
  15. # ---------------------------------------------------------------------------
  16. CFLAGS = -pipe -g -Os -mmcu=$(MCU) -Wall -fdata-sections -ffunction-sections
  17. CFLAGS += -Wa,-adhlns=$(BUILD_DIR)/$(*D)/$(*F).lst -MMD -MP -MF $(BUILD_DIR)/$(*D)/$(*F).d
  18. LDFLAGS = -Wl,-Map,$(@:.elf=.map),--cref,--relax,--gc-sections
  19. # ---------------------------------------------------------------------------
  20. $(TARGET): $(BUILD_DIR)/$(TARGET).elf
  21. @$(SIZE) -B -x --mcu=$(MCU) $<
  22. $(BUILD_DIR)/$(TARGET).elf: $(patsubst %,$(BUILD_DIR)/%,$(SOURCE:.c=.o))
  23. @echo " Linking file: $@"
  24. @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
  25. @$(OBJDUMP) -h -S $@ > $(@:.elf=.lss)
  26. @$(OBJCOPY) -j .text -j .data -O ihex $@ $(@:.elf=.hex)
  27. @$(OBJCOPY) -j .text -j .data -O binary $@ $(@:.elf=.bin)
  28. @$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $@ $(@:.elf=_eeprom.hex)
  29. @$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $@ $(@:.elf=_eeprom.bin)
  30. $(BUILD_DIR)/%.o: %.c $(MAKEFILE_LIST)
  31. @echo " Building file: $<"
  32. @$(shell test -d $(BUILD_DIR)/$(*D) || mkdir -p $(BUILD_DIR)/$(*D))
  33. @$(CC) $(CFLAGS) -o $@ -c $<
  34. include $(shell find $(BUILD_DIR) -name \*.d 2> /dev/null)
  35. clean:
  36. rm -rf $(BUILD_DIR)
  37. install: $(BUILD_DIR)/$(TARGET).elf
  38. avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) -U flash:w:$(<:.elf=.hex) -U eeprom:w:$(<:.elf=_eeprom.hex)
  39. fuses:
  40. avrdude $(AVRDUDE_PROG) -p $(AVRDUDE_MCU) $(patsubst %,-U %, $(AVRDUDE_FUSES))