summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile92
1 files changed, 18 insertions, 74 deletions
diff --git a/makefile b/makefile
index 640d80d..22224c0 100644
--- a/makefile
+++ b/makefile
@@ -1,18 +1,4 @@
-##########################################################################################################################
-# File automatically-generated by tool: [projectgenerator] version: [3.5.2] date: [Mon Mar 23 16:58:19 EDT 2020]
-##########################################################################################################################
-
-# ------------------------------------------------
-# Generic Makefile (based on gcc)
-#
-# ChangeLog :
-# 2017-02-10 - Several enhancements + project update mode
-# 2015-07-22 - first version
-# ------------------------------------------------
-
-######################################
-# target
-######################################
+# Target also determines which file is being compiled
TARGET = master
@@ -34,40 +20,16 @@ BUILD_DIR = build
######################################
# source
######################################
-# C sources
+# C sources for all ports
C_SOURCES = \
-src/main-master.c \
-src/stm32f4xx_it.c \
-src/stm32f4xx_hal_msp.c \
-src/system_stm32f4xx.c \
-src/pb_decode.c \
-src/pb_encode.c \
-src/pb_common.c \
+lib/nanopb/pb_decode.c \
+lib/nanopb/pb_encode.c \
+lib/nanopb/pb_common.c \
src/handshake.pb.c \
src/data.pb.c \
-lib/f4/stm32f4xx_hal_i2c.c \
-lib/f4/stm32f4xx_hal_i2c_ex.c \
-lib/f4/stm32f4xx_hal_rcc.c \
-lib/f4/stm32f4xx_hal_rcc_ex.c \
-lib/f4/stm32f4xx_hal_flash.c \
-lib/f4/stm32f4xx_hal_flash_ex.c \
-lib/f4/stm32f4xx_hal_flash_ramfunc.c \
-lib/f4/stm32f4xx_hal_gpio.c \
-lib/f4/stm32f4xx_hal_dma_ex.c \
-lib/f4/stm32f4xx_hal_dma.c \
-lib/f4/stm32f4xx_hal_pwr.c \
-lib/f4/stm32f4xx_hal_pwr_ex.c \
-lib/f4/stm32f4xx_hal_cortex.c \
-lib/f4/stm32f4xx_hal.c \
-lib/f4/stm32f4xx_hal_exti.c \
-lib/f4/stm32f4xx_hal_tim.c \
-lib/f4/stm32f4xx_hal_tim_ex.c \
-lib/f4/stm32f4xx_hal_uart.c
-
-# ASM sources
-ASM_SOURCES = \
-startup_stm32f401xc.s
+# set the main C source based on whether we're compiling the master or slave
+C_SOURCES+=$(addprefix src/, $(TARGET).c)
#######################################
# binaries
@@ -88,46 +50,30 @@ SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
-
+
#######################################
# CFLAGS
#######################################
-# cpu
-CPU = -mcpu=cortex-m4
-
-# fpu
-FPU = -mfpu=fpv4-sp-d16
-
-# float-abi
-FLOAT-ABI = -mfloat-abi=hard
-
-# mcu
-MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
-
# macros for gcc
# AS defines
AS_DEFS =
-# C defines
-C_DEFS = \
--DUSE_HAL_DRIVER \
--DSTM32F401xC
-
-
# AS includes
AS_INCLUDES =
-# C includes
+# General C includes for all ports. Since CMSIS is being included, that means this is restricted to ARM ports
C_INCLUDES = \
-Isrc \
--Ilib/f4 \
--Ilib/f4/Legacy \
-Ilib/cmsis \
--Ilib/cmsis/f4
-
-
+-Ilib/nanopb
+# Define the chip we're building for and include its makefile
+# Variable ASM_FILE will be defined in the included port makefile
+PORT = stm32f4
+PORT_DIR = ports/$(PORT)
+include $(PORT_DIR)/makefile
+ASM_SOURCES=$(PORT_DIR)/$(ASM_FILE)
# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
@@ -138,21 +84,19 @@ ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
-
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
-
#######################################
# LDFLAGS
#######################################
# link script
-LDSCRIPT = STM32F401CCUx_FLASH.ld
+# LDSCRIPT = STM32F401CCUx_FLASH.ld
# libraries
LIBS = -lc -lm -lnosys
LIBDIR =
-LDFLAGS = $(MCU) -specs=nosys.specs -specs=nano.specs -u _printf_float -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
+LDFLAGS = $(MCU) -specs=nosys.specs -specs=nano.specs -u _printf_float -T$(PORT_DIR)/$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin