summaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
authorAditya Naik2020-06-09 13:47:28 -0400
committerAditya Naik2020-06-09 13:47:28 -0400
commitb113916a5df90673bbe56fe7a0fd09ea3516d124 (patch)
tree0a515969f28df397586e87e9451aa0f474b3f971 /makefile
parent16d4cd12cb4bdfc3eda3ec6019d093f971d8aca8 (diff)
Added ports dir
Diffstat (limited to 'makefile')
-rw-r--r--makefile84
1 files changed, 13 insertions, 71 deletions
diff --git a/makefile b/makefile
index 43f5d4d..b53a7a5 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/master.c \
-src/stm32f4xx_it.c \
-src/stm32f4xx_hal_msp.c \
-src/system_stm32f4xx.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,47 +50,29 @@ 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
+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
@@ -139,21 +83,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