|
|
@ -1,66 +1,99 @@ |
|
|
|
## === CPU settings ===
|
|
|
|
###################################
|
|
|
|
|
|
|
|
# Makefile for MightyPork/avr-lib #
|
|
|
|
|
|
|
|
# Revision 3 #
|
|
|
|
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## ===== CPU settings =====
|
|
|
|
|
|
|
|
|
|
|
|
# CPU type
|
|
|
|
# CPU type
|
|
|
|
MCU = atmega328p
|
|
|
|
MCU = atmega328p
|
|
|
|
|
|
|
|
|
|
|
|
# CPU frequency
|
|
|
|
# CPU frequency
|
|
|
|
F_CPU = 16000000
|
|
|
|
F_CPU = 16000000
|
|
|
|
|
|
|
|
|
|
|
|
# Fuses
|
|
|
|
# Fuses
|
|
|
|
LFUSE = 0xFF
|
|
|
|
LFUSE = 0xFF
|
|
|
|
HFUSE = 0xDE
|
|
|
|
HFUSE = 0xDE
|
|
|
|
EFUSE = 0x05
|
|
|
|
EFUSE = 0x05
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OPTIMIZE = s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## ===== Source files =====
|
|
|
|
|
|
|
|
|
|
|
|
## === Source files ===
|
|
|
|
|
|
|
|
# Main C file
|
|
|
|
# Main C file
|
|
|
|
MAIN = main.c
|
|
|
|
MAIN = main.c
|
|
|
|
# Extra C files in this folder
|
|
|
|
|
|
|
|
LOCAL_SOURCE =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Library directory (with C files)
|
|
|
|
|
|
|
|
EXTRA_SOURCE_DIR = lib/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Library directory (with C and H files)
|
|
|
|
|
|
|
|
LIB_DIR = lib/
|
|
|
|
|
|
|
|
|
|
|
|
# C files in the library directory
|
|
|
|
# C files in the library directory
|
|
|
|
EXTRA_SOURCE_FILES = uart.c iopins.c stream.c adc.c dht11.c sonar.c onewire.c spi.c sd.c fat16.c
|
|
|
|
LIB_C_FILES = uart.c iopins.c stream.c adc.c dht11.c sonar.c onewire.c spi.c sd.c sd_blockdev.c fat16.c sd_fat.c
|
|
|
|
#Files that need config file:
|
|
|
|
|
|
|
|
# EXTRA_SOURCE_FILES += lcd.c
|
|
|
|
# Extra Files that need config file:
|
|
|
|
# EXTRA_SOURCE_FILES += color.c wsrgb.c
|
|
|
|
|
|
|
|
# EXTRA_SOURCE_FILES += debouce.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#LIB_C_FILES += lcd.c
|
|
|
|
|
|
|
|
#LIB_C_FILES += color.c wsrgb.c
|
|
|
|
|
|
|
|
#LIB_C_FILES += debouce.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LIB_H_FILES = adc.h calc.h dht11.h fat16.h fat16_internal.h iopins.h nsdelay.h onewire.h
|
|
|
|
|
|
|
|
LIB_H_FILES += sd.h sd_blockdev.h sd_fat.h blockdev.h sonar.h spi.h stream.h uart.h
|
|
|
|
|
|
|
|
LIB_H_FILES += lcd.h color.h wsrgb.h debounce.h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## ===== Programmer =====
|
|
|
|
|
|
|
|
|
|
|
|
## === Programmer ===
|
|
|
|
|
|
|
|
PROGRAMMER_TYPE = arduino
|
|
|
|
PROGRAMMER_TYPE = arduino
|
|
|
|
PROGRAMMER_ARGS = -b 57600 -P /dev/ttyUSB0
|
|
|
|
PROGRAMMER_ARGS = -b 57600 -P /dev/ttyUSB0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## === C flags ===
|
|
|
|
## ===== C flags =====
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -I. -I$(LIB_DIR)
|
|
|
|
|
|
|
|
CFLAGS += -funsigned-char
|
|
|
|
|
|
|
|
CFLAGS += -funsigned-bitfields
|
|
|
|
|
|
|
|
CFLAGS += -fpack-struct
|
|
|
|
|
|
|
|
CFLAGS += -fshort-enums
|
|
|
|
|
|
|
|
CFLAGS += -finline-functions
|
|
|
|
|
|
|
|
CFLAGS += -ffunction-sections
|
|
|
|
|
|
|
|
CFLAGS += -fdata-sections
|
|
|
|
|
|
|
|
CFLAGS += -Wall
|
|
|
|
|
|
|
|
CFLAGS += -Wextra
|
|
|
|
|
|
|
|
CFLAGS += -Wno-main
|
|
|
|
|
|
|
|
CFLAGS += -Wno-comment
|
|
|
|
|
|
|
|
CFLAGS += -Wno-unused-but-set-variable
|
|
|
|
|
|
|
|
CFLAGS += -Wfatal-errors
|
|
|
|
|
|
|
|
CFLAGS += -Wl,--gc-sections
|
|
|
|
|
|
|
|
CFLAGS += -Wl,--relax
|
|
|
|
|
|
|
|
CFLAGS += -Wl,--relax
|
|
|
|
|
|
|
|
|
|
|
|
CFLAGS = -std=gnu99 -mmcu=$(MCU) -DF_CPU=$(F_CPU)UL -I. -I$(EXTRA_SOURCE_DIR)
|
|
|
|
#CFLAGS += -lm ## Math
|
|
|
|
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
|
|
|
#CFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## Floating-point printf
|
|
|
|
CFLAGS += -Wall -Wno-main -Wno-strict-prototypes -Wno-comment
|
|
|
|
#CFLAGS += -Wl,-u,vfprintf -lprintf_min ## Smaller printf
|
|
|
|
CFLAGS += -g2 -Wextra -Wfatal-errors -Wno-unused-but-set-variable
|
|
|
|
|
|
|
|
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,--relax
|
|
|
|
CFLAGS_BUILD = $(CFLAGS) -O$(OPTIMIZE)
|
|
|
|
# CFLAGS += -lm ## Math
|
|
|
|
|
|
|
|
# CFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm ## for floating-point printf
|
|
|
|
|
|
|
|
# CFLAGS += -Wl,-u,vfprintf -lprintf_min ## for smaller printf
|
|
|
|
|
|
|
|
CFLAGS_BUILD = $(CFLAGS) -Os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
# ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Defined programs / locations
|
|
|
|
## Defined programs / locations
|
|
|
|
CC = avr-gcc
|
|
|
|
CC = avr-gcc
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
OBJCOPY = avr-objcopy
|
|
|
|
OBJDUMP = avr-objdump
|
|
|
|
OBJDUMP = avr-objdump
|
|
|
|
AVRSIZE = avr-size
|
|
|
|
AVRSIZE = avr-size
|
|
|
|
AVRDUDE = avrdude
|
|
|
|
AVRDUDE = avrdude
|
|
|
|
|
|
|
|
UART_TERM = gtkterm -p /dev/ttyUSB0
|
|
|
|
|
|
|
|
|
|
|
|
## === File lists ===
|
|
|
|
## === File lists ===
|
|
|
|
TARGET = $(strip $(basename $(MAIN)))
|
|
|
|
TARGET = $(strip $(basename $(MAIN)))
|
|
|
|
SRC1 = $(TARGET).c
|
|
|
|
SRC1 = $(TARGET).c
|
|
|
|
SRC = $(SRC1)
|
|
|
|
SRC = $(SRC1)
|
|
|
|
EXTRA_SOURCE = $(addprefix $(EXTRA_SOURCE_DIR), $(EXTRA_SOURCE_FILES))
|
|
|
|
EXTRA_SOURCE = $(addprefix $(LIB_DIR), $(LIB_C_FILES))
|
|
|
|
|
|
|
|
LIB_H_FILES_FILES = $(addprefix $(LIB_DIR), $(LIB_H_FILES))
|
|
|
|
SRC += $(EXTRA_SOURCE)
|
|
|
|
SRC += $(EXTRA_SOURCE)
|
|
|
|
SRC += $(LOCAL_SOURCE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HEADERS = $(SRC:.c=.h)
|
|
|
|
HEADERS = $(SRC:.c=.h)
|
|
|
|
OBJ = $(SRC:.c=.o)
|
|
|
|
OBJ = $(SRC:.c=.o)
|
|
|
@ -73,7 +106,7 @@ pre: $(TARGET).pre |
|
|
|
%.hex: %.elf |
|
|
|
%.hex: %.elf |
|
|
|
$(OBJCOPY) -R .eeprom -O ihex $< $@
|
|
|
|
$(OBJCOPY) -R .eeprom -O ihex $< $@
|
|
|
|
|
|
|
|
|
|
|
|
%.elf: $(SRC) |
|
|
|
%.elf: $(SRC) $(LIB_H_FILES_FILES) Makefile |
|
|
|
$(CC) $(CFLAGS_BUILD) $(SRC) --output $@
|
|
|
|
$(CC) $(CFLAGS_BUILD) $(SRC) --output $@
|
|
|
|
|
|
|
|
|
|
|
|
%.pre: $(SRC1) |
|
|
|
%.pre: $(SRC1) |
|
|
@ -131,7 +164,7 @@ shell: |
|
|
|
fser: all flash ser |
|
|
|
fser: all flash ser |
|
|
|
|
|
|
|
|
|
|
|
ser: |
|
|
|
ser: |
|
|
|
gtkterm -p /dev/ttyUSB0
|
|
|
|
$(UART_TERM)
|
|
|
|
|
|
|
|
|
|
|
|
# === fuses ===
|
|
|
|
# === fuses ===
|
|
|
|
|
|
|
|
|
|
|
|