Align some ChibiOS build logic (#8461)
[jackhill/qmk/firmware.git] / quantum / mcu_selection.mk
1 ifneq ($(findstring MKL26Z64, $(MCU)),)
2 # Cortex version
3 MCU = cortex-m0plus
4
5 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
6 ARMV = 6
7
8 ## chip/board settings
9 # - the next two should match the directories in
10 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
11 MCU_FAMILY = KINETIS
12 MCU_SERIES = KL2x
13
14 # Linker script to use
15 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
16 # or <keyboard_dir>/ld/
17 # - NOTE: a custom ld script is needed for EEPROM on Teensy LC
18 MCU_LDSCRIPT ?= MKL26Z64
19
20 # Startup code to use
21 # - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
22 MCU_STARTUP ?= kl2x
23
24 # Board: it should exist either in <chibios>/os/hal/boards/,
25 # <keyboard_dir>/boards/, or drivers/boards/
26 BOARD ?= PJRC_TEENSY_LC
27 endif
28
29 ifneq ($(findstring MK20DX128, $(MCU)),)
30 # Cortex version
31 MCU = cortex-m4
32
33 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
34 ARMV = 7
35
36 ## chip/board settings
37 # - the next two should match the directories in
38 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
39 MCU_FAMILY = KINETIS
40 MCU_SERIES = K20x
41
42 # Linker script to use
43 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
44 # or <keyboard_dir>/ld/
45 MCU_LDSCRIPT ?= MK20DX128
46
47 # Startup code to use
48 # - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
49 MCU_STARTUP ?= k20x5
50
51 # Board: it should exist either in <chibios>/os/hal/boards/,
52 # <keyboard_dir>/boards/, or drivers/boards/
53 BOARD ?= PJRC_TEENSY_3
54 endif
55
56 ifneq ($(findstring MK20DX256, $(MCU)),)
57 # Cortex version
58 MCU = cortex-m4
59
60 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
61 ARMV = 7
62
63 ## chip/board settings
64 # - the next two should match the directories in
65 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
66 MCU_FAMILY = KINETIS
67 MCU_SERIES = K20x
68
69 # Linker script to use
70 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
71 # or <keyboard_dir>/ld/
72 MCU_LDSCRIPT ?= MK20DX256
73
74 # Startup code to use
75 # - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
76 MCU_STARTUP ?= k20x7
77
78 # Board: it should exist either in <chibios>/os/hal/boards/,
79 # <keyboard_dir>/boards/, or drivers/boards/
80 BOARD ?= PJRC_TEENSY_3_1
81 endif
82
83 ifneq ($(findstring STM32F303, $(MCU)),)
84 # Cortex version
85 MCU = cortex-m4
86
87 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
88 ARMV = 7
89
90 ## chip/board settings
91 # - the next two should match the directories in
92 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
93 MCU_FAMILY = STM32
94 MCU_SERIES = STM32F3xx
95
96 # Linker script to use
97 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
98 # or <keyboard_dir>/ld/
99 MCU_LDSCRIPT ?= STM32F303xC
100
101 # Startup code to use
102 # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
103 MCU_STARTUP ?= stm32f3xx
104
105 # Board: it should exist either in <chibios>/os/hal/boards/,
106 # <keyboard_dir>/boards/, or drivers/boards/
107 BOARD ?= GENERIC_STM32_F303XC
108
109 USE_FPU ?= yes
110
111 # Options to pass to dfu-util when flashing
112 DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave
113 DFU_SUFFIX_ARGS ?= -v 0483 -p df11
114 endif
115
116 ifneq ($(findstring STM32F072, $(MCU)),)
117 # Cortex version
118 MCU = cortex-m0
119
120 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
121 ARMV = 6
122
123 ## chip/board settings
124 # - the next two should match the directories in
125 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
126 MCU_FAMILY = STM32
127 MCU_SERIES = STM32F0xx
128
129 # Linker script to use
130 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
131 # or <keyboard_dir>/ld/
132 MCU_LDSCRIPT ?= STM32F072xB
133
134 # Startup code to use
135 # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
136 MCU_STARTUP ?= stm32f0xx
137
138 # Board: it should exist either in <chibios>/os/hal/boards/,
139 # <keyboard_dir>/boards/, or drivers/boards/
140 BOARD ?= GENERIC_STM32_F072XB
141
142 USE_FPU ?= no
143
144 # Options to pass to dfu-util when flashing
145 DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave
146 DFU_SUFFIX_ARGS ?= -v 0483 -p df11
147 endif
148
149 ifneq ($(findstring STM32F042, $(MCU)),)
150 # Cortex version
151 MCU = cortex-m0
152
153 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
154 ARMV = 6
155
156 ## chip/board settings
157 # - the next two should match the directories in
158 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
159 MCU_FAMILY = STM32
160 MCU_SERIES = STM32F0xx
161
162 # Linker script to use
163 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
164 # or <keyboard_dir>/ld/
165 MCU_LDSCRIPT ?= STM32F042x6
166
167 # Startup code to use
168 # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
169 MCU_STARTUP ?= stm32f0xx
170
171 # Board: it should exist either in <chibios>/os/hal/boards/,
172 # <keyboard_dir>/boards/, or drivers/boards/
173 BOARD ?= GENERIC_STM32_F042X6
174
175 USE_FPU ?= no
176
177 # Options to pass to dfu-util when flashing
178 DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave
179 DFU_SUFFIX_ARGS ?= -v 0483 -p df11
180 endif
181
182 ifneq ($(findstring STM32F103, $(MCU)),)
183 # Cortex version
184 MCU = cortex-m3
185
186 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
187 ARMV = 7
188
189 ## chip/board settings
190 # - the next two should match the directories in
191 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
192 MCU_FAMILY = STM32
193 MCU_SERIES = STM32F1xx
194
195 # Linker script to use
196 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
197 # or <keyboard_dir>/ld/
198 MCU_LDSCRIPT ?= STM32F103x8
199
200 # Startup code to use
201 # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
202 MCU_STARTUP ?= stm32f1xx
203
204 # Board: it should exist either in <chibios>/os/hal/boards/,
205 # <keyboard_dir>/boards/, or drivers/boards/
206 BOARD ?= GENERIC_STM32_F103
207
208 USE_FPU ?= no
209
210 # Options to pass to dfu-util when flashing
211 DFU_ARGS ?= -d 0483:df11 -a 0 -s 0x08000000:leave
212 DFU_SUFFIX_ARGS ?= -v 0483 -p df11
213 endif
214
215 ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb1286))
216 PROTOCOL = LUFA
217
218 # Processor frequency.
219 # This will define a symbol, F_CPU, in all source code files equal to the
220 # processor frequency in Hz. You can then use this symbol in your source code to
221 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
222 # automatically to create a 32-bit value in your source code.
223 #
224 # This will be an integer division of F_USB below, as it is sourced by
225 # F_USB after it has run through any CPU prescalers. Note that this value
226 # does not *change* the processor frequency - it should merely be updated to
227 # reflect the processor speed set externally so that the code can use accurate
228 # software delays.
229 F_CPU ?= 16000000
230
231 # LUFA specific
232 #
233 # Target architecture (see library "Board Types" documentation).
234 ARCH = AVR8
235
236 # Input clock frequency.
237 # This will define a symbol, F_USB, in all source code files equal to the
238 # input clock frequency (before any prescaling is performed) in Hz. This value may
239 # differ from F_CPU if prescaling is used on the latter, and is required as the
240 # raw input clock is fed directly to the PLL sections of the AVR for high speed
241 # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
242 # at the end, this will be done automatically to create a 32-bit value in your
243 # source code.
244 #
245 # If no clock division is performed on the input clock inside the AVR (via the
246 # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
247 F_USB ?= $(F_CPU)
248
249 # Interrupt driven control endpoint task
250 ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes))
251 OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
252 endif
253 endif
254
255 ifneq (,$(filter $(MCU),atmega32a))
256 # MCU name for avrdude
257 AVRDUDE_MCU = m32
258
259 PROTOCOL = VUSB
260
261 # Processor frequency.
262 # This will define a symbol, F_CPU, in all source code files equal to the
263 # processor frequency in Hz. You can then use this symbol in your source code to
264 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
265 # automatically to create a 32-bit value in your source code.
266 F_CPU ?= 12000000
267
268 # unsupported features for now
269 NO_UART ?= yes
270 NO_SUSPEND_POWER_DOWN ?= yes
271 endif
272
273 ifneq (,$(filter $(MCU),atmega328p))
274 # MCU name for avrdude
275 AVRDUDE_MCU = m328p
276
277 PROTOCOL = VUSB
278
279 # Processor frequency.
280 # This will define a symbol, F_CPU, in all source code files equal to the
281 # processor frequency in Hz. You can then use this symbol in your source code to
282 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
283 # automatically to create a 32-bit value in your source code.
284 F_CPU ?= 16000000
285
286 # unsupported features for now
287 NO_UART ?= yes
288 NO_SUSPEND_POWER_DOWN ?= yes
289 endif