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.
112 lines
2.7 KiB
112 lines
2.7 KiB
# https://github.com/jkent/caterina-promicro
|
|
|
|
MCU = atmega328p
|
|
F_CPU = 16000000
|
|
|
|
# AVRDUDE settings
|
|
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/libssd1306/src -Ilib/porklib
|
|
|
|
LIB_SOURCES =
|
|
#LIB_SOURCES += lib/porklib/uart.c
|
|
#LIB_SOURCES += lib/porklib/uart.c
|
|
LIB_SOURCES += lib/porklib/iopins.c
|
|
#LIB_SOURCES += lib/porklib/stream.c
|
|
LIB_SOURCES += lib/porklib/adc.c
|
|
#LIB_SOURCES += lib/porklib/dht11.c
|
|
#LIB_SOURCES += lib/porklib/sonar.c
|
|
#LIB_SOURCES += lib/porklib/onewire.c
|
|
#LIB_SOURCES += lib/porklib/spi.c
|
|
#LIB_SOURCES += lib/porklib/sd.c
|
|
#LIB_SOURCES += lib/porklib/fat16.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
|
|
#-Llib/libssd1306/bld/ -l:libssd1306.a
|
|
|
|
# CFLAGS += -lm ## Math
|
|
# CFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf
|
|
# CFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
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) $<
|
|
|
|
# Build the display library
|
|
lib/libssd1306/bld/libssd1306.a:
|
|
$(MAKE) -C lib/libssd1306/ -f Makefile.avr MCU=atmega328p
|
|
|
|
$(TARGET).elf: $(OBJECTS) lib/libssd1306/bld/libssd1306.a | $(BUILD_DIR)
|
|
$(LD) $(CFLAGS) $(LFLAGS) -o $@ $^ lib/libssd1306/bld/libssd1306.a
|
|
|
|
%.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
|
|
|