diff options
author | Stefan Kerkmann <karlk90@pm.me> | 2021-10-18 07:23:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 16:23:20 +1100 |
commit | e50867d52d9c255570630a23514842749b45e4c1 (patch) | |
tree | e448e47262668e21084fb7439a38b0322136bb89 /platforms | |
parent | 7e3ff206b8600265ea086040b397f1a600c4a7f3 (diff) | |
download | qmk_firmware-e50867d52d9c255570630a23514842749b45e4c1.tar.gz qmk_firmware-e50867d52d9c255570630a23514842749b45e4c1.zip |
[Core] Add support for RISC-V builds and GD32VF103 MCU (#12508)
* Add support for RISC-V builds and GD32VF103 MCU
* Add toolchain selection in chibios.mk based on the mcu selected in
mcu_selection.mk
* Reorder and added comments to chibios.mk to have a streamlined makefile
* Add GD32VF103 mcu to possible targets for QMK.
* Add STM32 compatibility for GD32VF103 MCU, this is hacky but more efficent
then rewriting every driver.
* Add GigaDevice DFU bootloader as flash target, please note that
dfu-util of at least version 0.10 is needed.
* Add analog driver compatibility
* Add apa102 bitbang driver compatibility
* Add ws2812 bitbang driver compatibility
* Add eeprom in flash emulation compatibility
* Allow faster re-builds with ccache
* Add SiPeed Longan Nano to platform files
* Add SiPeed Longan Nano Onekeys
* Make quine compatible with other bootloaders
* Support builds with picolibc
* Add risc-v toolchain to arch and debian/ubuntu scripts
Diffstat (limited to 'platforms')
-rw-r--r-- | platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk | 9 | ||||
-rw-r--r-- | platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h | 23 | ||||
-rw-r--r-- | platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h | 302 | ||||
-rw-r--r-- | platforms/chibios/drivers/analog.c | 10 | ||||
-rw-r--r-- | platforms/chibios/drivers/ws2812.c | 2 | ||||
-rw-r--r-- | platforms/chibios/flash.mk | 2 |
6 files changed, 342 insertions, 6 deletions
diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk b/platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk new file mode 100644 index 000000000..960fc2678 --- /dev/null +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk | |||
@@ -0,0 +1,9 @@ | |||
1 | # List of all the board related files. | ||
2 | BOARDSRC = ${CHIBIOS_CONTRIB}/os/hal/boards/SIPEED_LONGAN_NANO/board.c | ||
3 | |||
4 | # Required include directories | ||
5 | BOARDINC = ${CHIBIOS_CONTRIB}/os/hal/boards/SIPEED_LONGAN_NANO | ||
6 | |||
7 | # Shared variables | ||
8 | ALLCSRC += $(BOARDSRC) | ||
9 | ALLINC += $(BOARDINC) | ||
diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h new file mode 100644 index 000000000..6e5adb0fe --- /dev/null +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* Copyright 2021 QMK | ||
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 | /* To compile the ChibiOS syscall stubs with picolibc | ||
18 | * the _reent struct has to be defined. */ | ||
19 | #if !defined(_FROM_ASM_) && defined(USE_PICOLIBC) | ||
20 | struct _reent; | ||
21 | #endif | ||
22 | |||
23 | #include_next <chconf.h> \ No newline at end of file | ||
diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h new file mode 100644 index 000000000..ab086567e --- /dev/null +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h | |||
@@ -0,0 +1,302 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
3 | ChibiOS - Copyright (C) 2021 Stefan Kerkmann | ||
4 | |||
5 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | you may not use this file except in compliance with the License. | ||
7 | You may obtain a copy of the License at | ||
8 | |||
9 | http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | |||
11 | Unless required by applicable law or agreed to in writing, software | ||
12 | distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | See the License for the specific language governing permissions and | ||
15 | limitations under the License. | ||
16 | */ | ||
17 | |||
18 | #pragma once | ||
19 | |||
20 | #define GD32VF103_MCUCONF | ||
21 | #define GD32VF103CB | ||
22 | |||
23 | /* | ||
24 | * GD32VF103 drivers configuration. | ||
25 | * The following settings override the default settings present in | ||
26 | * the various device driver implementation headers. | ||
27 | * Note that the settings for each driver only have effect if the whole | ||
28 | * driver is enabled in halconf.h. | ||
29 | * | ||
30 | * IRQ priorities: | ||
31 | * 0...15 Lowest...Highest. | ||
32 | * | ||
33 | * DMA priorities: | ||
34 | * 0...3 Lowest...Highest. | ||
35 | */ | ||
36 | |||
37 | /* | ||
38 | * HAL driver system settings. | ||
39 | */ | ||
40 | |||
41 | #if defined(OVERCLOCK_120MHZ) | ||
42 | /* (8MHz / 2) * 30 = 120MHz Sysclock */ | ||
43 | #define GD32_ALLOW_120MHZ_SYSCLK | ||
44 | #define GD32_PLLMF_VALUE 30 | ||
45 | #define GD32_USBFSPSC GD32_USBFSPSC_DIV2P5 | ||
46 | #else | ||
47 | /* (8MHz / 2) * 24 = 96MHz Sysclock */ | ||
48 | #define GD32_PLLMF_VALUE 24 | ||
49 | #define GD32_USBFSPSC GD32_USBFSPSC_DIV2 | ||
50 | #endif | ||
51 | |||
52 | #define GD32_NO_INIT FALSE | ||
53 | #define GD32_IRC8M_ENABLED TRUE | ||
54 | #define GD32_IRC40K_ENABLED FALSE | ||
55 | #define GD32_HXTAL_ENABLED TRUE | ||
56 | #define GD32_LXTAL_ENABLED FALSE | ||
57 | #define GD32_SCS GD32_SCS_PLL | ||
58 | #define GD32_PLLSEL GD32_PLLSEL_PREDV0 | ||
59 | #define GD32_PREDV0SEL GD32_PREDV0SEL_HXTAL | ||
60 | #define GD32_PREDV0_VALUE 2 | ||
61 | #define GD32_PREDV1_VALUE 2 | ||
62 | #define GD32_PLL1MF_VALUE 14 | ||
63 | #define GD32_PLL2MF_VALUE 13 | ||
64 | #define GD32_AHBPSC GD32_AHBPSC_DIV1 | ||
65 | #define GD32_APB1PSC GD32_APB1PSC_DIV2 | ||
66 | #define GD32_APB2PSC GD32_APB2PSC_DIV1 | ||
67 | #define GD32_ADCPSC GD32_ADCPSC_DIV16 | ||
68 | #define GD32_USB_CLOCK_REQUIRED TRUE | ||
69 | #define GD32_I2S_CLOCK_REQUIRED FALSE | ||
70 | #define GD32_CKOUT0SEL GD32_CKOUT0SEL_NOCLOCK | ||
71 | #define GD32_RTCSRC GD32_RTCSRC_NOCLOCK | ||
72 | #define GD32_PVD_ENABLE FALSE | ||
73 | #define GD32_LVDT GD32_LVDT_LEV0 | ||
74 | |||
75 | /* | ||
76 | * ECLIC system settings. | ||
77 | */ | ||
78 | #define ECLIC_TRIGGER_DEFAULT ECLIC_POSTIVE_EDGE_TRIGGER | ||
79 | #define ECLIC_DMA_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
80 | |||
81 | /* | ||
82 | * IRQ system settings. | ||
83 | */ | ||
84 | #define GD32_IRQ_EXTI0_PRIORITY 6 | ||
85 | #define GD32_IRQ_EXTI1_PRIORITY 6 | ||
86 | #define GD32_IRQ_EXTI2_PRIORITY 6 | ||
87 | #define GD32_IRQ_EXTI3_PRIORITY 6 | ||
88 | #define GD32_IRQ_EXTI4_PRIORITY 6 | ||
89 | #define GD32_IRQ_EXTI5_9_PRIORITY 6 | ||
90 | #define GD32_IRQ_EXTI10_15_PRIORITY 6 | ||
91 | #define GD32_IRQ_EXTI0_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
92 | #define GD32_IRQ_EXTI1_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
93 | #define GD32_IRQ_EXTI2_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
94 | #define GD32_IRQ_EXTI3_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
95 | #define GD32_IRQ_EXTI4_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
96 | #define GD32_IRQ_EXTI5_9_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
97 | #define GD32_IRQ_EXTI10_15_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
98 | |||
99 | /* | ||
100 | * ADC driver system settings. | ||
101 | */ | ||
102 | #define GD32_ADC_USE_ADC0 FALSE | ||
103 | #define GD32_ADC_ADC0_DMA_PRIORITY 2 | ||
104 | #define GD32_ADC_ADC0_IRQ_PRIORITY 6 | ||
105 | |||
106 | /* | ||
107 | * CAN driver system settings. | ||
108 | */ | ||
109 | #define GD32_CAN_USE_CAN0 FALSE | ||
110 | #define GD32_CAN_CAN0_IRQ_PRIORITY 11 | ||
111 | #define GD32_CAN_USE_CAN1 FALSE | ||
112 | #define GD32_CAN_CAN1_IRQ_PRIORITY 11 | ||
113 | #define GD32_CAN_CAN0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
114 | #define GD32_CAN_CAN1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
115 | |||
116 | /* | ||
117 | * CRC driver system settings. | ||
118 | */ | ||
119 | #define GD32_CRC_USE_CRC0 FALSE | ||
120 | #define GD32_CRC_CRC0_DMA_IRQ_PRIORITY 14 | ||
121 | #define GD32_CRC_CRC0_DMA_PRIORITY 2 | ||
122 | #define GD32_CRC_CRC0_DMA_STREAM GD32_DMA_STREAM_ID(0, 0) | ||
123 | #define CRC_USE_DMA FALSE | ||
124 | #define CRCSW_USE_CRC1 FALSE | ||
125 | #define CRCSW_CRC32_TABLE FALSE | ||
126 | #define CRCSW_CRC16_TABLE FALSE | ||
127 | #define CRCSW_PROGRAMMABLE FALSE | ||
128 | |||
129 | /* | ||
130 | * DAC driver system settings. | ||
131 | */ | ||
132 | #define GD32_DAC_USE_DAC_CH1 FALSE | ||
133 | #define GD32_DAC_USE_DAC_CH2 FALSE | ||
134 | |||
135 | /* | ||
136 | * GPT driver system settings. | ||
137 | */ | ||
138 | #define GD32_GPT_USE_TIM0 FALSE | ||
139 | #define GD32_GPT_USE_TIM1 FALSE | ||
140 | #define GD32_GPT_USE_TIM2 FALSE | ||
141 | #define GD32_GPT_USE_TIM3 FALSE | ||
142 | #define GD32_GPT_USE_TIM4 FALSE | ||
143 | #define GD32_GPT_TIM0_IRQ_PRIORITY 7 | ||
144 | #define GD32_GPT_TIM1_IRQ_PRIORITY 7 | ||
145 | #define GD32_GPT_TIM2_IRQ_PRIORITY 7 | ||
146 | #define GD32_GPT_TIM3_IRQ_PRIORITY 7 | ||
147 | #define GD32_GPT_TIM4_IRQ_PRIORITY 7 | ||
148 | #define GD32_GPT_TIM0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
149 | #define GD32_GPT_TIM1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
150 | #define GD32_GPT_TIM2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
151 | #define GD32_GPT_TIM3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
152 | #define GD32_GPT_TIM4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
153 | #define GD32_GPT_TIM5_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
154 | #define GD32_GPT_TIM6_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
155 | |||
156 | /* | ||
157 | * I2S driver system settings. | ||
158 | */ | ||
159 | #define GD32_I2S_USE_SPI1 FALSE | ||
160 | #define GD32_I2S_USE_SPI2 FALSE | ||
161 | #define GD32_I2S_SPI1_IRQ_PRIORITY 10 | ||
162 | #define GD32_I2S_SPI2_IRQ_PRIORITY 10 | ||
163 | #define GD32_I2S_SPI1_DMA_PRIORITY 1 | ||
164 | #define GD32_I2S_SPI2_DMA_PRIORITY 1 | ||
165 | #define GD32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure") | ||
166 | |||
167 | /* | ||
168 | * I2C driver system settings. | ||
169 | */ | ||
170 | #define GD32_I2C_USE_I2C0 FALSE | ||
171 | #define GD32_I2C_USE_I2C1 FALSE | ||
172 | #define GD32_I2C_BUSY_TIMEOUT 50 | ||
173 | #define GD32_I2C_I2C0_IRQ_PRIORITY 10 | ||
174 | #define GD32_I2C_I2C1_IRQ_PRIORITY 5 | ||
175 | #define GD32_I2C_I2C0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
176 | #define GD32_I2C_I2C1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
177 | #define GD32_I2C_I2C0_DMA_PRIORITY 2 | ||
178 | #define GD32_I2C_I2C1_DMA_PRIORITY 2 | ||
179 | #define GD32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") | ||
180 | |||
181 | /* | ||
182 | * ICU driver system settings. | ||
183 | */ | ||
184 | #define GD32_ICU_USE_TIM0 FALSE | ||
185 | #define GD32_ICU_USE_TIM1 FALSE | ||
186 | #define GD32_ICU_USE_TIM2 FALSE | ||
187 | #define GD32_ICU_USE_TIM3 FALSE | ||
188 | #define GD32_ICU_USE_TIM4 FALSE | ||
189 | #define GD32_ICU_TIM0_IRQ_PRIORITY 7 | ||
190 | #define GD32_ICU_TIM1_IRQ_PRIORITY 7 | ||
191 | #define GD32_ICU_TIM2_IRQ_PRIORITY 7 | ||
192 | #define GD32_ICU_TIM3_IRQ_PRIORITY 7 | ||
193 | #define GD32_ICU_TIM4_IRQ_PRIORITY 7 | ||
194 | #define GD32_ICU_TIM0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
195 | #define GD32_ICU_TIM1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
196 | #define GD32_ICU_TIM2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
197 | #define GD32_ICU_TIM3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
198 | #define GD32_ICU_TIM4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
199 | |||
200 | /* | ||
201 | * PWM driver system settings. | ||
202 | */ | ||
203 | #define GD32_PWM_USE_ADVANCED FALSE | ||
204 | #define GD32_PWM_USE_TIM0 FALSE | ||
205 | #define GD32_PWM_USE_TIM1 FALSE | ||
206 | #define GD32_PWM_USE_TIM2 FALSE | ||
207 | #define GD32_PWM_USE_TIM3 FALSE | ||
208 | #define GD32_PWM_USE_TIM4 FALSE | ||
209 | #define GD32_PWM_TIM0_IRQ_PRIORITY 10 | ||
210 | #define GD32_PWM_TIM1_IRQ_PRIORITY 10 | ||
211 | #define GD32_PWM_TIM2_IRQ_PRIORITY 10 | ||
212 | #define GD32_PWM_TIM3_IRQ_PRIORITY 10 | ||
213 | #define GD32_PWM_TIM4_IRQ_PRIORITY 10 | ||
214 | #define GD32_PWM_TIM0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
215 | #define GD32_PWM_TIM1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
216 | #define GD32_PWM_TIM2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
217 | #define GD32_PWM_TIM3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
218 | #define GD32_PWM_TIM4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
219 | |||
220 | /* | ||
221 | * RTC driver system settings. | ||
222 | */ | ||
223 | #define GD32_RTC_IRQ_PRIORITY 15 | ||
224 | #define GD32_RTC_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
225 | |||
226 | /* | ||
227 | * SERIAL driver system settings. | ||
228 | */ | ||
229 | #define GD32_SERIAL_USE_USART0 FALSE | ||
230 | #define GD32_SERIAL_USE_USART1 FALSE | ||
231 | #define GD32_SERIAL_USE_USART2 FALSE | ||
232 | #define GD32_SERIAL_USE_UART3 FALSE | ||
233 | #define GD32_SERIAL_USE_UART4 FALSE | ||
234 | #define GD32_SERIAL_USART0_PRIORITY 10 | ||
235 | #define GD32_SERIAL_USART1_PRIORITY 10 | ||
236 | #define GD32_SERIAL_USART2_PRIORITY 10 | ||
237 | #define GD32_SERIAL_UART3_PRIORITY 10 | ||
238 | #define GD32_SERIAL_UART4_PRIORITY 10 | ||
239 | #define GD32_SERIAL_USART0_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
240 | #define GD32_SERIAL_USART1_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
241 | #define GD32_SERIAL_USART2_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
242 | #define GD32_SERIAL_UART3_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
243 | #define GD32_SERIAL_UART4_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
244 | |||
245 | /* | ||
246 | * SPI driver system settings. | ||
247 | */ | ||
248 | #define GD32_SPI_USE_SPI0 FALSE | ||
249 | #define GD32_SPI_USE_SPI1 FALSE | ||
250 | #define GD32_SPI_USE_SPI2 FALSE | ||
251 | #define GD32_SPI_SPI0_DMA_PRIORITY 1 | ||
252 | #define GD32_SPI_SPI1_DMA_PRIORITY 1 | ||
253 | #define GD32_SPI_SPI2_DMA_PRIORITY 1 | ||
254 | #define GD32_SPI_SPI0_IRQ_PRIORITY 10 | ||
255 | #define GD32_SPI_SPI1_IRQ_PRIORITY 10 | ||
256 | #define GD32_SPI_SPI2_IRQ_PRIORITY 10 | ||
257 | #define GD32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") | ||
258 | |||
259 | /* | ||
260 | * ST driver system settings. | ||
261 | */ | ||
262 | #define GD32_ST_IRQ_PRIORITY 10 | ||
263 | #define GD32_ST_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
264 | #define GD32_ST_USE_TIMER 1 | ||
265 | |||
266 | /* | ||
267 | * UART driver system settings. | ||
268 | */ | ||
269 | #define GD32_UART_USE_USART0 FALSE | ||
270 | #define GD32_UART_USE_USART1 FALSE | ||
271 | #define GD32_UART_USE_USART2 FALSE | ||
272 | #define GD32_UART_USE_UART3 FALSE | ||
273 | #define GD32_UART_USE_UART4 FALSE | ||
274 | #define GD32_UART_USART0_IRQ_PRIORITY 10 | ||
275 | #define GD32_UART_USART1_IRQ_PRIORITY 10 | ||
276 | #define GD32_UART_USART2_IRQ_PRIORITY 10 | ||
277 | #define GD32_UART_UART3_IRQ_PRIORITY 10 | ||
278 | #define GD32_UART_UART4_IRQ_PRIORITY 10 | ||
279 | #define GD32_UART_USART0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
280 | #define GD32_UART_USART1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
281 | #define GD32_UART_USART2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
282 | #define GD32_UART_UART3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
283 | #define GD32_UART_UART4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
284 | #define GD32_UART_USART0_DMA_PRIORITY 3 | ||
285 | #define GD32_UART_USART1_DMA_PRIORITY 3 | ||
286 | #define GD32_UART_USART2_DMA_PRIORITY 3 | ||
287 | #define GD32_UART_UART3_DMA_PRIORITY 3 | ||
288 | #define GD32_UART_UART4_DMA_PRIORITY 3 | ||
289 | #define GD32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") | ||
290 | |||
291 | /* | ||
292 | * USB driver system settings. | ||
293 | */ | ||
294 | #define GD32_USB_USE_USBFS TRUE | ||
295 | #define GD32_USB_USBFS_IRQ_PRIORITY 10 | ||
296 | #define GD32_USB_USBFS_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
297 | #define GD32_USB_USBFS_RX_FIFO_SIZE 256 | ||
298 | |||
299 | /* | ||
300 | * WDG driver system settings. | ||
301 | */ | ||
302 | #define GD32_WDG_USE_FWDGT FALSE | ||
diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c index 8c476fcac..eb437665f 100644 --- a/platforms/chibios/drivers/analog.c +++ b/platforms/chibios/drivers/analog.c | |||
@@ -38,7 +38,7 @@ | |||
38 | // Otherwise assume V3 | 38 | // Otherwise assume V3 |
39 | #if defined(STM32F0XX) || defined(STM32L0XX) | 39 | #if defined(STM32F0XX) || defined(STM32L0XX) |
40 | # define USE_ADCV1 | 40 | # define USE_ADCV1 |
41 | #elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) | 41 | #elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(GD32VF103) |
42 | # define USE_ADCV2 | 42 | # define USE_ADCV2 |
43 | #endif | 43 | #endif |
44 | 44 | ||
@@ -75,7 +75,7 @@ | |||
75 | 75 | ||
76 | /* User configurable ADC options */ | 76 | /* User configurable ADC options */ |
77 | #ifndef ADC_COUNT | 77 | #ifndef ADC_COUNT |
78 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) | 78 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103) |
79 | # define ADC_COUNT 1 | 79 | # define ADC_COUNT 1 |
80 | # elif defined(STM32F3XX) | 80 | # elif defined(STM32F3XX) |
81 | # define ADC_COUNT 4 | 81 | # define ADC_COUNT 4 |
@@ -122,8 +122,8 @@ static ADCConversionGroup adcConversionGroup = { | |||
122 | .cfgr1 = ADC_CFGR1_CONT | ADC_RESOLUTION, | 122 | .cfgr1 = ADC_CFGR1_CONT | ADC_RESOLUTION, |
123 | .smpr = ADC_SAMPLING_RATE, | 123 | .smpr = ADC_SAMPLING_RATE, |
124 | #elif defined(USE_ADCV2) | 124 | #elif defined(USE_ADCV2) |
125 | # if !defined(STM32F1XX) | 125 | # if !defined(STM32F1XX) && !defined(GD32VF103) |
126 | .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... | 126 | .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... |
127 | # endif | 127 | # endif |
128 | .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), | 128 | .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), |
129 | .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), | 129 | .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), |
@@ -220,7 +220,7 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) { | |||
220 | case F9: return TO_MUX( ADC_CHANNEL_IN7, 2 ); | 220 | case F9: return TO_MUX( ADC_CHANNEL_IN7, 2 ); |
221 | case F10: return TO_MUX( ADC_CHANNEL_IN8, 2 ); | 221 | case F10: return TO_MUX( ADC_CHANNEL_IN8, 2 ); |
222 | # endif | 222 | # endif |
223 | #elif defined(STM32F1XX) | 223 | #elif defined(STM32F1XX) || defined(GD32VF103) |
224 | case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 ); | 224 | case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 ); |
225 | case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 ); | 225 | case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 ); |
226 | case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 ); | 226 | case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 ); |
diff --git a/platforms/chibios/drivers/ws2812.c b/platforms/chibios/drivers/ws2812.c index ffcdcff24..b46c46ae5 100644 --- a/platforms/chibios/drivers/ws2812.c +++ b/platforms/chibios/drivers/ws2812.c | |||
@@ -6,7 +6,7 @@ | |||
6 | /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ | 6 | /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ |
7 | 7 | ||
8 | #ifndef NOP_FUDGE | 8 | #ifndef NOP_FUDGE |
9 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) | 9 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) |
10 | # define NOP_FUDGE 0.4 | 10 | # define NOP_FUDGE 0.4 |
11 | # else | 11 | # else |
12 | # error("NOP_FUDGE configuration required") | 12 | # error("NOP_FUDGE configuration required") |
diff --git a/platforms/chibios/flash.mk b/platforms/chibios/flash.mk index c0b32c2f2..31f69595d 100644 --- a/platforms/chibios/flash.mk +++ b/platforms/chibios/flash.mk | |||
@@ -82,6 +82,8 @@ else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062) | |||
82 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY) | 82 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY) |
83 | else ifeq ($(strip $(MCU_FAMILY)),STM32) | 83 | else ifeq ($(strip $(MCU_FAMILY)),STM32) |
84 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) | 84 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) |
85 | else ifeq ($(strip $(MCU_FAMILY)),GD32V) | ||
86 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) | ||
85 | else | 87 | else |
86 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" | 88 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" |
87 | endif | 89 | endif |