forked from IOsetting/py32f0-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (149 loc) · 5.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
##### Project #####
PROJECT ?= utility
# The path for generated files
BUILD_DIR = Build
# MCU types:
# PY32F002Ax5
# PY32F002Bx5
# PY32F003x4, PY32F003x6, PY32F003x8,
# PY32F030x6, PY32F030x8,
# PY32F072xB
MCU_TYPE = PY32F003x4
##### Options #####
# Use LL library instead of HAL, y:yes, n:no
USE_LL_LIB ?= n
# Enable printf float %f support, y:yes, n:no
ENABLE_PRINTF_FLOAT ?= n
# Build with FreeRTOS, y:yes, n:no
USE_FREERTOS ?= n
# Build with CMSIS DSP functions, y:yes, n:no
USE_DSP ?= n
# Build with Waveshare e-paper lib, y:yes, n:no
USE_EPAPER ?= n
# Programmer, jlink or pyocd
FLASH_PROGRM ?= stm32flash
##### Toolchains #######
#ARM_TOOCHAIN ?= /opt/gcc-arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin
#ARM_TOOCHAIN ?= /opt/gcc-arm/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin
ARM_TOOCHAIN ?= /usr/bin
# path to JLinkExe
JLINKEXE ?= /opt/SEGGER/JLink/JLinkExe
# path to PyOCD
PYOCD_EXE ?= pyocd
##### Paths ############
# C and CPP source folders
CDIRS := User
# Single C and CPP source files
CFILES :=
CPPFILES :=
# ASM source folders
ADIRS := User
# Single ASM source files
AFILES :=
# Include paths
INCLUDES := Libraries/CMSIS/Core/Include \
Libraries/CMSIS/Device/PY32F0xx/Include \
User
##### Library Paths ############
# Library flags
LIB_FLAGS = $(MCU_TYPE)
# JLink device (Uppercases)
JLINK_DEVICE ?= $(shell echo $(MCU_TYPE) | tr '[:lower:]' '[:upper:]')
# PyOCD device (Lowercases)
PYOCD_DEVICE ?= $(shell echo $(MCU_TYPE) | tr '[:upper:]' '[:lower:]')
# Link descript file:
LDSCRIPT = Libraries/LDScripts/$(PYOCD_DEVICE).ld
ifneq (,$(findstring PY32F002B,$(MCU_TYPE)))
# PY32F002B >>>
CFILES += Libraries/CMSIS/Device/PY32F0xx/Source/system_py32f002b.c
ifeq ($(USE_LL_LIB),y)
CDIRS += Libraries/PY32F002B_LL_Driver/Src \
Libraries/PY32F002B_LL_BSP/Src
INCLUDES += Libraries/PY32F002B_LL_Driver/Inc \
Libraries/PY32F002B_LL_BSP/Inc
LIB_FLAGS += USE_FULL_LL_DRIVER
else
CDIRS += Libraries/PY32F002B_HAL_Driver/Src \
Libraries/PY32F002B_HAL_BSP/Src
INCLUDES += Libraries/PY32F002B_HAL_Driver/Inc \
Libraries/PY32F002B_HAL_BSP/Inc
endif
# Startup file
AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f002b.s
# PY32F002B <<<
else ifneq (,$(findstring PY32F07,$(MCU_TYPE)))
# PY32F07x >>>
CFILES += Libraries/CMSIS/Device/PY32F0xx/Source/system_py32f07x.c
CDIRS += Libraries/PY32F07x_HAL_Driver/Src \
Libraries/PY32F07x_HAL_BSP/Src
INCLUDES += Libraries/PY32F07x_HAL_Driver/Inc \
Libraries/PY32F07x_HAL_BSP/Inc
LIB_FLAGS += USE_HAL_DRIVER
# Startup file
AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f072.s
# PY32F07 <<<
else
# PY32F002A,003,030 >>>
CFILES += Libraries/CMSIS/Device/PY32F0xx/Source/system_py32f0xx.c
ifeq ($(USE_LL_LIB),y)
CDIRS += Libraries/PY32F0xx_LL_Driver/Src \
Libraries/PY32F0xx_LL_BSP/Src
INCLUDES += Libraries/PY32F0xx_LL_Driver/Inc \
Libraries/PY32F0xx_LL_BSP/Inc
LIB_FLAGS += USE_FULL_LL_DRIVER
else
CDIRS += Libraries/PY32F0xx_HAL_Driver/Src \
Libraries/PY32F0xx_HAL_BSP/Src
INCLUDES += Libraries/PY32F0xx_HAL_Driver/Inc \
Libraries/PY32F0xx_HAL_BSP/Inc
endif
# Startup file
ifneq (,$(findstring PY32F002A,$(LIB_FLAGS)))
AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f002a.s
endif
ifneq (,$(findstring PY32F003,$(LIB_FLAGS)))
AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f003.s
endif
ifneq (,$(findstring PY32F030,$(LIB_FLAGS)))
AFILES := Libraries/CMSIS/Device/PY32F0xx/Source/gcc/startup_py32f030.s
endif
# PY32F002A,003,030 <<<
endif
######## Additional Libs ########
ifeq ($(USE_FREERTOS),y)
CDIRS += Libraries/FreeRTOS \
Libraries/FreeRTOS/portable/GCC/ARM_CM0
CFILES += Libraries/FreeRTOS/portable/MemMang/heap_4.c
INCLUDES += Libraries/FreeRTOS/include \
Libraries/FreeRTOS/portable/GCC/ARM_CM0
endif
ifeq ($(USE_DSP),y)
CFILES += Libraries/CMSIS/DSP/Source/BasicMathFunctions/BasicMathFunctions.c \
Libraries/CMSIS/DSP/Source/BayesFunctions/BayesFunctions.c \
Libraries/CMSIS/DSP/Source/CommonTables/CommonTables.c \
Libraries/CMSIS/DSP/Source/ComplexMathFunctions/ComplexMathFunctions.c \
Libraries/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c \
Libraries/CMSIS/DSP/Source/DistanceFunctions/DistanceFunctions.c \
Libraries/CMSIS/DSP/Source/FastMathFunctions/FastMathFunctions.c \
Libraries/CMSIS/DSP/Source/FilteringFunctions/FilteringFunctions.c \
Libraries/CMSIS/DSP/Source/InterpolationFunctions/InterpolationFunctions.c \
Libraries/CMSIS/DSP/Source/MatrixFunctions/MatrixFunctions.c \
Libraries/CMSIS/DSP/Source/QuaternionMathFunctions/QuaternionMathFunctions.c \
Libraries/CMSIS/DSP/Source/StatisticsFunctions/StatisticsFunctions.c \
Libraries/CMSIS/DSP/Source/SupportFunctions/SupportFunctions.c \
Libraries/CMSIS/DSP/Source/SVMFunctions/SVMFunctions.c \
Libraries/CMSIS/DSP/Source/TransformFunctions/TransformFunctions.c
INCLUDES += Libraries/CMSIS/DSP/Include \
Libraries/CMSIS/DSP/PrivateInclude
endif
ifeq ($(USE_EPAPER),y)
CDIRS += Libraries/EPaper/Lib \
Libraries/EPaper/Examples \
Libraries/EPaper/Fonts \
Libraries/EPaper/GUI
INCLUDES += Libraries/EPaper/Lib \
Libraries/EPaper/Examples \
Libraries/EPaper/Fonts \
Libraries/EPaper/GUI
endif
include ./rules.mk