neopixel strip demo with two buttons and a speaker
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.
atmega-demo/Makefile

95 lines
2.1 KiB

2 years ago
# https://github.com/jkent/caterina-promicro
MCU = atmega328p
F_CPU = 16000000
# AVRDUDE settings # 57600
PROG_BAUD = 57600
PROG_DEV = /dev/ttyUSB0
PROG_TYPE = arduino
# Build the final AVRDUDE arguments
PROG_ARGS = -c $(PROG_TYPE) -p $(MCU) -b $(PROG_BAUD) -P $(PROG_DEV)
INCFLAGS += -Isrc/ -Ilib/porklib/
LIB_SOURCES =
LIB_SOURCES += lib/porklib/iopins.c
LIB_SOURCES += lib/porklib/wsrgb.c
LIB_SOURCES += lib/porklib/color.c
CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wno-main -Wno-strict-prototypes -Wno-comment
CFLAGS += -g2 -Wextra -Wfatal-errors -Wno-unused-but-set-variable
CFLAGS += -ffunction-sections -fdata-sections -Os -Wno-array-bounds
LFLAGS = -Wl,--gc-sections -Wl,--relax
# ---------------------------------------------------------------------------
APP = App
SRC_DIR = src
BUILD_DIR = build
## Defined programs / locations
CC = avr-gcc
LD = avr-gcc
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRSIZE = avr-size
AVRDUDE = avrdude
SOURCES=$(wildcard $(SRC_DIR)/*.c) $(LIB_SOURCES)
OBJECTS=$(SOURCES:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
DEPENDS=$(BUILD_DIR)/.depends
TARGET=$(BUILD_DIR)/$(APP)
.PHONY: all clean eeprom size
all: $(TARGET).hex size
debug:
@echo "SOURCES $(SOURCES)"
@echo "OBJECTS $(OBJECTS)"
@echo "TARGET $(TARGET)"
eeprom: $(TARGET).eeprom
size: $(TARGET).elf
$(AVRSIZE) -C --mcu=$(MCU) $<
$(TARGET).elf: $(OBJECTS) | $(BUILD_DIR)
$(LD) $(CFLAGS) $(INCFLAGS) $(LFLAGS) -o $@ $^
%.hex: %.elf
$(OBJCOPY) -R .eeprom -O ihex $< $@
%.eeprom: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) -c $(CFLAGS) $(INCFLAGS) -o $@ $<
$(DEPENDS): $(SOURCES) | $(BUILD_DIR)
$(CC) $(INCFLAGS) -MM $(SOURCES) | sed -e 's!^!$(BUILD_DIR)/!' >$@
$(BUILD_DIR):
mkdir -p $@
clean:
rm -rf $(BUILD_DIR)
## === avrdude ===
flash: $(TARGET).hex
$(AVRDUDE) $(PROG_ARGS) -U flash:w:$<
flashe: $(TARGET).eeprom
$(AVRDUDE) $(PROG_ARGS) -U eeprom:w:$<
shell:
$(AVRDUDE) $(PROG_ARGS) -nt