aboutsummaryrefslogtreecommitdiff
path: root/platforms/chibios/boards
diff options
context:
space:
mode:
Diffstat (limited to 'platforms/chibios/boards')
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F401/board/board.mk9
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F401/configs/board.h20
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F401/configs/bootloader_defs.h5
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h30
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F401/configs/mcuconf.h253
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/board/board.mk9
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/configs/board.h20
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/configs/bootloader_defs.h5
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h30
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/configs/mcuconf.h253
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld89
-rw-r--r--platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld89
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.c265
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.h896
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F042X6/configs/bootloader_defs.h5
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F042X6/configs/config.h20
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F042X6/configs/mcuconf.h168
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F072XB/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F072XB/configs/board.h20
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F072XB/configs/bootloader_defs.h5
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F072XB/configs/config.h20
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F072XB/configs/mcuconf.h179
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F303XC/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F303XC/configs/board.h37
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F303XC/configs/bootloader_defs.h5
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F303XC/configs/config.h20
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F303XC/configs/mcuconf.h273
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h24
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h23
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F407XE/configs/mcuconf.h355
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F446XE/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F446XE/configs/board.h24
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h23
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_F446XE/configs/mcuconf.h361
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_G431XB/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_G431XB/configs/config.h23
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_G431XB/configs/mcuconf.h307
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_G474XE/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h30
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_G474XE/configs/mcuconf.h372
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L412XB/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L412XB/configs/board.h24
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L412XB/configs/config.h26
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L412XB/configs/mcuconf.h282
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L433XC/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L433XC/configs/board.h24
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L433XC/configs/config.h26
-rw-r--r--platforms/chibios/boards/GENERIC_STM32_L433XC/configs/mcuconf.h292
-rw-r--r--platforms/chibios/boards/IC_TEENSY_3_1/board/board.c151
-rw-r--r--platforms/chibios/boards/IC_TEENSY_3_1/board/board.h295
-rw-r--r--platforms/chibios/boards/IC_TEENSY_3_1/board/board.mk9
-rw-r--r--platforms/chibios/boards/IC_TEENSY_4_1/board/board.mk1
-rw-r--r--platforms/chibios/boards/IC_TEENSY_4_1/rules.mk1
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/board/board.mk9
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/board.h37
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/bootloader_defs.h7
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h756
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/config.h20
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h531
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/configs/mcuconf.h273
-rw-r--r--platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk10
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c59
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.h166
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.mk9
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/configs/mcuconf.h209
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld22
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld22
-rw-r--r--platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld85
-rw-r--r--platforms/chibios/boards/common/configs/chconf.h756
-rw-r--r--platforms/chibios/boards/common/configs/halconf.h531
-rw-r--r--platforms/chibios/boards/common/ld/MKL26Z64.ld105
-rw-r--r--platforms/chibios/boards/common/ld/STM32L412xB.ld85
-rw-r--r--platforms/chibios/boards/keyboard-config-templates/board.h20
-rw-r--r--platforms/chibios/boards/keyboard-config-templates/chconf.h20
-rw-r--r--platforms/chibios/boards/keyboard-config-templates/halconf.h20
-rw-r--r--platforms/chibios/boards/keyboard-config-templates/mcuconf.h21
78 files changed, 9252 insertions, 0 deletions
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/board/board.mk b/platforms/chibios/boards/BLACKPILL_STM32_F401/board/board.mk
new file mode 100644
index 000000000..fddf7dace
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F401C_DISCOVERY/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F401C_DISCOVERY
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/board.h b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/board.h
new file mode 100644
index 000000000..30af6b0c8
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/board.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/bootloader_defs.h b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/bootloader_defs.h
new file mode 100644
index 000000000..4da3d39a3
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/bootloader_defs.h
@@ -0,0 +1,5 @@
1/* Address for jumping to bootloader on STM32 chips. */
2/* It is chip dependent, the correct number can be looked up here:
3 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4 */
5#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h
new file mode 100644
index 000000000..e181422eb
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/config.h
@@ -0,0 +1,30 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#define BOARD_OTG_NOVBUSSENS 1
19
20#ifndef STM32_LSECLK
21# define STM32_LSECLK 32768U
22#endif // STM32_LSECLK
23
24#ifndef STM32_HSECLK
25# define STM32_HSECLK 25000000U
26#endif // STM32_HSECLK
27
28#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
29# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
30#endif
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/mcuconf.h b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/mcuconf.h
new file mode 100644
index 000000000..ba6e934fe
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F401/configs/mcuconf.h
@@ -0,0 +1,253 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef MCUCONF_H
18#define MCUCONF_H
19
20/*
21 * STM32F4xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 15...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F4xx_MCUCONF
35
36/*
37 * HAL driver system settings.
38 */
39#define STM32_NO_INIT FALSE
40#define STM32_HSI_ENABLED TRUE
41#define STM32_LSI_ENABLED TRUE
42#define STM32_HSE_ENABLED TRUE
43#define STM32_LSE_ENABLED FALSE
44#define STM32_CLOCK48_REQUIRED TRUE
45#define STM32_SW STM32_SW_PLL
46#define STM32_PLLSRC STM32_PLLSRC_HSE
47#define STM32_PLLM_VALUE 25
48#define STM32_PLLN_VALUE 336
49#define STM32_PLLP_VALUE 4
50#define STM32_PLLQ_VALUE 7
51#define STM32_HPRE STM32_HPRE_DIV1
52#define STM32_PPRE1 STM32_PPRE1_DIV4
53#define STM32_PPRE2 STM32_PPRE2_DIV2
54#define STM32_RTCSEL STM32_RTCSEL_LSI
55#define STM32_RTCPRE_VALUE 8
56#define STM32_MCO1SEL STM32_MCO1SEL_HSI
57#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
58#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
59#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
60#define STM32_I2SSRC STM32_I2SSRC_CKIN
61#define STM32_PLLI2SN_VALUE 192
62#define STM32_PLLI2SR_VALUE 5
63#define STM32_PVD_ENABLE FALSE
64#define STM32_PLS STM32_PLS_LEV0
65#define STM32_BKPRAM_ENABLE FALSE
66
67/*
68 * IRQ system settings.
69 */
70#define STM32_IRQ_EXTI0_PRIORITY 6
71#define STM32_IRQ_EXTI1_PRIORITY 6
72#define STM32_IRQ_EXTI2_PRIORITY 6
73#define STM32_IRQ_EXTI3_PRIORITY 6
74#define STM32_IRQ_EXTI4_PRIORITY 6
75#define STM32_IRQ_EXTI5_9_PRIORITY 6
76#define STM32_IRQ_EXTI10_15_PRIORITY 6
77#define STM32_IRQ_EXTI16_PRIORITY 6
78#define STM32_IRQ_EXTI17_PRIORITY 15
79#define STM32_IRQ_EXTI18_PRIORITY 6
80#define STM32_IRQ_EXTI19_PRIORITY 6
81#define STM32_IRQ_EXTI20_PRIORITY 6
82#define STM32_IRQ_EXTI21_PRIORITY 15
83#define STM32_IRQ_EXTI22_PRIORITY 15
84
85/*
86 * ADC driver system settings.
87 */
88#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
89#define STM32_ADC_USE_ADC1 FALSE
90#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
91#define STM32_ADC_ADC1_DMA_PRIORITY 2
92#define STM32_ADC_IRQ_PRIORITY 6
93#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
94
95/*
96 * GPT driver system settings.
97 */
98#define STM32_GPT_USE_TIM1 FALSE
99#define STM32_GPT_USE_TIM2 FALSE
100#define STM32_GPT_USE_TIM3 FALSE
101#define STM32_GPT_USE_TIM4 FALSE
102#define STM32_GPT_USE_TIM5 FALSE
103#define STM32_GPT_USE_TIM9 FALSE
104#define STM32_GPT_USE_TIM11 FALSE
105#define STM32_GPT_TIM1_IRQ_PRIORITY 7
106#define STM32_GPT_TIM2_IRQ_PRIORITY 7
107#define STM32_GPT_TIM3_IRQ_PRIORITY 7
108#define STM32_GPT_TIM4_IRQ_PRIORITY 7
109#define STM32_GPT_TIM5_IRQ_PRIORITY 7
110#define STM32_GPT_TIM9_IRQ_PRIORITY 7
111#define STM32_GPT_TIM11_IRQ_PRIORITY 7
112
113/*
114 * I2C driver system settings.
115 */
116#define STM32_I2C_USE_I2C1 FALSE
117#define STM32_I2C_USE_I2C2 FALSE
118#define STM32_I2C_USE_I2C3 FALSE
119#define STM32_I2C_BUSY_TIMEOUT 50
120#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
121#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
122#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
123#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
124#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
125#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
126#define STM32_I2C_I2C1_IRQ_PRIORITY 5
127#define STM32_I2C_I2C2_IRQ_PRIORITY 5
128#define STM32_I2C_I2C3_IRQ_PRIORITY 5
129#define STM32_I2C_I2C1_DMA_PRIORITY 3
130#define STM32_I2C_I2C2_DMA_PRIORITY 3
131#define STM32_I2C_I2C3_DMA_PRIORITY 3
132#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
133
134/*
135 * I2S driver system settings.
136 */
137#define STM32_I2S_USE_SPI2 FALSE
138#define STM32_I2S_USE_SPI3 FALSE
139#define STM32_I2S_SPI2_IRQ_PRIORITY 10
140#define STM32_I2S_SPI3_IRQ_PRIORITY 10
141#define STM32_I2S_SPI2_DMA_PRIORITY 1
142#define STM32_I2S_SPI3_DMA_PRIORITY 1
143#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
144#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
145#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
146#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
147#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
148
149/*
150 * ICU driver system settings.
151 */
152#define STM32_ICU_USE_TIM1 FALSE
153#define STM32_ICU_USE_TIM2 FALSE
154#define STM32_ICU_USE_TIM3 FALSE
155#define STM32_ICU_USE_TIM4 FALSE
156#define STM32_ICU_USE_TIM5 FALSE
157#define STM32_ICU_USE_TIM9 FALSE
158#define STM32_ICU_TIM1_IRQ_PRIORITY 7
159#define STM32_ICU_TIM2_IRQ_PRIORITY 7
160#define STM32_ICU_TIM3_IRQ_PRIORITY 7
161#define STM32_ICU_TIM4_IRQ_PRIORITY 7
162#define STM32_ICU_TIM5_IRQ_PRIORITY 7
163#define STM32_ICU_TIM9_IRQ_PRIORITY 7
164
165/*
166 * PWM driver system settings.
167 */
168#define STM32_PWM_USE_ADVANCED FALSE
169#define STM32_PWM_USE_TIM1 FALSE
170#define STM32_PWM_USE_TIM2 FALSE
171#define STM32_PWM_USE_TIM3 FALSE
172#define STM32_PWM_USE_TIM4 FALSE
173#define STM32_PWM_USE_TIM5 FALSE
174#define STM32_PWM_USE_TIM9 FALSE
175#define STM32_PWM_TIM1_IRQ_PRIORITY 7
176#define STM32_PWM_TIM2_IRQ_PRIORITY 7
177#define STM32_PWM_TIM3_IRQ_PRIORITY 7
178#define STM32_PWM_TIM4_IRQ_PRIORITY 7
179#define STM32_PWM_TIM5_IRQ_PRIORITY 7
180#define STM32_PWM_TIM9_IRQ_PRIORITY 7
181
182/*
183 * SERIAL driver system settings.
184 */
185#define STM32_SERIAL_USE_USART1 FALSE
186#define STM32_SERIAL_USE_USART2 FALSE
187#define STM32_SERIAL_USE_USART6 FALSE
188#define STM32_SERIAL_USART1_PRIORITY 12
189#define STM32_SERIAL_USART2_PRIORITY 12
190#define STM32_SERIAL_USART6_PRIORITY 12
191
192/*
193 * SPI driver system settings.
194 */
195#define STM32_SPI_USE_SPI1 FALSE
196#define STM32_SPI_USE_SPI2 FALSE
197#define STM32_SPI_USE_SPI3 FALSE
198#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
199#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
200#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
201#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
202#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
203#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
204#define STM32_SPI_SPI1_DMA_PRIORITY 1
205#define STM32_SPI_SPI2_DMA_PRIORITY 1
206#define STM32_SPI_SPI3_DMA_PRIORITY 1
207#define STM32_SPI_SPI1_IRQ_PRIORITY 10
208#define STM32_SPI_SPI2_IRQ_PRIORITY 10
209#define STM32_SPI_SPI3_IRQ_PRIORITY 10
210#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
211
212/*
213 * ST driver system settings.
214 */
215#define STM32_ST_IRQ_PRIORITY 8
216#define STM32_ST_USE_TIMER 2
217
218/*
219 * UART driver system settings.
220 */
221#define STM32_UART_USE_USART1 FALSE
222#define STM32_UART_USE_USART2 FALSE
223#define STM32_UART_USE_USART6 FALSE
224#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
225#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
226#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
227#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
228#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
229#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
230#define STM32_UART_USART1_IRQ_PRIORITY 12
231#define STM32_UART_USART2_IRQ_PRIORITY 12
232#define STM32_UART_USART6_IRQ_PRIORITY 12
233#define STM32_UART_USART1_DMA_PRIORITY 0
234#define STM32_UART_USART2_DMA_PRIORITY 0
235#define STM32_UART_USART6_DMA_PRIORITY 0
236#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
237
238/*
239 * USB driver system settings.
240 */
241#define STM32_USB_USE_OTG1 TRUE
242#define STM32_USB_OTG1_IRQ_PRIORITY 14
243#define STM32_USB_OTG1_RX_FIFO_SIZE 512
244#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1
245#define STM32_USB_OTG_THREAD_STACK_SIZE 128
246#define STM32_USB_OTGFIFO_FILL_BASEPRI 0
247
248/*
249 * WDG driver system settings.
250 */
251#define STM32_WDG_USE_IWDG FALSE
252
253#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/board/board.mk b/platforms/chibios/boards/BLACKPILL_STM32_F411/board/board.mk
new file mode 100644
index 000000000..bb00b1a2b
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F411RE
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/board.h b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/board.h
new file mode 100644
index 000000000..30af6b0c8
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/board.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/bootloader_defs.h b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/bootloader_defs.h
new file mode 100644
index 000000000..4da3d39a3
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/bootloader_defs.h
@@ -0,0 +1,5 @@
1/* Address for jumping to bootloader on STM32 chips. */
2/* It is chip dependent, the correct number can be looked up here:
3 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4 */
5#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h
new file mode 100644
index 000000000..e181422eb
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/config.h
@@ -0,0 +1,30 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#define BOARD_OTG_NOVBUSSENS 1
19
20#ifndef STM32_LSECLK
21# define STM32_LSECLK 32768U
22#endif // STM32_LSECLK
23
24#ifndef STM32_HSECLK
25# define STM32_HSECLK 25000000U
26#endif // STM32_HSECLK
27
28#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
29# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
30#endif
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/mcuconf.h b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/mcuconf.h
new file mode 100644
index 000000000..0394ff56b
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/configs/mcuconf.h
@@ -0,0 +1,253 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef MCUCONF_H
18#define MCUCONF_H
19
20/*
21 * STM32F4xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 15...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F4xx_MCUCONF
35
36/*
37 * HAL driver system settings.
38 */
39#define STM32_NO_INIT FALSE
40#define STM32_HSI_ENABLED TRUE
41#define STM32_LSI_ENABLED TRUE
42#define STM32_HSE_ENABLED TRUE
43#define STM32_LSE_ENABLED FALSE
44#define STM32_CLOCK48_REQUIRED TRUE
45#define STM32_SW STM32_SW_PLL
46#define STM32_PLLSRC STM32_PLLSRC_HSE
47#define STM32_PLLM_VALUE 25
48#define STM32_PLLN_VALUE 384
49#define STM32_PLLP_VALUE 4
50#define STM32_PLLQ_VALUE 8
51#define STM32_HPRE STM32_HPRE_DIV1
52#define STM32_PPRE1 STM32_PPRE1_DIV4
53#define STM32_PPRE2 STM32_PPRE2_DIV2
54#define STM32_RTCSEL STM32_RTCSEL_LSI
55#define STM32_RTCPRE_VALUE 8
56#define STM32_MCO1SEL STM32_MCO1SEL_HSI
57#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
58#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
59#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
60#define STM32_I2SSRC STM32_I2SSRC_CKIN
61#define STM32_PLLI2SN_VALUE 192
62#define STM32_PLLI2SR_VALUE 5
63#define STM32_PVD_ENABLE FALSE
64#define STM32_PLS STM32_PLS_LEV0
65#define STM32_BKPRAM_ENABLE FALSE
66
67/*
68 * IRQ system settings.
69 */
70#define STM32_IRQ_EXTI0_PRIORITY 6
71#define STM32_IRQ_EXTI1_PRIORITY 6
72#define STM32_IRQ_EXTI2_PRIORITY 6
73#define STM32_IRQ_EXTI3_PRIORITY 6
74#define STM32_IRQ_EXTI4_PRIORITY 6
75#define STM32_IRQ_EXTI5_9_PRIORITY 6
76#define STM32_IRQ_EXTI10_15_PRIORITY 6
77#define STM32_IRQ_EXTI16_PRIORITY 6
78#define STM32_IRQ_EXTI17_PRIORITY 15
79#define STM32_IRQ_EXTI18_PRIORITY 6
80#define STM32_IRQ_EXTI19_PRIORITY 6
81#define STM32_IRQ_EXTI20_PRIORITY 6
82#define STM32_IRQ_EXTI21_PRIORITY 15
83#define STM32_IRQ_EXTI22_PRIORITY 15
84
85/*
86 * ADC driver system settings.
87 */
88#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
89#define STM32_ADC_USE_ADC1 FALSE
90#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
91#define STM32_ADC_ADC1_DMA_PRIORITY 2
92#define STM32_ADC_IRQ_PRIORITY 6
93#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
94
95/*
96 * GPT driver system settings.
97 */
98#define STM32_GPT_USE_TIM1 FALSE
99#define STM32_GPT_USE_TIM2 FALSE
100#define STM32_GPT_USE_TIM3 FALSE
101#define STM32_GPT_USE_TIM4 FALSE
102#define STM32_GPT_USE_TIM5 FALSE
103#define STM32_GPT_USE_TIM9 FALSE
104#define STM32_GPT_USE_TIM11 FALSE
105#define STM32_GPT_TIM1_IRQ_PRIORITY 7
106#define STM32_GPT_TIM2_IRQ_PRIORITY 7
107#define STM32_GPT_TIM3_IRQ_PRIORITY 7
108#define STM32_GPT_TIM4_IRQ_PRIORITY 7
109#define STM32_GPT_TIM5_IRQ_PRIORITY 7
110#define STM32_GPT_TIM9_IRQ_PRIORITY 7
111#define STM32_GPT_TIM11_IRQ_PRIORITY 7
112
113/*
114 * I2C driver system settings.
115 */
116#define STM32_I2C_USE_I2C1 FALSE
117#define STM32_I2C_USE_I2C2 FALSE
118#define STM32_I2C_USE_I2C3 FALSE
119#define STM32_I2C_BUSY_TIMEOUT 50
120#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
121#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
122#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
123#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
124#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
125#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
126#define STM32_I2C_I2C1_IRQ_PRIORITY 5
127#define STM32_I2C_I2C2_IRQ_PRIORITY 5
128#define STM32_I2C_I2C3_IRQ_PRIORITY 5
129#define STM32_I2C_I2C1_DMA_PRIORITY 3
130#define STM32_I2C_I2C2_DMA_PRIORITY 3
131#define STM32_I2C_I2C3_DMA_PRIORITY 3
132#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
133
134/*
135 * I2S driver system settings.
136 */
137#define STM32_I2S_USE_SPI2 FALSE
138#define STM32_I2S_USE_SPI3 FALSE
139#define STM32_I2S_SPI2_IRQ_PRIORITY 10
140#define STM32_I2S_SPI3_IRQ_PRIORITY 10
141#define STM32_I2S_SPI2_DMA_PRIORITY 1
142#define STM32_I2S_SPI3_DMA_PRIORITY 1
143#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
144#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
145#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
146#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
147#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
148
149/*
150 * ICU driver system settings.
151 */
152#define STM32_ICU_USE_TIM1 FALSE
153#define STM32_ICU_USE_TIM2 FALSE
154#define STM32_ICU_USE_TIM3 FALSE
155#define STM32_ICU_USE_TIM4 FALSE
156#define STM32_ICU_USE_TIM5 FALSE
157#define STM32_ICU_USE_TIM9 FALSE
158#define STM32_ICU_TIM1_IRQ_PRIORITY 7
159#define STM32_ICU_TIM2_IRQ_PRIORITY 7
160#define STM32_ICU_TIM3_IRQ_PRIORITY 7
161#define STM32_ICU_TIM4_IRQ_PRIORITY 7
162#define STM32_ICU_TIM5_IRQ_PRIORITY 7
163#define STM32_ICU_TIM9_IRQ_PRIORITY 7
164
165/*
166 * PWM driver system settings.
167 */
168#define STM32_PWM_USE_ADVANCED FALSE
169#define STM32_PWM_USE_TIM1 FALSE
170#define STM32_PWM_USE_TIM2 FALSE
171#define STM32_PWM_USE_TIM3 FALSE
172#define STM32_PWM_USE_TIM4 FALSE
173#define STM32_PWM_USE_TIM5 FALSE
174#define STM32_PWM_USE_TIM9 FALSE
175#define STM32_PWM_TIM1_IRQ_PRIORITY 7
176#define STM32_PWM_TIM2_IRQ_PRIORITY 7
177#define STM32_PWM_TIM3_IRQ_PRIORITY 7
178#define STM32_PWM_TIM4_IRQ_PRIORITY 7
179#define STM32_PWM_TIM5_IRQ_PRIORITY 7
180#define STM32_PWM_TIM9_IRQ_PRIORITY 7
181
182/*
183 * SERIAL driver system settings.
184 */
185#define STM32_SERIAL_USE_USART1 FALSE
186#define STM32_SERIAL_USE_USART2 FALSE
187#define STM32_SERIAL_USE_USART6 FALSE
188#define STM32_SERIAL_USART1_PRIORITY 12
189#define STM32_SERIAL_USART2_PRIORITY 12
190#define STM32_SERIAL_USART6_PRIORITY 12
191
192/*
193 * SPI driver system settings.
194 */
195#define STM32_SPI_USE_SPI1 FALSE
196#define STM32_SPI_USE_SPI2 FALSE
197#define STM32_SPI_USE_SPI3 FALSE
198#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
199#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
200#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
201#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
202#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
203#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
204#define STM32_SPI_SPI1_DMA_PRIORITY 1
205#define STM32_SPI_SPI2_DMA_PRIORITY 1
206#define STM32_SPI_SPI3_DMA_PRIORITY 1
207#define STM32_SPI_SPI1_IRQ_PRIORITY 10
208#define STM32_SPI_SPI2_IRQ_PRIORITY 10
209#define STM32_SPI_SPI3_IRQ_PRIORITY 10
210#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
211
212/*
213 * ST driver system settings.
214 */
215#define STM32_ST_IRQ_PRIORITY 8
216#define STM32_ST_USE_TIMER 2
217
218/*
219 * UART driver system settings.
220 */
221#define STM32_UART_USE_USART1 FALSE
222#define STM32_UART_USE_USART2 FALSE
223#define STM32_UART_USE_USART6 FALSE
224#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
225#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
226#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
227#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
228#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
229#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
230#define STM32_UART_USART1_IRQ_PRIORITY 12
231#define STM32_UART_USART2_IRQ_PRIORITY 12
232#define STM32_UART_USART6_IRQ_PRIORITY 12
233#define STM32_UART_USART1_DMA_PRIORITY 0
234#define STM32_UART_USART2_DMA_PRIORITY 0
235#define STM32_UART_USART6_DMA_PRIORITY 0
236#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
237
238/*
239 * USB driver system settings.
240 */
241#define STM32_USB_USE_OTG1 TRUE
242#define STM32_USB_OTG1_IRQ_PRIORITY 14
243#define STM32_USB_OTG1_RX_FIFO_SIZE 512
244#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1
245#define STM32_USB_OTG_THREAD_STACK_SIZE 128
246#define STM32_USB_OTGFIFO_FILL_BASEPRI 0
247
248/*
249 * WDG driver system settings.
250 */
251#define STM32_WDG_USE_IWDG FALSE
252
253#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld b/platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld
new file mode 100644
index 000000000..82253d3de
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xC_tinyuf2.ld
@@ -0,0 +1,89 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32F411xC memory setup.
19 */
20MEMORY
21{
22 flash0 (rx) : org = 0x08000000 + 64k, len = 256k - 64k /* tinyuf2 bootloader requires app to be located at 64k offset for this MCU */
23 flash1 (rx) : org = 0x00000000, len = 0
24 flash2 (rx) : org = 0x00000000, len = 0
25 flash3 (rx) : org = 0x00000000, len = 0
26 flash4 (rx) : org = 0x00000000, len = 0
27 flash5 (rx) : org = 0x00000000, len = 0
28 flash6 (rx) : org = 0x00000000, len = 0
29 flash7 (rx) : org = 0x00000000, len = 0
30 ram0 (wx) : org = 0x20000000, len = 128k
31 ram1 (wx) : org = 0x00000000, len = 0
32 ram2 (wx) : org = 0x00000000, len = 0
33 ram3 (wx) : org = 0x00000000, len = 0
34 ram4 (wx) : org = 0x00000000, len = 0
35 ram5 (wx) : org = 0x00000000, len = 0
36 ram6 (wx) : org = 0x00000000, len = 0
37 ram7 (wx) : org = 0x00000000, len = 0
38}
39
40/* For each data/text section two region are defined, a virtual region
41 and a load region (_LMA suffix).*/
42
43/* Flash region to be used for exception vectors.*/
44REGION_ALIAS("VECTORS_FLASH", flash0);
45REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
46
47/* Flash region to be used for constructors and destructors.*/
48REGION_ALIAS("XTORS_FLASH", flash0);
49REGION_ALIAS("XTORS_FLASH_LMA", flash0);
50
51/* Flash region to be used for code text.*/
52REGION_ALIAS("TEXT_FLASH", flash0);
53REGION_ALIAS("TEXT_FLASH_LMA", flash0);
54
55/* Flash region to be used for read only data.*/
56REGION_ALIAS("RODATA_FLASH", flash0);
57REGION_ALIAS("RODATA_FLASH_LMA", flash0);
58
59/* Flash region to be used for various.*/
60REGION_ALIAS("VARIOUS_FLASH", flash0);
61REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
62
63/* Flash region to be used for RAM(n) initialization data.*/
64REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
65
66/* RAM region to be used for Main stack. This stack accommodates the processing
67 of all exceptions and interrupts.*/
68REGION_ALIAS("MAIN_STACK_RAM", ram0);
69
70/* RAM region to be used for the process stack. This is the stack used by
71 the main() function.*/
72REGION_ALIAS("PROCESS_STACK_RAM", ram0);
73
74/* RAM region to be used for data segment.*/
75REGION_ALIAS("DATA_RAM", ram0);
76REGION_ALIAS("DATA_RAM_LMA", flash0);
77
78/* RAM region to be used for BSS segment.*/
79REGION_ALIAS("BSS_RAM", ram0);
80
81/* RAM region to be used for the default heap.*/
82REGION_ALIAS("HEAP_RAM", ram0);
83
84/* Generic rules inclusion.*/
85INCLUDE rules.ld
86
87/* TinyUF2 bootloader reset support */
88_board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */
89
diff --git a/platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld b/platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld
new file mode 100644
index 000000000..1656c67bf
--- /dev/null
+++ b/platforms/chibios/boards/BLACKPILL_STM32_F411/ld/STM32F411xE_tinyuf2.ld
@@ -0,0 +1,89 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32F411xE memory setup.
19 */
20MEMORY
21{
22 flash0 (rx) : org = 0x08000000 + 64k, len = 512k - 64k /* tinyuf2 bootloader requires app to be located at 64k offset for this MCU */
23 flash1 (rx) : org = 0x00000000, len = 0
24 flash2 (rx) : org = 0x00000000, len = 0
25 flash3 (rx) : org = 0x00000000, len = 0
26 flash4 (rx) : org = 0x00000000, len = 0
27 flash5 (rx) : org = 0x00000000, len = 0
28 flash6 (rx) : org = 0x00000000, len = 0
29 flash7 (rx) : org = 0x00000000, len = 0
30 ram0 (wx) : org = 0x20000000, len = 128k
31 ram1 (wx) : org = 0x00000000, len = 0
32 ram2 (wx) : org = 0x00000000, len = 0
33 ram3 (wx) : org = 0x00000000, len = 0
34 ram4 (wx) : org = 0x00000000, len = 0
35 ram5 (wx) : org = 0x00000000, len = 0
36 ram6 (wx) : org = 0x00000000, len = 0
37 ram7 (wx) : org = 0x00000000, len = 0
38}
39
40/* For each data/text section two region are defined, a virtual region
41 and a load region (_LMA suffix).*/
42
43/* Flash region to be used for exception vectors.*/
44REGION_ALIAS("VECTORS_FLASH", flash0);
45REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
46
47/* Flash region to be used for constructors and destructors.*/
48REGION_ALIAS("XTORS_FLASH", flash0);
49REGION_ALIAS("XTORS_FLASH_LMA", flash0);
50
51/* Flash region to be used for code text.*/
52REGION_ALIAS("TEXT_FLASH", flash0);
53REGION_ALIAS("TEXT_FLASH_LMA", flash0);
54
55/* Flash region to be used for read only data.*/
56REGION_ALIAS("RODATA_FLASH", flash0);
57REGION_ALIAS("RODATA_FLASH_LMA", flash0);
58
59/* Flash region to be used for various.*/
60REGION_ALIAS("VARIOUS_FLASH", flash0);
61REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
62
63/* Flash region to be used for RAM(n) initialization data.*/
64REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
65
66/* RAM region to be used for Main stack. This stack accommodates the processing
67 of all exceptions and interrupts.*/
68REGION_ALIAS("MAIN_STACK_RAM", ram0);
69
70/* RAM region to be used for the process stack. This is the stack used by
71 the main() function.*/
72REGION_ALIAS("PROCESS_STACK_RAM", ram0);
73
74/* RAM region to be used for data segment.*/
75REGION_ALIAS("DATA_RAM", ram0);
76REGION_ALIAS("DATA_RAM_LMA", flash0);
77
78/* RAM region to be used for BSS segment.*/
79REGION_ALIAS("BSS_RAM", ram0);
80
81/* RAM region to be used for the default heap.*/
82REGION_ALIAS("HEAP_RAM", ram0);
83
84/* Generic rules inclusion.*/
85INCLUDE rules.ld
86
87/* TinyUF2 bootloader reset support */
88_board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */
89
diff --git a/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.c b/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.c
new file mode 100644
index 000000000..0d7c88756
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.c
@@ -0,0 +1,265 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * This file has been automatically generated using ChibiStudio board
19 * generator plugin. Do not edit manually.
20 */
21
22#include <hal.h>
23#include <stm32_gpio.h>
24
25/*===========================================================================*/
26/* Driver local definitions. */
27/*===========================================================================*/
28
29/*===========================================================================*/
30/* Driver exported variables. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver local variables and types. */
35/*===========================================================================*/
36
37/**
38 * @brief Type of STM32 GPIO port setup.
39 */
40typedef struct {
41 uint32_t moder;
42 uint32_t otyper;
43 uint32_t ospeedr;
44 uint32_t pupdr;
45 uint32_t odr;
46 uint32_t afrl;
47 uint32_t afrh;
48} gpio_setup_t;
49
50/**
51 * @brief Type of STM32 GPIO initialization data.
52 */
53typedef struct {
54#if STM32_HAS_GPIOA || defined(__DOXYGEN__)
55 gpio_setup_t PAData;
56#endif
57#if STM32_HAS_GPIOB || defined(__DOXYGEN__)
58 gpio_setup_t PBData;
59#endif
60#if STM32_HAS_GPIOC || defined(__DOXYGEN__)
61 gpio_setup_t PCData;
62#endif
63#if STM32_HAS_GPIOD || defined(__DOXYGEN__)
64 gpio_setup_t PDData;
65#endif
66#if STM32_HAS_GPIOE || defined(__DOXYGEN__)
67 gpio_setup_t PEData;
68#endif
69#if STM32_HAS_GPIOF || defined(__DOXYGEN__)
70 gpio_setup_t PFData;
71#endif
72#if STM32_HAS_GPIOG || defined(__DOXYGEN__)
73 gpio_setup_t PGData;
74#endif
75#if STM32_HAS_GPIOH || defined(__DOXYGEN__)
76 gpio_setup_t PHData;
77#endif
78#if STM32_HAS_GPIOI || defined(__DOXYGEN__)
79 gpio_setup_t PIData;
80#endif
81#if STM32_HAS_GPIOJ || defined(__DOXYGEN__)
82 gpio_setup_t PJData;
83#endif
84#if STM32_HAS_GPIOK || defined(__DOXYGEN__)
85 gpio_setup_t PKData;
86#endif
87} gpio_config_t;
88
89/**
90 * @brief STM32 GPIO static initialization data.
91 */
92static const gpio_config_t gpio_default_config = {
93#if STM32_HAS_GPIOA
94 {VAL_GPIOA_MODER, VAL_GPIOA_OTYPER, VAL_GPIOA_OSPEEDR, VAL_GPIOA_PUPDR,
95 VAL_GPIOA_ODR, VAL_GPIOA_AFRL, VAL_GPIOA_AFRH},
96#endif
97#if STM32_HAS_GPIOB
98 {VAL_GPIOB_MODER, VAL_GPIOB_OTYPER, VAL_GPIOB_OSPEEDR, VAL_GPIOB_PUPDR,
99 VAL_GPIOB_ODR, VAL_GPIOB_AFRL, VAL_GPIOB_AFRH},
100#endif
101#if STM32_HAS_GPIOC
102 {VAL_GPIOC_MODER, VAL_GPIOC_OTYPER, VAL_GPIOC_OSPEEDR, VAL_GPIOC_PUPDR,
103 VAL_GPIOC_ODR, VAL_GPIOC_AFRL, VAL_GPIOC_AFRH},
104#endif
105#if STM32_HAS_GPIOD
106 {VAL_GPIOD_MODER, VAL_GPIOD_OTYPER, VAL_GPIOD_OSPEEDR, VAL_GPIOD_PUPDR,
107 VAL_GPIOD_ODR, VAL_GPIOD_AFRL, VAL_GPIOD_AFRH},
108#endif
109#if STM32_HAS_GPIOE
110 {VAL_GPIOE_MODER, VAL_GPIOE_OTYPER, VAL_GPIOE_OSPEEDR, VAL_GPIOE_PUPDR,
111 VAL_GPIOE_ODR, VAL_GPIOE_AFRL, VAL_GPIOE_AFRH},
112#endif
113#if STM32_HAS_GPIOF
114 {VAL_GPIOF_MODER, VAL_GPIOF_OTYPER, VAL_GPIOF_OSPEEDR, VAL_GPIOF_PUPDR,
115 VAL_GPIOF_ODR, VAL_GPIOF_AFRL, VAL_GPIOF_AFRH},
116#endif
117#if STM32_HAS_GPIOG
118 {VAL_GPIOG_MODER, VAL_GPIOG_OTYPER, VAL_GPIOG_OSPEEDR, VAL_GPIOG_PUPDR,
119 VAL_GPIOG_ODR, VAL_GPIOG_AFRL, VAL_GPIOG_AFRH},
120#endif
121#if STM32_HAS_GPIOH
122 {VAL_GPIOH_MODER, VAL_GPIOH_OTYPER, VAL_GPIOH_OSPEEDR, VAL_GPIOH_PUPDR,
123 VAL_GPIOH_ODR, VAL_GPIOH_AFRL, VAL_GPIOH_AFRH},
124#endif
125#if STM32_HAS_GPIOI
126 {VAL_GPIOI_MODER, VAL_GPIOI_OTYPER, VAL_GPIOI_OSPEEDR, VAL_GPIOI_PUPDR,
127 VAL_GPIOI_ODR, VAL_GPIOI_AFRL, VAL_GPIOI_AFRH},
128#endif
129#if STM32_HAS_GPIOJ
130 {VAL_GPIOJ_MODER, VAL_GPIOJ_OTYPER, VAL_GPIOJ_OSPEEDR, VAL_GPIOJ_PUPDR,
131 VAL_GPIOJ_ODR, VAL_GPIOJ_AFRL, VAL_GPIOJ_AFRH},
132#endif
133#if STM32_HAS_GPIOK
134 {VAL_GPIOK_MODER, VAL_GPIOK_OTYPER, VAL_GPIOK_OSPEEDR, VAL_GPIOK_PUPDR,
135 VAL_GPIOK_ODR, VAL_GPIOK_AFRL, VAL_GPIOK_AFRH}
136#endif
137};
138
139/*===========================================================================*/
140/* Driver local functions. */
141/*===========================================================================*/
142
143static void gpio_init(stm32_gpio_t *gpiop, const gpio_setup_t *config) {
144
145 gpiop->OTYPER = config->otyper;
146 gpiop->OSPEEDR = config->ospeedr;
147 gpiop->PUPDR = config->pupdr;
148 gpiop->ODR = config->odr;
149 gpiop->AFRL = config->afrl;
150 gpiop->AFRH = config->afrh;
151 gpiop->MODER = config->moder;
152}
153
154static void stm32_gpio_init(void) {
155
156 /* Enabling GPIO-related clocks, the mask comes from the
157 registry header file.*/
158 rccResetAHB(STM32_GPIO_EN_MASK);
159 rccEnableAHB(STM32_GPIO_EN_MASK, true);
160
161 /* Initializing all the defined GPIO ports.*/
162#if STM32_HAS_GPIOA
163 gpio_init(GPIOA, &gpio_default_config.PAData);
164#endif
165#if STM32_HAS_GPIOB
166 gpio_init(GPIOB, &gpio_default_config.PBData);
167#endif
168#if STM32_HAS_GPIOC
169 gpio_init(GPIOC, &gpio_default_config.PCData);
170#endif
171#if STM32_HAS_GPIOD
172 gpio_init(GPIOD, &gpio_default_config.PDData);
173#endif
174#if STM32_HAS_GPIOE
175 gpio_init(GPIOE, &gpio_default_config.PEData);
176#endif
177#if STM32_HAS_GPIOF
178 gpio_init(GPIOF, &gpio_default_config.PFData);
179#endif
180#if STM32_HAS_GPIOG
181 gpio_init(GPIOG, &gpio_default_config.PGData);
182#endif
183#if STM32_HAS_GPIOH
184 gpio_init(GPIOH, &gpio_default_config.PHData);
185#endif
186#if STM32_HAS_GPIOI
187 gpio_init(GPIOI, &gpio_default_config.PIData);
188#endif
189#if STM32_HAS_GPIOJ
190 gpio_init(GPIOJ, &gpio_default_config.PJData);
191#endif
192#if STM32_HAS_GPIOK
193 gpio_init(GPIOK, &gpio_default_config.PKData);
194#endif
195}
196
197/*===========================================================================*/
198/* Driver interrupt handlers. */
199/*===========================================================================*/
200
201/*===========================================================================*/
202/* Driver exported functions. */
203/*===========================================================================*/
204
205/**
206 * @brief Early initialization code.
207 * @details GPIO ports and system clocks are initialized before everything
208 * else.
209 */
210void __early_init(void) {
211 stm32_gpio_init();
212 stm32_clock_init();
213}
214
215#if HAL_USE_SDC || defined(__DOXYGEN__)
216/**
217 * @brief SDC card detection.
218 */
219bool sdc_lld_is_card_inserted(SDCDriver *sdcp) {
220
221 (void)sdcp;
222 /* TODO: Fill the implementation.*/
223 return true;
224}
225
226/**
227 * @brief SDC card write protection detection.
228 */
229bool sdc_lld_is_write_protected(SDCDriver *sdcp) {
230
231 (void)sdcp;
232 /* TODO: Fill the implementation.*/
233 return false;
234}
235#endif /* HAL_USE_SDC */
236
237#if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
238/**
239 * @brief MMC_SPI card detection.
240 */
241bool mmc_lld_is_card_inserted(MMCDriver *mmcp) {
242
243 (void)mmcp;
244 /* TODO: Fill the implementation.*/
245 return true;
246}
247
248/**
249 * @brief MMC_SPI card write protection detection.
250 */
251bool mmc_lld_is_write_protected(MMCDriver *mmcp) {
252
253 (void)mmcp;
254 /* TODO: Fill the implementation.*/
255 return false;
256}
257#endif
258
259/**
260 * @brief Board-specific initialization code.
261 * @todo Add your board-specific code, if any.
262 */
263void boardInit(void) {
264
265}
diff --git a/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.h b/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.h
new file mode 100644
index 000000000..ee9d31e04
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.h
@@ -0,0 +1,896 @@
1/*
2 ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16#ifndef _BOARD_H
17#define _BOARD_H
18
19/*
20 * Setup for STMicroelectronics STM32 Nucleo32-F042K6 board.
21 */
22
23/*
24 * Board identifier.
25 */
26#define BOARD_GENERIC_STM32_F042X6
27#define BOARD_NAME "Generic STM32F042 PCB"
28
29/*
30 * Board oscillators-related settings.
31 * NOTE: LSE not fitted.
32 * NOTE: HSE not fitted.
33 */
34#if !defined(STM32_LSECLK)
35#define STM32_LSECLK 0U
36#endif
37
38#define STM32_LSEDRV (3U << 3U)
39
40#if !defined(STM32_HSECLK)
41#define STM32_HSECLK 0U
42#endif
43
44/*
45 * MCU type as defined in the ST header.
46 */
47#define STM32F042x6
48
49/*
50 * IO pins assignments.
51 */
52#define GPIOA_PIN0 0U
53#define GPIOA_PIN1 1U
54#define GPIOA_PIN2 2U
55#define GPIOA_PIN3 3U
56#define GPIOA_PIN4 4U
57#define GPIOA_PIN5 5U
58#define GPIOA_PIN6 6U
59#define GPIOA_PIN7 7U
60#define GPIOA_PIN8 8U
61#define GPIOA_PIN9 9U
62#define GPIOA_PIN10 10U
63#define GPIOA_PIN11 11U
64#define GPIOA_PIN12 12U
65#define GPIOA_PIN13 13U
66#define GPIOA_PIN14 14U
67#define GPIOA_PIN15 15U
68
69#define GPIOB_PIN0 0U
70#define GPIOB_PIN1 1U
71#define GPIOB_PIN2 2U
72#define GPIOB_PIN3 3U
73#define GPIOB_PIN4 4U
74#define GPIOB_PIN5 5U
75#define GPIOB_PIN6 6U
76#define GPIOB_PIN7 7U
77#define GPIOB_PIN8 8U
78#define GPIOB_PIN9 9U
79#define GPIOB_PIN10 10U
80#define GPIOB_PIN11 11U
81#define GPIOB_PIN12 12U
82#define GPIOB_PIN13 13U
83#define GPIOB_PIN14 14U
84#define GPIOB_PIN15 15U
85
86#define GPIOC_PIN0 0U
87#define GPIOC_PIN1 1U
88#define GPIOC_PIN2 2U
89#define GPIOC_PIN3 3U
90#define GPIOC_PIN4 4U
91#define GPIOC_PIN5 5U
92#define GPIOC_PIN6 6U
93#define GPIOC_PIN7 7U
94#define GPIOC_PIN8 8U
95#define GPIOC_PIN9 9U
96#define GPIOC_PIN10 10U
97#define GPIOC_PIN11 11U
98#define GPIOC_PIN12 12U
99#define GPIOC_PIN13 13U
100#define GPIOC_PIN14 14U
101#define GPIOC_PIN15 15U
102
103#define GPIOD_PIN0 0U
104#define GPIOD_PIN1 1U
105#define GPIOD_PIN2 2U
106#define GPIOD_PIN3 3U
107#define GPIOD_PIN4 4U
108#define GPIOD_PIN5 5U
109#define GPIOD_PIN6 6U
110#define GPIOD_PIN7 7U
111#define GPIOD_PIN8 8U
112#define GPIOD_PIN9 9U
113#define GPIOD_PIN10 10U
114#define GPIOD_PIN11 11U
115#define GPIOD_PIN12 12U
116#define GPIOD_PIN13 13U
117#define GPIOD_PIN14 14U
118#define GPIOD_PIN15 15U
119
120#define GPIOE_PIN0 0U
121#define GPIOE_PIN1 1U
122#define GPIOE_PIN2 2U
123#define GPIOE_PIN3 3U
124#define GPIOE_PIN4 4U
125#define GPIOE_PIN5 5U
126#define GPIOE_PIN6 6U
127#define GPIOE_PIN7 7U
128#define GPIOE_PIN8 8U
129#define GPIOE_PIN9 9U
130#define GPIOE_PIN10 10U
131#define GPIOE_PIN11 11U
132#define GPIOE_PIN12 12U
133#define GPIOE_PIN13 13U
134#define GPIOE_PIN14 14U
135#define GPIOE_PIN15 15U
136
137#define GPIOF_PIN0 0U
138#define GPIOF_PIN1 1U
139#define GPIOF_PIN2 2U
140#define GPIOF_PIN3 3U
141#define GPIOF_PIN4 4U
142#define GPIOF_PIN5 5U
143#define GPIOF_PIN6 6U
144#define GPIOF_PIN7 7U
145#define GPIOF_PIN8 8U
146#define GPIOF_PIN9 9U
147#define GPIOF_PIN10 10U
148#define GPIOF_PIN11 11U
149#define GPIOF_PIN12 12U
150#define GPIOF_PIN13 13U
151#define GPIOF_PIN14 14U
152#define GPIOF_PIN15 15U
153
154/*
155 * IO lines assignments.
156 */
157
158#define LINE_BOOT0 PAL_LINE(GPIOB, 8U)
159#define LINE_SWCLK PAL_LINE(GPIOA, 14U)
160#define LINE_SWDIO PAL_LINE(GPIOA, 13U)
161
162/*
163 * I/O ports initial setup, this configuration is established soon after reset
164 * in the initialization code.
165 * Please refer to the STM32 Reference Manual for details.
166 */
167#define PIN_MODE_INPUT(n) (0U << ((n) * 2U))
168#define PIN_MODE_OUTPUT(n) (1U << ((n) * 2U))
169#define PIN_MODE_ALTERNATE(n) (2U << ((n) * 2U))
170#define PIN_MODE_ANALOG(n) (3U << ((n) * 2U))
171#define PIN_ODR_LOW(n) (0U << (n))
172#define PIN_ODR_HIGH(n) (1U << (n))
173#define PIN_OTYPE_PUSHPULL(n) (0U << (n))
174#define PIN_OTYPE_OPENDRAIN(n) (1U << (n))
175#define PIN_OSPEED_VERYLOW(n) (0U << ((n) * 2U))
176#define PIN_OSPEED_LOW(n) (1U << ((n) * 2U))
177#define PIN_OSPEED_MEDIUM(n) (2U << ((n) * 2U))
178#define PIN_OSPEED_HIGH(n) (3U << ((n) * 2U))
179#define PIN_PUPDR_FLOATING(n) (0U << ((n) * 2U))
180#define PIN_PUPDR_PULLUP(n) (1U << ((n) * 2U))
181#define PIN_PUPDR_PULLDOWN(n) (2U << ((n) * 2U))
182#define PIN_AFIO_AF(n, v) ((v) << (((n) % 8U) * 4U))
183
184/*
185 * GPIOA setup:
186 *
187 * PA0 - COL5
188 * PA1 - COL4
189 * PA2 - COL3
190 * PA3 - COL2
191 * PA4 - COL1
192 * PA5 - COL0
193 * PA6 - ROW4
194 * PA7 - ROW3
195 * PA8 - NC
196 * PA9 - ROW1
197 * PA10 - ROW0
198 * PA11 - USB_DM
199 * PA12 - USB_DP
200 * PA13 - COL15/SWDIO (for now, COL15)
201 * PA14 - COL14/SWCLK (for now, COL14)
202 * PA15 - COL13
203 */
204#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \
205 PIN_MODE_INPUT(GPIOA_PIN1) | \
206 PIN_MODE_INPUT(GPIOA_PIN2) | \
207 PIN_MODE_INPUT(GPIOA_PIN3) | \
208 PIN_MODE_INPUT(GPIOA_PIN4) | \
209 PIN_MODE_INPUT(GPIOA_PIN5) | \
210 PIN_MODE_INPUT(GPIOA_PIN6) | \
211 PIN_MODE_INPUT(GPIOA_PIN7) | \
212 PIN_MODE_INPUT(GPIOA_PIN8) | \
213 PIN_MODE_INPUT(GPIOA_PIN9) | \
214 PIN_MODE_INPUT(GPIOA_PIN10) | \
215 PIN_MODE_INPUT(GPIOA_PIN11) | \
216 PIN_MODE_INPUT(GPIOA_PIN12) | \
217 PIN_MODE_INPUT(GPIOA_PIN13) | \
218 PIN_MODE_INPUT(GPIOA_PIN14) | \
219 PIN_MODE_INPUT(GPIOA_PIN15))
220#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \
221 PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \
222 PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \
223 PIN_OTYPE_PUSHPULL(GPIOA_PIN3) | \
224 PIN_OTYPE_PUSHPULL(GPIOA_PIN4) | \
225 PIN_OTYPE_PUSHPULL(GPIOA_PIN5) | \
226 PIN_OTYPE_PUSHPULL(GPIOA_PIN6) | \
227 PIN_OTYPE_PUSHPULL(GPIOA_PIN7) | \
228 PIN_OTYPE_PUSHPULL(GPIOA_PIN8) | \
229 PIN_OTYPE_PUSHPULL(GPIOA_PIN9) | \
230 PIN_OTYPE_PUSHPULL(GPIOA_PIN10) | \
231 PIN_OTYPE_PUSHPULL(GPIOA_PIN11) | \
232 PIN_OTYPE_PUSHPULL(GPIOA_PIN12) | \
233 PIN_OTYPE_PUSHPULL(GPIOA_PIN13) | \
234 PIN_OTYPE_PUSHPULL(GPIOA_PIN14) | \
235 PIN_OTYPE_PUSHPULL(GPIOA_PIN15))
236#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOA_PIN0) | \
237 PIN_OSPEED_VERYLOW(GPIOA_PIN1) | \
238 PIN_OSPEED_VERYLOW(GPIOA_PIN2) | \
239 PIN_OSPEED_VERYLOW(GPIOA_PIN3) | \
240 PIN_OSPEED_VERYLOW(GPIOA_PIN4) | \
241 PIN_OSPEED_VERYLOW(GPIOA_PIN5) | \
242 PIN_OSPEED_VERYLOW(GPIOA_PIN6) | \
243 PIN_OSPEED_VERYLOW(GPIOA_PIN7) | \
244 PIN_OSPEED_VERYLOW(GPIOA_PIN8) | \
245 PIN_OSPEED_VERYLOW(GPIOA_PIN9) | \
246 PIN_OSPEED_VERYLOW(GPIOA_PIN10) | \
247 PIN_OSPEED_HIGH(GPIOA_PIN11) | \
248 PIN_OSPEED_VERYLOW(GPIOA_PIN12) | \
249 PIN_OSPEED_VERYLOW(GPIOA_PIN13) | \
250 PIN_OSPEED_VERYLOW(GPIOA_PIN14) | \
251 PIN_OSPEED_VERYLOW(GPIOA_PIN15))
252#define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLUP(GPIOA_PIN0) | \
253 PIN_PUPDR_PULLUP(GPIOA_PIN1) | \
254 PIN_PUPDR_PULLUP(GPIOA_PIN2) | \
255 PIN_PUPDR_PULLUP(GPIOA_PIN3) | \
256 PIN_PUPDR_PULLUP(GPIOA_PIN4) | \
257 PIN_PUPDR_PULLUP(GPIOA_PIN5) | \
258 PIN_PUPDR_PULLUP(GPIOA_PIN6) | \
259 PIN_PUPDR_PULLUP(GPIOA_PIN7) | \
260 PIN_PUPDR_PULLUP(GPIOA_PIN8) | \
261 PIN_PUPDR_PULLUP(GPIOA_PIN9) | \
262 PIN_PUPDR_PULLUP(GPIOA_PIN10) | \
263 PIN_PUPDR_FLOATING(GPIOA_PIN11) | \
264 PIN_PUPDR_FLOATING(GPIOA_PIN12) | \
265 PIN_PUPDR_PULLUP(GPIOA_PIN13) | \
266 PIN_PUPDR_PULLUP(GPIOA_PIN14) | \
267 PIN_PUPDR_PULLUP(GPIOA_PIN15))
268#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \
269 PIN_ODR_HIGH(GPIOA_PIN1) | \
270 PIN_ODR_HIGH(GPIOA_PIN2) | \
271 PIN_ODR_HIGH(GPIOA_PIN3) | \
272 PIN_ODR_HIGH(GPIOA_PIN4) | \
273 PIN_ODR_HIGH(GPIOA_PIN5) | \
274 PIN_ODR_HIGH(GPIOA_PIN6) | \
275 PIN_ODR_HIGH(GPIOA_PIN7) | \
276 PIN_ODR_HIGH(GPIOA_PIN8) | \
277 PIN_ODR_HIGH(GPIOA_PIN9) | \
278 PIN_ODR_HIGH(GPIOA_PIN10) | \
279 PIN_ODR_HIGH(GPIOA_PIN11) | \
280 PIN_ODR_HIGH(GPIOA_PIN12) | \
281 PIN_ODR_HIGH(GPIOA_PIN13) | \
282 PIN_ODR_HIGH(GPIOA_PIN14) | \
283 PIN_ODR_HIGH(GPIOA_PIN15))
284#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0U) | \
285 PIN_AFIO_AF(GPIOA_PIN1, 0U) | \
286 PIN_AFIO_AF(GPIOA_PIN2, 0U) | \
287 PIN_AFIO_AF(GPIOA_PIN3, 0U) | \
288 PIN_AFIO_AF(GPIOA_PIN4, 0U) | \
289 PIN_AFIO_AF(GPIOA_PIN5, 0U) | \
290 PIN_AFIO_AF(GPIOA_PIN6, 0U) | \
291 PIN_AFIO_AF(GPIOA_PIN7, 0U))
292#define VAL_GPIOA_AFRH (PIN_AFIO_AF(GPIOA_PIN8, 0U) | \
293 PIN_AFIO_AF(GPIOA_PIN9, 0U) | \
294 PIN_AFIO_AF(GPIOA_PIN10, 0U) | \
295 PIN_AFIO_AF(GPIOA_PIN11, 0U) | \
296 PIN_AFIO_AF(GPIOA_PIN12, 0U) | \
297 PIN_AFIO_AF(GPIOA_PIN13, 0U) | \
298 PIN_AFIO_AF(GPIOA_PIN14, 0U) | \
299 PIN_AFIO_AF(GPIOA_PIN15, 0U))
300
301/*
302 * GPIOB setup:
303 *
304 * PB0 - ROW2
305 * PB1 - RGB_D
306 * PB2 - PIN2 (input pullup).
307 * PB3 - COL12
308 * PB4 - COL11
309 * PB5 - COL10
310 * PB6 - COL9
311 * PB7 - COL8
312 * PB8 - BOOT0 (set as output for STM32F042)
313 * PB9 - PIN9 (input pullup).
314 * PB10 - PIN10 (input pullup).
315 * PB11 - PIN11 (input pullup).
316 * PB12 - PIN12 (input pullup).
317 * PB13 - PIN13 (input pullup).
318 * PB14 - PIN14 (input pullup).
319 * PB15 - PIN15 (input pullup).
320 */
321#define VAL_GPIOB_MODER (PIN_MODE_INPUT(GPIOB_PIN0) | \
322 PIN_MODE_OUTPUT(GPIOB_PIN1) | \
323 PIN_MODE_INPUT(GPIOB_PIN2) | \
324 PIN_MODE_INPUT(GPIOB_PIN3) | \
325 PIN_MODE_INPUT(GPIOB_PIN4) | \
326 PIN_MODE_INPUT(GPIOB_PIN5) | \
327 PIN_MODE_INPUT(GPIOB_PIN6) | \
328 PIN_MODE_INPUT(GPIOB_PIN7) | \
329 PIN_MODE_OUTPUT(GPIOB_PIN8) | \
330 PIN_MODE_INPUT(GPIOB_PIN9) | \
331 PIN_MODE_INPUT(GPIOB_PIN10) | \
332 PIN_MODE_INPUT(GPIOB_PIN11) | \
333 PIN_MODE_INPUT(GPIOB_PIN12) | \
334 PIN_MODE_INPUT(GPIOB_PIN13) | \
335 PIN_MODE_INPUT(GPIOB_PIN14) | \
336 PIN_MODE_INPUT(GPIOB_PIN15))
337#define VAL_GPIOB_OTYPER (PIN_OTYPE_PUSHPULL(GPIOB_PIN0) | \
338 PIN_OTYPE_PUSHPULL(GPIOB_PIN1) | \
339 PIN_OTYPE_PUSHPULL(GPIOB_PIN2) | \
340 PIN_OTYPE_PUSHPULL(GPIOB_PIN3) | \
341 PIN_OTYPE_PUSHPULL(GPIOB_PIN4) | \
342 PIN_OTYPE_PUSHPULL(GPIOB_PIN5) | \
343 PIN_OTYPE_PUSHPULL(GPIOB_PIN6) | \
344 PIN_OTYPE_PUSHPULL(GPIOB_PIN7) | \
345 PIN_OTYPE_PUSHPULL(GPIOB_PIN8) | \
346 PIN_OTYPE_PUSHPULL(GPIOB_PIN9) | \
347 PIN_OTYPE_PUSHPULL(GPIOB_PIN10) | \
348 PIN_OTYPE_PUSHPULL(GPIOB_PIN11) | \
349 PIN_OTYPE_PUSHPULL(GPIOB_PIN12) | \
350 PIN_OTYPE_PUSHPULL(GPIOB_PIN13) | \
351 PIN_OTYPE_PUSHPULL(GPIOB_PIN14) | \
352 PIN_OTYPE_PUSHPULL(GPIOB_PIN15))
353#define VAL_GPIOB_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOB_PIN0) | \
354 PIN_OSPEED_HIGH(GPIOB_PIN1) | \
355 PIN_OSPEED_HIGH(GPIOB_PIN2) | \
356 PIN_OSPEED_VERYLOW(GPIOB_PIN3) | \
357 PIN_OSPEED_VERYLOW(GPIOB_PIN4) | \
358 PIN_OSPEED_VERYLOW(GPIOB_PIN5) | \
359 PIN_OSPEED_VERYLOW(GPIOB_PIN6) | \
360 PIN_OSPEED_VERYLOW(GPIOB_PIN7) | \
361 PIN_OSPEED_VERYLOW(GPIOB_PIN8) | \
362 PIN_OSPEED_HIGH(GPIOB_PIN9) | \
363 PIN_OSPEED_HIGH(GPIOB_PIN10) | \
364 PIN_OSPEED_HIGH(GPIOB_PIN11) | \
365 PIN_OSPEED_HIGH(GPIOB_PIN12) | \
366 PIN_OSPEED_HIGH(GPIOB_PIN13) | \
367 PIN_OSPEED_HIGH(GPIOB_PIN14) | \
368 PIN_OSPEED_HIGH(GPIOB_PIN15))
369#define VAL_GPIOB_PUPDR (PIN_PUPDR_PULLUP(GPIOB_PIN0) | \
370 PIN_PUPDR_FLOATING(GPIOB_PIN1) | \
371 PIN_PUPDR_PULLUP(GPIOB_PIN2) | \
372 PIN_PUPDR_PULLUP(GPIOB_PIN3) | \
373 PIN_PUPDR_PULLUP(GPIOB_PIN4) | \
374 PIN_PUPDR_PULLUP(GPIOB_PIN5) | \
375 PIN_PUPDR_PULLUP(GPIOB_PIN6) | \
376 PIN_PUPDR_PULLUP(GPIOB_PIN7) | \
377 PIN_PUPDR_PULLDOWN(GPIOB_PIN8) | \
378 PIN_PUPDR_PULLUP(GPIOB_PIN9) | \
379 PIN_PUPDR_PULLUP(GPIOB_PIN10) | \
380 PIN_PUPDR_PULLUP(GPIOB_PIN11) | \
381 PIN_PUPDR_PULLUP(GPIOB_PIN12) | \
382 PIN_PUPDR_PULLUP(GPIOB_PIN13) | \
383 PIN_PUPDR_PULLUP(GPIOB_PIN14) | \
384 PIN_PUPDR_PULLUP(GPIOB_PIN15))
385#define VAL_GPIOB_ODR (PIN_ODR_HIGH(GPIOB_PIN0) | \
386 PIN_ODR_HIGH(GPIOB_PIN1) | \
387 PIN_ODR_HIGH(GPIOB_PIN2) | \
388 PIN_ODR_HIGH(GPIOB_PIN3) | \
389 PIN_ODR_HIGH(GPIOB_PIN4) | \
390 PIN_ODR_HIGH(GPIOB_PIN5) | \
391 PIN_ODR_HIGH(GPIOB_PIN6) | \
392 PIN_ODR_HIGH(GPIOB_PIN7) | \
393 PIN_ODR_HIGH(GPIOB_PIN8) | \
394 PIN_ODR_HIGH(GPIOB_PIN9) | \
395 PIN_ODR_HIGH(GPIOB_PIN10) | \
396 PIN_ODR_HIGH(GPIOB_PIN11) | \
397 PIN_ODR_HIGH(GPIOB_PIN12) | \
398 PIN_ODR_HIGH(GPIOB_PIN13) | \
399 PIN_ODR_HIGH(GPIOB_PIN14) | \
400 PIN_ODR_HIGH(GPIOB_PIN15))
401#define VAL_GPIOB_AFRL (PIN_AFIO_AF(GPIOB_PIN0, 0U) | \
402 PIN_AFIO_AF(GPIOB_PIN1, 0U) | \
403 PIN_AFIO_AF(GPIOB_PIN2, 0U) | \
404 PIN_AFIO_AF(GPIOB_PIN3, 0U) | \
405 PIN_AFIO_AF(GPIOB_PIN4, 0U) | \
406 PIN_AFIO_AF(GPIOB_PIN5, 0U) | \
407 PIN_AFIO_AF(GPIOB_PIN6, 0U) | \
408 PIN_AFIO_AF(GPIOB_PIN7, 0U))
409#define VAL_GPIOB_AFRH (PIN_AFIO_AF(GPIOB_PIN8, 0U) | \
410 PIN_AFIO_AF(GPIOB_PIN9, 0U) | \
411 PIN_AFIO_AF(GPIOB_PIN10, 0U) | \
412 PIN_AFIO_AF(GPIOB_PIN11, 0U) | \
413 PIN_AFIO_AF(GPIOB_PIN12, 0U) | \
414 PIN_AFIO_AF(GPIOB_PIN13, 0U) | \
415 PIN_AFIO_AF(GPIOB_PIN14, 0U) | \
416 PIN_AFIO_AF(GPIOB_PIN15, 0U))
417
418/*
419 * GPIOC setup:
420 *
421 * PC0 - PIN0 (input pullup).
422 * PC1 - PIN1 (input pullup).
423 * PC2 - PIN2 (input pullup).
424 * PC3 - PIN3 (input pullup).
425 * PC4 - PIN4 (input pullup).
426 * PC5 - PIN5 (input pullup).
427 * PC6 - PIN6 (input pullup).
428 * PC7 - PIN7 (input pullup).
429 * PC8 - PIN8 (input pullup).
430 * PC9 - PIN9 (input pullup).
431 * PC10 - PIN10 (input pullup).
432 * PC11 - PIN11 (input pullup).
433 * PC12 - PIN12 (input pullup).
434 * PC13 - PIN13 (input pullup).
435 * PC14 - PIN14 (input pullup).
436 * PC15 - PIN15 (input pullup).
437 */
438#define VAL_GPIOC_MODER (PIN_MODE_INPUT(GPIOC_PIN0) | \
439 PIN_MODE_INPUT(GPIOC_PIN1) | \
440 PIN_MODE_INPUT(GPIOC_PIN2) | \
441 PIN_MODE_INPUT(GPIOC_PIN3) | \
442 PIN_MODE_INPUT(GPIOC_PIN4) | \
443 PIN_MODE_INPUT(GPIOC_PIN5) | \
444 PIN_MODE_INPUT(GPIOC_PIN6) | \
445 PIN_MODE_INPUT(GPIOC_PIN7) | \
446 PIN_MODE_INPUT(GPIOC_PIN8) | \
447 PIN_MODE_INPUT(GPIOC_PIN9) | \
448 PIN_MODE_INPUT(GPIOC_PIN10) | \
449 PIN_MODE_INPUT(GPIOC_PIN11) | \
450 PIN_MODE_INPUT(GPIOC_PIN12) | \
451 PIN_MODE_INPUT(GPIOC_PIN13) | \
452 PIN_MODE_INPUT(GPIOC_PIN14) | \
453 PIN_MODE_INPUT(GPIOC_PIN15))
454#define VAL_GPIOC_OTYPER (PIN_OTYPE_PUSHPULL(GPIOC_PIN0) | \
455 PIN_OTYPE_PUSHPULL(GPIOC_PIN1) | \
456 PIN_OTYPE_PUSHPULL(GPIOC_PIN2) | \
457 PIN_OTYPE_PUSHPULL(GPIOC_PIN3) | \
458 PIN_OTYPE_PUSHPULL(GPIOC_PIN4) | \
459 PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | \
460 PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | \
461 PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | \
462 PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | \
463 PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | \
464 PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | \
465 PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | \
466 PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | \
467 PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | \
468 PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | \
469 PIN_OTYPE_PUSHPULL(GPIOC_PIN15))
470#define VAL_GPIOC_OSPEEDR (PIN_OSPEED_HIGH(GPIOC_PIN0) | \
471 PIN_OSPEED_HIGH(GPIOC_PIN1) | \
472 PIN_OSPEED_HIGH(GPIOC_PIN2) | \
473 PIN_OSPEED_HIGH(GPIOC_PIN3) | \
474 PIN_OSPEED_HIGH(GPIOC_PIN4) | \
475 PIN_OSPEED_HIGH(GPIOC_PIN5) | \
476 PIN_OSPEED_HIGH(GPIOC_PIN6) | \
477 PIN_OSPEED_HIGH(GPIOC_PIN7) | \
478 PIN_OSPEED_HIGH(GPIOC_PIN8) | \
479 PIN_OSPEED_HIGH(GPIOC_PIN9) | \
480 PIN_OSPEED_HIGH(GPIOC_PIN10) | \
481 PIN_OSPEED_HIGH(GPIOC_PIN11) | \
482 PIN_OSPEED_HIGH(GPIOC_PIN12) | \
483 PIN_OSPEED_HIGH(GPIOC_PIN13) | \
484 PIN_OSPEED_HIGH(GPIOC_PIN14) | \
485 PIN_OSPEED_HIGH(GPIOC_PIN15))
486#define VAL_GPIOC_PUPDR (PIN_PUPDR_PULLUP(GPIOC_PIN0) | \
487 PIN_PUPDR_PULLUP(GPIOC_PIN1) | \
488 PIN_PUPDR_PULLUP(GPIOC_PIN2) | \
489 PIN_PUPDR_PULLUP(GPIOC_PIN3) | \
490 PIN_PUPDR_PULLUP(GPIOC_PIN4) | \
491 PIN_PUPDR_PULLUP(GPIOC_PIN5) | \
492 PIN_PUPDR_PULLUP(GPIOC_PIN6) | \
493 PIN_PUPDR_PULLUP(GPIOC_PIN7) | \
494 PIN_PUPDR_PULLUP(GPIOC_PIN8) | \
495 PIN_PUPDR_PULLUP(GPIOC_PIN9) | \
496 PIN_PUPDR_PULLUP(GPIOC_PIN10) | \
497 PIN_PUPDR_PULLUP(GPIOC_PIN11) | \
498 PIN_PUPDR_PULLUP(GPIOC_PIN12) | \
499 PIN_PUPDR_PULLUP(GPIOC_PIN13) | \
500 PIN_PUPDR_PULLUP(GPIOC_PIN14) | \
501 PIN_PUPDR_PULLUP(GPIOC_PIN15))
502#define VAL_GPIOC_ODR (PIN_ODR_HIGH(GPIOC_PIN0) | \
503 PIN_ODR_HIGH(GPIOC_PIN1) | \
504 PIN_ODR_HIGH(GPIOC_PIN2) | \
505 PIN_ODR_HIGH(GPIOC_PIN3) | \
506 PIN_ODR_HIGH(GPIOC_PIN4) | \
507 PIN_ODR_HIGH(GPIOC_PIN5) | \
508 PIN_ODR_HIGH(GPIOC_PIN6) | \
509 PIN_ODR_HIGH(GPIOC_PIN7) | \
510 PIN_ODR_HIGH(GPIOC_PIN8) | \
511 PIN_ODR_HIGH(GPIOC_PIN9) | \
512 PIN_ODR_HIGH(GPIOC_PIN10) | \
513 PIN_ODR_HIGH(GPIOC_PIN11) | \
514 PIN_ODR_HIGH(GPIOC_PIN12) | \
515 PIN_ODR_HIGH(GPIOC_PIN13) | \
516 PIN_ODR_HIGH(GPIOC_PIN14) | \
517 PIN_ODR_HIGH(GPIOC_PIN15))
518#define VAL_GPIOC_AFRL (PIN_AFIO_AF(GPIOC_PIN0, 0U) | \
519 PIN_AFIO_AF(GPIOC_PIN1, 0U) | \
520 PIN_AFIO_AF(GPIOC_PIN2, 0U) | \
521 PIN_AFIO_AF(GPIOC_PIN3, 0U) | \
522 PIN_AFIO_AF(GPIOC_PIN4, 0U) | \
523 PIN_AFIO_AF(GPIOC_PIN5, 0U) | \
524 PIN_AFIO_AF(GPIOC_PIN6, 0U) | \
525 PIN_AFIO_AF(GPIOC_PIN7, 0U))
526#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0U) | \
527 PIN_AFIO_AF(GPIOC_PIN9, 0U) | \
528 PIN_AFIO_AF(GPIOC_PIN10, 0U) | \
529 PIN_AFIO_AF(GPIOC_PIN11, 0U) | \
530 PIN_AFIO_AF(GPIOC_PIN12, 0U) | \
531 PIN_AFIO_AF(GPIOC_PIN13, 0U) | \
532 PIN_AFIO_AF(GPIOC_PIN14, 0U) | \
533 PIN_AFIO_AF(GPIOC_PIN15, 0U))
534
535/*
536 * GPIOD setup:
537 *
538 * PD0 - PIN0 (input pullup).
539 * PD1 - PIN1 (input pullup).
540 * PD2 - PIN2 (input pullup).
541 * PD3 - PIN3 (input pullup).
542 * PD4 - PIN4 (input pullup).
543 * PD5 - PIN5 (input pullup).
544 * PD6 - PIN6 (input pullup).
545 * PD7 - PIN7 (input pullup).
546 * PD8 - PIN8 (input pullup).
547 * PD9 - PIN9 (input pullup).
548 * PD10 - PIN10 (input pullup).
549 * PD11 - PIN11 (input pullup).
550 * PD12 - PIN12 (input pullup).
551 * PD13 - PIN13 (input pullup).
552 * PD14 - PIN14 (input pullup).
553 * PD15 - PIN15 (input pullup).
554 */
555#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | \
556 PIN_MODE_INPUT(GPIOD_PIN1) | \
557 PIN_MODE_INPUT(GPIOD_PIN2) | \
558 PIN_MODE_INPUT(GPIOD_PIN3) | \
559 PIN_MODE_INPUT(GPIOD_PIN4) | \
560 PIN_MODE_INPUT(GPIOD_PIN5) | \
561 PIN_MODE_INPUT(GPIOD_PIN6) | \
562 PIN_MODE_INPUT(GPIOD_PIN7) | \
563 PIN_MODE_INPUT(GPIOD_PIN8) | \
564 PIN_MODE_INPUT(GPIOD_PIN9) | \
565 PIN_MODE_INPUT(GPIOD_PIN10) | \
566 PIN_MODE_INPUT(GPIOD_PIN11) | \
567 PIN_MODE_INPUT(GPIOD_PIN12) | \
568 PIN_MODE_INPUT(GPIOD_PIN13) | \
569 PIN_MODE_INPUT(GPIOD_PIN14) | \
570 PIN_MODE_INPUT(GPIOD_PIN15))
571#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | \
572 PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | \
573 PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | \
574 PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | \
575 PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | \
576 PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | \
577 PIN_OTYPE_PUSHPULL(GPIOD_PIN6) | \
578 PIN_OTYPE_PUSHPULL(GPIOD_PIN7) | \
579 PIN_OTYPE_PUSHPULL(GPIOD_PIN8) | \
580 PIN_OTYPE_PUSHPULL(GPIOD_PIN9) | \
581 PIN_OTYPE_PUSHPULL(GPIOD_PIN10) | \
582 PIN_OTYPE_PUSHPULL(GPIOD_PIN11) | \
583 PIN_OTYPE_PUSHPULL(GPIOD_PIN12) | \
584 PIN_OTYPE_PUSHPULL(GPIOD_PIN13) | \
585 PIN_OTYPE_PUSHPULL(GPIOD_PIN14) | \
586 PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
587#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_HIGH(GPIOD_PIN0) | \
588 PIN_OSPEED_HIGH(GPIOD_PIN1) | \
589 PIN_OSPEED_HIGH(GPIOD_PIN2) | \
590 PIN_OSPEED_HIGH(GPIOD_PIN3) | \
591 PIN_OSPEED_HIGH(GPIOD_PIN4) | \
592 PIN_OSPEED_HIGH(GPIOD_PIN5) | \
593 PIN_OSPEED_HIGH(GPIOD_PIN6) | \
594 PIN_OSPEED_HIGH(GPIOD_PIN7) | \
595 PIN_OSPEED_HIGH(GPIOD_PIN8) | \
596 PIN_OSPEED_HIGH(GPIOD_PIN9) | \
597 PIN_OSPEED_HIGH(GPIOD_PIN10) | \
598 PIN_OSPEED_HIGH(GPIOD_PIN11) | \
599 PIN_OSPEED_HIGH(GPIOD_PIN12) | \
600 PIN_OSPEED_HIGH(GPIOD_PIN13) | \
601 PIN_OSPEED_HIGH(GPIOD_PIN14) | \
602 PIN_OSPEED_HIGH(GPIOD_PIN15))
603#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | \
604 PIN_PUPDR_PULLUP(GPIOD_PIN1) | \
605 PIN_PUPDR_PULLUP(GPIOD_PIN2) | \
606 PIN_PUPDR_PULLUP(GPIOD_PIN3) | \
607 PIN_PUPDR_PULLUP(GPIOD_PIN4) | \
608 PIN_PUPDR_PULLUP(GPIOD_PIN5) | \
609 PIN_PUPDR_PULLUP(GPIOD_PIN6) | \
610 PIN_PUPDR_PULLUP(GPIOD_PIN7) | \
611 PIN_PUPDR_PULLUP(GPIOD_PIN8) | \
612 PIN_PUPDR_PULLUP(GPIOD_PIN9) | \
613 PIN_PUPDR_PULLUP(GPIOD_PIN10) | \
614 PIN_PUPDR_PULLUP(GPIOD_PIN11) | \
615 PIN_PUPDR_PULLUP(GPIOD_PIN12) | \
616 PIN_PUPDR_PULLUP(GPIOD_PIN13) | \
617 PIN_PUPDR_PULLUP(GPIOD_PIN14) | \
618 PIN_PUPDR_PULLUP(GPIOD_PIN15))
619#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | \
620 PIN_ODR_HIGH(GPIOD_PIN1) | \
621 PIN_ODR_HIGH(GPIOD_PIN2) | \
622 PIN_ODR_HIGH(GPIOD_PIN3) | \
623 PIN_ODR_HIGH(GPIOD_PIN4) | \
624 PIN_ODR_HIGH(GPIOD_PIN5) | \
625 PIN_ODR_HIGH(GPIOD_PIN6) | \
626 PIN_ODR_HIGH(GPIOD_PIN7) | \
627 PIN_ODR_HIGH(GPIOD_PIN8) | \
628 PIN_ODR_HIGH(GPIOD_PIN9) | \
629 PIN_ODR_HIGH(GPIOD_PIN10) | \
630 PIN_ODR_HIGH(GPIOD_PIN11) | \
631 PIN_ODR_HIGH(GPIOD_PIN12) | \
632 PIN_ODR_HIGH(GPIOD_PIN13) | \
633 PIN_ODR_HIGH(GPIOD_PIN14) | \
634 PIN_ODR_HIGH(GPIOD_PIN15))
635#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0U) | \
636 PIN_AFIO_AF(GPIOD_PIN1, 0U) | \
637 PIN_AFIO_AF(GPIOD_PIN2, 0U) | \
638 PIN_AFIO_AF(GPIOD_PIN3, 0U) | \
639 PIN_AFIO_AF(GPIOD_PIN4, 0U) | \
640 PIN_AFIO_AF(GPIOD_PIN5, 0U) | \
641 PIN_AFIO_AF(GPIOD_PIN6, 0U) | \
642 PIN_AFIO_AF(GPIOD_PIN7, 0U))
643#define VAL_GPIOD_AFRH (PIN_AFIO_AF(GPIOD_PIN8, 0U) | \
644 PIN_AFIO_AF(GPIOD_PIN9, 0U) | \
645 PIN_AFIO_AF(GPIOD_PIN10, 0U) | \
646 PIN_AFIO_AF(GPIOD_PIN11, 0U) | \
647 PIN_AFIO_AF(GPIOD_PIN12, 0U) | \
648 PIN_AFIO_AF(GPIOD_PIN13, 0U) | \
649 PIN_AFIO_AF(GPIOD_PIN14, 0U) | \
650 PIN_AFIO_AF(GPIOD_PIN15, 0U))
651
652/*
653 * GPIOE setup:
654 *
655 * PE0 - PIN0 (input pullup).
656 * PE1 - PIN1 (input pullup).
657 * PE2 - PIN2 (input pullup).
658 * PE3 - PIN3 (input pullup).
659 * PE4 - PIN4 (input pullup).
660 * PE5 - PIN5 (input pullup).
661 * PE6 - PIN6 (input pullup).
662 * PE7 - PIN7 (input pullup).
663 * PE8 - PIN8 (input pullup).
664 * PE9 - PIN9 (input pullup).
665 * PE10 - PIN10 (input pullup).
666 * PE11 - PIN11 (input pullup).
667 * PE12 - PIN12 (input pullup).
668 * PE13 - PIN13 (input pullup).
669 * PE14 - PIN14 (input pullup).
670 * PE15 - PIN15 (input pullup).
671 */
672#define VAL_GPIOE_MODER (PIN_MODE_INPUT(GPIOE_PIN0) | \
673 PIN_MODE_INPUT(GPIOE_PIN1) | \
674 PIN_MODE_INPUT(GPIOE_PIN2) | \
675 PIN_MODE_INPUT(GPIOE_PIN3) | \
676 PIN_MODE_INPUT(GPIOE_PIN4) | \
677 PIN_MODE_INPUT(GPIOE_PIN5) | \
678 PIN_MODE_INPUT(GPIOE_PIN6) | \
679 PIN_MODE_INPUT(GPIOE_PIN7) | \
680 PIN_MODE_INPUT(GPIOE_PIN8) | \
681 PIN_MODE_INPUT(GPIOE_PIN9) | \
682 PIN_MODE_INPUT(GPIOE_PIN10) | \
683 PIN_MODE_INPUT(GPIOE_PIN11) | \
684 PIN_MODE_INPUT(GPIOE_PIN12) | \
685 PIN_MODE_INPUT(GPIOE_PIN13) | \
686 PIN_MODE_INPUT(GPIOE_PIN14) | \
687 PIN_MODE_INPUT(GPIOE_PIN15))
688#define VAL_GPIOE_OTYPER (PIN_OTYPE_PUSHPULL(GPIOE_PIN0) | \
689 PIN_OTYPE_PUSHPULL(GPIOE_PIN1) | \
690 PIN_OTYPE_PUSHPULL(GPIOE_PIN2) | \
691 PIN_OTYPE_PUSHPULL(GPIOE_PIN3) | \
692 PIN_OTYPE_PUSHPULL(GPIOE_PIN4) | \
693 PIN_OTYPE_PUSHPULL(GPIOE_PIN5) | \
694 PIN_OTYPE_PUSHPULL(GPIOE_PIN6) | \
695 PIN_OTYPE_PUSHPULL(GPIOE_PIN7) | \
696 PIN_OTYPE_PUSHPULL(GPIOE_PIN8) | \
697 PIN_OTYPE_PUSHPULL(GPIOE_PIN9) | \
698 PIN_OTYPE_PUSHPULL(GPIOE_PIN10) | \
699 PIN_OTYPE_PUSHPULL(GPIOE_PIN11) | \
700 PIN_OTYPE_PUSHPULL(GPIOE_PIN12) | \
701 PIN_OTYPE_PUSHPULL(GPIOE_PIN13) | \
702 PIN_OTYPE_PUSHPULL(GPIOE_PIN14) | \
703 PIN_OTYPE_PUSHPULL(GPIOE_PIN15))
704#define VAL_GPIOE_OSPEEDR (PIN_OSPEED_HIGH(GPIOE_PIN0) | \
705 PIN_OSPEED_HIGH(GPIOE_PIN1) | \
706 PIN_OSPEED_HIGH(GPIOE_PIN2) | \
707 PIN_OSPEED_HIGH(GPIOE_PIN3) | \
708 PIN_OSPEED_HIGH(GPIOE_PIN4) | \
709 PIN_OSPEED_HIGH(GPIOE_PIN5) | \
710 PIN_OSPEED_HIGH(GPIOE_PIN6) | \
711 PIN_OSPEED_HIGH(GPIOE_PIN7) | \
712 PIN_OSPEED_HIGH(GPIOE_PIN8) | \
713 PIN_OSPEED_HIGH(GPIOE_PIN9) | \
714 PIN_OSPEED_HIGH(GPIOE_PIN10) | \
715 PIN_OSPEED_HIGH(GPIOE_PIN11) | \
716 PIN_OSPEED_HIGH(GPIOE_PIN12) | \
717 PIN_OSPEED_HIGH(GPIOE_PIN13) | \
718 PIN_OSPEED_HIGH(GPIOE_PIN14) | \
719 PIN_OSPEED_HIGH(GPIOE_PIN15))
720#define VAL_GPIOE_PUPDR (PIN_PUPDR_PULLUP(GPIOE_PIN0) | \
721 PIN_PUPDR_PULLUP(GPIOE_PIN1) | \
722 PIN_PUPDR_PULLUP(GPIOE_PIN2) | \
723 PIN_PUPDR_PULLUP(GPIOE_PIN3) | \
724 PIN_PUPDR_PULLUP(GPIOE_PIN4) | \
725 PIN_PUPDR_PULLUP(GPIOE_PIN5) | \
726 PIN_PUPDR_PULLUP(GPIOE_PIN6) | \
727 PIN_PUPDR_PULLUP(GPIOE_PIN7) | \
728 PIN_PUPDR_PULLUP(GPIOE_PIN8) | \
729 PIN_PUPDR_PULLUP(GPIOE_PIN9) | \
730 PIN_PUPDR_PULLUP(GPIOE_PIN10) | \
731 PIN_PUPDR_PULLUP(GPIOE_PIN11) | \
732 PIN_PUPDR_PULLUP(GPIOE_PIN12) | \
733 PIN_PUPDR_PULLUP(GPIOE_PIN13) | \
734 PIN_PUPDR_PULLUP(GPIOE_PIN14) | \
735 PIN_PUPDR_PULLUP(GPIOE_PIN15))
736#define VAL_GPIOE_ODR (PIN_ODR_HIGH(GPIOE_PIN0) | \
737 PIN_ODR_HIGH(GPIOE_PIN1) | \
738 PIN_ODR_HIGH(GPIOE_PIN2) | \
739 PIN_ODR_HIGH(GPIOE_PIN3) | \
740 PIN_ODR_HIGH(GPIOE_PIN4) | \
741 PIN_ODR_HIGH(GPIOE_PIN5) | \
742 PIN_ODR_HIGH(GPIOE_PIN6) | \
743 PIN_ODR_HIGH(GPIOE_PIN7) | \
744 PIN_ODR_HIGH(GPIOE_PIN8) | \
745 PIN_ODR_HIGH(GPIOE_PIN9) | \
746 PIN_ODR_HIGH(GPIOE_PIN10) | \
747 PIN_ODR_HIGH(GPIOE_PIN11) | \
748 PIN_ODR_HIGH(GPIOE_PIN12) | \
749 PIN_ODR_HIGH(GPIOE_PIN13) | \
750 PIN_ODR_HIGH(GPIOE_PIN14) | \
751 PIN_ODR_HIGH(GPIOE_PIN15))
752#define VAL_GPIOE_AFRL (PIN_AFIO_AF(GPIOE_PIN0, 0U) | \
753 PIN_AFIO_AF(GPIOE_PIN1, 0U) | \
754 PIN_AFIO_AF(GPIOE_PIN2, 0U) | \
755 PIN_AFIO_AF(GPIOE_PIN3, 0U) | \
756 PIN_AFIO_AF(GPIOE_PIN4, 0U) | \
757 PIN_AFIO_AF(GPIOE_PIN5, 0U) | \
758 PIN_AFIO_AF(GPIOE_PIN6, 0U) | \
759 PIN_AFIO_AF(GPIOE_PIN7, 0U))
760#define VAL_GPIOE_AFRH (PIN_AFIO_AF(GPIOE_PIN8, 0U) | \
761 PIN_AFIO_AF(GPIOE_PIN9, 0U) | \
762 PIN_AFIO_AF(GPIOE_PIN10, 0U) | \
763 PIN_AFIO_AF(GPIOE_PIN11, 0U) | \
764 PIN_AFIO_AF(GPIOE_PIN12, 0U) | \
765 PIN_AFIO_AF(GPIOE_PIN13, 0U) | \
766 PIN_AFIO_AF(GPIOE_PIN14, 0U) | \
767 PIN_AFIO_AF(GPIOE_PIN15, 0U))
768
769/*
770 * GPIOF setup:
771 *
772 * PF0 - COL7
773 * PF1 - COL6
774 * PF2 - PIN2 (input pullup).
775 * PF3 - PIN3 (input pullup).
776 * PF4 - PIN4 (input pullup).
777 * PF5 - PIN5 (input pullup).
778 * PF6 - PIN6 (input pullup).
779 * PF7 - PIN7 (input pullup).
780 * PF8 - PIN8 (input pullup).
781 * PF9 - PIN9 (input pullup).
782 * PF10 - PIN10 (input pullup).
783 * PF11 - PIN11 (input pullup).
784 * PF12 - PIN12 (input pullup).
785 * PF13 - PIN13 (input pullup).
786 * PF14 - PIN14 (input pullup).
787 * PF15 - PIN15 (input pullup).
788 */
789#define VAL_GPIOF_MODER (PIN_MODE_INPUT(GPIOF_PIN0) | \
790 PIN_MODE_INPUT(GPIOF_PIN1) | \
791 PIN_MODE_INPUT(GPIOF_PIN2) | \
792 PIN_MODE_INPUT(GPIOF_PIN3) | \
793 PIN_MODE_INPUT(GPIOF_PIN4) | \
794 PIN_MODE_INPUT(GPIOF_PIN5) | \
795 PIN_MODE_INPUT(GPIOF_PIN6) | \
796 PIN_MODE_INPUT(GPIOF_PIN7) | \
797 PIN_MODE_INPUT(GPIOF_PIN8) | \
798 PIN_MODE_INPUT(GPIOF_PIN9) | \
799 PIN_MODE_INPUT(GPIOF_PIN10) | \
800 PIN_MODE_INPUT(GPIOF_PIN11) | \
801 PIN_MODE_INPUT(GPIOF_PIN12) | \
802 PIN_MODE_INPUT(GPIOF_PIN13) | \
803 PIN_MODE_INPUT(GPIOF_PIN14) | \
804 PIN_MODE_INPUT(GPIOF_PIN15))
805#define VAL_GPIOF_OTYPER (PIN_OTYPE_PUSHPULL(GPIOF_PIN0) | \
806 PIN_OTYPE_PUSHPULL(GPIOF_PIN1) | \
807 PIN_OTYPE_PUSHPULL(GPIOF_PIN2) | \
808 PIN_OTYPE_PUSHPULL(GPIOF_PIN3) | \
809 PIN_OTYPE_PUSHPULL(GPIOF_PIN4) | \
810 PIN_OTYPE_PUSHPULL(GPIOF_PIN5) | \
811 PIN_OTYPE_PUSHPULL(GPIOF_PIN6) | \
812 PIN_OTYPE_PUSHPULL(GPIOF_PIN7) | \
813 PIN_OTYPE_PUSHPULL(GPIOF_PIN8) | \
814 PIN_OTYPE_PUSHPULL(GPIOF_PIN9) | \
815 PIN_OTYPE_PUSHPULL(GPIOF_PIN10) | \
816 PIN_OTYPE_PUSHPULL(GPIOF_PIN11) | \
817 PIN_OTYPE_PUSHPULL(GPIOF_PIN12) | \
818 PIN_OTYPE_PUSHPULL(GPIOF_PIN13) | \
819 PIN_OTYPE_PUSHPULL(GPIOF_PIN14) | \
820 PIN_OTYPE_PUSHPULL(GPIOF_PIN15))
821#define VAL_GPIOF_OSPEEDR (PIN_OSPEED_VERYLOW(GPIOF_PIN0) | \
822 PIN_OSPEED_VERYLOW(GPIOF_PIN1) | \
823 PIN_OSPEED_HIGH(GPIOF_PIN2) | \
824 PIN_OSPEED_HIGH(GPIOF_PIN3) | \
825 PIN_OSPEED_HIGH(GPIOF_PIN4) | \
826 PIN_OSPEED_HIGH(GPIOF_PIN5) | \
827 PIN_OSPEED_HIGH(GPIOF_PIN6) | \
828 PIN_OSPEED_HIGH(GPIOF_PIN7) | \
829 PIN_OSPEED_HIGH(GPIOF_PIN8) | \
830 PIN_OSPEED_HIGH(GPIOF_PIN9) | \
831 PIN_OSPEED_HIGH(GPIOF_PIN10) | \
832 PIN_OSPEED_HIGH(GPIOF_PIN11) | \
833 PIN_OSPEED_HIGH(GPIOF_PIN12) | \
834 PIN_OSPEED_HIGH(GPIOF_PIN13) | \
835 PIN_OSPEED_HIGH(GPIOF_PIN14) | \
836 PIN_OSPEED_HIGH(GPIOF_PIN15))
837#define VAL_GPIOF_PUPDR (PIN_PUPDR_PULLUP(GPIOF_PIN0) | \
838 PIN_PUPDR_PULLUP(GPIOF_PIN1) | \
839 PIN_PUPDR_PULLUP(GPIOF_PIN2) | \
840 PIN_PUPDR_PULLUP(GPIOF_PIN3) | \
841 PIN_PUPDR_PULLUP(GPIOF_PIN4) | \
842 PIN_PUPDR_PULLUP(GPIOF_PIN5) | \
843 PIN_PUPDR_PULLUP(GPIOF_PIN6) | \
844 PIN_PUPDR_PULLUP(GPIOF_PIN7) | \
845 PIN_PUPDR_PULLUP(GPIOF_PIN8) | \
846 PIN_PUPDR_PULLUP(GPIOF_PIN9) | \
847 PIN_PUPDR_PULLUP(GPIOF_PIN10) | \
848 PIN_PUPDR_PULLUP(GPIOF_PIN11) | \
849 PIN_PUPDR_PULLUP(GPIOF_PIN12) | \
850 PIN_PUPDR_PULLUP(GPIOF_PIN13) | \
851 PIN_PUPDR_PULLUP(GPIOF_PIN14) | \
852 PIN_PUPDR_PULLUP(GPIOF_PIN15))
853#define VAL_GPIOF_ODR (PIN_ODR_HIGH(GPIOF_PIN0) | \
854 PIN_ODR_HIGH(GPIOF_PIN1) | \
855 PIN_ODR_HIGH(GPIOF_PIN2) | \
856 PIN_ODR_HIGH(GPIOF_PIN3) | \
857 PIN_ODR_HIGH(GPIOF_PIN4) | \
858 PIN_ODR_HIGH(GPIOF_PIN5) | \
859 PIN_ODR_HIGH(GPIOF_PIN6) | \
860 PIN_ODR_HIGH(GPIOF_PIN7) | \
861 PIN_ODR_HIGH(GPIOF_PIN8) | \
862 PIN_ODR_HIGH(GPIOF_PIN9) | \
863 PIN_ODR_HIGH(GPIOF_PIN10) | \
864 PIN_ODR_HIGH(GPIOF_PIN11) | \
865 PIN_ODR_HIGH(GPIOF_PIN12) | \
866 PIN_ODR_HIGH(GPIOF_PIN13) | \
867 PIN_ODR_HIGH(GPIOF_PIN14) | \
868 PIN_ODR_HIGH(GPIOF_PIN15))
869#define VAL_GPIOF_AFRL (PIN_AFIO_AF(GPIOF_PIN0, 0U) | \
870 PIN_AFIO_AF(GPIOF_PIN1, 0U) | \
871 PIN_AFIO_AF(GPIOF_PIN2, 0U) | \
872 PIN_AFIO_AF(GPIOF_PIN3, 0U) | \
873 PIN_AFIO_AF(GPIOF_PIN4, 0U) | \
874 PIN_AFIO_AF(GPIOF_PIN5, 0U) | \
875 PIN_AFIO_AF(GPIOF_PIN6, 0U) | \
876 PIN_AFIO_AF(GPIOF_PIN7, 0U))
877#define VAL_GPIOF_AFRH (PIN_AFIO_AF(GPIOF_PIN8, 0U) | \
878 PIN_AFIO_AF(GPIOF_PIN9, 0U) | \
879 PIN_AFIO_AF(GPIOF_PIN10, 0U) | \
880 PIN_AFIO_AF(GPIOF_PIN11, 0U) | \
881 PIN_AFIO_AF(GPIOF_PIN12, 0U) | \
882 PIN_AFIO_AF(GPIOF_PIN13, 0U) | \
883 PIN_AFIO_AF(GPIOF_PIN14, 0U) | \
884 PIN_AFIO_AF(GPIOF_PIN15, 0U))
885
886#if !defined(_FROM_ASM_)
887#ifdef __cplusplus
888extern "C" {
889#endif
890 void boardInit(void);
891#ifdef __cplusplus
892}
893#endif
894#endif /* _FROM_ASM_ */
895
896#endif /* _BOARD_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.mk
new file mode 100644
index 000000000..842e33590
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F042X6/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(BOARD_PATH)/board/board.c
3
4# Required include directories
5BOARDINC = $(BOARD_PATH)/board
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/bootloader_defs.h b/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/bootloader_defs.h
new file mode 100644
index 000000000..25113425a
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/bootloader_defs.h
@@ -0,0 +1,5 @@
1/* Address for jumping to bootloader on STM32 chips. */
2/* It is chip dependent, the correct number can be looked up here:
3 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4 */
5#define STM32_BOOTLOADER_ADDRESS 0x1FFFC400
diff --git a/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/config.h
new file mode 100644
index 000000000..a73f0c0b4
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/config.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
19# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
20#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/mcuconf.h
new file mode 100644
index 000000000..286e1230c
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F042X6/configs/mcuconf.h
@@ -0,0 +1,168 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
12*/
13
14#ifndef _MCUCONF_H_
15#define _MCUCONF_H_
16
17/*
18 * STM32F0xx drivers configuration.
19 * The following settings override the default settings present in
20 * the various device driver implementation headers.
21 * Note that the settings for each driver only have effect if the whole
22 * driver is enabled in halconf.h.
23 *
24 * IRQ priorities:
25 * 3...0 Lowest...Highest.
26 *
27 * DMA priorities:
28 * 0...3 Lowest...Highest.
29 */
30
31#define STM32F0xx_MCUCONF
32
33/*
34 * HAL driver system settings.
35 */
36#define STM32_NO_INIT FALSE
37#define STM32_PVD_ENABLE FALSE
38#define STM32_PLS STM32_PLS_LEV0
39#define STM32_HSI_ENABLED TRUE
40#define STM32_HSI14_ENABLED TRUE
41#define STM32_HSI48_ENABLED FALSE
42#define STM32_LSI_ENABLED TRUE
43#define STM32_HSE_ENABLED FALSE
44#define STM32_LSE_ENABLED FALSE
45#define STM32_SW STM32_SW_PLL
46#define STM32_PLLSRC STM32_PLLSRC_HSI_DIV2
47#define STM32_PREDIV_VALUE 1
48#define STM32_PLLMUL_VALUE 12
49#define STM32_HPRE STM32_HPRE_DIV1
50#define STM32_PPRE STM32_PPRE_DIV1
51#define STM32_ADCSW STM32_ADCSW_HSI14
52#define STM32_ADCPRE STM32_ADCPRE_DIV4
53#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
54#define STM32_ADCPRE STM32_ADCPRE_DIV4
55#define STM32_ADCSW STM32_ADCSW_HSI14
56#define STM32_USBSW STM32_USBSW_HSI48
57#define STM32_CECSW STM32_CECSW_HSI
58#define STM32_I2C1SW STM32_I2C1SW_HSI
59#define STM32_USART1SW STM32_USART1SW_PCLK
60#define STM32_RTCSEL STM32_RTCSEL_LSI
61
62/*
63 * ADC driver system settings.
64 */
65#define STM32_ADC_USE_ADC1 FALSE
66#define STM32_ADC_ADC1_DMA_PRIORITY 2
67#define STM32_ADC_IRQ_PRIORITY 2
68#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 2
69
70/*
71 * EXT driver system settings.
72 */
73#define STM32_EXT_EXTI0_1_IRQ_PRIORITY 3
74#define STM32_EXT_EXTI2_3_IRQ_PRIORITY 3
75#define STM32_EXT_EXTI4_15_IRQ_PRIORITY 3
76#define STM32_EXT_EXTI16_IRQ_PRIORITY 3
77#define STM32_EXT_EXTI17_IRQ_PRIORITY 3
78
79/*
80 * GPT driver system settings.
81 */
82#define STM32_GPT_USE_TIM1 FALSE
83#define STM32_GPT_USE_TIM2 FALSE
84#define STM32_GPT_USE_TIM3 FALSE
85#define STM32_GPT_USE_TIM14 FALSE
86#define STM32_GPT_TIM1_IRQ_PRIORITY 2
87#define STM32_GPT_TIM2_IRQ_PRIORITY 2
88#define STM32_GPT_TIM3_IRQ_PRIORITY 2
89#define STM32_GPT_TIM14_IRQ_PRIORITY 2
90
91/*
92 * I2C driver system settings.
93 */
94#define STM32_I2C_USE_I2C1 FALSE
95#define STM32_I2C_USE_I2C2 FALSE
96#define STM32_I2C_BUSY_TIMEOUT 50
97#define STM32_I2C_I2C1_IRQ_PRIORITY 3
98#define STM32_I2C_I2C2_IRQ_PRIORITY 3
99#define STM32_I2C_USE_DMA TRUE
100#define STM32_I2C_I2C1_DMA_PRIORITY 1
101#define STM32_I2C_I2C2_DMA_PRIORITY 1
102#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
103
104/*
105 * ICU driver system settings.
106 */
107#define STM32_ICU_USE_TIM1 FALSE
108#define STM32_ICU_USE_TIM2 FALSE
109#define STM32_ICU_USE_TIM3 FALSE
110#define STM32_ICU_TIM1_IRQ_PRIORITY 3
111#define STM32_ICU_TIM2_IRQ_PRIORITY 3
112#define STM32_ICU_TIM3_IRQ_PRIORITY 3
113
114/*
115 * PWM driver system settings.
116 */
117#define STM32_PWM_USE_ADVANCED FALSE
118#define STM32_PWM_USE_TIM1 FALSE
119#define STM32_PWM_USE_TIM2 FALSE
120#define STM32_PWM_USE_TIM3 FALSE
121#define STM32_PWM_TIM1_IRQ_PRIORITY 3
122#define STM32_PWM_TIM2_IRQ_PRIORITY 3
123#define STM32_PWM_TIM3_IRQ_PRIORITY 3
124
125/*
126 * SERIAL driver system settings.
127 */
128#define STM32_SERIAL_USE_USART1 FALSE
129#define STM32_SERIAL_USE_USART2 FALSE
130#define STM32_SERIAL_USART1_PRIORITY 3
131#define STM32_SERIAL_USART2_PRIORITY 3
132
133/*
134 * SPI driver system settings.
135 */
136#define STM32_SPI_USE_SPI1 FALSE
137#define STM32_SPI_USE_SPI2 FALSE
138#define STM32_SPI_SPI1_DMA_PRIORITY 1
139#define STM32_SPI_SPI2_DMA_PRIORITY 1
140#define STM32_SPI_SPI1_IRQ_PRIORITY 2
141#define STM32_SPI_SPI2_IRQ_PRIORITY 2
142#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
143
144/*
145 * ST driver system settings.
146 */
147#define STM32_ST_IRQ_PRIORITY 2
148#define STM32_ST_USE_TIMER 2
149
150/*
151 * UART driver system settings.
152 */
153#define STM32_UART_USE_USART1 FALSE
154#define STM32_UART_USE_USART2 FALSE
155#define STM32_UART_USART1_IRQ_PRIORITY 3
156#define STM32_UART_USART2_IRQ_PRIORITY 3
157#define STM32_UART_USART1_DMA_PRIORITY 0
158#define STM32_UART_USART2_DMA_PRIORITY 0
159#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
160
161/*
162 * USB driver system settings.
163 */
164#define STM32_USB_USE_USB1 TRUE
165#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
166#define STM32_USB_USB1_LP_IRQ_PRIORITY 3
167
168#endif /* _MCUCONF_H_ */
diff --git a/platforms/chibios/boards/GENERIC_STM32_F072XB/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F072XB/board/board.mk
new file mode 100644
index 000000000..3f0e6c46e
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F072XB/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F072RB/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F072RB
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/board.h
new file mode 100644
index 000000000..30af6b0c8
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/board.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/bootloader_defs.h b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/bootloader_defs.h
new file mode 100644
index 000000000..dccd0fa5d
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/bootloader_defs.h
@@ -0,0 +1,5 @@
1/* Address for jumping to bootloader on STM32 chips. */
2/* It is chip dependent, the correct number can be looked up here (page 175):
3 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4 */
5#define STM32_BOOTLOADER_ADDRESS 0x1FFFC800
diff --git a/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/config.h
new file mode 100644
index 000000000..a73f0c0b4
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/config.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
19# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
20#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/mcuconf.h
new file mode 100644
index 000000000..32b2777a8
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F072XB/configs/mcuconf.h
@@ -0,0 +1,179 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20/*
21 * STM32F0xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 3...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F0xx_MCUCONF
35// #define STM32F070xB
36
37/*
38 * HAL driver system settings.
39 */
40#define STM32_NO_INIT FALSE
41#define STM32_PVD_ENABLE FALSE
42#define STM32_PLS STM32_PLS_LEV0
43#define STM32_HSI_ENABLED TRUE
44#define STM32_HSI14_ENABLED TRUE
45#define STM32_HSI48_ENABLED FALSE
46#define STM32_LSI_ENABLED TRUE
47#define STM32_HSE_ENABLED FALSE
48#define STM32_LSE_ENABLED FALSE
49#define STM32_SW STM32_SW_PLL
50#define STM32_PLLSRC STM32_PLLSRC_HSI_DIV2
51#define STM32_PREDIV_VALUE 1
52#define STM32_PLLMUL_VALUE 12
53#define STM32_HPRE STM32_HPRE_DIV1
54#define STM32_PPRE STM32_PPRE_DIV1
55#define STM32_ADCSW STM32_ADCSW_HSI14
56#define STM32_ADCPRE STM32_ADCPRE_DIV4
57#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
58#define STM32_ADCPRE STM32_ADCPRE_DIV4
59#define STM32_ADCSW STM32_ADCSW_HSI14
60#define STM32_USBSW STM32_USBSW_HSI48
61#define STM32_CECSW STM32_CECSW_HSI
62#define STM32_I2C1SW STM32_I2C1SW_HSI
63#define STM32_USART1SW STM32_USART1SW_PCLK
64#define STM32_RTCSEL STM32_RTCSEL_LSI
65
66/*
67 * IRQ system settings.
68 */
69#define STM32_IRQ_EXTI0_1_IRQ_PRIORITY 3
70#define STM32_IRQ_EXTI2_3_IRQ_PRIORITY 3
71#define STM32_IRQ_EXTI4_15_IRQ_PRIORITY 3
72#define STM32_IRQ_EXTI16_IRQ_PRIORITY 3
73#define STM32_IRQ_EXTI17_20_IRQ_PRIORITY 3
74#define STM32_IRQ_EXTI21_22_IRQ_PRIORITY 3
75
76/*
77 * ADC driver system settings.
78 */
79#define STM32_ADC_USE_ADC1 FALSE
80#define STM32_ADC_ADC1_DMA_PRIORITY 2
81#define STM32_ADC_IRQ_PRIORITY 2
82#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 2
83
84/*
85 * GPT driver system settings.
86 */
87#define STM32_GPT_USE_TIM1 FALSE
88#define STM32_GPT_USE_TIM2 FALSE
89#define STM32_GPT_USE_TIM3 FALSE
90#define STM32_GPT_USE_TIM14 FALSE
91#define STM32_GPT_TIM1_IRQ_PRIORITY 2
92#define STM32_GPT_TIM2_IRQ_PRIORITY 2
93#define STM32_GPT_TIM3_IRQ_PRIORITY 2
94#define STM32_GPT_TIM14_IRQ_PRIORITY 2
95
96/*
97 * I2C driver system settings.
98 */
99#define STM32_I2C_USE_I2C1 FALSE
100#define STM32_I2C_USE_I2C2 FALSE
101#define STM32_I2C_BUSY_TIMEOUT 50
102#define STM32_I2C_I2C1_IRQ_PRIORITY 3
103#define STM32_I2C_I2C2_IRQ_PRIORITY 3
104#define STM32_I2C_USE_DMA TRUE
105#define STM32_I2C_I2C1_DMA_PRIORITY 1
106#define STM32_I2C_I2C2_DMA_PRIORITY 1
107#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
108#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
109#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
110
111/*
112 * ICU driver system settings.
113 */
114#define STM32_ICU_USE_TIM1 FALSE
115#define STM32_ICU_USE_TIM2 FALSE
116#define STM32_ICU_USE_TIM3 FALSE
117#define STM32_ICU_TIM1_IRQ_PRIORITY 3
118#define STM32_ICU_TIM2_IRQ_PRIORITY 3
119#define STM32_ICU_TIM3_IRQ_PRIORITY 3
120
121/*
122 * PWM driver system settings.
123 */
124#define STM32_PWM_USE_ADVANCED FALSE
125#define STM32_PWM_USE_TIM1 FALSE
126#define STM32_PWM_USE_TIM2 FALSE
127#define STM32_PWM_USE_TIM3 FALSE
128#define STM32_PWM_TIM1_IRQ_PRIORITY 3
129#define STM32_PWM_TIM2_IRQ_PRIORITY 3
130#define STM32_PWM_TIM3_IRQ_PRIORITY 3
131
132/*
133 * SERIAL driver system settings.
134 */
135#define STM32_SERIAL_USE_USART1 FALSE
136#define STM32_SERIAL_USE_USART2 FALSE
137#define STM32_SERIAL_USART1_PRIORITY 3
138#define STM32_SERIAL_USART2_PRIORITY 3
139
140/*
141 * SPI driver system settings.
142 */
143#define STM32_SPI_USE_SPI1 FALSE
144#define STM32_SPI_USE_SPI2 FALSE
145#define STM32_SPI_SPI1_DMA_PRIORITY 1
146#define STM32_SPI_SPI2_DMA_PRIORITY 1
147#define STM32_SPI_SPI1_IRQ_PRIORITY 2
148#define STM32_SPI_SPI2_IRQ_PRIORITY 2
149#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
150#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
151#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
152#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
153#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
154
155/*
156 * ST driver system settings.
157 */
158#define STM32_ST_IRQ_PRIORITY 2
159#define STM32_ST_USE_TIMER 2
160
161/*
162 * UART driver system settings.
163 */
164#define STM32_UART_USE_USART1 FALSE
165#define STM32_UART_USE_USART2 FALSE
166#define STM32_UART_USART1_IRQ_PRIORITY 3
167#define STM32_UART_USART2_IRQ_PRIORITY 3
168#define STM32_UART_USART1_DMA_PRIORITY 0
169#define STM32_UART_USART2_DMA_PRIORITY 0
170#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
171
172/*
173 * USB driver system settings.
174 */
175#define STM32_USB_USE_USB1 TRUE
176#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
177#define STM32_USB_USB1_LP_IRQ_PRIORITY 3
178
179#endif /* _MCUCONF_H_ */
diff --git a/platforms/chibios/boards/GENERIC_STM32_F303XC/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F303XC/board/board.mk
new file mode 100644
index 000000000..f891e6524
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F303XC/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/board.h
new file mode 100644
index 000000000..97159964d
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/board.h
@@ -0,0 +1,37 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32_HSE_BYPASS
21
22/*
23 * USB bus activation macro, required by the USB driver.
24 */
25#define usb_lld_connect_bus(usbp) \
26 do { \
27 palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_ALTERNATE(14)); \
28 } while (0)
29
30/*
31 * USB bus de-activation macro, required by the USB driver.
32 */
33#define usb_lld_disconnect_bus(usbp) \
34 do { \
35 palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL); \
36 palClearPad(GPIOA, GPIOA_USB_DP); \
37 } while (0)
diff --git a/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/bootloader_defs.h b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/bootloader_defs.h
new file mode 100644
index 000000000..87ac7b10d
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/bootloader_defs.h
@@ -0,0 +1,5 @@
1/* Address for jumping to bootloader on STM32 chips. */
2/* It is chip dependent, the correct number can be looked up here:
3 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4 */
5#define STM32_BOOTLOADER_ADDRESS 0x1FFFD800
diff --git a/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/config.h
new file mode 100644
index 000000000..a73f0c0b4
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/config.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
19# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
20#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/mcuconf.h
new file mode 100644
index 000000000..c6f5a8ac5
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F303XC/configs/mcuconf.h
@@ -0,0 +1,273 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef MCUCONF_H
18#define MCUCONF_H
19
20/*
21 * STM32F3xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 15...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F3xx_MCUCONF
35#define STM32F303_MCUCONF
36
37/*
38 * HAL driver system settings.
39 */
40#define STM32_NO_INIT FALSE
41#define STM32_PVD_ENABLE FALSE
42#define STM32_PLS STM32_PLS_LEV0
43#define STM32_HSI_ENABLED TRUE
44#define STM32_LSI_ENABLED TRUE
45#define STM32_HSE_ENABLED TRUE
46#define STM32_LSE_ENABLED FALSE
47#define STM32_SW STM32_SW_PLL
48#define STM32_PLLSRC STM32_PLLSRC_HSE
49#define STM32_PREDIV_VALUE 1
50#define STM32_PLLMUL_VALUE 9
51#define STM32_HPRE STM32_HPRE_DIV1
52#define STM32_PPRE1 STM32_PPRE1_DIV2
53#define STM32_PPRE2 STM32_PPRE2_DIV2
54#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
55#define STM32_ADC12PRES STM32_ADC12PRES_DIV1
56#define STM32_ADC34PRES STM32_ADC34PRES_DIV1
57#define STM32_USART1SW STM32_USART1SW_PCLK
58#define STM32_USART2SW STM32_USART2SW_PCLK
59#define STM32_USART3SW STM32_USART3SW_PCLK
60#define STM32_UART4SW STM32_UART4SW_PCLK
61#define STM32_UART5SW STM32_UART5SW_PCLK
62#define STM32_I2C1SW STM32_I2C1SW_SYSCLK
63#define STM32_I2C2SW STM32_I2C2SW_SYSCLK
64#define STM32_TIM1SW STM32_TIM1SW_PCLK2
65#define STM32_TIM8SW STM32_TIM8SW_PCLK2
66#define STM32_RTCSEL STM32_RTCSEL_LSI
67#define STM32_USB_CLOCK_REQUIRED TRUE
68#define STM32_USBPRE STM32_USBPRE_DIV1P5
69
70/*
71 * IRQ system settings.
72 */
73#define STM32_IRQ_EXTI0_PRIORITY 6
74#define STM32_IRQ_EXTI1_PRIORITY 6
75#define STM32_IRQ_EXTI2_PRIORITY 6
76#define STM32_IRQ_EXTI3_PRIORITY 6
77#define STM32_IRQ_EXTI4_PRIORITY 6
78#define STM32_IRQ_EXTI5_9_PRIORITY 6
79#define STM32_IRQ_EXTI10_15_PRIORITY 6
80#define STM32_IRQ_EXTI16_PRIORITY 6
81#define STM32_IRQ_EXTI17_PRIORITY 15
82#define STM32_IRQ_EXTI18_PRIORITY 6
83#define STM32_IRQ_EXTI19_PRIORITY 15
84#define STM32_IRQ_EXTI20_PRIORITY 15
85#define STM32_IRQ_EXTI21_22_29_PRIORITY 6
86#define STM32_IRQ_EXTI30_32_PRIORITY 6
87#define STM32_IRQ_EXTI33_PRIORITY 6
88#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
89#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
90#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
91#define STM32_IRQ_TIM1_CC_PRIORITY 7
92
93/*
94 * ADC driver system settings.
95 */
96#define STM32_ADC_DUAL_MODE FALSE
97#define STM32_ADC_COMPACT_SAMPLES FALSE
98#define STM32_ADC_USE_ADC1 FALSE
99#define STM32_ADC_USE_ADC2 FALSE
100#define STM32_ADC_USE_ADC3 FALSE
101#define STM32_ADC_USE_ADC4 FALSE
102#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
103#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
104#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
105#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
106#define STM32_ADC_ADC1_DMA_PRIORITY 2
107#define STM32_ADC_ADC2_DMA_PRIORITY 2
108#define STM32_ADC_ADC3_DMA_PRIORITY 2
109#define STM32_ADC_ADC4_DMA_PRIORITY 2
110#define STM32_ADC_ADC12_IRQ_PRIORITY 5
111#define STM32_ADC_ADC3_IRQ_PRIORITY 5
112#define STM32_ADC_ADC4_IRQ_PRIORITY 5
113#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
114#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
115#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5
116#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5
117#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
118#define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
119
120/*
121 * CAN driver system settings.
122 */
123#define STM32_CAN_USE_CAN1 FALSE
124#define STM32_CAN_CAN1_IRQ_PRIORITY 11
125
126/*
127 * DAC driver system settings.
128 */
129#define STM32_DAC_DUAL_MODE FALSE
130#define STM32_DAC_USE_DAC1_CH1 FALSE
131#define STM32_DAC_USE_DAC1_CH2 FALSE
132#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
133#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
134#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
135#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
136
137/*
138 * GPT driver system settings.
139 */
140#define STM32_GPT_USE_TIM1 FALSE
141#define STM32_GPT_USE_TIM2 FALSE
142#define STM32_GPT_USE_TIM3 FALSE
143#define STM32_GPT_USE_TIM4 FALSE
144#define STM32_GPT_USE_TIM6 FALSE
145#define STM32_GPT_USE_TIM7 FALSE
146#define STM32_GPT_USE_TIM8 FALSE
147#define STM32_GPT_USE_TIM15 FALSE
148#define STM32_GPT_USE_TIM16 FALSE
149#define STM32_GPT_USE_TIM17 FALSE
150#define STM32_GPT_TIM1_IRQ_PRIORITY 7
151#define STM32_GPT_TIM2_IRQ_PRIORITY 7
152#define STM32_GPT_TIM3_IRQ_PRIORITY 7
153#define STM32_GPT_TIM4_IRQ_PRIORITY 7
154#define STM32_GPT_TIM6_IRQ_PRIORITY 7
155#define STM32_GPT_TIM7_IRQ_PRIORITY 7
156#define STM32_GPT_TIM8_IRQ_PRIORITY 7
157
158/*
159 * I2C driver system settings.
160 */
161#define STM32_I2C_USE_I2C1 FALSE
162#define STM32_I2C_USE_I2C2 FALSE
163#define STM32_I2C_BUSY_TIMEOUT 50
164#define STM32_I2C_I2C1_IRQ_PRIORITY 10
165#define STM32_I2C_I2C2_IRQ_PRIORITY 10
166#define STM32_I2C_USE_DMA TRUE
167#define STM32_I2C_I2C1_DMA_PRIORITY 1
168#define STM32_I2C_I2C2_DMA_PRIORITY 1
169#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
170
171/*
172 * ICU driver system settings.
173 */
174#define STM32_ICU_USE_TIM1 FALSE
175#define STM32_ICU_USE_TIM2 FALSE
176#define STM32_ICU_USE_TIM3 FALSE
177#define STM32_ICU_USE_TIM4 FALSE
178#define STM32_ICU_USE_TIM8 FALSE
179#define STM32_ICU_USE_TIM15 FALSE
180#define STM32_ICU_TIM1_IRQ_PRIORITY 7
181#define STM32_ICU_TIM2_IRQ_PRIORITY 7
182#define STM32_ICU_TIM3_IRQ_PRIORITY 7
183#define STM32_ICU_TIM4_IRQ_PRIORITY 7
184#define STM32_ICU_TIM8_IRQ_PRIORITY 7
185
186/*
187 * PWM driver system settings.
188 */
189#define STM32_PWM_USE_ADVANCED FALSE
190#define STM32_PWM_USE_TIM1 FALSE
191#define STM32_PWM_USE_TIM2 FALSE
192#define STM32_PWM_USE_TIM3 FALSE
193#define STM32_PWM_USE_TIM4 FALSE
194#define STM32_PWM_USE_TIM8 FALSE
195#define STM32_PWM_USE_TIM15 FALSE
196#define STM32_PWM_USE_TIM16 FALSE
197#define STM32_PWM_USE_TIM17 FALSE
198#define STM32_PWM_TIM1_IRQ_PRIORITY 7
199#define STM32_PWM_TIM2_IRQ_PRIORITY 7
200#define STM32_PWM_TIM3_IRQ_PRIORITY 7
201#define STM32_PWM_TIM4_IRQ_PRIORITY 7
202#define STM32_PWM_TIM8_IRQ_PRIORITY 7
203
204/*
205 * RTC driver system settings.
206 */
207#define STM32_RTC_PRESA_VALUE 32
208#define STM32_RTC_PRESS_VALUE 1024
209#define STM32_RTC_CR_INIT 0
210#define STM32_RTC_TAMPCR_INIT 0
211
212/*
213 * SERIAL driver system settings.
214 */
215#define STM32_SERIAL_USE_USART1 FALSE
216#define STM32_SERIAL_USE_USART2 FALSE
217#define STM32_SERIAL_USE_USART3 FALSE
218#define STM32_SERIAL_USE_UART4 FALSE
219#define STM32_SERIAL_USE_UART5 FALSE
220#define STM32_SERIAL_USART1_PRIORITY 12
221#define STM32_SERIAL_USART2_PRIORITY 12
222#define STM32_SERIAL_USART3_PRIORITY 12
223#define STM32_SERIAL_UART4_PRIORITY 12
224#define STM32_SERIAL_UART5_PRIORITY 12
225
226/*
227 * SPI driver system settings.
228 */
229#define STM32_SPI_USE_SPI1 FALSE
230#define STM32_SPI_USE_SPI2 FALSE
231#define STM32_SPI_USE_SPI3 FALSE
232#define STM32_SPI_SPI1_DMA_PRIORITY 1
233#define STM32_SPI_SPI2_DMA_PRIORITY 1
234#define STM32_SPI_SPI3_DMA_PRIORITY 1
235#define STM32_SPI_SPI1_IRQ_PRIORITY 10
236#define STM32_SPI_SPI2_IRQ_PRIORITY 10
237#define STM32_SPI_SPI3_IRQ_PRIORITY 10
238#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
239
240/*
241 * ST driver system settings.
242 */
243#define STM32_ST_IRQ_PRIORITY 8
244#define STM32_ST_USE_TIMER 2
245
246/*
247 * UART driver system settings.
248 */
249#define STM32_UART_USE_USART1 FALSE
250#define STM32_UART_USE_USART2 FALSE
251#define STM32_UART_USE_USART3 FALSE
252#define STM32_UART_USART1_IRQ_PRIORITY 12
253#define STM32_UART_USART2_IRQ_PRIORITY 12
254#define STM32_UART_USART3_IRQ_PRIORITY 12
255#define STM32_UART_USART1_DMA_PRIORITY 0
256#define STM32_UART_USART2_DMA_PRIORITY 0
257#define STM32_UART_USART3_DMA_PRIORITY 0
258#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
259
260/*
261 * USB driver system settings.
262 */
263#define STM32_USB_USE_USB1 TRUE
264#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
265#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
266#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
267
268/*
269 * WDG driver system settings.
270 */
271#define STM32_WDG_USE_IWDG FALSE
272
273#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk
new file mode 100644
index 000000000..6c837bb8e
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC) \ No newline at end of file
diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h
new file mode 100644
index 000000000..22c4e4cd7
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h
@@ -0,0 +1,24 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#define STM32_HSECLK 8000000
19// The following is required to disable the pull-down on PA9, when PA9 is used for the keyboard matrix:
20#define BOARD_OTG_NOVBUSSENS
21
22#include_next "board.h"
23
24#undef STM32_HSE_BYPASS \ No newline at end of file
diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h
new file mode 100644
index 000000000..cc52a953e
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h
@@ -0,0 +1,23 @@
1/* Copyright 2021 Andrei Purdea
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/* Address for jumping to bootloader on STM32 chips. */
18/* It is chip dependent, the correct number can be looked up by checking against ST's application note AN2606.
19 */
20#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
21#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
22# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
23#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/mcuconf.h
new file mode 100644
index 000000000..4be47fe1b
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/mcuconf.h
@@ -0,0 +1,355 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef MCUCONF_H
18#define MCUCONF_H
19
20/*
21 * STM32F4xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 15...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F4xx_MCUCONF
35#define STM32F405_MCUCONF
36#define STM32F415_MCUCONF
37#define STM32F407_MCUCONF
38#define STM32F417_MCUCONF
39
40/*
41 * HAL driver system settings.
42 */
43#define STM32_NO_INIT FALSE
44#define STM32_PVD_ENABLE FALSE
45#define STM32_PLS STM32_PLS_LEV0
46#define STM32_BKPRAM_ENABLE FALSE
47#define STM32_HSI_ENABLED TRUE
48#define STM32_LSI_ENABLED TRUE
49#define STM32_HSE_ENABLED TRUE
50#define STM32_LSE_ENABLED FALSE
51#define STM32_CLOCK48_REQUIRED TRUE
52#define STM32_SW STM32_SW_PLL
53#define STM32_PLLSRC STM32_PLLSRC_HSE
54#define STM32_PLLM_VALUE 8
55#define STM32_PLLN_VALUE 336
56#define STM32_PLLP_VALUE 2
57#define STM32_PLLQ_VALUE 7
58#define STM32_HPRE STM32_HPRE_DIV1
59#define STM32_PPRE1 STM32_PPRE1_DIV4
60#define STM32_PPRE2 STM32_PPRE2_DIV2
61#define STM32_RTCSEL STM32_RTCSEL_LSI
62#define STM32_RTCPRE_VALUE 8
63#define STM32_MCO1SEL STM32_MCO1SEL_HSI
64#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
65#define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK
66#define STM32_MCO2PRE STM32_MCO2PRE_DIV5
67#define STM32_I2SSRC STM32_I2SSRC_CKIN
68#define STM32_PLLI2SN_VALUE 192
69#define STM32_PLLI2SR_VALUE 5
70
71/*
72 * IRQ system settings.
73 */
74#define STM32_IRQ_EXTI0_PRIORITY 6
75#define STM32_IRQ_EXTI1_PRIORITY 6
76#define STM32_IRQ_EXTI2_PRIORITY 6
77#define STM32_IRQ_EXTI3_PRIORITY 6
78#define STM32_IRQ_EXTI4_PRIORITY 6
79#define STM32_IRQ_EXTI5_9_PRIORITY 6
80#define STM32_IRQ_EXTI10_15_PRIORITY 6
81#define STM32_IRQ_EXTI16_PRIORITY 6
82#define STM32_IRQ_EXTI17_PRIORITY 15
83#define STM32_IRQ_EXTI18_PRIORITY 6
84#define STM32_IRQ_EXTI19_PRIORITY 6
85#define STM32_IRQ_EXTI20_PRIORITY 6
86#define STM32_IRQ_EXTI21_PRIORITY 15
87#define STM32_IRQ_EXTI22_PRIORITY 15
88
89/*
90 * ADC driver system settings.
91 */
92#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
93#define STM32_ADC_USE_ADC1 FALSE
94#define STM32_ADC_USE_ADC2 FALSE
95#define STM32_ADC_USE_ADC3 FALSE
96#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
97#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
98#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
99#define STM32_ADC_ADC1_DMA_PRIORITY 2
100#define STM32_ADC_ADC2_DMA_PRIORITY 2
101#define STM32_ADC_ADC3_DMA_PRIORITY 2
102#define STM32_ADC_IRQ_PRIORITY 6
103#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
104#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 6
105#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 6
106
107/*
108 * CAN driver system settings.
109 */
110#define STM32_CAN_USE_CAN1 FALSE
111#define STM32_CAN_USE_CAN2 FALSE
112#define STM32_CAN_CAN1_IRQ_PRIORITY 11
113#define STM32_CAN_CAN2_IRQ_PRIORITY 11
114
115/*
116 * DAC driver system settings.
117 */
118#define STM32_DAC_DUAL_MODE FALSE
119#define STM32_DAC_USE_DAC1_CH1 FALSE
120#define STM32_DAC_USE_DAC1_CH2 FALSE
121#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
122#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
123#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
124#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
125#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
126#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
127
128/*
129 * GPT driver system settings.
130 */
131#define STM32_GPT_USE_TIM1 FALSE
132#define STM32_GPT_USE_TIM2 FALSE
133#define STM32_GPT_USE_TIM3 FALSE
134#define STM32_GPT_USE_TIM4 FALSE
135#define STM32_GPT_USE_TIM5 FALSE
136#define STM32_GPT_USE_TIM6 FALSE
137#define STM32_GPT_USE_TIM7 FALSE
138#define STM32_GPT_USE_TIM8 FALSE
139#define STM32_GPT_USE_TIM9 FALSE
140#define STM32_GPT_USE_TIM11 FALSE
141#define STM32_GPT_USE_TIM12 FALSE
142#define STM32_GPT_USE_TIM14 FALSE
143#define STM32_GPT_TIM1_IRQ_PRIORITY 7
144#define STM32_GPT_TIM2_IRQ_PRIORITY 7
145#define STM32_GPT_TIM3_IRQ_PRIORITY 7
146#define STM32_GPT_TIM4_IRQ_PRIORITY 7
147#define STM32_GPT_TIM5_IRQ_PRIORITY 7
148#define STM32_GPT_TIM6_IRQ_PRIORITY 7
149#define STM32_GPT_TIM7_IRQ_PRIORITY 7
150#define STM32_GPT_TIM8_IRQ_PRIORITY 7
151#define STM32_GPT_TIM9_IRQ_PRIORITY 7
152#define STM32_GPT_TIM11_IRQ_PRIORITY 7
153#define STM32_GPT_TIM12_IRQ_PRIORITY 7
154#define STM32_GPT_TIM14_IRQ_PRIORITY 7
155
156/*
157 * I2C driver system settings.
158 */
159#define STM32_I2C_USE_I2C1 FALSE
160#define STM32_I2C_USE_I2C2 FALSE
161#define STM32_I2C_USE_I2C3 FALSE
162#define STM32_I2C_BUSY_TIMEOUT 50
163#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
164#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
165#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
166#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
167#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
168#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
169#define STM32_I2C_I2C1_IRQ_PRIORITY 5
170#define STM32_I2C_I2C2_IRQ_PRIORITY 5
171#define STM32_I2C_I2C3_IRQ_PRIORITY 5
172#define STM32_I2C_I2C1_DMA_PRIORITY 3
173#define STM32_I2C_I2C2_DMA_PRIORITY 3
174#define STM32_I2C_I2C3_DMA_PRIORITY 3
175#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
176
177/*
178 * I2S driver system settings.
179 */
180#define STM32_I2S_USE_SPI2 FALSE
181#define STM32_I2S_USE_SPI3 FALSE
182#define STM32_I2S_SPI2_IRQ_PRIORITY 10
183#define STM32_I2S_SPI3_IRQ_PRIORITY 10
184#define STM32_I2S_SPI2_DMA_PRIORITY 1
185#define STM32_I2S_SPI3_DMA_PRIORITY 1
186#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
187#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
188#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
189#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
190#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
191
192/*
193 * ICU driver system settings.
194 */
195#define STM32_ICU_USE_TIM1 FALSE
196#define STM32_ICU_USE_TIM2 FALSE
197#define STM32_ICU_USE_TIM3 FALSE
198#define STM32_ICU_USE_TIM4 FALSE
199#define STM32_ICU_USE_TIM5 FALSE
200#define STM32_ICU_USE_TIM8 FALSE
201#define STM32_ICU_USE_TIM9 FALSE
202#define STM32_ICU_TIM1_IRQ_PRIORITY 7
203#define STM32_ICU_TIM2_IRQ_PRIORITY 7
204#define STM32_ICU_TIM3_IRQ_PRIORITY 7
205#define STM32_ICU_TIM4_IRQ_PRIORITY 7
206#define STM32_ICU_TIM5_IRQ_PRIORITY 7
207#define STM32_ICU_TIM8_IRQ_PRIORITY 7
208#define STM32_ICU_TIM9_IRQ_PRIORITY 7
209
210/*
211 * MAC driver system settings.
212 */
213#define STM32_MAC_TRANSMIT_BUFFERS 2
214#define STM32_MAC_RECEIVE_BUFFERS 4
215#define STM32_MAC_BUFFERS_SIZE 1522
216#define STM32_MAC_PHY_TIMEOUT 100
217#define STM32_MAC_ETH1_CHANGE_PHY_STATE TRUE
218#define STM32_MAC_ETH1_IRQ_PRIORITY 13
219#define STM32_MAC_IP_CHECKSUM_OFFLOAD 0
220
221/*
222 * PWM driver system settings.
223 */
224#define STM32_PWM_USE_ADVANCED FALSE
225#define STM32_PWM_USE_TIM1 FALSE
226#define STM32_PWM_USE_TIM2 FALSE
227#define STM32_PWM_USE_TIM3 FALSE
228#define STM32_PWM_USE_TIM4 FALSE
229#define STM32_PWM_USE_TIM5 FALSE
230#define STM32_PWM_USE_TIM8 FALSE
231#define STM32_PWM_USE_TIM9 FALSE
232#define STM32_PWM_TIM1_IRQ_PRIORITY 7
233#define STM32_PWM_TIM2_IRQ_PRIORITY 7
234#define STM32_PWM_TIM3_IRQ_PRIORITY 7
235#define STM32_PWM_TIM4_IRQ_PRIORITY 7
236#define STM32_PWM_TIM5_IRQ_PRIORITY 7
237#define STM32_PWM_TIM8_IRQ_PRIORITY 7
238#define STM32_PWM_TIM9_IRQ_PRIORITY 7
239
240/*
241 * RTC driver system settings.
242 */
243#define STM32_RTC_PRESA_VALUE 32
244#define STM32_RTC_PRESS_VALUE 1024
245#define STM32_RTC_CR_INIT 0
246#define STM32_RTC_TAMPCR_INIT 0
247
248/*
249 * SDC driver system settings.
250 */
251#define STM32_SDC_SDIO_DMA_PRIORITY 3
252#define STM32_SDC_SDIO_IRQ_PRIORITY 9
253#define STM32_SDC_WRITE_TIMEOUT_MS 1000
254#define STM32_SDC_READ_TIMEOUT_MS 1000
255#define STM32_SDC_CLOCK_ACTIVATION_DELAY 10
256#define STM32_SDC_SDIO_UNALIGNED_SUPPORT TRUE
257#define STM32_SDC_SDIO_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
258
259/*
260 * SERIAL driver system settings.
261 */
262#define STM32_SERIAL_USE_USART1 FALSE
263#define STM32_SERIAL_USE_USART2 FALSE
264#define STM32_SERIAL_USE_USART3 FALSE
265#define STM32_SERIAL_USE_UART4 FALSE
266#define STM32_SERIAL_USE_UART5 FALSE
267#define STM32_SERIAL_USE_USART6 FALSE
268#define STM32_SERIAL_USART1_PRIORITY 12
269#define STM32_SERIAL_USART2_PRIORITY 12
270#define STM32_SERIAL_USART3_PRIORITY 12
271#define STM32_SERIAL_UART4_PRIORITY 12
272#define STM32_SERIAL_UART5_PRIORITY 12
273#define STM32_SERIAL_USART6_PRIORITY 12
274
275/*
276 * SPI driver system settings.
277 */
278#define STM32_SPI_USE_SPI1 FALSE
279#define STM32_SPI_USE_SPI2 FALSE
280#define STM32_SPI_USE_SPI3 FALSE
281#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
282#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
283#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
284#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
285#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
286#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
287#define STM32_SPI_SPI1_DMA_PRIORITY 1
288#define STM32_SPI_SPI2_DMA_PRIORITY 1
289#define STM32_SPI_SPI3_DMA_PRIORITY 1
290#define STM32_SPI_SPI1_IRQ_PRIORITY 10
291#define STM32_SPI_SPI2_IRQ_PRIORITY 10
292#define STM32_SPI_SPI3_IRQ_PRIORITY 10
293#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
294
295/*
296 * ST driver system settings.
297 */
298#define STM32_ST_IRQ_PRIORITY 8
299#define STM32_ST_USE_TIMER 2
300
301/*
302 * UART driver system settings.
303 */
304#define STM32_UART_USE_USART1 FALSE
305#define STM32_UART_USE_USART2 FALSE
306#define STM32_UART_USE_USART3 FALSE
307#define STM32_UART_USE_UART4 FALSE
308#define STM32_UART_USE_UART5 FALSE
309#define STM32_UART_USE_USART6 FALSE
310#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
311#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
312#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
313#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
314#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
315#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
316#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
317#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
318#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
319#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
320#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
321#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
322#define STM32_UART_USART1_IRQ_PRIORITY 12
323#define STM32_UART_USART2_IRQ_PRIORITY 12
324#define STM32_UART_USART3_IRQ_PRIORITY 12
325#define STM32_UART_UART4_IRQ_PRIORITY 12
326#define STM32_UART_UART5_IRQ_PRIORITY 12
327#define STM32_UART_USART6_IRQ_PRIORITY 12
328#define STM32_UART_USART1_DMA_PRIORITY 0
329#define STM32_UART_USART2_DMA_PRIORITY 0
330#define STM32_UART_USART3_DMA_PRIORITY 0
331#define STM32_UART_UART4_DMA_PRIORITY 0
332#define STM32_UART_UART5_DMA_PRIORITY 0
333#define STM32_UART_USART6_DMA_PRIORITY 0
334#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
335
336/*
337 * USB driver system settings.
338 */
339#define STM32_USB_USE_OTG1 TRUE
340#define STM32_USB_USE_OTG2 FALSE
341#define STM32_USB_OTG1_IRQ_PRIORITY 14
342#define STM32_USB_OTG2_IRQ_PRIORITY 14
343#define STM32_USB_OTG1_RX_FIFO_SIZE 512
344#define STM32_USB_OTG2_RX_FIFO_SIZE 1024
345#define STM32_USB_HOST_WAKEUP_DURATION 2
346
347#define STM32_USB_OTG_THREAD_PRIO NORMALPRIO+1
348#define STM32_USB_OTG_THREAD_STACK_SIZE 128
349
350/*
351 * WDG driver system settings.
352 */
353#define STM32_WDG_USE_IWDG FALSE
354
355#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_F446XE/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F446XE/board/board.mk
new file mode 100644
index 000000000..57897941c
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F446XE/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F446RE/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F446RE
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/board.h
new file mode 100644
index 000000000..80dfcffa9
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/board.h
@@ -0,0 +1,24 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#define STM32_HSECLK 16000000
19// The following is required to disable the pull-down on PA9, when PA9 is used for the keyboard matrix:
20#define BOARD_OTG_NOVBUSSENS
21
22#include_next "board.h"
23
24#undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h
new file mode 100644
index 000000000..cc52a953e
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h
@@ -0,0 +1,23 @@
1/* Copyright 2021 Andrei Purdea
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/* Address for jumping to bootloader on STM32 chips. */
18/* It is chip dependent, the correct number can be looked up by checking against ST's application note AN2606.
19 */
20#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
21#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
22# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
23#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/mcuconf.h
new file mode 100644
index 000000000..d2de75590
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/mcuconf.h
@@ -0,0 +1,361 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef MCUCONF_H
18#define MCUCONF_H
19
20/*
21 * STM32F4xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 15...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F4xx_MCUCONF
35
36/*
37 * HAL driver system settings.
38 */
39#define STM32_NO_INIT FALSE
40#define STM32_HSI_ENABLED FALSE
41#define STM32_LSI_ENABLED TRUE
42#define STM32_HSE_ENABLED TRUE
43#define STM32_LSE_ENABLED FALSE
44#define STM32_CLOCK48_REQUIRED TRUE
45#define STM32_SW STM32_SW_PLL
46#define STM32_PLLSRC STM32_PLLSRC_HSE
47#define STM32_PLLM_VALUE 8
48#define STM32_PLLN_VALUE 180
49#define STM32_PLLP_VALUE 2
50#define STM32_PLLQ_VALUE 7
51#define STM32_PLLI2SN_VALUE 192
52#define STM32_PLLI2SM_VALUE 8
53#define STM32_PLLI2SR_VALUE 4
54#define STM32_PLLI2SP_VALUE 4
55#define STM32_PLLI2SQ_VALUE 4
56#define STM32_PLLSAIN_VALUE 192
57#define STM32_PLLSAIM_VALUE 8
58#define STM32_PLLSAIP_VALUE 8
59#define STM32_PLLSAIQ_VALUE 4
60#define STM32_HPRE STM32_HPRE_DIV1
61#define STM32_PPRE1 STM32_PPRE1_DIV4
62#define STM32_PPRE2 STM32_PPRE2_DIV2
63#define STM32_RTCSEL STM32_RTCSEL_LSI
64#define STM32_RTCPRE_VALUE 8
65#define STM32_MCO1SEL STM32_MCO1SEL_HSE
66#define STM32_MCO1PRE STM32_MCO1PRE_DIV1
67#define STM32_MCO2SEL STM32_MCO2SEL_PLLI2S
68#define STM32_MCO2PRE STM32_MCO2PRE_DIV1
69#define STM32_I2SSRC STM32_I2SSRC_PLLI2S
70#define STM32_SAI1SEL STM32_SAI2SEL_PLLR
71#define STM32_SAI2SEL STM32_SAI2SEL_PLLR
72#define STM32_CK48MSEL STM32_CK48MSEL_PLLALT
73#define STM32_PVD_ENABLE FALSE
74#define STM32_PLS STM32_PLS_LEV0
75#define STM32_BKPRAM_ENABLE FALSE
76
77/*
78 * IRQ system settings.
79 */
80#define STM32_IRQ_EXTI0_PRIORITY 6
81#define STM32_IRQ_EXTI1_PRIORITY 6
82#define STM32_IRQ_EXTI2_PRIORITY 6
83#define STM32_IRQ_EXTI3_PRIORITY 6
84#define STM32_IRQ_EXTI4_PRIORITY 6
85#define STM32_IRQ_EXTI5_9_PRIORITY 6
86#define STM32_IRQ_EXTI10_15_PRIORITY 6
87#define STM32_IRQ_EXTI16_PRIORITY 6
88#define STM32_IRQ_EXTI17_PRIORITY 15
89#define STM32_IRQ_EXTI18_PRIORITY 6
90#define STM32_IRQ_EXTI19_PRIORITY 6
91#define STM32_IRQ_EXTI20_PRIORITY 6
92#define STM32_IRQ_EXTI21_PRIORITY 15
93#define STM32_IRQ_EXTI22_PRIORITY 15
94
95/*
96 * ADC driver system settings.
97 */
98#define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4
99#define STM32_ADC_USE_ADC1 FALSE
100#define STM32_ADC_USE_ADC2 FALSE
101#define STM32_ADC_USE_ADC3 FALSE
102#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
103#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
104#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
105#define STM32_ADC_ADC1_DMA_PRIORITY 2
106#define STM32_ADC_ADC2_DMA_PRIORITY 2
107#define STM32_ADC_ADC3_DMA_PRIORITY 2
108#define STM32_ADC_IRQ_PRIORITY 6
109#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 6
110#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 6
111#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 6
112
113/*
114 * CAN driver system settings.
115 */
116#define STM32_CAN_USE_CAN1 FALSE
117#define STM32_CAN_USE_CAN2 FALSE
118#define STM32_CAN_CAN1_IRQ_PRIORITY 11
119#define STM32_CAN_CAN2_IRQ_PRIORITY 11
120
121/*
122 * DAC driver system settings.
123 */
124#define STM32_DAC_DUAL_MODE FALSE
125#define STM32_DAC_USE_DAC1_CH1 FALSE
126#define STM32_DAC_USE_DAC1_CH2 FALSE
127#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
128#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
129#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
130#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
131#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
132#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
133
134/*
135 * GPT driver system settings.
136 */
137#define STM32_GPT_USE_TIM1 FALSE
138#define STM32_GPT_USE_TIM2 FALSE
139#define STM32_GPT_USE_TIM3 FALSE
140#define STM32_GPT_USE_TIM4 FALSE
141#define STM32_GPT_USE_TIM5 FALSE
142#define STM32_GPT_USE_TIM6 FALSE
143#define STM32_GPT_USE_TIM7 FALSE
144#define STM32_GPT_USE_TIM8 FALSE
145#define STM32_GPT_USE_TIM9 FALSE
146#define STM32_GPT_USE_TIM11 FALSE
147#define STM32_GPT_USE_TIM12 FALSE
148#define STM32_GPT_USE_TIM14 FALSE
149#define STM32_GPT_TIM1_IRQ_PRIORITY 7
150#define STM32_GPT_TIM2_IRQ_PRIORITY 7
151#define STM32_GPT_TIM3_IRQ_PRIORITY 7
152#define STM32_GPT_TIM4_IRQ_PRIORITY 7
153#define STM32_GPT_TIM5_IRQ_PRIORITY 7
154#define STM32_GPT_TIM6_IRQ_PRIORITY 7
155#define STM32_GPT_TIM7_IRQ_PRIORITY 7
156#define STM32_GPT_TIM8_IRQ_PRIORITY 7
157#define STM32_GPT_TIM9_IRQ_PRIORITY 7
158#define STM32_GPT_TIM11_IRQ_PRIORITY 7
159#define STM32_GPT_TIM12_IRQ_PRIORITY 7
160#define STM32_GPT_TIM14_IRQ_PRIORITY 7
161
162/*
163 * I2C driver system settings.
164 */
165#define STM32_I2C_USE_I2C1 FALSE
166#define STM32_I2C_USE_I2C2 FALSE
167#define STM32_I2C_USE_I2C3 FALSE
168#define STM32_I2C_BUSY_TIMEOUT 50
169#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
170#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
171#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
172#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
173#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
174#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
175#define STM32_I2C_I2C1_IRQ_PRIORITY 5
176#define STM32_I2C_I2C2_IRQ_PRIORITY 5
177#define STM32_I2C_I2C3_IRQ_PRIORITY 5
178#define STM32_I2C_I2C1_DMA_PRIORITY 3
179#define STM32_I2C_I2C2_DMA_PRIORITY 3
180#define STM32_I2C_I2C3_DMA_PRIORITY 3
181#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
182
183/*
184 * I2S driver system settings.
185 */
186#define STM32_I2S_USE_SPI2 FALSE
187#define STM32_I2S_USE_SPI3 FALSE
188#define STM32_I2S_SPI2_IRQ_PRIORITY 10
189#define STM32_I2S_SPI3_IRQ_PRIORITY 10
190#define STM32_I2S_SPI2_DMA_PRIORITY 1
191#define STM32_I2S_SPI3_DMA_PRIORITY 1
192#define STM32_I2S_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
193#define STM32_I2S_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
194#define STM32_I2S_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
195#define STM32_I2S_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
196#define STM32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure")
197
198/*
199 * ICU driver system settings.
200 */
201#define STM32_ICU_USE_TIM1 FALSE
202#define STM32_ICU_USE_TIM2 FALSE
203#define STM32_ICU_USE_TIM3 FALSE
204#define STM32_ICU_USE_TIM4 FALSE
205#define STM32_ICU_USE_TIM5 FALSE
206#define STM32_ICU_USE_TIM8 FALSE
207#define STM32_ICU_USE_TIM9 FALSE
208#define STM32_ICU_TIM1_IRQ_PRIORITY 7
209#define STM32_ICU_TIM2_IRQ_PRIORITY 7
210#define STM32_ICU_TIM3_IRQ_PRIORITY 7
211#define STM32_ICU_TIM4_IRQ_PRIORITY 7
212#define STM32_ICU_TIM5_IRQ_PRIORITY 7
213#define STM32_ICU_TIM8_IRQ_PRIORITY 7
214#define STM32_ICU_TIM9_IRQ_PRIORITY 7
215
216/*
217 * MAC driver system settings.
218 */
219#define STM32_MAC_TRANSMIT_BUFFERS 2
220#define STM32_MAC_RECEIVE_BUFFERS 4
221#define STM32_MAC_BUFFERS_SIZE 1522
222#define STM32_MAC_PHY_TIMEOUT 100
223#define STM32_MAC_ETH1_CHANGE_PHY_STATE TRUE
224#define STM32_MAC_ETH1_IRQ_PRIORITY 13
225#define STM32_MAC_IP_CHECKSUM_OFFLOAD 0
226
227/*
228 * PWM driver system settings.
229 */
230#define STM32_PWM_USE_ADVANCED FALSE
231#define STM32_PWM_USE_TIM1 FALSE
232#define STM32_PWM_USE_TIM2 FALSE
233#define STM32_PWM_USE_TIM3 FALSE
234#define STM32_PWM_USE_TIM4 FALSE
235#define STM32_PWM_USE_TIM5 FALSE
236#define STM32_PWM_USE_TIM8 FALSE
237#define STM32_PWM_USE_TIM9 FALSE
238#define STM32_PWM_TIM1_IRQ_PRIORITY 7
239#define STM32_PWM_TIM2_IRQ_PRIORITY 7
240#define STM32_PWM_TIM3_IRQ_PRIORITY 7
241#define STM32_PWM_TIM4_IRQ_PRIORITY 7
242#define STM32_PWM_TIM5_IRQ_PRIORITY 7
243#define STM32_PWM_TIM8_IRQ_PRIORITY 7
244#define STM32_PWM_TIM9_IRQ_PRIORITY 7
245
246/*
247 * SDC driver system settings.
248 */
249#define STM32_SDC_SDIO_DMA_PRIORITY 3
250#define STM32_SDC_SDIO_IRQ_PRIORITY 9
251#define STM32_SDC_WRITE_TIMEOUT_MS 1000
252#define STM32_SDC_READ_TIMEOUT_MS 1000
253#define STM32_SDC_CLOCK_ACTIVATION_DELAY 10
254#define STM32_SDC_SDIO_UNALIGNED_SUPPORT TRUE
255#define STM32_SDC_SDIO_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
256
257/*
258 * SERIAL driver system settings.
259 */
260#define STM32_SERIAL_USE_USART1 FALSE
261#define STM32_SERIAL_USE_USART2 FALSE
262#define STM32_SERIAL_USE_USART3 FALSE
263#define STM32_SERIAL_USE_UART4 FALSE
264#define STM32_SERIAL_USE_UART5 FALSE
265#define STM32_SERIAL_USE_USART6 FALSE
266#define STM32_SERIAL_USE_UART7 FALSE
267#define STM32_SERIAL_USE_UART8 FALSE
268#define STM32_SERIAL_USART1_PRIORITY 12
269#define STM32_SERIAL_USART2_PRIORITY 12
270#define STM32_SERIAL_USART3_PRIORITY 12
271#define STM32_SERIAL_UART4_PRIORITY 12
272#define STM32_SERIAL_UART5_PRIORITY 12
273#define STM32_SERIAL_USART6_PRIORITY 12
274#define STM32_SERIAL_UART7_PRIORITY 12
275#define STM32_SERIAL_UART8_PRIORITY 12
276
277/*
278 * SPI driver system settings.
279 */
280#define STM32_SPI_USE_SPI1 FALSE
281#define STM32_SPI_USE_SPI2 FALSE
282#define STM32_SPI_USE_SPI3 FALSE
283#define STM32_SPI_USE_SPI4 FALSE
284#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
285#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
286#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
287#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
288#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
289#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
290#define STM32_SPI_SPI4_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0)
291#define STM32_SPI_SPI4_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
292#define STM32_SPI_SPI1_DMA_PRIORITY 1
293#define STM32_SPI_SPI2_DMA_PRIORITY 1
294#define STM32_SPI_SPI3_DMA_PRIORITY 1
295#define STM32_SPI_SPI4_DMA_PRIORITY 1
296#define STM32_SPI_SPI1_IRQ_PRIORITY 10
297#define STM32_SPI_SPI2_IRQ_PRIORITY 10
298#define STM32_SPI_SPI3_IRQ_PRIORITY 10
299#define STM32_SPI_SPI4_IRQ_PRIORITY 10
300#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
301
302/*
303 * ST driver system settings.
304 */
305#define STM32_ST_IRQ_PRIORITY 8
306#define STM32_ST_USE_TIMER 2
307
308/*
309 * UART driver system settings.
310 */
311#define STM32_UART_USE_USART1 FALSE
312#define STM32_UART_USE_USART2 FALSE
313#define STM32_UART_USE_USART3 FALSE
314#define STM32_UART_USE_UART4 FALSE
315#define STM32_UART_USE_UART5 FALSE
316#define STM32_UART_USE_USART6 FALSE
317#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
318#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
319#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
320#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
321#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
322#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
323#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
324#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
325#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0)
326#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
327#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
328#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
329#define STM32_UART_USART1_IRQ_PRIORITY 12
330#define STM32_UART_USART2_IRQ_PRIORITY 12
331#define STM32_UART_USART3_IRQ_PRIORITY 12
332#define STM32_UART_UART4_IRQ_PRIORITY 12
333#define STM32_UART_UART5_IRQ_PRIORITY 12
334#define STM32_UART_USART6_IRQ_PRIORITY 12
335#define STM32_UART_USART1_DMA_PRIORITY 0
336#define STM32_UART_USART2_DMA_PRIORITY 0
337#define STM32_UART_USART3_DMA_PRIORITY 0
338#define STM32_UART_UART4_DMA_PRIORITY 0
339#define STM32_UART_UART5_DMA_PRIORITY 0
340#define STM32_UART_USART6_DMA_PRIORITY 0
341#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
342
343/*
344 * USB driver system settings.
345 */
346#define STM32_USB_USE_OTG1 TRUE
347#define STM32_USB_USE_OTG2 FALSE
348#define STM32_USB_OTG1_IRQ_PRIORITY 14
349#define STM32_USB_OTG2_IRQ_PRIORITY 14
350#define STM32_USB_OTG1_RX_FIFO_SIZE 512
351#define STM32_USB_OTG2_RX_FIFO_SIZE 1024
352#define STM32_USB_OTG_THREAD_PRIO LOWPRIO
353#define STM32_USB_OTG_THREAD_STACK_SIZE 128
354#define STM32_USB_OTGFIFO_FILL_BASEPRI 0
355
356/*
357 * WDG driver system settings.
358 */
359#define STM32_WDG_USE_IWDG FALSE
360
361#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_G431XB/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_G431XB/board/board.mk
new file mode 100644
index 000000000..0acbcd83c
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_G431XB/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G431RB/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G431RB
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_G431XB/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_G431XB/configs/config.h
new file mode 100644
index 000000000..39ce627e7
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_G431XB/configs/config.h
@@ -0,0 +1,23 @@
1/* Copyright 2018-2020 Nick Brassel (@tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/* Address for jumping to bootloader on STM32 chips. */
18/* It is chip dependent, the correct number can be looked up here (page 175):
19 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
20 * This also requires a patch to chibios:
21 * <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
22 */
23#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
diff --git a/platforms/chibios/boards/GENERIC_STM32_G431XB/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_G431XB/configs/mcuconf.h
new file mode 100644
index 000000000..182d4885d
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_G431XB/configs/mcuconf.h
@@ -0,0 +1,307 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32G4xx drivers configuration.
19 * The following settings override the default settings present in
20 * the various device driver implementation headers.
21 * Note that the settings for each driver only have effect if the whole
22 * driver is enabled in halconf.h.
23 *
24 * IRQ priorities:
25 * 15...0 Lowest...Highest.
26 *
27 * DMA priorities:
28 * 0...3 Lowest...Highest.
29 */
30
31#ifndef MCUCONF_H
32#define MCUCONF_H
33
34#define STM32G4xx_MCUCONF
35#define STM32G431_MCUCONF
36#define STM32G441_MCUCONF
37
38/*
39 * HAL driver system settings.
40 */
41#define STM32_NO_INIT FALSE
42#define STM32_VOS STM32_VOS_RANGE1
43#define STM32_PWR_CR2 (PWR_CR2_PLS_LEV0)
44#define STM32_PWR_CR3 (PWR_CR3_EIWF)
45#define STM32_PWR_CR4 (0U)
46#define STM32_HSI16_ENABLED TRUE
47#define STM32_HSI48_ENABLED TRUE
48#define STM32_HSE_ENABLED FALSE
49#define STM32_LSI_ENABLED TRUE
50#define STM32_LSE_ENABLED FALSE
51#define STM32_SW STM32_SW_PLLRCLK
52#define STM32_PLLSRC STM32_PLLSRC_HSI16
53#define STM32_PLLM_VALUE 4
54#define STM32_PLLN_VALUE 80
55#define STM32_PLLPDIV_VALUE 0
56#define STM32_PLLP_VALUE 7
57#define STM32_PLLQ_VALUE 8
58#define STM32_PLLR_VALUE 2
59#define STM32_HPRE STM32_HPRE_DIV1
60#define STM32_PPRE1 STM32_PPRE1_DIV1
61#define STM32_PPRE2 STM32_PPRE2_DIV1
62#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
63#define STM32_MCOPRE STM32_MCOPRE_DIV1
64#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
65
66/*
67 * Peripherals clock sources.
68 */
69#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
70#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
71#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
72#define STM32_UART4SEL STM32_UART4SEL_SYSCLK
73#define STM32_LPUART1SEL STM32_LPUART1SEL_PCLK1
74#define STM32_I2C1SEL STM32_I2C1SEL_PCLK1
75#define STM32_I2C2SEL STM32_I2C2SEL_PCLK1
76#define STM32_I2C3SEL STM32_I2C3SEL_PCLK1
77#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
78#define STM32_SAI1SEL STM32_SAI1SEL_SYSCLK
79#define STM32_I2S23SEL STM32_I2S23SEL_SYSCLK
80#define STM32_FDCANSEL STM32_FDCANSEL_PCLK1
81#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
82#define STM32_ADC12SEL STM32_ADC12SEL_PLLPCLK
83#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK
84
85/*
86 * IRQ system settings.
87 */
88#define STM32_IRQ_EXTI0_PRIORITY 6
89#define STM32_IRQ_EXTI1_PRIORITY 6
90#define STM32_IRQ_EXTI2_PRIORITY 6
91#define STM32_IRQ_EXTI3_PRIORITY 6
92#define STM32_IRQ_EXTI4_PRIORITY 6
93#define STM32_IRQ_EXTI5_9_PRIORITY 6
94#define STM32_IRQ_EXTI10_15_PRIORITY 6
95#define STM32_IRQ_EXTI164041_PRIORITY 6
96#define STM32_IRQ_EXTI17_PRIORITY 6
97#define STM32_IRQ_EXTI18_PRIORITY 6
98#define STM32_IRQ_EXTI19_PRIORITY 6
99#define STM32_IRQ_EXTI20_PRIORITY 6
100#define STM32_IRQ_EXTI212229_PRIORITY 6
101#define STM32_IRQ_EXTI30_32_PRIORITY 6
102#define STM32_IRQ_EXTI33_PRIORITY 6
103
104#define STM32_IRQ_FDCAN1_PRIORITY 10
105
106#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
107#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
108#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
109#define STM32_IRQ_TIM1_CC_PRIORITY 7
110#define STM32_IRQ_TIM2_PRIORITY 7
111#define STM32_IRQ_TIM3_PRIORITY 7
112#define STM32_IRQ_TIM4_PRIORITY 7
113#define STM32_IRQ_TIM6_PRIORITY 7
114#define STM32_IRQ_TIM7_PRIORITY 7
115#define STM32_IRQ_TIM8_UP_PRIORITY 7
116#define STM32_IRQ_TIM8_CC_PRIORITY 7
117
118#define STM32_IRQ_USART1_PRIORITY 12
119#define STM32_IRQ_USART2_PRIORITY 12
120#define STM32_IRQ_USART3_PRIORITY 12
121#define STM32_IRQ_UART4_PRIORITY 12
122#define STM32_IRQ_LPUART1_PRIORITY 12
123
124/*
125 * ADC driver system settings.
126 */
127#define STM32_ADC_DUAL_MODE FALSE
128#define STM32_ADC_COMPACT_SAMPLES FALSE
129#define STM32_ADC_USE_ADC1 FALSE
130#define STM32_ADC_USE_ADC2 FALSE
131#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
132#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
133#define STM32_ADC_ADC1_DMA_PRIORITY 2
134#define STM32_ADC_ADC2_DMA_PRIORITY 2
135#define STM32_ADC_ADC12_IRQ_PRIORITY 5
136#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
137#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
138#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV4
139#define STM32_ADC_ADC12_PRESC ADC_CCR_PRESC_DIV2
140
141/*
142 * CAN driver system settings.
143 */
144#define STM32_CAN_USE_FDCAN1 FALSE
145
146/*
147 * DAC driver system settings.
148 */
149#define STM32_DAC_DUAL_MODE FALSE
150#define STM32_DAC_USE_DAC1_CH1 FALSE
151#define STM32_DAC_USE_DAC1_CH2 FALSE
152#define STM32_DAC_USE_DAC3_CH1 FALSE
153#define STM32_DAC_USE_DAC3_CH2 FALSE
154#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
155#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
156#define STM32_DAC_DAC3_CH1_IRQ_PRIORITY 10
157#define STM32_DAC_DAC3_CH2_IRQ_PRIORITY 10
158#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
159#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
160#define STM32_DAC_DAC3_CH1_DMA_PRIORITY 2
161#define STM32_DAC_DAC3_CH2_DMA_PRIORITY 2
162#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
163#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
164#define STM32_DAC_DAC3_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
165#define STM32_DAC_DAC3_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
166
167/*
168 * GPT driver system settings.
169 */
170#define STM32_GPT_USE_TIM1 FALSE
171#define STM32_GPT_USE_TIM2 FALSE
172#define STM32_GPT_USE_TIM3 FALSE
173#define STM32_GPT_USE_TIM4 FALSE
174#define STM32_GPT_USE_TIM6 FALSE
175#define STM32_GPT_USE_TIM7 FALSE
176#define STM32_GPT_USE_TIM8 FALSE
177#define STM32_GPT_USE_TIM15 FALSE
178#define STM32_GPT_USE_TIM16 FALSE
179#define STM32_GPT_USE_TIM17 FALSE
180
181/*
182 * I2C driver system settings.
183 */
184#define STM32_I2C_USE_I2C1 FALSE
185#define STM32_I2C_USE_I2C2 FALSE
186#define STM32_I2C_USE_I2C3 FALSE
187#define STM32_I2C_BUSY_TIMEOUT 50
188#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
189#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
190#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
191#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
192#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
193#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
194#define STM32_I2C_I2C1_IRQ_PRIORITY 5
195#define STM32_I2C_I2C2_IRQ_PRIORITY 5
196#define STM32_I2C_I2C3_IRQ_PRIORITY 5
197#define STM32_I2C_I2C1_DMA_PRIORITY 3
198#define STM32_I2C_I2C2_DMA_PRIORITY 3
199#define STM32_I2C_I2C3_DMA_PRIORITY 3
200#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
201
202/*
203 * ICU driver system settings.
204 */
205#define STM32_ICU_USE_TIM1 FALSE
206#define STM32_ICU_USE_TIM2 FALSE
207#define STM32_ICU_USE_TIM3 FALSE
208#define STM32_ICU_USE_TIM4 FALSE
209#define STM32_ICU_USE_TIM8 FALSE
210#define STM32_ICU_USE_TIM15 FALSE
211
212/*
213 * PWM driver system settings.
214 */
215#define STM32_PWM_USE_ADVANCED FALSE
216#define STM32_PWM_USE_TIM1 FALSE
217#define STM32_PWM_USE_TIM2 FALSE
218#define STM32_PWM_USE_TIM3 FALSE
219#define STM32_PWM_USE_TIM4 FALSE
220#define STM32_PWM_USE_TIM8 FALSE
221#define STM32_PWM_USE_TIM15 FALSE
222#define STM32_PWM_USE_TIM16 FALSE
223#define STM32_PWM_USE_TIM17 FALSE
224
225/*
226 * RTC driver system settings.
227 */
228
229/*
230 * SDC driver system settings.
231 */
232
233/*
234 * SERIAL driver system settings.
235 */
236#define STM32_SERIAL_USE_USART1 FALSE
237#define STM32_SERIAL_USE_USART2 FALSE
238#define STM32_SERIAL_USE_USART3 FALSE
239#define STM32_SERIAL_USE_UART4 FALSE
240#define STM32_SERIAL_USE_LPUART1 FALSE
241
242/*
243 * SPI driver system settings.
244 */
245#define STM32_SPI_USE_SPI1 FALSE
246#define STM32_SPI_USE_SPI2 FALSE
247#define STM32_SPI_USE_SPI3 FALSE
248#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
249#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
250#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
251#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
252#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
253#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
254#define STM32_SPI_SPI1_DMA_PRIORITY 1
255#define STM32_SPI_SPI2_DMA_PRIORITY 1
256#define STM32_SPI_SPI3_DMA_PRIORITY 1
257#define STM32_SPI_SPI1_IRQ_PRIORITY 10
258#define STM32_SPI_SPI2_IRQ_PRIORITY 10
259#define STM32_SPI_SPI3_IRQ_PRIORITY 10
260#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
261
262/*
263 * ST driver system settings.
264 */
265#define STM32_ST_IRQ_PRIORITY 8
266#define STM32_ST_USE_TIMER 2
267
268/*
269 * TRNG driver system settings.
270 */
271#define STM32_TRNG_USE_RNG1 FALSE
272
273/*
274 * UART driver system settings.
275 */
276#define STM32_UART_USE_USART1 FALSE
277#define STM32_UART_USE_USART2 FALSE
278#define STM32_UART_USE_USART3 FALSE
279#define STM32_UART_USE_UART4 FALSE
280#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
281#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
282#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
283#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
284#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
285#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
286#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
287#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
288#define STM32_UART_USART1_DMA_PRIORITY 0
289#define STM32_UART_USART2_DMA_PRIORITY 0
290#define STM32_UART_USART3_DMA_PRIORITY 0
291#define STM32_UART_UART4_DMA_PRIORITY 0
292#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
293
294/*
295 * USB driver system settings.
296 */
297#define STM32_USB_USE_USB1 TRUE
298#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
299#define STM32_USB_USB1_HP_IRQ_PRIORITY 5
300#define STM32_USB_USB1_LP_IRQ_PRIORITY 6
301
302/*
303 * WDG driver system settings.
304 */
305#define STM32_WDG_USE_IWDG FALSE
306
307#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_G474XE/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_G474XE/board/board.mk
new file mode 100644
index 000000000..957adf509
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_G474XE/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G474RE/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G474RE
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h
new file mode 100644
index 000000000..eb74d68e8
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h
@@ -0,0 +1,30 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#ifndef STM32_BOOTLOADER_DUAL_BANK
19# define STM32_BOOTLOADER_DUAL_BANK FALSE
20#endif
21
22// To Enter bootloader from `RESET` keycode, you'll need to dedicate a GPIO to
23// charge an RC network on the BOOT0 pin.
24// See the QMK Discord's #hardware channel pins for an example circuit.
25// Insert these two lines into your keyboard's `config.h` file.
26// In the case below, PB7 is selected to charge.
27#if 0
28#define STM32_BOOTLOADER_DUAL_BANK TRUE
29#define STM32_BOOTLOADER_DUAL_BANK_GPIO B7
30#endif \ No newline at end of file
diff --git a/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/mcuconf.h
new file mode 100644
index 000000000..117e920e3
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/mcuconf.h
@@ -0,0 +1,372 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32G4xx drivers configuration.
19 * The following settings override the default settings present in
20 * the various device driver implementation headers.
21 * Note that the settings for each driver only have effect if the whole
22 * driver is enabled in halconf.h.
23 *
24 * IRQ priorities:
25 * 15...0 Lowest...Highest.
26 *
27 * DMA priorities:
28 * 0...3 Lowest...Highest.
29 */
30
31#ifndef MCUCONF_H
32#define MCUCONF_H
33
34#define STM32G4xx_MCUCONF
35#define STM32G473_MCUCONF
36#define STM32G483_MCUCONF
37#define STM32G474_MCUCONF
38#define STM32G484_MCUCONF
39
40/*
41 * HAL driver system settings.
42 */
43#define STM32_NO_INIT FALSE
44#define STM32_VOS STM32_VOS_RANGE1
45#define STM32_PWR_CR2 (PWR_CR2_PLS_LEV0)
46#define STM32_PWR_CR3 (PWR_CR3_EIWF)
47#define STM32_PWR_CR4 (0U)
48#define STM32_HSI16_ENABLED TRUE
49#define STM32_HSI48_ENABLED TRUE
50#define STM32_HSE_ENABLED FALSE
51#define STM32_LSI_ENABLED FALSE
52#define STM32_LSE_ENABLED FALSE
53#define STM32_SW STM32_SW_PLLRCLK
54#define STM32_PLLSRC STM32_PLLSRC_HSI16
55#define STM32_PLLM_VALUE 2
56#define STM32_PLLN_VALUE 40
57#define STM32_PLLPDIV_VALUE 0
58#define STM32_PLLP_VALUE 7
59#define STM32_PLLQ_VALUE 2
60#define STM32_PLLR_VALUE 2
61#define STM32_HPRE STM32_HPRE_DIV1
62#define STM32_PPRE1 STM32_PPRE1_DIV1
63#define STM32_PPRE2 STM32_PPRE2_DIV1
64#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
65#define STM32_MCOPRE STM32_MCOPRE_DIV1
66#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
67
68/*
69 * Peripherals clock sources.
70 */
71#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
72#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
73#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
74#define STM32_UART4SEL STM32_UART4SEL_SYSCLK
75#define STM32_UART5SEL STM32_UART5SEL_SYSCLK
76#define STM32_LPUART1SEL STM32_LPUART1SEL_PCLK1
77#define STM32_I2C1SEL STM32_I2C1SEL_PCLK1
78#define STM32_I2C2SEL STM32_I2C2SEL_PCLK1
79#define STM32_I2C3SEL STM32_I2C3SEL_PCLK1
80#define STM32_I2C4SEL STM32_I2C4SEL_PCLK1
81#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
82#define STM32_SAI1SEL STM32_SAI1SEL_SYSCLK
83#define STM32_I2S23SEL STM32_I2S23SEL_SYSCLK
84#define STM32_FDCANSEL STM32_FDCANSEL_HSE
85#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
86#define STM32_ADC12SEL STM32_ADC12SEL_PLLPCLK
87#define STM32_ADC345SEL STM32_ADC345SEL_PLLPCLK
88#define STM32_QSPISEL STM32_QSPISEL_SYSCLK
89#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK
90
91/*
92 * IRQ system settings.
93 */
94#define STM32_IRQ_EXTI0_PRIORITY 6
95#define STM32_IRQ_EXTI1_PRIORITY 6
96#define STM32_IRQ_EXTI2_PRIORITY 6
97#define STM32_IRQ_EXTI3_PRIORITY 6
98#define STM32_IRQ_EXTI4_PRIORITY 6
99#define STM32_IRQ_EXTI5_9_PRIORITY 6
100#define STM32_IRQ_EXTI10_15_PRIORITY 6
101#define STM32_IRQ_EXTI164041_PRIORITY 6
102#define STM32_IRQ_EXTI17_PRIORITY 6
103#define STM32_IRQ_EXTI18_PRIORITY 6
104#define STM32_IRQ_EXTI19_PRIORITY 6
105#define STM32_IRQ_EXTI20_PRIORITY 6
106#define STM32_IRQ_EXTI212229_PRIORITY 6
107#define STM32_IRQ_EXTI30_32_PRIORITY 6
108#define STM32_IRQ_EXTI33_PRIORITY 6
109
110#define STM32_IRQ_FDCAN1_PRIORITY 10
111#define STM32_IRQ_FDCAN2_PRIORITY 10
112#define STM32_IRQ_FDCAN3_PRIORITY 10
113
114#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
115#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
116#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
117#define STM32_IRQ_TIM1_CC_PRIORITY 7
118#define STM32_IRQ_TIM2_PRIORITY 7
119#define STM32_IRQ_TIM3_PRIORITY 7
120#define STM32_IRQ_TIM4_PRIORITY 7
121#define STM32_IRQ_TIM5_PRIORITY 7
122#define STM32_IRQ_TIM6_PRIORITY 7
123#define STM32_IRQ_TIM7_PRIORITY 7
124#define STM32_IRQ_TIM8_UP_PRIORITY 7
125#define STM32_IRQ_TIM8_CC_PRIORITY 7
126#define STM32_IRQ_TIM20_UP_PRIORITY 7
127#define STM32_IRQ_TIM20_CC_PRIORITY 7
128
129#define STM32_IRQ_USART1_PRIORITY 12
130#define STM32_IRQ_USART2_PRIORITY 12
131#define STM32_IRQ_USART3_PRIORITY 12
132#define STM32_IRQ_UART4_PRIORITY 12
133#define STM32_IRQ_UART5_PRIORITY 12
134#define STM32_IRQ_LPUART1_PRIORITY 12
135
136/*
137 * ADC driver system settings.
138 */
139#define STM32_ADC_DUAL_MODE FALSE
140#define STM32_ADC_COMPACT_SAMPLES FALSE
141#define STM32_ADC_USE_ADC1 FALSE
142#define STM32_ADC_USE_ADC2 FALSE
143#define STM32_ADC_USE_ADC3 FALSE
144#define STM32_ADC_USE_ADC4 FALSE
145#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
146#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
147#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID_ANY
148#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID_ANY
149#define STM32_ADC_ADC1_DMA_PRIORITY 2
150#define STM32_ADC_ADC2_DMA_PRIORITY 2
151#define STM32_ADC_ADC3_DMA_PRIORITY 2
152#define STM32_ADC_ADC4_DMA_PRIORITY 2
153#define STM32_ADC_ADC12_IRQ_PRIORITY 5
154#define STM32_ADC_ADC3_IRQ_PRIORITY 5
155#define STM32_ADC_ADC4_IRQ_PRIORITY 5
156#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
157#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
158#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5
159#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5
160#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV4
161#define STM32_ADC_ADC345_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV4
162#define STM32_ADC_ADC12_PRESC ADC_CCR_PRESC_DIV2
163#define STM32_ADC_ADC345_PRESC ADC_CCR_PRESC_DIV2
164
165/*
166 * CAN driver system settings.
167 */
168#define STM32_CAN_USE_FDCAN1 FALSE
169#define STM32_CAN_USE_FDCAN2 FALSE
170#define STM32_CAN_USE_FDCAN3 FALSE
171
172/*
173 * DAC driver system settings.
174 */
175#define STM32_DAC_DUAL_MODE FALSE
176#define STM32_DAC_USE_DAC1_CH1 FALSE
177#define STM32_DAC_USE_DAC1_CH2 FALSE
178#define STM32_DAC_USE_DAC2_CH1 FALSE
179#define STM32_DAC_USE_DAC3_CH1 FALSE
180#define STM32_DAC_USE_DAC3_CH2 FALSE
181#define STM32_DAC_USE_DAC4_CH1 FALSE
182#define STM32_DAC_USE_DAC4_CH2 FALSE
183#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
184#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
185#define STM32_DAC_DAC2_CH1_IRQ_PRIORITY 10
186#define STM32_DAC_DAC3_CH1_IRQ_PRIORITY 10
187#define STM32_DAC_DAC3_CH2_IRQ_PRIORITY 10
188#define STM32_DAC_DAC4_CH1_IRQ_PRIORITY 10
189#define STM32_DAC_DAC4_CH2_IRQ_PRIORITY 10
190#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
191#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
192#define STM32_DAC_DAC2_CH1_DMA_PRIORITY 2
193#define STM32_DAC_DAC3_CH1_DMA_PRIORITY 2
194#define STM32_DAC_DAC3_CH2_DMA_PRIORITY 2
195#define STM32_DAC_DAC4_CH1_DMA_PRIORITY 2
196#define STM32_DAC_DAC4_CH2_DMA_PRIORITY 2
197#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
198#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
199#define STM32_DAC_DAC2_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
200#define STM32_DAC_DAC3_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
201#define STM32_DAC_DAC3_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
202#define STM32_DAC_DAC4_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY
203#define STM32_DAC_DAC4_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY
204
205/*
206 * GPT driver system settings.
207 */
208#define STM32_GPT_USE_TIM1 FALSE
209#define STM32_GPT_USE_TIM2 FALSE
210#define STM32_GPT_USE_TIM3 FALSE
211#define STM32_GPT_USE_TIM4 FALSE
212#define STM32_GPT_USE_TIM5 FALSE
213#define STM32_GPT_USE_TIM6 FALSE
214#define STM32_GPT_USE_TIM7 FALSE
215#define STM32_GPT_USE_TIM8 FALSE
216#define STM32_GPT_USE_TIM15 FALSE
217#define STM32_GPT_USE_TIM16 FALSE
218#define STM32_GPT_USE_TIM17 FALSE
219
220/*
221 * I2C driver system settings.
222 */
223#define STM32_I2C_USE_I2C1 FALSE
224#define STM32_I2C_USE_I2C2 FALSE
225#define STM32_I2C_USE_I2C3 FALSE
226#define STM32_I2C_USE_I2C4 FALSE
227#define STM32_I2C_BUSY_TIMEOUT 50
228#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
229#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
230#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
231#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
232#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
233#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
234#define STM32_I2C_I2C4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
235#define STM32_I2C_I2C4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
236#define STM32_I2C_I2C1_IRQ_PRIORITY 5
237#define STM32_I2C_I2C2_IRQ_PRIORITY 5
238#define STM32_I2C_I2C3_IRQ_PRIORITY 5
239#define STM32_I2C_I2C4_IRQ_PRIORITY 5
240#define STM32_I2C_I2C1_DMA_PRIORITY 3
241#define STM32_I2C_I2C2_DMA_PRIORITY 3
242#define STM32_I2C_I2C3_DMA_PRIORITY 3
243#define STM32_I2C_I2C4_DMA_PRIORITY 3
244#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
245
246/*
247 * ICU driver system settings.
248 */
249#define STM32_ICU_USE_TIM1 FALSE
250#define STM32_ICU_USE_TIM2 FALSE
251#define STM32_ICU_USE_TIM3 FALSE
252#define STM32_ICU_USE_TIM4 FALSE
253#define STM32_ICU_USE_TIM5 FALSE
254#define STM32_ICU_USE_TIM8 FALSE
255#define STM32_ICU_USE_TIM15 FALSE
256#define STM32_ICU_USE_TIM16 FALSE
257#define STM32_ICU_USE_TIM17 FALSE
258
259/*
260 * PWM driver system settings.
261 */
262#define STM32_PWM_USE_ADVANCED FALSE
263#define STM32_PWM_USE_TIM1 FALSE
264#define STM32_PWM_USE_TIM2 FALSE
265#define STM32_PWM_USE_TIM3 FALSE
266#define STM32_PWM_USE_TIM4 FALSE
267#define STM32_PWM_USE_TIM5 FALSE
268#define STM32_PWM_USE_TIM8 FALSE
269#define STM32_PWM_USE_TIM15 FALSE
270#define STM32_PWM_USE_TIM16 FALSE
271#define STM32_PWM_USE_TIM17 FALSE
272#define STM32_PWM_USE_TIM20 FALSE
273
274/*
275 * RTC driver system settings.
276 */
277
278/*
279 * SDC driver system settings.
280 */
281
282/*
283 * SERIAL driver system settings.
284 */
285#define STM32_SERIAL_USE_USART1 FALSE
286#define STM32_SERIAL_USE_USART2 FALSE
287#define STM32_SERIAL_USE_USART3 FALSE
288#define STM32_SERIAL_USE_UART4 FALSE
289#define STM32_SERIAL_USE_UART5 FALSE
290#define STM32_SERIAL_USE_LPUART1 FALSE
291
292/*
293 * SPI driver system settings.
294 */
295#define STM32_SPI_USE_SPI1 FALSE
296#define STM32_SPI_USE_SPI2 FALSE
297#define STM32_SPI_USE_SPI3 FALSE
298#define STM32_SPI_USE_SPI4 FALSE
299#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
300#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
301#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
302#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
303#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
304#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
305#define STM32_SPI_SPI4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
306#define STM32_SPI_SPI4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
307#define STM32_SPI_SPI1_DMA_PRIORITY 1
308#define STM32_SPI_SPI2_DMA_PRIORITY 1
309#define STM32_SPI_SPI3_DMA_PRIORITY 1
310#define STM32_SPI_SPI4_DMA_PRIORITY 1
311#define STM32_SPI_SPI1_IRQ_PRIORITY 10
312#define STM32_SPI_SPI2_IRQ_PRIORITY 10
313#define STM32_SPI_SPI3_IRQ_PRIORITY 10
314#define STM32_SPI_SPI4_IRQ_PRIORITY 10
315#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
316
317/*
318 * ST driver system settings.
319 */
320#define STM32_ST_IRQ_PRIORITY 8
321#define STM32_ST_USE_TIMER 2
322
323/*
324 * TRNG driver system settings.
325 */
326#define STM32_TRNG_USE_RNG1 FALSE
327
328/*
329 * UART driver system settings.
330 */
331#define STM32_UART_USE_USART1 FALSE
332#define STM32_UART_USE_USART2 FALSE
333#define STM32_UART_USE_USART3 FALSE
334#define STM32_UART_USE_UART4 FALSE
335#define STM32_UART_USE_UART5 FALSE
336#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
337#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
338#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
339#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
340#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
341#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
342#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
343#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
344#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
345#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY
346#define STM32_UART_USART1_DMA_PRIORITY 0
347#define STM32_UART_USART2_DMA_PRIORITY 0
348#define STM32_UART_USART3_DMA_PRIORITY 0
349#define STM32_UART_UART4_DMA_PRIORITY 0
350#define STM32_UART_UART5_DMA_PRIORITY 0
351#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
352
353/*
354 * USB driver system settings.
355 */
356#define STM32_USB_USE_USB1 TRUE
357#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
358#define STM32_USB_USB1_HP_IRQ_PRIORITY 5
359#define STM32_USB_USB1_LP_IRQ_PRIORITY 5
360
361/*
362 * WDG driver system settings.
363 */
364#define STM32_WDG_USE_IWDG FALSE
365
366/*
367 * WSPI driver system settings.
368 */
369#define STM32_WSPI_USE_QUADSPI1 FALSE
370#define STM32_WSPI_QUADSPI1_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
371
372#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_L412XB/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_L412XB/board/board.mk
new file mode 100644
index 000000000..1250385eb
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L412XB/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/board.h
new file mode 100644
index 000000000..2e37d95fe
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/board.h
@@ -0,0 +1,24 @@
1/* Copyright 2018-2021 Harrison Chan (@Xelus)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32L432xx
21
22// Pretend that we're an L443xx as the ChibiOS definitions for L4x2/L4x3 mistakenly don't enable GPIOH, I2C2, or SPI2.
23// Until ChibiOS upstream is fixed, this should be kept at L443, as nothing in QMK currently utilises the crypto peripheral on the L443.
24#define STM32L443xx
diff --git a/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/config.h
new file mode 100644
index 000000000..c27c61b19
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/config.h
@@ -0,0 +1,26 @@
1/* Copyright 2018-2021 Harrison Chan (@Xelus)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/* Address for jumping to bootloader on STM32 chips. */
18/* It is chip dependent, the correct number can be looked up by checking against ST's application note AN2606.
19 */
20#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
21
22#define PAL_STM32_OSPEED_HIGHEST PAL_STM32_OSPEED_HIGH
23
24#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
25# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
26#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/mcuconf.h
new file mode 100644
index 000000000..8ad5a8da2
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L412XB/configs/mcuconf.h
@@ -0,0 +1,282 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32L4xx drivers configuration.
19 * The following settings override the default settings present in
20 * the various device driver implementation headers.
21 * Note that the settings for each driver only have effect if the whole
22 * driver is enabled in halconf.h.
23 *
24 * IRQ priorities:
25 * 15...0 Lowest...Highest.
26 *
27 * DMA priorities:
28 * 0...3 Lowest...Highest.
29 */
30
31#ifndef MCUCONF_H
32#define MCUCONF_H
33
34#define STM32L4xx_MCUCONF
35#define STM32L412_MCUCONF
36#define STM32L422_MCUCONF
37#define STM32L432_MCUCONF
38#define STM32L433_MCUCONF
39#define STM32L442_MCUCONF
40#define STM32L443_MCUCONF
41
42/*
43 * HAL driver system settings.
44 */
45#define STM32_NO_INIT FALSE
46#define STM32_VOS STM32_VOS_RANGE1
47#define STM32_PVD_ENABLE FALSE
48#define STM32_PLS STM32_PLS_LEV0
49#define STM32_HSI16_ENABLED TRUE
50#define STM32_HSI48_ENABLED TRUE
51#define STM32_LSI_ENABLED FALSE
52#define STM32_HSE_ENABLED FALSE
53#define STM32_LSE_ENABLED FALSE
54#define STM32_MSIPLL_ENABLED FALSE
55#define STM32_ADC_CLOCK_ENABLED TRUE
56#define STM32_USB_CLOCK_ENABLED TRUE
57#define STM32_SAI1_CLOCK_ENABLED TRUE
58#define STM32_SAI2_CLOCK_ENABLED TRUE
59#define STM32_MSIRANGE STM32_MSIRANGE_4M
60#define STM32_MSISRANGE STM32_MSISRANGE_4M
61#define STM32_SW STM32_SW_PLL
62#define STM32_PLLSRC STM32_PLLSRC_HSI16
63#define STM32_PLLM_VALUE 4
64#define STM32_PLLN_VALUE 80
65#define STM32_PLLP_VALUE 7
66#define STM32_PLLQ_VALUE 4
67#define STM32_PLLR_VALUE 4
68#define STM32_HPRE STM32_HPRE_DIV1
69#define STM32_PPRE1 STM32_PPRE1_DIV1
70#define STM32_PPRE2 STM32_PPRE2_DIV1
71#define STM32_STOPWUCK STM32_STOPWUCK_MSI
72#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
73#define STM32_MCOPRE STM32_MCOPRE_DIV1
74#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
75#define STM32_PLLSAI1N_VALUE 72
76#define STM32_PLLSAI1P_VALUE 7
77#define STM32_PLLSAI1Q_VALUE 6
78#define STM32_PLLSAI1R_VALUE 6
79#define STM32_PLLSAI2N_VALUE 72
80#define STM32_PLLSAI2P_VALUE 7
81#define STM32_PLLSAI2R_VALUE 6
82
83/*
84 * Peripherals clock sources.
85 */
86#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
87#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
88#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
89#define STM32_UART4SEL STM32_UART4SEL_SYSCLK
90#define STM32_UART5SEL STM32_UART5SEL_SYSCLK
91#define STM32_LPUART1SEL STM32_LPUART1SEL_SYSCLK
92#define STM32_I2C1SEL STM32_I2C1SEL_SYSCLK
93#define STM32_I2C2SEL STM32_I2C2SEL_SYSCLK
94#define STM32_I2C3SEL STM32_I2C3SEL_SYSCLK
95#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
96#define STM32_LPTIM2SEL STM32_LPTIM2SEL_PCLK1
97#define STM32_SAI1SEL STM32_SAI1SEL_OFF
98#define STM32_SAI2SEL STM32_SAI2SEL_OFF
99#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
100#define STM32_ADCSEL STM32_ADCSEL_SYSCLK
101#define STM32_SWPMI1SEL STM32_SWPMI1SEL_PCLK1
102#define STM32_RTCSEL STM32_RTCSEL_LSI
103
104/*
105 * IRQ system settings.
106 */
107#define STM32_IRQ_EXTI0_PRIORITY 6
108#define STM32_IRQ_EXTI1_PRIORITY 6
109#define STM32_IRQ_EXTI2_PRIORITY 6
110#define STM32_IRQ_EXTI3_PRIORITY 6
111#define STM32_IRQ_EXTI4_PRIORITY 6
112#define STM32_IRQ_EXTI5_9_PRIORITY 6
113#define STM32_IRQ_EXTI10_15_PRIORITY 6
114#define STM32_IRQ_EXTI1635_38_PRIORITY 6
115#define STM32_IRQ_EXTI18_PRIORITY 6
116#define STM32_IRQ_EXTI19_PRIORITY 6
117#define STM32_IRQ_EXTI20_PRIORITY 6
118#define STM32_IRQ_EXTI21_22_PRIORITY 15
119
120#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
121#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
122#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
123#define STM32_IRQ_TIM1_CC_PRIORITY 7
124#define STM32_IRQ_TIM2_PRIORITY 7
125#define STM32_IRQ_TIM6_PRIORITY 7
126#define STM32_IRQ_TIM7_PRIORITY 7
127
128#define STM32_IRQ_USART1_PRIORITY 12
129#define STM32_IRQ_USART2_PRIORITY 12
130#define STM32_IRQ_USART3_PRIORITY 12
131#define STM32_IRQ_LPUART1_PRIORITY 12
132
133/*
134 * ADC driver system settings.
135 */
136#define STM32_ADC_COMPACT_SAMPLES FALSE
137#define STM32_ADC_USE_ADC1 FALSE
138#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
139#define STM32_ADC_ADC1_DMA_PRIORITY 2
140#define STM32_ADC_ADC12_IRQ_PRIORITY 5
141#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
142#define STM32_ADC_ADC123_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
143#define STM32_ADC_ADC123_PRESC ADC_CCR_PRESC_DIV2
144
145/*
146 * CAN driver system settings.
147 */
148#define STM32_CAN_USE_CAN1 FALSE
149#define STM32_CAN_CAN1_IRQ_PRIORITY 11
150
151/*
152 * DAC driver system settings.
153 */
154#define STM32_DAC_DUAL_MODE FALSE
155#define STM32_DAC_USE_DAC1_CH1 FALSE
156#define STM32_DAC_USE_DAC1_CH2 FALSE
157#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
158#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
159#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
160#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
161#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
162#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
163
164/*
165 * GPT driver system settings.
166 */
167#define STM32_GPT_USE_TIM1 FALSE
168#define STM32_GPT_USE_TIM2 FALSE
169#define STM32_GPT_USE_TIM6 FALSE
170#define STM32_GPT_USE_TIM7 FALSE
171#define STM32_GPT_USE_TIM15 FALSE
172#define STM32_GPT_USE_TIM16 FALSE
173
174/*
175 * I2C driver system settings.
176 */
177#define STM32_I2C_USE_I2C1 FALSE
178#define STM32_I2C_USE_I2C3 FALSE
179#define STM32_I2C_BUSY_TIMEOUT 50
180#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
181#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
182#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
183#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
184#define STM32_I2C_I2C1_IRQ_PRIORITY 5
185#define STM32_I2C_I2C3_IRQ_PRIORITY 5
186#define STM32_I2C_I2C1_DMA_PRIORITY 3
187#define STM32_I2C_I2C3_DMA_PRIORITY 3
188#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
189
190/*
191 * ICU driver system settings.
192 */
193#define STM32_ICU_USE_TIM1 FALSE
194#define STM32_ICU_USE_TIM2 FALSE
195#define STM32_ICU_USE_TIM15 FALSE
196#define STM32_ICU_USE_TIM16 FALSE
197
198/*
199 * PWM driver system settings.
200 */
201#define STM32_PWM_USE_ADVANCED FALSE
202#define STM32_PWM_USE_TIM1 FALSE
203#define STM32_PWM_USE_TIM2 FALSE
204#define STM32_PWM_USE_TIM15 FALSE
205#define STM32_PWM_USE_TIM16 FALSE
206
207/*
208 * RTC driver system settings.
209 */
210#define STM32_RTC_PRESA_VALUE 32
211#define STM32_RTC_PRESS_VALUE 1024
212#define STM32_RTC_CR_INIT 0
213#define STM32_RTC_TAMPCR_INIT 0
214
215/*
216 * SERIAL driver system settings.
217 */
218#define STM32_SERIAL_USE_USART1 FALSE
219#define STM32_SERIAL_USE_USART2 FALSE
220#define STM32_SERIAL_USE_LPUART1 FALSE
221#define STM32_SERIAL_USART1_PRIORITY 12
222#define STM32_SERIAL_USART2_PRIORITY 12
223#define STM32_SERIAL_LPUART1_PRIORITY 12
224
225/*
226 * SPI driver system settings.
227 */
228#define STM32_SPI_USE_SPI1 FALSE
229#define STM32_SPI_USE_SPI3 FALSE
230#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
231#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
232#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
233#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
234#define STM32_SPI_SPI1_DMA_PRIORITY 1
235#define STM32_SPI_SPI3_DMA_PRIORITY 1
236#define STM32_SPI_SPI1_IRQ_PRIORITY 10
237#define STM32_SPI_SPI3_IRQ_PRIORITY 10
238#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
239
240/*
241 * ST driver system settings.
242 */
243#define STM32_ST_IRQ_PRIORITY 8
244#define STM32_ST_USE_TIMER 2
245
246/*
247 * TRNG driver system settings.
248 */
249#define STM32_TRNG_USE_RNG1 FALSE
250
251/*
252 * UART driver system settings.
253 */
254#define STM32_UART_USE_USART1 FALSE
255#define STM32_UART_USE_USART2 FALSE
256#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
257#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 6)
258#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
259#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
260#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
261
262/*
263 * USB driver system settings.
264 */
265#define STM32_USB_USE_USB1 TRUE
266#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
267#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
268#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
269
270/*
271 * WDG driver system settings.
272 */
273#define STM32_WDG_USE_IWDG FALSE
274
275/*
276 * WSPI driver system settings.
277 */
278#define STM32_WSPI_USE_QUADSPI1 FALSE
279#define STM32_WSPI_QUADSPI1_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
280#define STM32_WSPI_QUADSPI1_PRESCALER_VALUE 1
281
282#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/GENERIC_STM32_L433XC/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_L433XC/board/board.mk
new file mode 100644
index 000000000..1250385eb
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L433XC/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO32_L432KC
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/board.h
new file mode 100644
index 000000000..2e37d95fe
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/board.h
@@ -0,0 +1,24 @@
1/* Copyright 2018-2021 Harrison Chan (@Xelus)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32L432xx
21
22// Pretend that we're an L443xx as the ChibiOS definitions for L4x2/L4x3 mistakenly don't enable GPIOH, I2C2, or SPI2.
23// Until ChibiOS upstream is fixed, this should be kept at L443, as nothing in QMK currently utilises the crypto peripheral on the L443.
24#define STM32L443xx
diff --git a/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/config.h
new file mode 100644
index 000000000..c27c61b19
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/config.h
@@ -0,0 +1,26 @@
1/* Copyright 2018-2021 Harrison Chan (@Xelus)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17/* Address for jumping to bootloader on STM32 chips. */
18/* It is chip dependent, the correct number can be looked up by checking against ST's application note AN2606.
19 */
20#define STM32_BOOTLOADER_ADDRESS 0x1FFF0000
21
22#define PAL_STM32_OSPEED_HIGHEST PAL_STM32_OSPEED_HIGH
23
24#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
25# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
26#endif
diff --git a/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/mcuconf.h
new file mode 100644
index 000000000..948c740f6
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_STM32_L433XC/configs/mcuconf.h
@@ -0,0 +1,292 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 http://www.apache.org/licenses/LICENSE-2.0
7 Unless required by applicable law or agreed to in writing, software
8 distributed under the License is distributed on an "AS IS" BASIS,
9 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 See the License for the specific language governing permissions and
11 limitations under the License.
12*/
13
14/*
15 * STM32L4xx drivers configuration.
16 * The following settings override the default settings present in
17 * the various device driver implementation headers.
18 * Note that the settings for each driver only have effect if the whole
19 * driver is enabled in halconf.h.
20 *
21 * IRQ priorities:
22 * 15...0 Lowest...Highest.
23 *
24 * DMA priorities:
25 * 0...3 Lowest...Highest.
26 */
27
28#ifndef MCUCONF_H
29#define MCUCONF_H
30
31#define STM32L4xx_MCUCONF
32#define STM32L443_MCUCONF
33
34/*
35 * HAL driver system settings.
36 */
37#define STM32_NO_INIT FALSE
38#define STM32_VOS STM32_VOS_RANGE1
39#define STM32_PVD_ENABLE FALSE
40#define STM32_PLS STM32_PLS_LEV0
41#define STM32_HSI16_ENABLED TRUE
42#define STM32_HSI48_ENABLED TRUE
43#define STM32_LSI_ENABLED TRUE
44#define STM32_HSE_ENABLED FALSE
45#define STM32_LSE_ENABLED FALSE
46#define STM32_MSIPLL_ENABLED FALSE
47#define STM32_MSIRANGE STM32_MSIRANGE_4M
48#define STM32_MSISRANGE STM32_MSISRANGE_4M
49#define STM32_SW STM32_SW_PLL
50#define STM32_PLLSRC STM32_PLLSRC_HSI16
51#define STM32_PLLM_VALUE 1
52#define STM32_PLLN_VALUE 10
53#define STM32_PLLPDIV_VALUE 0
54#define STM32_PLLP_VALUE 7
55#define STM32_PLLQ_VALUE 2
56#define STM32_PLLR_VALUE 2
57#define STM32_HPRE STM32_HPRE_DIV1
58#define STM32_PPRE1 STM32_PPRE1_DIV1
59#define STM32_PPRE2 STM32_PPRE2_DIV1
60#define STM32_STOPWUCK STM32_STOPWUCK_MSI
61#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
62#define STM32_MCOPRE STM32_MCOPRE_DIV1
63#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
64#define STM32_PLLSAI1N_VALUE 24
65#define STM32_PLLSAI1PDIV_VALUE 0
66#define STM32_PLLSAI1P_VALUE 7
67#define STM32_PLLSAI1Q_VALUE 2
68#define STM32_PLLSAI1R_VALUE 2
69
70/*
71 * Peripherals clock sources.
72 */
73#define STM32_USART1SEL STM32_USART1SEL_SYSCLK
74#define STM32_USART2SEL STM32_USART2SEL_SYSCLK
75#define STM32_USART3SEL STM32_USART3SEL_SYSCLK
76#define STM32_LPUART1SEL STM32_LPUART1SEL_SYSCLK
77#define STM32_I2C1SEL STM32_I2C1SEL_SYSCLK
78#define STM32_I2C2SEL STM32_I2C2SEL_SYSCLK
79#define STM32_I2C3SEL STM32_I2C3SEL_SYSCLK
80#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK1
81#define STM32_LPTIM2SEL STM32_LPTIM2SEL_PCLK1
82#define STM32_SAI1SEL STM32_SAI1SEL_OFF
83#define STM32_CLK48SEL STM32_CLK48SEL_HSI48
84#define STM32_ADCSEL STM32_ADCSEL_SYSCLK
85#define STM32_SWPMI1SEL STM32_SWPMI1SEL_PCLK1
86#define STM32_RTCSEL STM32_RTCSEL_LSI
87
88/*
89 * IRQ system settings.
90 */
91#define STM32_IRQ_EXTI0_PRIORITY 6
92#define STM32_IRQ_EXTI1_PRIORITY 6
93#define STM32_IRQ_EXTI2_PRIORITY 6
94#define STM32_IRQ_EXTI3_PRIORITY 6
95#define STM32_IRQ_EXTI4_PRIORITY 6
96#define STM32_IRQ_EXTI5_9_PRIORITY 6
97#define STM32_IRQ_EXTI10_15_PRIORITY 6
98#define STM32_IRQ_EXTI1635_38_PRIORITY 6
99#define STM32_IRQ_EXTI18_PRIORITY 6
100#define STM32_IRQ_EXTI19_PRIORITY 6
101#define STM32_IRQ_EXTI20_PRIORITY 6
102#define STM32_IRQ_EXTI21_22_PRIORITY 15
103
104#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
105#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
106#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
107#define STM32_IRQ_TIM1_CC_PRIORITY 7
108#define STM32_IRQ_TIM2_PRIORITY 7
109#define STM32_IRQ_TIM6_PRIORITY 7
110#define STM32_IRQ_TIM7_PRIORITY 7
111
112#define STM32_IRQ_USART1_PRIORITY 12
113#define STM32_IRQ_USART2_PRIORITY 12
114#define STM32_IRQ_USART3_PRIORITY 12
115#define STM32_IRQ_LPUART1_PRIORITY 12
116
117/*
118 * ADC driver system settings.
119 */
120#define STM32_ADC_COMPACT_SAMPLES FALSE
121#define STM32_ADC_USE_ADC1 FALSE
122#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
123#define STM32_ADC_ADC1_DMA_PRIORITY 2
124#define STM32_ADC_ADC12_IRQ_PRIORITY 5
125#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
126#define STM32_ADC_ADC123_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
127#define STM32_ADC_ADC123_PRESC ADC_CCR_PRESC_DIV2
128
129/*
130 * CAN driver system settings.
131 */
132#define STM32_CAN_USE_CAN1 FALSE
133#define STM32_CAN_CAN1_IRQ_PRIORITY 11
134
135/*
136 * DAC driver system settings.
137 */
138#define STM32_DAC_DUAL_MODE FALSE
139#define STM32_DAC_USE_DAC1_CH1 FALSE
140#define STM32_DAC_USE_DAC1_CH2 FALSE
141#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
142#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
143#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
144#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
145#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
146#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
147
148/*
149 * GPT driver system settings.
150 */
151#define STM32_GPT_USE_TIM1 FALSE
152#define STM32_GPT_USE_TIM2 FALSE
153#define STM32_GPT_USE_TIM6 FALSE
154#define STM32_GPT_USE_TIM7 FALSE
155#define STM32_GPT_USE_TIM15 FALSE
156#define STM32_GPT_USE_TIM16 FALSE
157
158/*
159 * I2C driver system settings.
160 */
161#define STM32_I2C_USE_I2C1 FALSE
162#define STM32_I2C_USE_I2C2 FALSE
163#define STM32_I2C_USE_I2C3 FALSE
164#define STM32_I2C_BUSY_TIMEOUT 50
165#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
166#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
167#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
168#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
169#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
170#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
171#define STM32_I2C_I2C1_IRQ_PRIORITY 5
172#define STM32_I2C_I2C2_IRQ_PRIORITY 5
173#define STM32_I2C_I2C3_IRQ_PRIORITY 5
174#define STM32_I2C_I2C1_DMA_PRIORITY 3
175#define STM32_I2C_I2C2_DMA_PRIORITY 3
176#define STM32_I2C_I2C3_DMA_PRIORITY 3
177#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
178
179/*
180 * ICU driver system settings.
181 */
182#define STM32_ICU_USE_TIM1 FALSE
183#define STM32_ICU_USE_TIM2 FALSE
184#define STM32_ICU_USE_TIM15 FALSE
185#define STM32_ICU_USE_TIM16 FALSE
186
187/*
188 * PWM driver system settings.
189 */
190#define STM32_PWM_USE_ADVANCED FALSE
191#define STM32_PWM_USE_TIM1 FALSE
192#define STM32_PWM_USE_TIM2 FALSE
193#define STM32_PWM_USE_TIM15 FALSE
194#define STM32_PWM_USE_TIM16 FALSE
195
196/*
197 * RTC driver system settings.
198 */
199#define STM32_RTC_PRESA_VALUE 32
200#define STM32_RTC_PRESS_VALUE 1024
201#define STM32_RTC_CR_INIT 0
202#define STM32_RTC_TAMPCR_INIT 0
203
204/*
205 * SDMMC drive system settings.
206 */
207#define STM32_SDC_USE_SDMMC1 FALSE
208#define STM32_SDC_SDMMC_UNALIGNED_SUPPORT TRUE
209#define STM32_SDC_SDMMC_WRITE_TIMEOUT 1000
210#define STM32_SDC_SDMMC_READ_TIMEOUT 1000
211#define STM32_SDC_SDMMC_CLOCK_DELAY 10
212#define STM32_SDC_SDMMC1_DMA_PRIORITY 3
213#define STM32_SDC_SDMMC1_IRQ_PRIORITY 9
214#define STM32_SDC_SDMMC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
215
216/*
217 * SERIAL driver system settings.
218 */
219#define STM32_SERIAL_USE_USART1 FALSE
220#define STM32_SERIAL_USE_USART2 FALSE
221#define STM32_SERIAL_USE_USART3 FALSE
222#define STM32_SERIAL_USE_LPUART1 FALSE
223#define STM32_SERIAL_USART1_PRIORITY 12
224#define STM32_SERIAL_USART2_PRIORITY 12
225#define STM32_SERIAL_USART3_PRIORITY 12
226#define STM32_SERIAL_LPUART1_PRIORITY 12
227
228/*
229 * SPI driver system settings.
230 */
231#define STM32_SPI_USE_SPI1 FALSE
232#define STM32_SPI_USE_SPI2 FALSE
233#define STM32_SPI_USE_SPI3 FALSE
234#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3)
235#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 4)
236#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4)
237#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5)
238#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
239#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
240#define STM32_SPI_SPI1_DMA_PRIORITY 1
241#define STM32_SPI_SPI2_DMA_PRIORITY 1
242#define STM32_SPI_SPI3_DMA_PRIORITY 1
243#define STM32_SPI_SPI1_IRQ_PRIORITY 10
244#define STM32_SPI_SPI2_IRQ_PRIORITY 10
245#define STM32_SPI_SPI3_IRQ_PRIORITY 10
246#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
247
248/*
249 * ST driver system settings.
250 */
251#define STM32_ST_IRQ_PRIORITY 8
252#define STM32_ST_USE_TIMER 2
253
254/*
255 * TRNG driver system settings.
256 */
257#define STM32_TRNG_USE_RNG1 FALSE
258
259/*
260 * UART driver system settings.
261 */
262#define STM32_UART_USE_USART1 FALSE
263#define STM32_UART_USE_USART2 FALSE
264#define STM32_UART_USE_USART3 FALSE
265#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
266#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 6)
267#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6)
268#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7)
269#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)
270#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2)
271#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
272
273/*
274 * USB driver system settings.
275 */
276#define STM32_USB_USE_USB1 TRUE
277#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
278#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
279#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
280
281/*
282 * WDG driver system settings.
283 */
284#define STM32_WDG_USE_IWDG FALSE
285
286/*
287 * WSPI driver system settings.
288 */
289#define STM32_WSPI_USE_QUADSPI1 FALSE
290#define STM32_WSPI_QUADSPI1_DMA_STREAM STM32_DMA_STREAM_ID(2, 7)
291
292#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/IC_TEENSY_3_1/board/board.c b/platforms/chibios/boards/IC_TEENSY_3_1/board/board.c
new file mode 100644
index 000000000..424e0c975
--- /dev/null
+++ b/platforms/chibios/boards/IC_TEENSY_3_1/board/board.c
@@ -0,0 +1,151 @@
1/*
2 ChibiOS - Copyright (C) 2015 RedoX https://github.com/RedoXyde
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16#include <hal.h>
17
18#if HAL_USE_PAL || defined(__DOXYGEN__)
19/**
20 * @brief PAL setup.
21 * @details Digital I/O ports static configuration as defined in @p board.h.
22 * This variable is used by the HAL when initializing the PAL driver.
23 */
24const PALConfig pal_default_config = {
25 .ports =
26 {
27 {
28 /*
29 * PORTA setup.
30 *
31 * PTA4 - PIN33
32 * PTA5 - PIN24
33 * PTA12 - PIN3
34 * PTA13 - PIN4
35 *
36 * PTA18/19 crystal
37 * PTA0/3 SWD
38 */
39 .port = IOPORT1,
40 .pads =
41 {
42 PAL_MODE_ALTERNATIVE_7, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_7, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_INPUT_ANALOG, PAL_MODE_INPUT_ANALOG, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
43 },
44 },
45 {
46 /*
47 * PORTB setup.
48 *
49 * PTB0 - PIN16
50 * PTB1 - PIN17
51 * PTB2 - PIN19
52 * PTB3 - PIN18
53 * PTB16 - PIN0 - UART0_TX
54 * PTB17 - PIN1 - UART0_RX
55 * PTB18 - PIN32
56 * PTB19 - PIN25
57 */
58 .port = IOPORT2,
59 .pads =
60 {
61 PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_ALTERNATIVE_3, PAL_MODE_ALTERNATIVE_3, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
62 },
63 },
64 {
65 /*
66 * PORTC setup.
67 *
68 * PTC0 - PIN15
69 * PTC1 - PIN22
70 * PTC2 - PIN23
71 * PTC3 - PIN9
72 * PTC4 - PIN10
73 * PTC5 - PIN13
74 * PTC6 - PIN11
75 * PTC7 - PIN12
76 * PTC8 - PIN28
77 * PTC9 - PIN27
78 * PTC10 - PIN29
79 * PTC11 - PIN30
80 */
81 .port = IOPORT3,
82 .pads =
83 {
84 PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
85 },
86 },
87 {
88 /*
89 * PORTD setup.
90 *
91 * PTD0 - PIN2
92 * PTD1 - PIN14
93 * PTD2 - PIN7
94 * PTD3 - PIN8
95 * PTD4 - PIN6
96 * PTD5 - PIN20
97 * PTD6 - PIN21
98 * PTD7 - PIN5
99 */
100 .port = IOPORT4,
101 .pads =
102 {
103 PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
104 },
105 },
106 {
107 /*
108 * PORTE setup.
109 *
110 * PTE0 - PIN31
111 * PTE1 - PIN26
112 */
113 .port = IOPORT5,
114 .pads =
115 {
116 PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_OUTPUT_PUSHPULL, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED, PAL_MODE_UNCONNECTED,
117 },
118 },
119 },
120};
121#endif
122
123// NOTE: This value comes from kiibohd/controller and is the location of a value
124// which needs to be checked before disabling the watchdog (which happens in
125// k20x_clock_init)
126#define WDOG_TMROUTL *(volatile uint16_t *)0x40052012
127
128/**
129 * @brief Early initialization code.
130 * @details This initialization must be performed just after stack setup
131 * and before any other initialization.
132 */
133void __early_init(void) {
134 // This is a dirty hack and should only be used as a temporary fix until this
135 // is upstreamed.
136 while (WDOG_TMROUTL < 2)
137 ; // Must wait for WDOG timer if already running, before jumping
138
139 k20x_clock_init();
140}
141
142/**
143 * @brief Board-specific initialization code.
144 * @todo Add your board-specific code, if any.
145 */
146void boardInit(void) {}
147
148
149void restart_usb_driver(USBDriver *usbp) {
150 // Do nothing. Restarting the USB driver on these boards breaks it.
151}
diff --git a/platforms/chibios/boards/IC_TEENSY_3_1/board/board.h b/platforms/chibios/boards/IC_TEENSY_3_1/board/board.h
new file mode 100644
index 000000000..c8259ab0c
--- /dev/null
+++ b/platforms/chibios/boards/IC_TEENSY_3_1/board/board.h
@@ -0,0 +1,295 @@
1/*
2 ChibiOS - Copyright (C) 2015 RedoX https://github.com/RedoXyde
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef _BOARD_H_
18#define _BOARD_H_
19
20/*
21 * Setup for the PJRC Teensy 3.1 board.
22 */
23
24/*
25 * Board identifier.
26 */
27#define BOARD_PJRC_TEENSY_3_1
28#define BOARD_NAME "PJRC Teensy 3.1"
29
30/* External 16 MHz crystal */
31#define KINETIS_XTAL_FREQUENCY 16000000UL
32
33/* Use internal capacitors for the crystal */
34#define KINETIS_BOARD_OSCILLATOR_SETTING OSC_CR_SC8P | OSC_CR_SC2P
35
36/*
37 * MCU type
38 */
39#define K20x7
40
41/*
42 * IO pins assignments.
43 */
44#define PORTA_PIN0 0
45#define PORTA_PIN1 1
46#define PORTA_PIN2 2
47#define PORTA_PIN3 3
48#define TEENSY_PIN33 4
49#define TEENSY_PIN24 5
50#define PORTA_PIN6 6
51#define PORTA_PIN7 7
52#define PORTA_PIN8 8
53#define PORTA_PIN9 9
54#define PORTA_PIN10 10
55#define PORTA_PIN11 11
56#define TEENSY_PIN3 12
57#define TEENSY_PIN4 13
58#define PORTA_PIN14 14
59#define PORTA_PIN15 15
60#define PORTA_PIN16 16
61#define PORTA_PIN17 17
62#define PORTA_PIN18 18
63#define PORTA_PIN19 19
64#define PORTA_PIN20 20
65#define PORTA_PIN21 21
66#define PORTA_PIN22 22
67#define PORTA_PIN23 23
68#define PORTA_PIN24 24
69#define PORTA_PIN25 25
70#define PORTA_PIN26 26
71#define PORTA_PIN27 27
72#define PORTA_PIN28 28
73#define PORTA_PIN29 29
74#define PORTA_PIN30 30
75#define PORTA_PIN31 31
76
77#define TEENSY_PIN3_IOPORT IOPORT1
78#define TEENSY_PIN4_IOPORT IOPORT1
79#define TEENSY_PIN24_IOPORT IOPORT1
80#define TEENSY_PIN33_IOPORT IOPORT1
81
82#define TEENSY_PIN16 0
83#define TEENSY_PIN17 1
84#define TEENSY_PIN19 2
85#define TEENSY_PIN18 3
86#define PORTB_PIN4 4
87#define PORTB_PIN5 5
88#define PORTB_PIN6 6
89#define PORTB_PIN7 7
90#define PORTB_PIN8 8
91#define PORTB_PIN9 9
92#define PORTB_PIN10 10
93#define PORTB_PIN11 11
94#define PORTB_PIN12 12
95#define PORTB_PIN13 13
96#define PORTB_PIN14 14
97#define PORTB_PIN15 15
98#define TEENSY_PIN0 16
99#define TEENSY_PIN1 17
100#define TEENSY_PIN32 18
101#define TEENSY_PIN25 19
102#define PORTB_PIN20 20
103#define PORTB_PIN21 21
104#define PORTB_PIN22 22
105#define PORTB_PIN23 23
106#define PORTB_PIN24 24
107#define PORTB_PIN25 25
108#define PORTB_PIN26 26
109#define PORTB_PIN27 27
110#define PORTB_PIN28 28
111#define PORTB_PIN29 29
112#define PORTB_PIN30 30
113#define PORTB_PIN31 31
114
115#define TEENSY_PIN0_IOPORT IOPORT2
116#define TEENSY_PIN1_IOPORT IOPORT2
117#define TEENSY_PIN16_IOPORT IOPORT2
118#define TEENSY_PIN17_IOPORT IOPORT2
119#define TEENSY_PIN18_IOPORT IOPORT2
120#define TEENSY_PIN19_IOPORT IOPORT2
121#define TEENSY_PIN25_IOPORT IOPORT2
122#define TEENSY_PIN32_IOPORT IOPORT2
123
124#define TEENSY_PIN15 0
125#define TEENSY_PIN22 1
126#define TEENSY_PIN23 2
127#define TEENSY_PIN9 3
128#define TEENSY_PIN10 4
129#define TEENSY_PIN13 5
130#define TEENSY_PIN11 6
131#define TEENSY_PIN12 7
132#define TEENSY_PIN28 8
133#define TEENSY_PIN27 9
134#define TEENSY_PIN29 10
135#define TEENSY_PIN30 11
136#define PORTC_PIN12 12
137#define PORTC_PIN13 13
138#define PORTC_PIN14 14
139#define PORTC_PIN15 15
140#define PORTC_PIN16 16
141#define PORTC_PIN17 17
142#define PORTC_PIN18 18
143#define PORTC_PIN19 19
144#define PORTC_PIN20 20
145#define PORTC_PIN21 21
146#define PORTC_PIN22 22
147#define PORTC_PIN23 23
148#define PORTC_PIN24 24
149#define PORTC_PIN25 25
150#define PORTC_PIN26 26
151#define PORTC_PIN27 27
152#define PORTC_PIN28 28
153#define PORTC_PIN29 29
154#define PORTC_PIN30 30
155#define PORTC_PIN31 31
156
157#define TEENSY_PIN9_IOPORT IOPORT3
158#define TEENSY_PIN10_IOPORT IOPORT3
159#define TEENSY_PIN11_IOPORT IOPORT3
160#define TEENSY_PIN12_IOPORT IOPORT3
161#define TEENSY_PIN13_IOPORT IOPORT3
162#define TEENSY_PIN15_IOPORT IOPORT3
163#define TEENSY_PIN22_IOPORT IOPORT3
164#define TEENSY_PIN23_IOPORT IOPORT3
165#define TEENSY_PIN27_IOPORT IOPORT3
166#define TEENSY_PIN28_IOPORT IOPORT3
167#define TEENSY_PIN29_IOPORT IOPORT3
168#define TEENSY_PIN30_IOPORT IOPORT3
169
170#define TEENSY_PIN2 0
171#define TEENSY_PIN14 1
172#define TEENSY_PIN7 2
173#define TEENSY_PIN8 3
174#define TEENSY_PIN6 4
175#define TEENSY_PIN20 5
176#define TEENSY_PIN21 6
177#define TEENSY_PIN5 7
178#define PORTD_PIN8 8
179#define PORTD_PIN9 9
180#define PORTD_PIN10 10
181#define PORTD_PIN11 11
182#define PORTD_PIN12 12
183#define PORTD_PIN13 13
184#define PORTD_PIN14 14
185#define PORTD_PIN15 15
186#define PORTD_PIN16 16
187#define PORTD_PIN17 17
188#define PORTD_PIN18 18
189#define PORTD_PIN19 19
190#define PORTD_PIN20 20
191#define PORTD_PIN21 21
192#define PORTD_PIN22 22
193#define PORTD_PIN23 23
194#define PORTD_PIN24 24
195#define PORTD_PIN25 25
196#define PORTD_PIN26 26
197#define PORTD_PIN27 27
198#define PORTD_PIN28 28
199#define PORTD_PIN29 29
200#define PORTD_PIN30 30
201#define PORTD_PIN31 31
202
203#define TEENSY_PIN2_IOPORT IOPORT4
204#define TEENSY_PIN5_IOPORT IOPORT4
205#define TEENSY_PIN6_IOPORT IOPORT4
206#define TEENSY_PIN7_IOPORT IOPORT4
207#define TEENSY_PIN8_IOPORT IOPORT4
208#define TEENSY_PIN14_IOPORT IOPORT4
209#define TEENSY_PIN20_IOPORT IOPORT4
210#define TEENSY_PIN21_IOPORT IOPORT4
211
212#define TEENSY_PIN31 0
213#define TEENSY_PIN26 1
214#define PORTE_PIN2 2
215#define PORTE_PIN3 3
216#define PORTE_PIN4 4
217#define PORTE_PIN5 5
218#define PORTE_PIN6 6
219#define PORTE_PIN7 7
220#define PORTE_PIN8 8
221#define PORTE_PIN9 9
222#define PORTE_PIN10 10
223#define PORTE_PIN11 11
224#define PORTE_PIN12 12
225#define PORTE_PIN13 13
226#define PORTE_PIN14 14
227#define PORTE_PIN15 15
228#define PORTE_PIN16 16
229#define PORTE_PIN17 17
230#define PORTE_PIN18 18
231#define PORTE_PIN19 19
232#define PORTE_PIN20 20
233#define PORTE_PIN21 21
234#define PORTE_PIN22 22
235#define PORTE_PIN23 23
236#define PORTE_PIN24 24
237#define PORTE_PIN25 25
238#define PORTE_PIN26 26
239#define PORTE_PIN27 27
240#define PORTE_PIN28 28
241#define PORTE_PIN29 29
242#define PORTE_PIN30 30
243#define PORTE_PIN31 31
244
245#define TEENSY_PIN26_IOPORT IOPORT5
246#define TEENSY_PIN31_IOPORT IOPORT5
247
248#define LINE_PIN1 PAL_LINE(TEENSY_PIN1_IOPORT, TEENSY_PIN1)
249#define LINE_PIN2 PAL_LINE(TEENSY_PIN2_IOPORT, TEENSY_PIN2)
250#define LINE_PIN3 PAL_LINE(TEENSY_PIN3_IOPORT, TEENSY_PIN3)
251#define LINE_PIN4 PAL_LINE(TEENSY_PIN4_IOPORT, TEENSY_PIN4)
252#define LINE_PIN5 PAL_LINE(TEENSY_PIN5_IOPORT, TEENSY_PIN5)
253#define LINE_PIN6 PAL_LINE(TEENSY_PIN6_IOPORT, TEENSY_PIN6)
254#define LINE_PIN7 PAL_LINE(TEENSY_PIN7_IOPORT, TEENSY_PIN7)
255#define LINE_PIN8 PAL_LINE(TEENSY_PIN8_IOPORT, TEENSY_PIN8)
256#define LINE_PIN9 PAL_LINE(TEENSY_PIN9_IOPORT, TEENSY_PIN9)
257#define LINE_PIN10 PAL_LINE(TEENSY_PIN10_IOPORT, TEENSY_PIN10)
258#define LINE_PIN11 PAL_LINE(TEENSY_PIN11_IOPORT, TEENSY_PIN11)
259#define LINE_PIN12 PAL_LINE(TEENSY_PIN12_IOPORT, TEENSY_PIN12)
260#define LINE_PIN13 PAL_LINE(TEENSY_PIN13_IOPORT, TEENSY_PIN13)
261#define LINE_PIN14 PAL_LINE(TEENSY_PIN14_IOPORT, TEENSY_PIN14)
262#define LINE_PIN15 PAL_LINE(TEENSY_PIN15_IOPORT, TEENSY_PIN15)
263#define LINE_PIN16 PAL_LINE(TEENSY_PIN16_IOPORT, TEENSY_PIN16)
264#define LINE_PIN17 PAL_LINE(TEENSY_PIN17_IOPORT, TEENSY_PIN17)
265#define LINE_PIN18 PAL_LINE(TEENSY_PIN18_IOPORT, TEENSY_PIN18)
266#define LINE_PIN19 PAL_LINE(TEENSY_PIN19_IOPORT, TEENSY_PIN19)
267#define LINE_PIN20 PAL_LINE(TEENSY_PIN20_IOPORT, TEENSY_PIN20)
268#define LINE_PIN21 PAL_LINE(TEENSY_PIN21_IOPORT, TEENSY_PIN21)
269#define LINE_PIN22 PAL_LINE(TEENSY_PIN22_IOPORT, TEENSY_PIN22)
270#define LINE_PIN23 PAL_LINE(TEENSY_PIN23_IOPORT, TEENSY_PIN23)
271#define LINE_PIN24 PAL_LINE(TEENSY_PIN24_IOPORT, TEENSY_PIN24)
272#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
273#define LINE_PIN25 PAL_LINE(TEENSY_PIN25_IOPORT, TEENSY_PIN25)
274#define LINE_PIN26 PAL_LINE(TEENSY_PIN26_IOPORT, TEENSY_PIN26)
275#define LINE_PIN27 PAL_LINE(TEENSY_PIN27_IOPORT, TEENSY_PIN27)
276#define LINE_PIN28 PAL_LINE(TEENSY_PIN28_IOPORT, TEENSY_PIN28)
277#define LINE_PIN29 PAL_LINE(TEENSY_PIN29_IOPORT, TEENSY_PIN29)
278#define LINE_PIN30 PAL_LINE(TEENSY_PIN30_IOPORT, TEENSY_PIN30)
279#define LINE_PIN31 PAL_LINE(TEENSY_PIN31_IOPORT, TEENSY_PIN31)
280#define LINE_PIN32 PAL_LINE(TEENSY_PIN32_IOPORT, TEENSY_PIN32)
281#define LINE_PIN33 PAL_LINE(TEENSY_PIN33_IOPORT, TEENSY_PIN33)
282
283#define LINE_LED LINE_PIN13
284
285#if !defined(_FROM_ASM_)
286# ifdef __cplusplus
287extern "C" {
288# endif
289void boardInit(void);
290# ifdef __cplusplus
291}
292# endif
293#endif /* _FROM_ASM_ */
294
295#endif /* _BOARD_H_ */
diff --git a/platforms/chibios/boards/IC_TEENSY_3_1/board/board.mk b/platforms/chibios/boards/IC_TEENSY_3_1/board/board.mk
new file mode 100644
index 000000000..842e33590
--- /dev/null
+++ b/platforms/chibios/boards/IC_TEENSY_3_1/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(BOARD_PATH)/board/board.c
3
4# Required include directories
5BOARDINC = $(BOARD_PATH)/board
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/IC_TEENSY_4_1/board/board.mk b/platforms/chibios/boards/IC_TEENSY_4_1/board/board.mk
new file mode 100644
index 000000000..bc242ac3c
--- /dev/null
+++ b/platforms/chibios/boards/IC_TEENSY_4_1/board/board.mk
@@ -0,0 +1 @@
include $(CHIBIOS_CONTRIB)/os/hal/boards/PJRC_TEENSY_4_1/board.mk
diff --git a/platforms/chibios/boards/IC_TEENSY_4_1/rules.mk b/platforms/chibios/boards/IC_TEENSY_4_1/rules.mk
new file mode 100644
index 000000000..0c62d209c
--- /dev/null
+++ b/platforms/chibios/boards/IC_TEENSY_4_1/rules.mk
@@ -0,0 +1 @@
TEENSY_LOADER_CLI_MCU = imxrt1062
diff --git a/platforms/chibios/boards/QMK_PROTON_C/board/board.mk b/platforms/chibios/boards/QMK_PROTON_C/board/board.mk
new file mode 100644
index 000000000..f891e6524
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY/board.c
3
4# Required include directories
5BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F3_DISCOVERY
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/board.h b/platforms/chibios/boards/QMK_PROTON_C/configs/board.h
new file mode 100644
index 000000000..97159964d
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/board.h
@@ -0,0 +1,37 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next "board.h"
19
20#undef STM32_HSE_BYPASS
21
22/*
23 * USB bus activation macro, required by the USB driver.
24 */
25#define usb_lld_connect_bus(usbp) \
26 do { \
27 palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_ALTERNATE(14)); \
28 } while (0)
29
30/*
31 * USB bus de-activation macro, required by the USB driver.
32 */
33#define usb_lld_disconnect_bus(usbp) \
34 do { \
35 palSetPadMode(GPIOA, GPIOA_USB_DP, PAL_MODE_OUTPUT_PUSHPULL); \
36 palClearPad(GPIOA, GPIOA_USB_DP); \
37 } while (0)
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/bootloader_defs.h b/platforms/chibios/boards/QMK_PROTON_C/configs/bootloader_defs.h
new file mode 100644
index 000000000..3b0e9d20a
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/bootloader_defs.h
@@ -0,0 +1,7 @@
1/* Address for jumping to bootloader on STM32 chips. */
2/* It is chip dependent, the correct number can be looked up here:
3 * http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf
4 * This also requires a patch to chibios:
5 * <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
6 */
7#define STM32_BOOTLOADER_ADDRESS 0x1FFFD800
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h b/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h
new file mode 100644
index 000000000..a1cbf6808
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/chconf.h
@@ -0,0 +1,756 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file rt/templates/chconf.h
19 * @brief Configuration file template.
20 * @details A copy of this file must be placed in each project directory, it
21 * contains the application specific kernel settings.
22 *
23 * @addtogroup config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 100000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 2
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM TRUE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY TRUE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT TRUE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS TRUE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES TRUE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY TRUE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC TRUE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES TRUE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP TRUE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS TRUE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS TRUE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES TRUE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES FALSE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES FALSE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS FALSE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY FALSE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES TRUE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES TRUE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS TRUE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES TRUE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK FALSE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS FALSE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS FALSE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK TRUE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS FALSE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748/** @} */
749
750/*===========================================================================*/
751/* Port-specific settings (override port settings defaulted in chcore.h). */
752/*===========================================================================*/
753
754#endif /* CHCONF_H */
755
756/** @} */
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/config.h b/platforms/chibios/boards/QMK_PROTON_C/configs/config.h
new file mode 100644
index 000000000..a73f0c0b4
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/config.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
19# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
20#endif
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h b/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h
new file mode 100644
index 000000000..d7a639a6d
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/halconf.h
@@ -0,0 +1,531 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include <mcuconf.h>
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC FALSE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC TRUE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT TRUE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C TRUE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU FALSE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM TRUE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL FALSE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB TRUE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI TRUE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART FALSE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB TRUE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS TRUE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT TRUE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 128
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 1
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT TRUE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#endif /* HALCONF_H */
530
531/** @} */
diff --git a/platforms/chibios/boards/QMK_PROTON_C/configs/mcuconf.h b/platforms/chibios/boards/QMK_PROTON_C/configs/mcuconf.h
new file mode 100644
index 000000000..4d7b586c0
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/configs/mcuconf.h
@@ -0,0 +1,273 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef MCUCONF_H
18#define MCUCONF_H
19
20/*
21 * STM32F3xx drivers configuration.
22 * The following settings override the default settings present in
23 * the various device driver implementation headers.
24 * Note that the settings for each driver only have effect if the whole
25 * driver is enabled in halconf.h.
26 *
27 * IRQ priorities:
28 * 15...0 Lowest...Highest.
29 *
30 * DMA priorities:
31 * 0...3 Lowest...Highest.
32 */
33
34#define STM32F3xx_MCUCONF
35#define STM32F303_MCUCONF
36
37/*
38 * HAL driver system settings.
39 */
40#define STM32_NO_INIT FALSE
41#define STM32_PVD_ENABLE FALSE
42#define STM32_PLS STM32_PLS_LEV0
43#define STM32_HSI_ENABLED TRUE
44#define STM32_LSI_ENABLED TRUE
45#define STM32_HSE_ENABLED TRUE
46#define STM32_LSE_ENABLED FALSE
47#define STM32_SW STM32_SW_PLL
48#define STM32_PLLSRC STM32_PLLSRC_HSE
49#define STM32_PREDIV_VALUE 1
50#define STM32_PLLMUL_VALUE 9
51#define STM32_HPRE STM32_HPRE_DIV1
52#define STM32_PPRE1 STM32_PPRE1_DIV2
53#define STM32_PPRE2 STM32_PPRE2_DIV2
54#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
55#define STM32_ADC12PRES STM32_ADC12PRES_DIV1
56#define STM32_ADC34PRES STM32_ADC34PRES_DIV1
57#define STM32_USART1SW STM32_USART1SW_PCLK
58#define STM32_USART2SW STM32_USART2SW_PCLK
59#define STM32_USART3SW STM32_USART3SW_PCLK
60#define STM32_UART4SW STM32_UART4SW_PCLK
61#define STM32_UART5SW STM32_UART5SW_PCLK
62#define STM32_I2C1SW STM32_I2C1SW_SYSCLK
63#define STM32_I2C2SW STM32_I2C2SW_SYSCLK
64#define STM32_TIM1SW STM32_TIM1SW_PCLK2
65#define STM32_TIM8SW STM32_TIM8SW_PCLK2
66#define STM32_RTCSEL STM32_RTCSEL_LSI
67#define STM32_USB_CLOCK_REQUIRED TRUE
68#define STM32_USBPRE STM32_USBPRE_DIV1P5
69
70/*
71 * IRQ system settings.
72 */
73#define STM32_IRQ_EXTI0_PRIORITY 6
74#define STM32_IRQ_EXTI1_PRIORITY 6
75#define STM32_IRQ_EXTI2_PRIORITY 6
76#define STM32_IRQ_EXTI3_PRIORITY 6
77#define STM32_IRQ_EXTI4_PRIORITY 6
78#define STM32_IRQ_EXTI5_9_PRIORITY 6
79#define STM32_IRQ_EXTI10_15_PRIORITY 6
80#define STM32_IRQ_EXTI16_PRIORITY 6
81#define STM32_IRQ_EXTI17_PRIORITY 15
82#define STM32_IRQ_EXTI18_PRIORITY 6
83#define STM32_IRQ_EXTI19_PRIORITY 15
84#define STM32_IRQ_EXTI20_PRIORITY 15
85#define STM32_IRQ_EXTI21_22_29_PRIORITY 6
86#define STM32_IRQ_EXTI30_32_PRIORITY 6
87#define STM32_IRQ_EXTI33_PRIORITY 6
88#define STM32_IRQ_TIM1_BRK_TIM15_PRIORITY 7
89#define STM32_IRQ_TIM1_UP_TIM16_PRIORITY 7
90#define STM32_IRQ_TIM1_TRGCO_TIM17_PRIORITY 7
91#define STM32_IRQ_TIM1_CC_PRIORITY 7
92
93/*
94 * ADC driver system settings.
95 */
96#define STM32_ADC_DUAL_MODE FALSE
97#define STM32_ADC_COMPACT_SAMPLES FALSE
98#define STM32_ADC_USE_ADC1 FALSE
99#define STM32_ADC_USE_ADC2 FALSE
100#define STM32_ADC_USE_ADC3 FALSE
101#define STM32_ADC_USE_ADC4 FALSE
102#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(1, 1)
103#define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 1)
104#define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 5)
105#define STM32_ADC_ADC4_DMA_STREAM STM32_DMA_STREAM_ID(2, 2)
106#define STM32_ADC_ADC1_DMA_PRIORITY 2
107#define STM32_ADC_ADC2_DMA_PRIORITY 2
108#define STM32_ADC_ADC3_DMA_PRIORITY 2
109#define STM32_ADC_ADC4_DMA_PRIORITY 2
110#define STM32_ADC_ADC12_IRQ_PRIORITY 5
111#define STM32_ADC_ADC3_IRQ_PRIORITY 5
112#define STM32_ADC_ADC4_IRQ_PRIORITY 5
113#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5
114#define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5
115#define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5
116#define STM32_ADC_ADC4_DMA_IRQ_PRIORITY 5
117#define STM32_ADC_ADC12_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
118#define STM32_ADC_ADC34_CLOCK_MODE ADC_CCR_CKMODE_AHB_DIV1
119
120/*
121 * CAN driver system settings.
122 */
123#define STM32_CAN_USE_CAN1 FALSE
124#define STM32_CAN_CAN1_IRQ_PRIORITY 11
125
126/*
127 * DAC driver system settings.
128 */
129#define STM32_DAC_DUAL_MODE FALSE
130#define STM32_DAC_USE_DAC1_CH1 TRUE
131#define STM32_DAC_USE_DAC1_CH2 TRUE
132#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 10
133#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 10
134#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2
135#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2
136
137/*
138 * GPT driver system settings.
139 */
140#define STM32_GPT_USE_TIM1 FALSE
141#define STM32_GPT_USE_TIM2 FALSE
142#define STM32_GPT_USE_TIM3 FALSE
143#define STM32_GPT_USE_TIM4 FALSE
144#define STM32_GPT_USE_TIM6 TRUE
145#define STM32_GPT_USE_TIM7 TRUE
146#define STM32_GPT_USE_TIM8 TRUE
147#define STM32_GPT_USE_TIM15 TRUE
148#define STM32_GPT_USE_TIM16 FALSE
149#define STM32_GPT_USE_TIM17 FALSE
150#define STM32_GPT_TIM1_IRQ_PRIORITY 7
151#define STM32_GPT_TIM2_IRQ_PRIORITY 7
152#define STM32_GPT_TIM3_IRQ_PRIORITY 7
153#define STM32_GPT_TIM4_IRQ_PRIORITY 7
154#define STM32_GPT_TIM6_IRQ_PRIORITY 7
155#define STM32_GPT_TIM7_IRQ_PRIORITY 7
156#define STM32_GPT_TIM8_IRQ_PRIORITY 7
157
158/*
159 * I2C driver system settings.
160 */
161#define STM32_I2C_USE_I2C1 TRUE
162#define STM32_I2C_USE_I2C2 FALSE
163#define STM32_I2C_BUSY_TIMEOUT 50
164#define STM32_I2C_I2C1_IRQ_PRIORITY 10
165#define STM32_I2C_I2C2_IRQ_PRIORITY 10
166#define STM32_I2C_USE_DMA TRUE
167#define STM32_I2C_I2C1_DMA_PRIORITY 1
168#define STM32_I2C_I2C2_DMA_PRIORITY 1
169#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
170
171/*
172 * ICU driver system settings.
173 */
174#define STM32_ICU_USE_TIM1 FALSE
175#define STM32_ICU_USE_TIM2 FALSE
176#define STM32_ICU_USE_TIM3 FALSE
177#define STM32_ICU_USE_TIM4 FALSE
178#define STM32_ICU_USE_TIM8 FALSE
179#define STM32_ICU_USE_TIM15 FALSE
180#define STM32_ICU_TIM1_IRQ_PRIORITY 7
181#define STM32_ICU_TIM2_IRQ_PRIORITY 7
182#define STM32_ICU_TIM3_IRQ_PRIORITY 7
183#define STM32_ICU_TIM4_IRQ_PRIORITY 7
184#define STM32_ICU_TIM8_IRQ_PRIORITY 7
185
186/*
187 * PWM driver system settings.
188 */
189#define STM32_PWM_USE_ADVANCED FALSE
190#define STM32_PWM_USE_TIM1 FALSE
191#define STM32_PWM_USE_TIM2 FALSE
192#define STM32_PWM_USE_TIM3 TRUE
193#define STM32_PWM_USE_TIM4 TRUE
194#define STM32_PWM_USE_TIM8 FALSE
195#define STM32_PWM_USE_TIM15 FALSE
196#define STM32_PWM_USE_TIM16 FALSE
197#define STM32_PWM_USE_TIM17 FALSE
198#define STM32_PWM_TIM1_IRQ_PRIORITY 7
199#define STM32_PWM_TIM2_IRQ_PRIORITY 7
200#define STM32_PWM_TIM3_IRQ_PRIORITY 7
201#define STM32_PWM_TIM4_IRQ_PRIORITY 7
202#define STM32_PWM_TIM8_IRQ_PRIORITY 7
203
204/*
205 * RTC driver system settings.
206 */
207#define STM32_RTC_PRESA_VALUE 32
208#define STM32_RTC_PRESS_VALUE 1024
209#define STM32_RTC_CR_INIT 0
210#define STM32_RTC_TAMPCR_INIT 0
211
212/*
213 * SERIAL driver system settings.
214 */
215#define STM32_SERIAL_USE_USART1 TRUE
216#define STM32_SERIAL_USE_USART2 FALSE
217#define STM32_SERIAL_USE_USART3 FALSE
218#define STM32_SERIAL_USE_UART4 FALSE
219#define STM32_SERIAL_USE_UART5 FALSE
220#define STM32_SERIAL_USART1_PRIORITY 12
221#define STM32_SERIAL_USART2_PRIORITY 12
222#define STM32_SERIAL_USART3_PRIORITY 12
223#define STM32_SERIAL_UART4_PRIORITY 12
224#define STM32_SERIAL_UART5_PRIORITY 12
225
226/*
227 * SPI driver system settings.
228 */
229#define STM32_SPI_USE_SPI1 FALSE
230#define STM32_SPI_USE_SPI2 TRUE
231#define STM32_SPI_USE_SPI3 FALSE
232#define STM32_SPI_SPI1_DMA_PRIORITY 1
233#define STM32_SPI_SPI2_DMA_PRIORITY 1
234#define STM32_SPI_SPI3_DMA_PRIORITY 1
235#define STM32_SPI_SPI1_IRQ_PRIORITY 10
236#define STM32_SPI_SPI2_IRQ_PRIORITY 10
237#define STM32_SPI_SPI3_IRQ_PRIORITY 10
238#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
239
240/*
241 * ST driver system settings.
242 */
243#define STM32_ST_IRQ_PRIORITY 8
244#define STM32_ST_USE_TIMER 2
245
246/*
247 * UART driver system settings.
248 */
249#define STM32_UART_USE_USART1 FALSE
250#define STM32_UART_USE_USART2 FALSE
251#define STM32_UART_USE_USART3 FALSE
252#define STM32_UART_USART1_IRQ_PRIORITY 12
253#define STM32_UART_USART2_IRQ_PRIORITY 12
254#define STM32_UART_USART3_IRQ_PRIORITY 12
255#define STM32_UART_USART1_DMA_PRIORITY 0
256#define STM32_UART_USART2_DMA_PRIORITY 0
257#define STM32_UART_USART3_DMA_PRIORITY 0
258#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
259
260/*
261 * USB driver system settings.
262 */
263#define STM32_USB_USE_USB1 TRUE
264#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
265#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
266#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
267
268/*
269 * WDG driver system settings.
270 */
271#define STM32_WDG_USE_IWDG FALSE
272
273#endif /* MCUCONF_H */
diff --git a/platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk b/platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk
new file mode 100644
index 000000000..061815467
--- /dev/null
+++ b/platforms/chibios/boards/QMK_PROTON_C/convert_to_proton_c.mk
@@ -0,0 +1,10 @@
1# Proton C MCU settings for converting AVR projects
2TARGET := $(TARGET)_proton_c
3MCU := STM32F303
4BOARD := QMK_PROTON_C
5BOOTLOADER := stm32-dfu
6OPT_DEFS += -DCONVERT_TO_PROTON_C
7
8# These are defaults based on what has been implemented for ARM boards
9AUDIO_ENABLE ?= yes
10WS2812_DRIVER ?= bitbang
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c
new file mode 100644
index 000000000..8a34e81f2
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.c
@@ -0,0 +1,59 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#include <hal.h>
18
19// Value to place in RTC backup register 10 for persistent bootloader mode
20#define RTC_BOOTLOADER_FLAG 0x424C
21
22/**
23 * @brief PAL setup.
24 * @details Digital I/O ports static configuration as defined in @p board.h.
25 * This variable is used by the HAL when initializing the PAL driver.
26 */
27#if HAL_USE_PAL || defined(__DOXYGEN__)
28const PALConfig pal_default_config =
29{
30 {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH},
31 {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH},
32 {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
33 {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
34 {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
35};
36#endif
37
38__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {}
39
40/*
41 * Early initialization code.
42 * This initialization must be performed just after stack setup and before
43 * any other initialization.
44 */
45void __early_init(void) {
46 enter_bootloader_mode_if_requested();
47
48 stm32_clock_init();
49}
50
51/*
52 * Board-specific initialization code.
53 */
54void boardInit(void) {
55 //JTAG-DP Disabled and SW-DP Enabled
56 AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
57 //Set backup register DR10 to enter bootloader on reset
58 BKP->DR10 = RTC_BOOTLOADER_FLAG;
59}
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.h b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.h
new file mode 100644
index 000000000..09d182d6c
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.h
@@ -0,0 +1,166 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef _BOARD_H_
18#define _BOARD_H_
19
20/*
21 * Setup for a Generic STM32F103 board.
22 */
23
24/*
25 * Board identifier.
26 */
27#define BOARD_STM32_F103_STM32DUINO
28#define BOARD_NAME "GENERIC STM32F103C8T6 board - stm32duino bootloader"
29
30/*
31 * Board frequencies.
32 */
33#define STM32_LSECLK 32768
34#define STM32_HSECLK 8000000
35
36/*
37 * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
38 */
39#define STM32F103xB
40
41/*
42 * IO pins assignments
43 */
44
45/* on-board */
46
47#define GPIOA_LED 8
48#define GPIOD_OSC_IN 0
49#define GPIOD_OSC_OUT 1
50
51/* In case your board has a "USB enable" hardware
52 controlled by a pin, define it here. (It could be just
53 a 1.5k resistor connected to D+ line.)
54*/
55/*
56#define GPIOB_USB_DISC 10
57*/
58
59/*
60 * I/O ports initial setup, this configuration is established soon after reset
61 * in the initialization code.
62 *
63 * The digits have the following meaning:
64 * 0 - Analog input.
65 * 1 - Push Pull output 10MHz.
66 * 2 - Push Pull output 2MHz.
67 * 3 - Push Pull output 50MHz.
68 * 4 - Digital input.
69 * 5 - Open Drain output 10MHz.
70 * 6 - Open Drain output 2MHz.
71 * 7 - Open Drain output 50MHz.
72 * 8 - Digital input with PullUp or PullDown resistor depending on ODR.
73 * 9 - Alternate Push Pull output 10MHz.
74 * A - Alternate Push Pull output 2MHz.
75 * B - Alternate Push Pull output 50MHz.
76 * C - Reserved.
77 * D - Alternate Open Drain output 10MHz.
78 * E - Alternate Open Drain output 2MHz.
79 * F - Alternate Open Drain output 50MHz.
80 * Please refer to the STM32 Reference Manual for details.
81 */
82
83/*
84 * Port A setup.
85 * Everything input with pull-up except:
86 * PA2 - Alternate output (USART2 TX).
87 * PA3 - Normal input (USART2 RX).
88 * PA9 - Alternate output (USART1 TX).
89 * PA10 - Normal input (USART1 RX).
90 */
91#define VAL_GPIOACRL 0x88884B88 /* PA7...PA0 */
92#define VAL_GPIOACRH 0x888884B8 /* PA15...PA8 */
93#define VAL_GPIOAODR 0xFFFFFFFF
94
95/*
96 * Port B setup.
97 * Everything input with pull-up except:
98 * PB10 - Push Pull output (USB switch).
99 */
100#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
101#define VAL_GPIOBCRH 0x88888388 /* PB15...PB8 */
102#define VAL_GPIOBODR 0xFFFFFFFF
103
104/*
105 * Port C setup.
106 * Everything input with pull-up except:
107 * PC13 - Push Pull output (LED).
108 */
109#define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
110#define VAL_GPIOCCRH 0x88388888 /* PC15...PC8 */
111#define VAL_GPIOCODR 0xFFFFFFFF
112
113/*
114 * Port D setup.
115 * Everything input with pull-up except:
116 * PD0 - Normal input (XTAL).
117 * PD1 - Normal input (XTAL).
118 */
119#define VAL_GPIODCRL 0x88888844 /* PD7...PD0 */
120#define VAL_GPIODCRH 0x88888888 /* PD15...PD8 */
121#define VAL_GPIODODR 0xFFFFFFFF
122
123/*
124 * Port E setup.
125 * Everything input with pull-up except:
126 */
127#define VAL_GPIOECRL 0x88888888 /* PE7...PE0 */
128#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
129#define VAL_GPIOEODR 0xFFFFFFFF
130
131/*
132 * USB bus activation macro, required by the USB driver.
133 */
134/* The point is that most of the generic STM32F103* boards
135 have a 1.5k resistor connected on one end to the D+ line
136 and on the other end to some pin. Or even a slightly more
137 complicated "USB enable" circuit, controlled by a pin.
138 That should go here.
139
140 However on some boards (e.g. one that I have), there's no
141 such hardware. In which case it's better to not do anything.
142*/
143/*
144#define usb_lld_connect_bus(usbp) palClearPad(GPIOB, GPIOB_USB_DISC)
145*/
146#define usb_lld_connect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_INPUT);
147
148/*
149 * USB bus de-activation macro, required by the USB driver.
150 */
151/*
152#define usb_lld_disconnect_bus(usbp) palSetPad(GPIOB, GPIOB_USB_DISC)
153*/
154#define usb_lld_disconnect_bus(usbp) palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 12);
155
156#if !defined(_FROM_ASM_)
157#ifdef __cplusplus
158extern "C" {
159#endif
160 void boardInit(void);
161#ifdef __cplusplus
162}
163#endif
164#endif /* _FROM_ASM_ */
165
166#endif /* _BOARD_H_ */
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.mk b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.mk
new file mode 100644
index 000000000..842e33590
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/board/board.mk
@@ -0,0 +1,9 @@
1# List of all the board related files.
2BOARDSRC = $(BOARD_PATH)/board/board.c
3
4# Required include directories
5BOARDINC = $(BOARD_PATH)/board
6
7# Shared variables
8ALLCSRC += $(BOARDSRC)
9ALLINC += $(BOARDINC)
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/configs/mcuconf.h b/platforms/chibios/boards/STM32_F103_STM32DUINO/configs/mcuconf.h
new file mode 100644
index 000000000..9945e7408
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/configs/mcuconf.h
@@ -0,0 +1,209 @@
1/*
2 ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#ifndef _MCUCONF_H_
18#define _MCUCONF_H_
19
20#define STM32F103_MCUCONF
21
22/*
23 * STM32F103 drivers configuration.
24 * The following settings override the default settings present in
25 * the various device driver implementation headers.
26 * Note that the settings for each driver only have effect if the whole
27 * driver is enabled in halconf.h.
28 *
29 * IRQ priorities:
30 * 15...0 Lowest...Highest.
31 *
32 * DMA priorities:
33 * 0...3 Lowest...Highest.
34 */
35
36/*
37 * HAL driver system settings.
38 */
39#define STM32_NO_INIT FALSE
40#define STM32_HSI_ENABLED TRUE
41#define STM32_LSI_ENABLED FALSE
42#define STM32_HSE_ENABLED TRUE
43#define STM32_LSE_ENABLED FALSE
44#define STM32_SW STM32_SW_PLL
45#define STM32_PLLSRC STM32_PLLSRC_HSE
46#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1
47#define STM32_PLLMUL_VALUE 9
48#define STM32_HPRE STM32_HPRE_DIV1
49#define STM32_PPRE1 STM32_PPRE1_DIV2
50#define STM32_PPRE2 STM32_PPRE2_DIV2
51#define STM32_ADCPRE STM32_ADCPRE_DIV4
52#define STM32_USB_CLOCK_REQUIRED TRUE
53#define STM32_USBPRE STM32_USBPRE_DIV1P5
54#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK
55#define STM32_RTCSEL STM32_RTCSEL_HSEDIV
56#define STM32_PVD_ENABLE FALSE
57#define STM32_PLS STM32_PLS_LEV0
58
59/*
60 * ADC driver system settings.
61 */
62#define STM32_ADC_USE_ADC1 FALSE
63#define STM32_ADC_ADC1_DMA_PRIORITY 2
64#define STM32_ADC_ADC1_IRQ_PRIORITY 6
65
66/*
67 * CAN driver system settings.
68 */
69#define STM32_CAN_USE_CAN1 FALSE
70#define STM32_CAN_CAN1_IRQ_PRIORITY 11
71
72/*
73 * EXT driver system settings.
74 */
75#define STM32_EXT_EXTI0_IRQ_PRIORITY 6
76#define STM32_EXT_EXTI1_IRQ_PRIORITY 6
77#define STM32_EXT_EXTI2_IRQ_PRIORITY 6
78#define STM32_EXT_EXTI3_IRQ_PRIORITY 6
79#define STM32_EXT_EXTI4_IRQ_PRIORITY 6
80#define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6
81#define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6
82#define STM32_EXT_EXTI16_IRQ_PRIORITY 6
83#define STM32_EXT_EXTI17_IRQ_PRIORITY 6
84#define STM32_EXT_EXTI18_IRQ_PRIORITY 6
85#define STM32_EXT_EXTI19_IRQ_PRIORITY 6
86
87/*
88 * GPT driver system settings.
89 */
90#define STM32_GPT_USE_TIM1 FALSE
91#define STM32_GPT_USE_TIM2 FALSE
92#define STM32_GPT_USE_TIM3 FALSE
93#define STM32_GPT_USE_TIM4 FALSE
94#define STM32_GPT_USE_TIM5 FALSE
95#define STM32_GPT_USE_TIM8 FALSE
96#define STM32_GPT_TIM1_IRQ_PRIORITY 7
97#define STM32_GPT_TIM2_IRQ_PRIORITY 7
98#define STM32_GPT_TIM3_IRQ_PRIORITY 7
99#define STM32_GPT_TIM4_IRQ_PRIORITY 7
100#define STM32_GPT_TIM5_IRQ_PRIORITY 7
101#define STM32_GPT_TIM8_IRQ_PRIORITY 7
102
103/*
104 * I2C driver system settings.
105 */
106#define STM32_I2C_USE_I2C1 FALSE
107#define STM32_I2C_USE_I2C2 FALSE
108#define STM32_I2C_BUSY_TIMEOUT 50
109#define STM32_I2C_I2C1_IRQ_PRIORITY 5
110#define STM32_I2C_I2C2_IRQ_PRIORITY 5
111#define STM32_I2C_I2C1_DMA_PRIORITY 3
112#define STM32_I2C_I2C2_DMA_PRIORITY 3
113#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure")
114
115/*
116 * ICU driver system settings.
117 */
118#define STM32_ICU_USE_TIM1 FALSE
119#define STM32_ICU_USE_TIM2 FALSE
120#define STM32_ICU_USE_TIM3 FALSE
121#define STM32_ICU_USE_TIM4 FALSE
122#define STM32_ICU_USE_TIM5 FALSE
123#define STM32_ICU_USE_TIM8 FALSE
124#define STM32_ICU_TIM1_IRQ_PRIORITY 7
125#define STM32_ICU_TIM2_IRQ_PRIORITY 7
126#define STM32_ICU_TIM3_IRQ_PRIORITY 7
127#define STM32_ICU_TIM4_IRQ_PRIORITY 7
128#define STM32_ICU_TIM5_IRQ_PRIORITY 7
129#define STM32_ICU_TIM8_IRQ_PRIORITY 7
130
131/*
132 * PWM driver system settings.
133 */
134#define STM32_PWM_USE_ADVANCED FALSE
135#define STM32_PWM_USE_TIM1 FALSE
136#define STM32_PWM_USE_TIM2 FALSE
137#define STM32_PWM_USE_TIM3 FALSE
138#define STM32_PWM_USE_TIM4 FALSE
139#define STM32_PWM_USE_TIM5 FALSE
140#define STM32_PWM_USE_TIM8 FALSE
141#define STM32_PWM_TIM1_IRQ_PRIORITY 7
142#define STM32_PWM_TIM2_IRQ_PRIORITY 7
143#define STM32_PWM_TIM3_IRQ_PRIORITY 7
144#define STM32_PWM_TIM4_IRQ_PRIORITY 7
145#define STM32_PWM_TIM5_IRQ_PRIORITY 7
146#define STM32_PWM_TIM8_IRQ_PRIORITY 7
147
148/*
149 * RTC driver system settings.
150 */
151#define STM32_RTC_IRQ_PRIORITY 15
152
153/*
154 * SERIAL driver system settings.
155 */
156#define STM32_SERIAL_USE_USART1 FALSE
157#define STM32_SERIAL_USE_USART2 FALSE
158#define STM32_SERIAL_USE_USART3 FALSE
159#define STM32_SERIAL_USE_UART4 FALSE
160#define STM32_SERIAL_USE_UART5 FALSE
161#define STM32_SERIAL_USART1_PRIORITY 12
162#define STM32_SERIAL_USART2_PRIORITY 12
163#define STM32_SERIAL_USART3_PRIORITY 12
164#define STM32_SERIAL_UART4_PRIORITY 12
165#define STM32_SERIAL_UART5_PRIORITY 12
166
167/*
168 * SPI driver system settings.
169 */
170#define STM32_SPI_USE_SPI1 FALSE
171#define STM32_SPI_USE_SPI2 TRUE
172#define STM32_SPI_USE_SPI3 FALSE
173#define STM32_SPI_SPI1_DMA_PRIORITY 1
174#define STM32_SPI_SPI2_DMA_PRIORITY 1
175#define STM32_SPI_SPI3_DMA_PRIORITY 1
176#define STM32_SPI_SPI1_IRQ_PRIORITY 10
177#define STM32_SPI_SPI2_IRQ_PRIORITY 10
178#define STM32_SPI_SPI3_IRQ_PRIORITY 10
179#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure")
180
181/*
182 * ST driver system settings.
183 */
184#define STM32_ST_IRQ_PRIORITY 8
185#define STM32_ST_USE_TIMER 2
186
187/*
188 * UART driver system settings.
189 */
190#define STM32_UART_USE_USART1 FALSE
191#define STM32_UART_USE_USART2 FALSE
192#define STM32_UART_USE_USART3 FALSE
193#define STM32_UART_USART1_IRQ_PRIORITY 12
194#define STM32_UART_USART2_IRQ_PRIORITY 12
195#define STM32_UART_USART3_IRQ_PRIORITY 12
196#define STM32_UART_USART1_DMA_PRIORITY 0
197#define STM32_UART_USART2_DMA_PRIORITY 0
198#define STM32_UART_USART3_DMA_PRIORITY 0
199#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
200
201/*
202 * USB driver system settings.
203 */
204#define STM32_USB_USE_USB1 TRUE
205#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
206#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
207#define STM32_USB_USB1_LP_IRQ_PRIORITY 14
208
209#endif /* _MCUCONF_H_ */
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld
new file mode 100644
index 000000000..a4bd566b5
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103x8_stm32duino_bootloader.ld
@@ -0,0 +1,22 @@
1/*
2 ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32F103x8 memory setup for use with the STM32Duino bootloader.
19 */
20f103_flash_size = 64k;
21
22INCLUDE stm32duino_bootloader_common.ld
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld
new file mode 100644
index 000000000..dc47400dc
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/STM32F103xB_stm32duino_bootloader.ld
@@ -0,0 +1,22 @@
1/*
2 ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32F103xB memory setup for use with the STM32Duino bootloader.
19 */
20f103_flash_size = 128k;
21
22INCLUDE stm32duino_bootloader_common.ld
diff --git a/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld
new file mode 100644
index 000000000..76cd3153b
--- /dev/null
+++ b/platforms/chibios/boards/STM32_F103_STM32DUINO/ld/stm32duino_bootloader_common.ld
@@ -0,0 +1,85 @@
1/*
2 ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32Duino bootloader common memory setup.
19 */
20MEMORY
21{
22 flash0 : org = 0x08002000, len = f103_flash_size - 0x2000
23 flash1 : org = 0x00000000, len = 0
24 flash2 : org = 0x00000000, len = 0
25 flash3 : org = 0x00000000, len = 0
26 flash4 : org = 0x00000000, len = 0
27 flash5 : org = 0x00000000, len = 0
28 flash6 : org = 0x00000000, len = 0
29 flash7 : org = 0x00000000, len = 0
30 ram0 : org = 0x20000000, len = 20k
31 ram1 : org = 0x00000000, len = 0
32 ram2 : org = 0x00000000, len = 0
33 ram3 : org = 0x00000000, len = 0
34 ram4 : org = 0x00000000, len = 0
35 ram5 : org = 0x00000000, len = 0
36 ram6 : org = 0x00000000, len = 0
37 ram7 : org = 0x00000000, len = 0
38}
39
40/* For each data/text section two region are defined, a virtual region
41 and a load region (_LMA suffix).*/
42
43/* Flash region to be used for exception vectors.*/
44REGION_ALIAS("VECTORS_FLASH", flash0);
45REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
46
47/* Flash region to be used for constructors and destructors.*/
48REGION_ALIAS("XTORS_FLASH", flash0);
49REGION_ALIAS("XTORS_FLASH_LMA", flash0);
50
51/* Flash region to be used for code text.*/
52REGION_ALIAS("TEXT_FLASH", flash0);
53REGION_ALIAS("TEXT_FLASH_LMA", flash0);
54
55/* Flash region to be used for read only data.*/
56REGION_ALIAS("RODATA_FLASH", flash0);
57REGION_ALIAS("RODATA_FLASH_LMA", flash0);
58
59/* Flash region to be used for various.*/
60REGION_ALIAS("VARIOUS_FLASH", flash0);
61REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
62
63/* Flash region to be used for RAM(n) initialization data.*/
64REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
65
66/* RAM region to be used for Main stack. This stack accommodates the processing
67 of all exceptions and interrupts.*/
68REGION_ALIAS("MAIN_STACK_RAM", ram0);
69
70/* RAM region to be used for the process stack. This is the stack used by
71 the main() function.*/
72REGION_ALIAS("PROCESS_STACK_RAM", ram0);
73
74/* RAM region to be used for data segment.*/
75REGION_ALIAS("DATA_RAM", ram0);
76REGION_ALIAS("DATA_RAM_LMA", flash0);
77
78/* RAM region to be used for BSS segment.*/
79REGION_ALIAS("BSS_RAM", ram0);
80
81/* RAM region to be used for the default heap.*/
82REGION_ALIAS("HEAP_RAM", ram0);
83
84/* Generic rules inclusion.*/
85INCLUDE rules.ld
diff --git a/platforms/chibios/boards/common/configs/chconf.h b/platforms/chibios/boards/common/configs/chconf.h
new file mode 100644
index 000000000..44327a82d
--- /dev/null
+++ b/platforms/chibios/boards/common/configs/chconf.h
@@ -0,0 +1,756 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file rt/templates/chconf.h
19 * @brief Configuration file template.
20 * @details A copy of this file must be placed in each project directory, it
21 * contains the application specific kernel settings.
22 *
23 * @addtogroup config
24 * @details Kernel related settings and hooks.
25 * @{
26 */
27
28#ifndef CHCONF_H
29#define CHCONF_H
30
31#define _CHIBIOS_RT_CONF_
32#define _CHIBIOS_RT_CONF_VER_6_1_
33
34/*===========================================================================*/
35/**
36 * @name System timers settings
37 * @{
38 */
39/*===========================================================================*/
40
41/**
42 * @brief System time counter resolution.
43 * @note Allowed values are 16 or 32 bits.
44 */
45#if !defined(CH_CFG_ST_RESOLUTION)
46#define CH_CFG_ST_RESOLUTION 32
47#endif
48
49/**
50 * @brief System tick frequency.
51 * @details Frequency of the system timer that drives the system ticks. This
52 * setting also defines the system tick time unit.
53 */
54#if !defined(CH_CFG_ST_FREQUENCY)
55#define CH_CFG_ST_FREQUENCY 100000
56#endif
57
58/**
59 * @brief Time intervals data size.
60 * @note Allowed values are 16, 32 or 64 bits.
61 */
62#if !defined(CH_CFG_INTERVALS_SIZE)
63#define CH_CFG_INTERVALS_SIZE 32
64#endif
65
66/**
67 * @brief Time types data size.
68 * @note Allowed values are 16 or 32 bits.
69 */
70#if !defined(CH_CFG_TIME_TYPES_SIZE)
71#define CH_CFG_TIME_TYPES_SIZE 32
72#endif
73
74/**
75 * @brief Time delta constant for the tick-less mode.
76 * @note If this value is zero then the system uses the classic
77 * periodic tick. This value represents the minimum number
78 * of ticks that is safe to specify in a timeout directive.
79 * The value one is not valid, timeouts are rounded up to
80 * this value.
81 */
82#if !defined(CH_CFG_ST_TIMEDELTA)
83#define CH_CFG_ST_TIMEDELTA 2
84#endif
85
86/** @} */
87
88/*===========================================================================*/
89/**
90 * @name Kernel parameters and options
91 * @{
92 */
93/*===========================================================================*/
94
95/**
96 * @brief Round robin interval.
97 * @details This constant is the number of system ticks allowed for the
98 * threads before preemption occurs. Setting this value to zero
99 * disables the preemption for threads with equal priority and the
100 * round robin becomes cooperative. Note that higher priority
101 * threads can still preempt, the kernel is always preemptive.
102 * @note Disabling the round robin preemption makes the kernel more compact
103 * and generally faster.
104 * @note The round robin preemption is not supported in tickless mode and
105 * must be set to zero in that case.
106 */
107#if !defined(CH_CFG_TIME_QUANTUM)
108#define CH_CFG_TIME_QUANTUM 0
109#endif
110
111/**
112 * @brief Idle thread automatic spawn suppression.
113 * @details When this option is activated the function @p chSysInit()
114 * does not spawn the idle thread. The application @p main()
115 * function becomes the idle thread and must implement an
116 * infinite loop.
117 */
118#if !defined(CH_CFG_NO_IDLE_THREAD)
119#define CH_CFG_NO_IDLE_THREAD FALSE
120#endif
121
122/** @} */
123
124/*===========================================================================*/
125/**
126 * @name Performance options
127 * @{
128 */
129/*===========================================================================*/
130
131/**
132 * @brief OS optimization.
133 * @details If enabled then time efficient rather than space efficient code
134 * is used when two possible implementations exist.
135 *
136 * @note This is not related to the compiler optimization options.
137 * @note The default is @p TRUE.
138 */
139#if !defined(CH_CFG_OPTIMIZE_SPEED)
140#define CH_CFG_OPTIMIZE_SPEED TRUE
141#endif
142
143/** @} */
144
145/*===========================================================================*/
146/**
147 * @name Subsystem options
148 * @{
149 */
150/*===========================================================================*/
151
152/**
153 * @brief Time Measurement APIs.
154 * @details If enabled then the time measurement APIs are included in
155 * the kernel.
156 *
157 * @note The default is @p TRUE.
158 */
159#if !defined(CH_CFG_USE_TM)
160#define CH_CFG_USE_TM FALSE
161#endif
162
163/**
164 * @brief Threads registry APIs.
165 * @details If enabled then the registry APIs are included in the kernel.
166 *
167 * @note The default is @p TRUE.
168 */
169#if !defined(CH_CFG_USE_REGISTRY)
170#define CH_CFG_USE_REGISTRY FALSE
171#endif
172
173/**
174 * @brief Threads synchronization APIs.
175 * @details If enabled then the @p chThdWait() function is included in
176 * the kernel.
177 *
178 * @note The default is @p TRUE.
179 */
180#if !defined(CH_CFG_USE_WAITEXIT)
181#define CH_CFG_USE_WAITEXIT FALSE
182#endif
183
184/**
185 * @brief Semaphores APIs.
186 * @details If enabled then the Semaphores APIs are included in the kernel.
187 *
188 * @note The default is @p TRUE.
189 */
190#if !defined(CH_CFG_USE_SEMAPHORES)
191#define CH_CFG_USE_SEMAPHORES TRUE
192#endif
193
194/**
195 * @brief Semaphores queuing mode.
196 * @details If enabled then the threads are enqueued on semaphores by
197 * priority rather than in FIFO order.
198 *
199 * @note The default is @p FALSE. Enable this if you have special
200 * requirements.
201 * @note Requires @p CH_CFG_USE_SEMAPHORES.
202 */
203#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY)
204#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
205#endif
206
207/**
208 * @brief Mutexes APIs.
209 * @details If enabled then the mutexes APIs are included in the kernel.
210 *
211 * @note The default is @p TRUE.
212 */
213#if !defined(CH_CFG_USE_MUTEXES)
214#define CH_CFG_USE_MUTEXES TRUE
215#endif
216
217/**
218 * @brief Enables recursive behavior on mutexes.
219 * @note Recursive mutexes are heavier and have an increased
220 * memory footprint.
221 *
222 * @note The default is @p FALSE.
223 * @note Requires @p CH_CFG_USE_MUTEXES.
224 */
225#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE)
226#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE
227#endif
228
229/**
230 * @brief Conditional Variables APIs.
231 * @details If enabled then the conditional variables APIs are included
232 * in the kernel.
233 *
234 * @note The default is @p TRUE.
235 * @note Requires @p CH_CFG_USE_MUTEXES.
236 */
237#if !defined(CH_CFG_USE_CONDVARS)
238#define CH_CFG_USE_CONDVARS FALSE
239#endif
240
241/**
242 * @brief Conditional Variables APIs with timeout.
243 * @details If enabled then the conditional variables APIs with timeout
244 * specification are included in the kernel.
245 *
246 * @note The default is @p TRUE.
247 * @note Requires @p CH_CFG_USE_CONDVARS.
248 */
249#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT)
250#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE
251#endif
252
253/**
254 * @brief Events Flags APIs.
255 * @details If enabled then the event flags APIs are included in the kernel.
256 *
257 * @note The default is @p TRUE.
258 */
259#if !defined(CH_CFG_USE_EVENTS)
260#define CH_CFG_USE_EVENTS TRUE
261#endif
262
263/**
264 * @brief Events Flags APIs with timeout.
265 * @details If enabled then the events APIs with timeout specification
266 * are included in the kernel.
267 *
268 * @note The default is @p TRUE.
269 * @note Requires @p CH_CFG_USE_EVENTS.
270 */
271#if !defined(CH_CFG_USE_EVENTS_TIMEOUT)
272#define CH_CFG_USE_EVENTS_TIMEOUT TRUE
273#endif
274
275/**
276 * @brief Synchronous Messages APIs.
277 * @details If enabled then the synchronous messages APIs are included
278 * in the kernel.
279 *
280 * @note The default is @p TRUE.
281 */
282#if !defined(CH_CFG_USE_MESSAGES)
283#define CH_CFG_USE_MESSAGES FALSE
284#endif
285
286/**
287 * @brief Synchronous Messages queuing mode.
288 * @details If enabled then messages are served by priority rather than in
289 * FIFO order.
290 *
291 * @note The default is @p FALSE. Enable this if you have special
292 * requirements.
293 * @note Requires @p CH_CFG_USE_MESSAGES.
294 */
295#if !defined(CH_CFG_USE_MESSAGES_PRIORITY)
296#define CH_CFG_USE_MESSAGES_PRIORITY FALSE
297#endif
298
299/**
300 * @brief Dynamic Threads APIs.
301 * @details If enabled then the dynamic threads creation APIs are included
302 * in the kernel.
303 *
304 * @note The default is @p TRUE.
305 * @note Requires @p CH_CFG_USE_WAITEXIT.
306 * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
307 */
308#if !defined(CH_CFG_USE_DYNAMIC)
309#define CH_CFG_USE_DYNAMIC FALSE
310#endif
311
312/** @} */
313
314/*===========================================================================*/
315/**
316 * @name OSLIB options
317 * @{
318 */
319/*===========================================================================*/
320
321/**
322 * @brief Mailboxes APIs.
323 * @details If enabled then the asynchronous messages (mailboxes) APIs are
324 * included in the kernel.
325 *
326 * @note The default is @p TRUE.
327 * @note Requires @p CH_CFG_USE_SEMAPHORES.
328 */
329#if !defined(CH_CFG_USE_MAILBOXES)
330#define CH_CFG_USE_MAILBOXES FALSE
331#endif
332
333/**
334 * @brief Core Memory Manager APIs.
335 * @details If enabled then the core memory manager APIs are included
336 * in the kernel.
337 *
338 * @note The default is @p TRUE.
339 */
340#if !defined(CH_CFG_USE_MEMCORE)
341#define CH_CFG_USE_MEMCORE TRUE
342#endif
343
344/**
345 * @brief Managed RAM size.
346 * @details Size of the RAM area to be managed by the OS. If set to zero
347 * then the whole available RAM is used. The core memory is made
348 * available to the heap allocator and/or can be used directly through
349 * the simplified core memory allocator.
350 *
351 * @note In order to let the OS manage the whole RAM the linker script must
352 * provide the @p __heap_base__ and @p __heap_end__ symbols.
353 * @note Requires @p CH_CFG_USE_MEMCORE.
354 */
355#if !defined(CH_CFG_MEMCORE_SIZE)
356#define CH_CFG_MEMCORE_SIZE 0
357#endif
358
359/**
360 * @brief Heap Allocator APIs.
361 * @details If enabled then the memory heap allocator APIs are included
362 * in the kernel.
363 *
364 * @note The default is @p TRUE.
365 * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
366 * @p CH_CFG_USE_SEMAPHORES.
367 * @note Mutexes are recommended.
368 */
369#if !defined(CH_CFG_USE_HEAP)
370#define CH_CFG_USE_HEAP FALSE
371#endif
372
373/**
374 * @brief Memory Pools Allocator APIs.
375 * @details If enabled then the memory pools allocator APIs are included
376 * in the kernel.
377 *
378 * @note The default is @p TRUE.
379 */
380#if !defined(CH_CFG_USE_MEMPOOLS)
381#define CH_CFG_USE_MEMPOOLS FALSE
382#endif
383
384/**
385 * @brief Objects FIFOs APIs.
386 * @details If enabled then the objects FIFOs APIs are included
387 * in the kernel.
388 *
389 * @note The default is @p TRUE.
390 */
391#if !defined(CH_CFG_USE_OBJ_FIFOS)
392#define CH_CFG_USE_OBJ_FIFOS FALSE
393#endif
394
395/**
396 * @brief Pipes APIs.
397 * @details If enabled then the pipes APIs are included
398 * in the kernel.
399 *
400 * @note The default is @p TRUE.
401 */
402#if !defined(CH_CFG_USE_PIPES)
403#define CH_CFG_USE_PIPES FALSE
404#endif
405
406/**
407 * @brief Objects Caches APIs.
408 * @details If enabled then the objects caches APIs are included
409 * in the kernel.
410 *
411 * @note The default is @p TRUE.
412 */
413#if !defined(CH_CFG_USE_OBJ_CACHES)
414#define CH_CFG_USE_OBJ_CACHES FALSE
415#endif
416
417/**
418 * @brief Delegate threads APIs.
419 * @details If enabled then the delegate threads APIs are included
420 * in the kernel.
421 *
422 * @note The default is @p TRUE.
423 */
424#if !defined(CH_CFG_USE_DELEGATES)
425#define CH_CFG_USE_DELEGATES FALSE
426#endif
427
428/**
429 * @brief Jobs Queues APIs.
430 * @details If enabled then the jobs queues APIs are included
431 * in the kernel.
432 *
433 * @note The default is @p TRUE.
434 */
435#if !defined(CH_CFG_USE_JOBS)
436#define CH_CFG_USE_JOBS FALSE
437#endif
438
439/** @} */
440
441/*===========================================================================*/
442/**
443 * @name Objects factory options
444 * @{
445 */
446/*===========================================================================*/
447
448/**
449 * @brief Objects Factory APIs.
450 * @details If enabled then the objects factory APIs are included in the
451 * kernel.
452 *
453 * @note The default is @p FALSE.
454 */
455#if !defined(CH_CFG_USE_FACTORY)
456#define CH_CFG_USE_FACTORY FALSE
457#endif
458
459/**
460 * @brief Maximum length for object names.
461 * @details If the specified length is zero then the name is stored by
462 * pointer but this could have unintended side effects.
463 */
464#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH)
465#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
466#endif
467
468/**
469 * @brief Enables the registry of generic objects.
470 */
471#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY)
472#define CH_CFG_FACTORY_OBJECTS_REGISTRY FALSE
473#endif
474
475/**
476 * @brief Enables factory for generic buffers.
477 */
478#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS)
479#define CH_CFG_FACTORY_GENERIC_BUFFERS FALSE
480#endif
481
482/**
483 * @brief Enables factory for semaphores.
484 */
485#if !defined(CH_CFG_FACTORY_SEMAPHORES)
486#define CH_CFG_FACTORY_SEMAPHORES FALSE
487#endif
488
489/**
490 * @brief Enables factory for mailboxes.
491 */
492#if !defined(CH_CFG_FACTORY_MAILBOXES)
493#define CH_CFG_FACTORY_MAILBOXES FALSE
494#endif
495
496/**
497 * @brief Enables factory for objects FIFOs.
498 */
499#if !defined(CH_CFG_FACTORY_OBJ_FIFOS)
500#define CH_CFG_FACTORY_OBJ_FIFOS FALSE
501#endif
502
503/**
504 * @brief Enables factory for Pipes.
505 */
506#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
507#define CH_CFG_FACTORY_PIPES FALSE
508#endif
509
510/** @} */
511
512/*===========================================================================*/
513/**
514 * @name Debug options
515 * @{
516 */
517/*===========================================================================*/
518
519/**
520 * @brief Debug option, kernel statistics.
521 *
522 * @note The default is @p FALSE.
523 */
524#if !defined(CH_DBG_STATISTICS)
525#define CH_DBG_STATISTICS FALSE
526#endif
527
528/**
529 * @brief Debug option, system state check.
530 * @details If enabled the correct call protocol for system APIs is checked
531 * at runtime.
532 *
533 * @note The default is @p FALSE.
534 */
535#if !defined(CH_DBG_SYSTEM_STATE_CHECK)
536#define CH_DBG_SYSTEM_STATE_CHECK FALSE
537#endif
538
539/**
540 * @brief Debug option, parameters checks.
541 * @details If enabled then the checks on the API functions input
542 * parameters are activated.
543 *
544 * @note The default is @p FALSE.
545 */
546#if !defined(CH_DBG_ENABLE_CHECKS)
547#define CH_DBG_ENABLE_CHECKS FALSE
548#endif
549
550/**
551 * @brief Debug option, consistency checks.
552 * @details If enabled then all the assertions in the kernel code are
553 * activated. This includes consistency checks inside the kernel,
554 * runtime anomalies and port-defined checks.
555 *
556 * @note The default is @p FALSE.
557 */
558#if !defined(CH_DBG_ENABLE_ASSERTS)
559#define CH_DBG_ENABLE_ASSERTS FALSE
560#endif
561
562/**
563 * @brief Debug option, trace buffer.
564 * @details If enabled then the trace buffer is activated.
565 *
566 * @note The default is @p CH_DBG_TRACE_MASK_DISABLED.
567 */
568#if !defined(CH_DBG_TRACE_MASK)
569#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED
570#endif
571
572/**
573 * @brief Trace buffer entries.
574 * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
575 * different from @p CH_DBG_TRACE_MASK_DISABLED.
576 */
577#if !defined(CH_DBG_TRACE_BUFFER_SIZE)
578#define CH_DBG_TRACE_BUFFER_SIZE 128
579#endif
580
581/**
582 * @brief Debug option, stack checks.
583 * @details If enabled then a runtime stack check is performed.
584 *
585 * @note The default is @p FALSE.
586 * @note The stack check is performed in a architecture/port dependent way.
587 * It may not be implemented or some ports.
588 * @note The default failure mode is to halt the system with the global
589 * @p panic_msg variable set to @p NULL.
590 */
591#if !defined(CH_DBG_ENABLE_STACK_CHECK)
592#define CH_DBG_ENABLE_STACK_CHECK FALSE
593#endif
594
595/**
596 * @brief Debug option, stacks initialization.
597 * @details If enabled then the threads working area is filled with a byte
598 * value when a thread is created. This can be useful for the
599 * runtime measurement of the used stack.
600 *
601 * @note The default is @p FALSE.
602 */
603#if !defined(CH_DBG_FILL_THREADS)
604#define CH_DBG_FILL_THREADS FALSE
605#endif
606
607/**
608 * @brief Debug option, threads profiling.
609 * @details If enabled then a field is added to the @p thread_t structure that
610 * counts the system ticks occurred while executing the thread.
611 *
612 * @note The default is @p FALSE.
613 * @note This debug option is not currently compatible with the
614 * tickless mode.
615 */
616#if !defined(CH_DBG_THREADS_PROFILING)
617#define CH_DBG_THREADS_PROFILING FALSE
618#endif
619
620/** @} */
621
622/*===========================================================================*/
623/**
624 * @name Kernel hooks
625 * @{
626 */
627/*===========================================================================*/
628
629/**
630 * @brief System structure extension.
631 * @details User fields added to the end of the @p ch_system_t structure.
632 */
633#define CH_CFG_SYSTEM_EXTRA_FIELDS \
634 /* Add threads custom fields here.*/
635
636/**
637 * @brief System initialization hook.
638 * @details User initialization code added to the @p chSysInit() function
639 * just before interrupts are enabled globally.
640 */
641#define CH_CFG_SYSTEM_INIT_HOOK() { \
642 /* Add threads initialization code here.*/ \
643}
644
645/**
646 * @brief Threads descriptor structure extension.
647 * @details User fields added to the end of the @p thread_t structure.
648 */
649#define CH_CFG_THREAD_EXTRA_FIELDS \
650 /* Add threads custom fields here.*/
651
652/**
653 * @brief Threads initialization hook.
654 * @details User initialization code added to the @p _thread_init() function.
655 *
656 * @note It is invoked from within @p _thread_init() and implicitly from all
657 * the threads creation APIs.
658 */
659#define CH_CFG_THREAD_INIT_HOOK(tp) { \
660 /* Add threads initialization code here.*/ \
661}
662
663/**
664 * @brief Threads finalization hook.
665 * @details User finalization code added to the @p chThdExit() API.
666 */
667#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
668 /* Add threads finalization code here.*/ \
669}
670
671/**
672 * @brief Context switch hook.
673 * @details This hook is invoked just before switching between threads.
674 */
675#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
676 /* Context switch code here.*/ \
677}
678
679/**
680 * @brief ISR enter hook.
681 */
682#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
683 /* IRQ prologue code here.*/ \
684}
685
686/**
687 * @brief ISR exit hook.
688 */
689#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
690 /* IRQ epilogue code here.*/ \
691}
692
693/**
694 * @brief Idle thread enter hook.
695 * @note This hook is invoked within a critical zone, no OS functions
696 * should be invoked from here.
697 * @note This macro can be used to activate a power saving mode.
698 */
699#define CH_CFG_IDLE_ENTER_HOOK() { \
700 /* Idle-enter code here.*/ \
701}
702
703/**
704 * @brief Idle thread leave hook.
705 * @note This hook is invoked within a critical zone, no OS functions
706 * should be invoked from here.
707 * @note This macro can be used to deactivate a power saving mode.
708 */
709#define CH_CFG_IDLE_LEAVE_HOOK() { \
710 /* Idle-leave code here.*/ \
711}
712
713/**
714 * @brief Idle Loop hook.
715 * @details This hook is continuously invoked by the idle thread loop.
716 */
717#define CH_CFG_IDLE_LOOP_HOOK() { \
718 /* Idle loop code here.*/ \
719}
720
721/**
722 * @brief System tick event hook.
723 * @details This hook is invoked in the system tick handler immediately
724 * after processing the virtual timers queue.
725 */
726#define CH_CFG_SYSTEM_TICK_HOOK() { \
727 /* System tick event code here.*/ \
728}
729
730/**
731 * @brief System halt hook.
732 * @details This hook is invoked in case to a system halting error before
733 * the system is halted.
734 */
735#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
736 /* System halt code here.*/ \
737}
738
739/**
740 * @brief Trace hook.
741 * @details This hook is invoked each time a new record is written in the
742 * trace buffer.
743 */
744#define CH_CFG_TRACE_HOOK(tep) { \
745 /* Trace code here.*/ \
746}
747
748/** @} */
749
750/*===========================================================================*/
751/* Port-specific settings (override port settings defaulted in chcore.h). */
752/*===========================================================================*/
753
754#endif /* CHCONF_H */
755
756/** @} */
diff --git a/platforms/chibios/boards/common/configs/halconf.h b/platforms/chibios/boards/common/configs/halconf.h
new file mode 100644
index 000000000..c80f67ee2
--- /dev/null
+++ b/platforms/chibios/boards/common/configs/halconf.h
@@ -0,0 +1,531 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file templates/halconf.h
19 * @brief HAL configuration header.
20 * @details HAL configuration file, this file allows to enable or disable the
21 * various device drivers from your application. You may also use
22 * this file in order to override the device drivers default settings.
23 *
24 * @addtogroup HAL_CONF
25 * @{
26 */
27
28#ifndef HALCONF_H
29#define HALCONF_H
30
31#define _CHIBIOS_HAL_CONF_
32#define _CHIBIOS_HAL_CONF_VER_7_1_
33
34#include <mcuconf.h>
35
36/**
37 * @brief Enables the PAL subsystem.
38 */
39#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
40#define HAL_USE_PAL TRUE
41#endif
42
43/**
44 * @brief Enables the ADC subsystem.
45 */
46#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
47#define HAL_USE_ADC FALSE
48#endif
49
50/**
51 * @brief Enables the CAN subsystem.
52 */
53#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
54#define HAL_USE_CAN FALSE
55#endif
56
57/**
58 * @brief Enables the cryptographic subsystem.
59 */
60#if !defined(HAL_USE_CRY) || defined(__DOXYGEN__)
61#define HAL_USE_CRY FALSE
62#endif
63
64/**
65 * @brief Enables the DAC subsystem.
66 */
67#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
68#define HAL_USE_DAC FALSE
69#endif
70
71/**
72 * @brief Enables the EFlash subsystem.
73 */
74#if !defined(HAL_USE_EFL) || defined(__DOXYGEN__)
75#define HAL_USE_EFL FALSE
76#endif
77
78/**
79 * @brief Enables the GPT subsystem.
80 */
81#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
82#define HAL_USE_GPT FALSE
83#endif
84
85/**
86 * @brief Enables the I2C subsystem.
87 */
88#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
89#define HAL_USE_I2C FALSE
90#endif
91
92/**
93 * @brief Enables the I2S subsystem.
94 */
95#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
96#define HAL_USE_I2S FALSE
97#endif
98
99/**
100 * @brief Enables the ICU subsystem.
101 */
102#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
103#define HAL_USE_ICU FALSE
104#endif
105
106/**
107 * @brief Enables the MAC subsystem.
108 */
109#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
110#define HAL_USE_MAC FALSE
111#endif
112
113/**
114 * @brief Enables the MMC_SPI subsystem.
115 */
116#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
117#define HAL_USE_MMC_SPI FALSE
118#endif
119
120/**
121 * @brief Enables the PWM subsystem.
122 */
123#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
124#define HAL_USE_PWM FALSE
125#endif
126
127/**
128 * @brief Enables the RTC subsystem.
129 */
130#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
131#define HAL_USE_RTC FALSE
132#endif
133
134/**
135 * @brief Enables the SDC subsystem.
136 */
137#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
138#define HAL_USE_SDC FALSE
139#endif
140
141/**
142 * @brief Enables the SERIAL subsystem.
143 */
144#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
145#define HAL_USE_SERIAL FALSE
146#endif
147
148/**
149 * @brief Enables the SERIAL over USB subsystem.
150 */
151#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
152#define HAL_USE_SERIAL_USB FALSE
153#endif
154
155/**
156 * @brief Enables the SIO subsystem.
157 */
158#if !defined(HAL_USE_SIO) || defined(__DOXYGEN__)
159#define HAL_USE_SIO FALSE
160#endif
161
162/**
163 * @brief Enables the SPI subsystem.
164 */
165#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
166#define HAL_USE_SPI FALSE
167#endif
168
169/**
170 * @brief Enables the TRNG subsystem.
171 */
172#if !defined(HAL_USE_TRNG) || defined(__DOXYGEN__)
173#define HAL_USE_TRNG FALSE
174#endif
175
176/**
177 * @brief Enables the UART subsystem.
178 */
179#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
180#define HAL_USE_UART FALSE
181#endif
182
183/**
184 * @brief Enables the USB subsystem.
185 */
186#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
187#define HAL_USE_USB TRUE
188#endif
189
190/**
191 * @brief Enables the WDG subsystem.
192 */
193#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
194#define HAL_USE_WDG FALSE
195#endif
196
197/**
198 * @brief Enables the WSPI subsystem.
199 */
200#if !defined(HAL_USE_WSPI) || defined(__DOXYGEN__)
201#define HAL_USE_WSPI FALSE
202#endif
203
204/*===========================================================================*/
205/* PAL driver related settings. */
206/*===========================================================================*/
207
208/**
209 * @brief Enables synchronous APIs.
210 * @note Disabling this option saves both code and data space.
211 */
212#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__)
213#define PAL_USE_CALLBACKS FALSE
214#endif
215
216/**
217 * @brief Enables synchronous APIs.
218 * @note Disabling this option saves both code and data space.
219 */
220#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__)
221#define PAL_USE_WAIT FALSE
222#endif
223
224/*===========================================================================*/
225/* ADC driver related settings. */
226/*===========================================================================*/
227
228/**
229 * @brief Enables synchronous APIs.
230 * @note Disabling this option saves both code and data space.
231 */
232#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
233#define ADC_USE_WAIT TRUE
234#endif
235
236/**
237 * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
238 * @note Disabling this option saves both code and data space.
239 */
240#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
241#define ADC_USE_MUTUAL_EXCLUSION TRUE
242#endif
243
244/*===========================================================================*/
245/* CAN driver related settings. */
246/*===========================================================================*/
247
248/**
249 * @brief Sleep mode related APIs inclusion switch.
250 */
251#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
252#define CAN_USE_SLEEP_MODE TRUE
253#endif
254
255/**
256 * @brief Enforces the driver to use direct callbacks rather than OSAL events.
257 */
258#if !defined(CAN_ENFORCE_USE_CALLBACKS) || defined(__DOXYGEN__)
259#define CAN_ENFORCE_USE_CALLBACKS FALSE
260#endif
261
262/*===========================================================================*/
263/* CRY driver related settings. */
264/*===========================================================================*/
265
266/**
267 * @brief Enables the SW fall-back of the cryptographic driver.
268 * @details When enabled, this option, activates a fall-back software
269 * implementation for algorithms not supported by the underlying
270 * hardware.
271 * @note Fall-back implementations may not be present for all algorithms.
272 */
273#if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__)
274#define HAL_CRY_USE_FALLBACK FALSE
275#endif
276
277/**
278 * @brief Makes the driver forcibly use the fall-back implementations.
279 */
280#if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__)
281#define HAL_CRY_ENFORCE_FALLBACK FALSE
282#endif
283
284/*===========================================================================*/
285/* DAC driver related settings. */
286/*===========================================================================*/
287
288/**
289 * @brief Enables synchronous APIs.
290 * @note Disabling this option saves both code and data space.
291 */
292#if !defined(DAC_USE_WAIT) || defined(__DOXYGEN__)
293#define DAC_USE_WAIT TRUE
294#endif
295
296/**
297 * @brief Enables the @p dacAcquireBus() and @p dacReleaseBus() APIs.
298 * @note Disabling this option saves both code and data space.
299 */
300#if !defined(DAC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
301#define DAC_USE_MUTUAL_EXCLUSION TRUE
302#endif
303
304/*===========================================================================*/
305/* I2C driver related settings. */
306/*===========================================================================*/
307
308/**
309 * @brief Enables the mutual exclusion APIs on the I2C bus.
310 */
311#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
312#define I2C_USE_MUTUAL_EXCLUSION TRUE
313#endif
314
315/*===========================================================================*/
316/* MAC driver related settings. */
317/*===========================================================================*/
318
319/**
320 * @brief Enables the zero-copy API.
321 */
322#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
323#define MAC_USE_ZERO_COPY FALSE
324#endif
325
326/**
327 * @brief Enables an event sources for incoming packets.
328 */
329#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
330#define MAC_USE_EVENTS TRUE
331#endif
332
333/*===========================================================================*/
334/* MMC_SPI driver related settings. */
335/*===========================================================================*/
336
337/**
338 * @brief Delays insertions.
339 * @details If enabled this options inserts delays into the MMC waiting
340 * routines releasing some extra CPU time for the threads with
341 * lower priority, this may slow down the driver a bit however.
342 * This option is recommended also if the SPI driver does not
343 * use a DMA channel and heavily loads the CPU.
344 */
345#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
346#define MMC_NICE_WAITING TRUE
347#endif
348
349/*===========================================================================*/
350/* SDC driver related settings. */
351/*===========================================================================*/
352
353/**
354 * @brief Number of initialization attempts before rejecting the card.
355 * @note Attempts are performed at 10mS intervals.
356 */
357#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
358#define SDC_INIT_RETRY 100
359#endif
360
361/**
362 * @brief Include support for MMC cards.
363 * @note MMC support is not yet implemented so this option must be kept
364 * at @p FALSE.
365 */
366#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
367#define SDC_MMC_SUPPORT FALSE
368#endif
369
370/**
371 * @brief Delays insertions.
372 * @details If enabled this options inserts delays into the MMC waiting
373 * routines releasing some extra CPU time for the threads with
374 * lower priority, this may slow down the driver a bit however.
375 */
376#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
377#define SDC_NICE_WAITING TRUE
378#endif
379
380/**
381 * @brief OCR initialization constant for V20 cards.
382 */
383#if !defined(SDC_INIT_OCR_V20) || defined(__DOXYGEN__)
384#define SDC_INIT_OCR_V20 0x50FF8000U
385#endif
386
387/**
388 * @brief OCR initialization constant for non-V20 cards.
389 */
390#if !defined(SDC_INIT_OCR) || defined(__DOXYGEN__)
391#define SDC_INIT_OCR 0x80100000U
392#endif
393
394/*===========================================================================*/
395/* SERIAL driver related settings. */
396/*===========================================================================*/
397
398/**
399 * @brief Default bit rate.
400 * @details Configuration parameter, this is the baud rate selected for the
401 * default configuration.
402 */
403#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
404#define SERIAL_DEFAULT_BITRATE 38400
405#endif
406
407/**
408 * @brief Serial buffers size.
409 * @details Configuration parameter, you can change the depth of the queue
410 * buffers depending on the requirements of your application.
411 * @note The default is 16 bytes for both the transmission and receive
412 * buffers.
413 */
414#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
415#define SERIAL_BUFFERS_SIZE 128
416#endif
417
418/*===========================================================================*/
419/* SERIAL_USB driver related setting. */
420/*===========================================================================*/
421
422/**
423 * @brief Serial over USB buffers size.
424 * @details Configuration parameter, the buffer size must be a multiple of
425 * the USB data endpoint maximum packet size.
426 * @note The default is 256 bytes for both the transmission and receive
427 * buffers.
428 */
429#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
430#define SERIAL_USB_BUFFERS_SIZE 1
431#endif
432
433/**
434 * @brief Serial over USB number of buffers.
435 * @note The default is 2 buffers.
436 */
437#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
438#define SERIAL_USB_BUFFERS_NUMBER 2
439#endif
440
441/*===========================================================================*/
442/* SPI driver related settings. */
443/*===========================================================================*/
444
445/**
446 * @brief Enables synchronous APIs.
447 * @note Disabling this option saves both code and data space.
448 */
449#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
450#define SPI_USE_WAIT TRUE
451#endif
452
453/**
454 * @brief Enables circular transfers APIs.
455 * @note Disabling this option saves both code and data space.
456 */
457#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
458#define SPI_USE_CIRCULAR FALSE
459#endif
460
461/**
462 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
463 * @note Disabling this option saves both code and data space.
464 */
465#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
466#define SPI_USE_MUTUAL_EXCLUSION TRUE
467#endif
468
469/**
470 * @brief Handling method for SPI CS line.
471 * @note Disabling this option saves both code and data space.
472 */
473#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
474#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
475#endif
476
477/*===========================================================================*/
478/* UART driver related settings. */
479/*===========================================================================*/
480
481/**
482 * @brief Enables synchronous APIs.
483 * @note Disabling this option saves both code and data space.
484 */
485#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
486#define UART_USE_WAIT FALSE
487#endif
488
489/**
490 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
491 * @note Disabling this option saves both code and data space.
492 */
493#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
494#define UART_USE_MUTUAL_EXCLUSION FALSE
495#endif
496
497/*===========================================================================*/
498/* USB driver related settings. */
499/*===========================================================================*/
500
501/**
502 * @brief Enables synchronous APIs.
503 * @note Disabling this option saves both code and data space.
504 */
505#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
506#define USB_USE_WAIT TRUE
507#endif
508
509/*===========================================================================*/
510/* WSPI driver related settings. */
511/*===========================================================================*/
512
513/**
514 * @brief Enables synchronous APIs.
515 * @note Disabling this option saves both code and data space.
516 */
517#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
518#define WSPI_USE_WAIT TRUE
519#endif
520
521/**
522 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
523 * @note Disabling this option saves both code and data space.
524 */
525#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
526#define WSPI_USE_MUTUAL_EXCLUSION TRUE
527#endif
528
529#endif /* HALCONF_H */
530
531/** @} */
diff --git a/platforms/chibios/boards/common/ld/MKL26Z64.ld b/platforms/chibios/boards/common/ld/MKL26Z64.ld
new file mode 100644
index 000000000..c4ca8b874
--- /dev/null
+++ b/platforms/chibios/boards/common/ld/MKL26Z64.ld
@@ -0,0 +1,105 @@
1/*
2 * Copyright (C) 2013-2016 Fabio Utzig, http://fabioutzig.com
3 * (C) 2016 flabbergast <s3+flabbergast@sdfeu.org>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24/*
25 * KL26Z64 memory setup.
26 */
27MEMORY
28{
29 flash0 : org = 0x00000000, len = 0x100
30 flash1 : org = 0x00000400, len = 0x10
31 flash2 : org = 0x00000410, len = 62k - 0x410
32 flash3 : org = 0x0000F800, len = 2k
33 flash4 : org = 0x00000000, len = 0
34 flash5 : org = 0x00000000, len = 0
35 flash6 : org = 0x00000000, len = 0
36 flash7 : org = 0x00000000, len = 0
37 ram0 : org = 0x1FFFF800, len = 8k
38 ram1 : org = 0x00000000, len = 0
39 ram2 : org = 0x00000000, len = 0
40 ram3 : org = 0x00000000, len = 0
41 ram4 : org = 0x00000000, len = 0
42 ram5 : org = 0x00000000, len = 0
43 ram6 : org = 0x00000000, len = 0
44 ram7 : org = 0x00000000, len = 0
45}
46
47/* Flash region for the configuration bytes.*/
48SECTIONS
49{
50 .cfmprotect : ALIGN(4) SUBALIGN(4)
51 {
52 KEEP(*(.cfmconfig))
53 } > flash1
54}
55
56/* For each data/text section two region are defined, a virtual region
57 and a load region (_LMA suffix).*/
58
59/* Flash region to be used for exception vectors.*/
60REGION_ALIAS("VECTORS_FLASH", flash0);
61REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
62
63/* Flash region to be used for constructors and destructors.*/
64REGION_ALIAS("XTORS_FLASH", flash2);
65REGION_ALIAS("XTORS_FLASH_LMA", flash2);
66
67/* Flash region to be used for code text.*/
68REGION_ALIAS("TEXT_FLASH", flash2);
69REGION_ALIAS("TEXT_FLASH_LMA", flash2);
70
71/* Flash region to be used for read only data.*/
72REGION_ALIAS("RODATA_FLASH", flash2);
73REGION_ALIAS("RODATA_FLASH_LMA", flash2);
74
75/* Flash region to be used for various.*/
76REGION_ALIAS("VARIOUS_FLASH", flash2);
77REGION_ALIAS("VARIOUS_FLASH_LMA", flash2);
78
79/* Flash region to be used for RAM(n) initialization data.*/
80REGION_ALIAS("RAM_INIT_FLASH_LMA", flash2);
81
82/* RAM region to be used for Main stack. This stack accommodates the processing
83 of all exceptions and interrupts.*/
84REGION_ALIAS("MAIN_STACK_RAM", ram0);
85
86/* RAM region to be used for the process stack. This is the stack used by
87 the main() function.*/
88REGION_ALIAS("PROCESS_STACK_RAM", ram0);
89
90/* RAM region to be used for data segment.*/
91REGION_ALIAS("DATA_RAM", ram0);
92REGION_ALIAS("DATA_RAM_LMA", flash2);
93
94/* RAM region to be used for BSS segment.*/
95REGION_ALIAS("BSS_RAM", ram0);
96
97/* RAM region to be used for the default heap.*/
98REGION_ALIAS("HEAP_RAM", ram0);
99
100__eeprom_workarea_start__ = ORIGIN(flash3);
101__eeprom_workarea_size__ = LENGTH(flash3);
102__eeprom_workarea_end__ = __eeprom_workarea_start__ + __eeprom_workarea_size__;
103
104/* Generic rules inclusion.*/
105INCLUDE rules.ld
diff --git a/platforms/chibios/boards/common/ld/STM32L412xB.ld b/platforms/chibios/boards/common/ld/STM32L412xB.ld
new file mode 100644
index 000000000..5718d6bc7
--- /dev/null
+++ b/platforms/chibios/boards/common/ld/STM32L412xB.ld
@@ -0,0 +1,85 @@
1/*
2 ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/*
18 * STM32L412xB memory setup.
19 */
20MEMORY
21{
22 flash0 : org = 0x08000000, len = 128k
23 flash1 : org = 0x00000000, len = 0
24 flash2 : org = 0x00000000, len = 0
25 flash3 : org = 0x00000000, len = 0
26 flash4 : org = 0x00000000, len = 0
27 flash5 : org = 0x00000000, len = 0
28 flash6 : org = 0x00000000, len = 0
29 flash7 : org = 0x00000000, len = 0
30 ram0 : org = 0x20000000, len = 32k
31 ram1 : org = 0x00000000, len = 0
32 ram2 : org = 0x00000000, len = 0
33 ram3 : org = 0x00000000, len = 0
34 ram4 : org = 0x00000000, len = 0
35 ram5 : org = 0x00000000, len = 0
36 ram6 : org = 0x00000000, len = 0
37 ram7 : org = 0x00000000, len = 0
38}
39
40/* For each data/text section two region are defined, a virtual region
41 and a load region (_LMA suffix).*/
42
43/* Flash region to be used for exception vectors.*/
44REGION_ALIAS("VECTORS_FLASH", flash0);
45REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
46
47/* Flash region to be used for constructors and destructors.*/
48REGION_ALIAS("XTORS_FLASH", flash0);
49REGION_ALIAS("XTORS_FLASH_LMA", flash0);
50
51/* Flash region to be used for code text.*/
52REGION_ALIAS("TEXT_FLASH", flash0);
53REGION_ALIAS("TEXT_FLASH_LMA", flash0);
54
55/* Flash region to be used for read only data.*/
56REGION_ALIAS("RODATA_FLASH", flash0);
57REGION_ALIAS("RODATA_FLASH_LMA", flash0);
58
59/* Flash region to be used for various.*/
60REGION_ALIAS("VARIOUS_FLASH", flash0);
61REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
62
63/* Flash region to be used for RAM(n) initialization data.*/
64REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
65
66/* RAM region to be used for Main stack. This stack accommodates the processing
67 of all exceptions and interrupts.*/
68REGION_ALIAS("MAIN_STACK_RAM", ram0);
69
70/* RAM region to be used for the process stack. This is the stack used by
71 the main() function.*/
72REGION_ALIAS("PROCESS_STACK_RAM", ram0);
73
74/* RAM region to be used for data segment.*/
75REGION_ALIAS("DATA_RAM", ram0);
76REGION_ALIAS("DATA_RAM_LMA", flash0);
77
78/* RAM region to be used for BSS segment.*/
79REGION_ALIAS("BSS_RAM", ram0);
80
81/* RAM region to be used for the default heap.*/
82REGION_ALIAS("HEAP_RAM", ram0);
83
84/* Generic rules inclusion.*/
85INCLUDE rules.ld
diff --git a/platforms/chibios/boards/keyboard-config-templates/board.h b/platforms/chibios/boards/keyboard-config-templates/board.h
new file mode 100644
index 000000000..5b840c389
--- /dev/null
+++ b/platforms/chibios/boards/keyboard-config-templates/board.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next <board.h>
19
20// #undef STM32_HSE_BYPASS
diff --git a/platforms/chibios/boards/keyboard-config-templates/chconf.h b/platforms/chibios/boards/keyboard-config-templates/chconf.h
new file mode 100644
index 000000000..fca444747
--- /dev/null
+++ b/platforms/chibios/boards/keyboard-config-templates/chconf.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18// #define CH_CFG_OPTIMIZE_SPEED TRUE
19
20#include_next <chconf.h>
diff --git a/platforms/chibios/boards/keyboard-config-templates/halconf.h b/platforms/chibios/boards/keyboard-config-templates/halconf.h
new file mode 100644
index 000000000..456020f16
--- /dev/null
+++ b/platforms/chibios/boards/keyboard-config-templates/halconf.h
@@ -0,0 +1,20 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18// #define HAL_USE_DAC TRUE
19
20#include_next <halconf.h>
diff --git a/platforms/chibios/boards/keyboard-config-templates/mcuconf.h b/platforms/chibios/boards/keyboard-config-templates/mcuconf.h
new file mode 100644
index 000000000..c690b02f4
--- /dev/null
+++ b/platforms/chibios/boards/keyboard-config-templates/mcuconf.h
@@ -0,0 +1,21 @@
1/* Copyright 2020 Nick Brassel (tzarc)
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16#pragma once
17
18#include_next <mcuconf.h>
19
20// #undef STM32_HSE_ENABLED
21// #define STM32_HSE_ENABLED FALSE