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.

63 lines
1.7 KiB

11 years ago
TARGET = rc5switch
TARGET_MCU = attiny24
# ---------------------------------------------------------
BUILD = build
CC = avr-gcc
NM = avr-nm
SIZE = avr-size
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
override CFLAGS = -g -Wall -Os -mmcu=$(TARGET_MCU) -Wa,-gstabs,-adhlns=$(BUILD)/$(*D)/$(*F).lst -MMD -MP -MF $(BUILD)/$(*D)/$(*F).d -pipe
override LDFLAGS = -Wl,-Map=$(BUILD)/$(TARGET).map,--cref
# ---------------------------------------------------------
SRC := $(wildcard *.c)
all: $(addprefix $(BUILD)/$(TARGET), .elf .lss .sym .bin .hex _eeprom.bin _eeprom.hex)
# @$(SIZE) -x -C --mcu=$(TARGET_MCU) $<
%.lss: %.elf
@$(OBJDUMP) -h -S -C $< > $@
%.sym: %.elf
@$(NM) -n $< > $@
%.bin: %.elf
@$(OBJCOPY) -j .text -j .data -O binary $< $@
%.hex: %.elf
@$(OBJCOPY) -j .text -j .data -O ihex $< $@
%_eeprom.bin: %.elf
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ 2> /dev/null
%_eeprom.hex: %.elf
@$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ 2> /dev/null
$(BUILD)/$(TARGET).elf: $(patsubst %,$(BUILD)/%,$(SRC:.c=.o))
@echo " Linking file: $@"
@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) > /dev/null
@$(SIZE) -x -B $^ $@
$(BUILD)/%.o: %.c $(MAKEFILE_LIST)
@echo " Building file: $<"
@$(shell mkdir -p $(BUILD)/$(*D))
@$(CC) -c $(CFLAGS) $< -o $@
clean:
rm -rf $(BUILD)
install: $(BUILD)/$(TARGET).hex $(BUILD)/$(TARGET)_eeprom.hex
avrdude -c dragon_isp -P usb -p t24 -U flash:w:$(BUILD)/$(TARGET).hex -U eeprom:w:$(BUILD)/$(TARGET)_eeprom.hex
# no self programming, 2.7V BOD, 8MHz internal RC Osz.
fuses:
avrdude -c dragon_isp -P usb -p t24 -U lfuse:w:0xc2:m -U hfuse:w:0xdd:m -U efuse:w:0xff:m
-include $(shell find $(BUILD) -name *.d 2> /dev/null)