aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builddefs/mcu_selection.mk31
-rw-r--r--data/schemas/keyboard.jsonschema4
-rw-r--r--docs/compatible_microcontrollers.md4
-rw-r--r--lib/python/qmk/constants.py2
-rw-r--r--lib/python/qmk/info.py2
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c82
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.h56
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.mk9
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/bootloader_defs.h12
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h757
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h20
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/halconf.h532
-rw-r--r--platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/mcuconf.h168
-rw-r--r--platforms/chibios/chibios_config.h12
-rw-r--r--platforms/chibios/drivers/i2c_master.c3
-rw-r--r--platforms/chibios/drivers/spi_master.c33
-rw-r--r--platforms/chibios/drivers/uart.c4
-rw-r--r--platforms/chibios/drivers/uart.h16
-rw-r--r--platforms/chibios/flash.mk16
-rw-r--r--platforms/chibios/platform.mk4
20 files changed, 1763 insertions, 4 deletions
diff --git a/builddefs/mcu_selection.mk b/builddefs/mcu_selection.mk
index 1251b7a2b..46d34aabe 100644
--- a/builddefs/mcu_selection.mk
+++ b/builddefs/mcu_selection.mk
@@ -540,10 +540,39 @@ ifneq (,$(filter $(MCU),STM32L412 STM32L422))
540 UF2_FAMILY ?= STM32L4 540 UF2_FAMILY ?= STM32L4
541endif 541endif
542 542
543ifneq ($(findstring WB32F3G71, $(MCU)),)
544 # Cortex version
545 MCU = cortex-m3
546
547 # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
548 ARMV = 7
549
550 ## chip/board settings
551 # - the next two should match the directories in
552 # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
553 MCU_FAMILY = WB32
554 MCU_SERIES = WB32F3G71xx
555
556 # Linker script to use
557 # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
558 # or <keyboard_dir>/ld/
559 MCU_LDSCRIPT ?= WB32F3G71x9
560
561 # Startup code to use
562 # - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
563 MCU_STARTUP ?= wb32f3g71xx
564
565 # Board: it should exist either in <chibios>/os/hal/boards/,
566 # <keyboard_dir>/boards/, or drivers/boards/
567 BOARD ?= GENERIC_WB32_F3G71XX
568
569 USE_FPU ?= no
570endif
571
543ifneq ($(findstring GD32VF103, $(MCU)),) 572ifneq ($(findstring GD32VF103, $(MCU)),)
544 # RISC-V 573 # RISC-V
545 MCU = risc-v 574 MCU = risc-v
546 575
547 # RISC-V extensions and abi configuration 576 # RISC-V extensions and abi configuration
548 MCU_ARCH = rv32imac 577 MCU_ARCH = rv32imac
549 MCU_ABI = ilp32 578 MCU_ABI = ilp32
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema
index 37a0643ab..308f9b782 100644
--- a/data/schemas/keyboard.jsonschema
+++ b/data/schemas/keyboard.jsonschema
@@ -13,7 +13,7 @@
13 }, 13 },
14 "processor": { 14 "processor": {
15 "type": "string", 15 "type": "string",
16 "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "GD32VF103", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"] 16 "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "GD32VF103", "WB32F3G71", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"]
17 }, 17 },
18 "audio": { 18 "audio": {
19 "type": "object", 19 "type": "object",
@@ -57,7 +57,7 @@
57 }, 57 },
58 "bootloader": { 58 "bootloader": {
59 "type": "string", 59 "type": "string",
60 "enum": ["atmel-dfu", "bootloadhid", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "gd32v-dfu", "unknown", "usbasploader", "USBasp", "tinyuf2"], 60 "enum": ["atmel-dfu", "bootloadhid", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "gd32v-dfu", "wb32-dfu", "unknown", "usbasploader", "USBasp", "tinyuf2"],
61 }, 61 },
62 "bootloader_instructions": { 62 "bootloader_instructions": {
63 "type": "string", 63 "type": "string",
diff --git a/docs/compatible_microcontrollers.md b/docs/compatible_microcontrollers.md
index 39e9061c2..eb3e2c3e5 100644
--- a/docs/compatible_microcontrollers.md
+++ b/docs/compatible_microcontrollers.md
@@ -37,6 +37,10 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s
37 * [STM32L422](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x2.html) 37 * [STM32L422](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x2.html)
38 * [STM32L433](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html) 38 * [STM32L433](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html)
39 * [STM32L443](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html) 39 * [STM32L443](https://www.st.com/en/microcontrollers-microprocessors/stm32l4x3.html)
40
41 ### WestBerryTech (WB32)
42
43 * [WB32F3G71xx](http://www.westberrytech.com)
40 44
41### NXP (Kinetis) 45### NXP (Kinetis)
42 46
diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py
index 73f596ba2..754091a97 100644
--- a/lib/python/qmk/constants.py
+++ b/lib/python/qmk/constants.py
@@ -13,7 +13,7 @@ QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware'
13MAX_KEYBOARD_SUBFOLDERS = 5 13MAX_KEYBOARD_SUBFOLDERS = 5
14 14
15# Supported processor types 15# Supported processor types
16CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L433', 'STM32L443', 'GD32VF103' 16CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L433', 'STM32L443', 'GD32VF103', 'WB32F3G71'
17LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None 17LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
18VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' 18VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
19 19
diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py
index dc42fdd4d..9a07fc842 100644
--- a/lib/python/qmk/info.py
+++ b/lib/python/qmk/info.py
@@ -624,6 +624,8 @@ def arm_processor_rules(info_data, rules):
624 if 'bootloader' not in info_data: 624 if 'bootloader' not in info_data:
625 if 'STM32' in info_data['processor']: 625 if 'STM32' in info_data['processor']:
626 info_data['bootloader'] = 'stm32-dfu' 626 info_data['bootloader'] = 'stm32-dfu'
627 elif 'WB32' in info_data['processor']:
628 info_data['bootloader'] = 'wb32-dfu'
627 else: 629 else:
628 info_data['bootloader'] = 'unknown' 630 info_data['bootloader'] = 'unknown'
629 631
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c
new file mode 100644
index 000000000..e38a7e005
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.c
@@ -0,0 +1,82 @@
1/*
2 Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
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
24/*===========================================================================*/
25/* Driver local definitions. */
26/*===========================================================================*/
27
28/*===========================================================================*/
29/* Driver exported variables. */
30/*===========================================================================*/
31
32/*===========================================================================*/
33/* Driver local variables and types. */
34/*===========================================================================*/
35
36/*===========================================================================*/
37/* Driver local functions. */
38/*===========================================================================*/
39
40static void wb32_gpio_init(void) {
41
42#if WB32_HAS_GPIOA
43 rccEnableAPB1(RCC_APB1ENR_GPIOAEN);
44#endif
45
46#if WB32_HAS_GPIOB
47 rccEnableAPB1(RCC_APB1ENR_GPIOBEN);
48#endif
49
50#if WB32_HAS_GPIOC
51 rccEnableAPB1(RCC_APB1ENR_GPIOCEN);
52#endif
53
54#if WB32_HAS_GPIOD
55 rccEnableAPB1(RCC_APB1ENR_GPIODEN);
56#endif
57}
58
59/*===========================================================================*/
60/* Driver interrupt handlers. */
61/*===========================================================================*/
62
63/*===========================================================================*/
64/* Driver exported functions. */
65/*===========================================================================*/
66/*
67 * Early initialization code.
68 * This initialization must be performed just after stack setup and before
69 * any other initialization.
70 */
71void __early_init(void) {
72
73 wb32_clock_init();
74 wb32_gpio_init();
75}
76/**
77 * @brief Board-specific initialization code.
78 * @note You can add your board-specific code here.
79 */
80void boardInit(void) {
81
82}
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.h
new file mode 100644
index 000000000..51dc84db9
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.h
@@ -0,0 +1,56 @@
1#pragma once
2/*
3 Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
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/*
19 * This file has been automatically generated using ChibiStudio board
20 * generator plugin. Do not edit manually.
21 */
22
23#ifndef BOARD_H
24#define BOARD_H
25
26/*===========================================================================*/
27/* Driver constants. */
28/*===========================================================================*/
29
30/*
31 * Setup board.
32 */
33
34/*
35 * Board identifier.
36 */
37#define WB32F3G71x9
38#if !defined(WB32F3G71xx)
39 #define WB32F3G71xx
40#endif
41
42/*===========================================================================*/
43/* External declarations. */
44/*===========================================================================*/
45
46#if !defined(_FROM_ASM_)
47#ifdef __cplusplus
48extern "C" {
49#endif
50 void boardInit(void);
51#ifdef __cplusplus
52}
53#endif
54#endif /* _FROM_ASM_ */
55
56#endif /* BOARD_H */
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.mk b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/board/board.mk
new file mode 100644
index 000000000..842e33590
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/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_WB32_F3G71XX/configs/bootloader_defs.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/bootloader_defs.h
new file mode 100644
index 000000000..c929d2ad0
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/bootloader_defs.h
@@ -0,0 +1,12 @@
1/* Address for jumping to bootloader on WB32 chips. */
2/* It is chip dependent, the correct number can be looked up here:
3 * http://www.westberrytech.com/down/mcu/data/WB32F3G71xx_rm.pdf
4 */
5#ifndef WB32_BOOTLOADER_ADDRESS
6# undef STM32_BOOTLOADER_ADDRESS
7# define WB32_BOOTLOADER_ADDRESS 0x1FFFE000
8# define STM32_BOOTLOADER_ADDRESS WB32_BOOTLOADER_ADDRESS
9#else
10# undef STM32_BOOTLOADER_ADDRESS
11# define STM32_BOOTLOADER_ADDRESS WB32_BOOTLOADER_ADDRESS
12#endif
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h
new file mode 100644
index 000000000..1b8bd5d84
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h
@@ -0,0 +1,757 @@
1/*
2 Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
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 10000
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 0
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 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 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 TRUE
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 TRUE
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 TRUE
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 TRUE
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 TRUE
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_ALL
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 TRUE
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/*===========================================================================*/
752/* Port-specific settings (override port settings defaulted in chcore.h). */
753/*===========================================================================*/
754
755#endif /* CHCONF_H */
756
757/** @} */
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h
new file mode 100644
index 000000000..3d3e1165e
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/config.h
@@ -0,0 +1,20 @@
1/* Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
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 FALSE
20#endif
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/halconf.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/halconf.h
new file mode 100644
index 000000000..ac6ec9ead
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/halconf.h
@@ -0,0 +1,532 @@
1/*
2 Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
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 // additional : The original is 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 FALSE
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 FALSE
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 FALSE
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 FALSE
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 FALSE
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 16
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 256
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/**
463 * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
464 * @note Disabling this option saves both code and data space.
465 */
466#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
467#define SPI_USE_MUTUAL_EXCLUSION TRUE
468#endif
469
470/**
471 * @brief Handling method for SPI CS line.
472 * @note Disabling this option saves both code and data space.
473 */
474#if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__)
475#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD
476#endif
477
478/*===========================================================================*/
479/* UART driver related settings. */
480/*===========================================================================*/
481
482/**
483 * @brief Enables synchronous APIs.
484 * @note Disabling this option saves both code and data space.
485 */
486#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__)
487#define UART_USE_WAIT FALSE
488#endif
489
490/**
491 * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs.
492 * @note Disabling this option saves both code and data space.
493 */
494#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
495#define UART_USE_MUTUAL_EXCLUSION FALSE
496#endif
497
498/*===========================================================================*/
499/* USB driver related settings. */
500/*===========================================================================*/
501
502/**
503 * @brief Enables synchronous APIs.
504 * @note Disabling this option saves both code and data space.
505 */
506#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
507#define USB_USE_WAIT TRUE
508#endif
509
510/*===========================================================================*/
511/* WSPI driver related settings. */
512/*===========================================================================*/
513
514/**
515 * @brief Enables synchronous APIs.
516 * @note Disabling this option saves both code and data space.
517 */
518#if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__)
519#define WSPI_USE_WAIT TRUE
520#endif
521
522/**
523 * @brief Enables the @p wspiAcquireBus() and @p wspiReleaseBus() APIs.
524 * @note Disabling this option saves both code and data space.
525 */
526#if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
527#define WSPI_USE_MUTUAL_EXCLUSION TRUE
528#endif
529
530#endif /* HALCONF_H */
531
532/** @} */
diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/mcuconf.h
new file mode 100644
index 000000000..7c1fdaf57
--- /dev/null
+++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/mcuconf.h
@@ -0,0 +1,168 @@
1/*
2 Copyright (C) 2021 Westberry Technology (ChangZhou) Corp., Ltd
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 WB32F3G71xx_MCUCONF TRUE
21
22/*
23 * WB32F3G71 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 */
33
34/**
35 * @name Internal clock sources
36 * @{
37 */
38#define WB32_HSECLK 12000000
39#define WB32_LSECLK 32768
40
41/*
42 * HAL driver system settings.
43 */
44#define WB32_NO_INIT FALSE
45#define WB32_MHSI_ENABLED TRUE
46#define WB32_FHSI_ENABLED FALSE
47#define WB32_LSI_ENABLED FALSE
48#define WB32_HSE_ENABLED TRUE
49#define WB32_LSE_ENABLED FALSE
50#define WB32_PLL_ENABLED TRUE
51#define WB32_MAINCLKSRC WB32_MAINCLKSRC_PLL
52#define WB32_PLLSRC WB32_PLLSRC_HSE
53#define WB32_PLLDIV_VALUE 2
54#define WB32_PLLMUL_VALUE 12 //The allowed range is 12,16,20,24.
55#define WB32_HPRE 1
56#define WB32_PPRE1 1
57#define WB32_PPRE2 1
58#define WB32_USBPRE WB32_USBPRE_DIV1P5
59
60/*
61 * EXTI driver system settings.
62 */
63#define WB32_IRQ_EXTI0_PRIORITY 6
64#define WB32_IRQ_EXTI1_PRIORITY 6
65#define WB32_IRQ_EXTI2_PRIORITY 6
66#define WB32_IRQ_EXTI3_PRIORITY 6
67#define WB32_IRQ_EXTI4_PRIORITY 6
68#define WB32_IRQ_EXTI5_9_PRIORITY 6
69#define WB32_IRQ_EXTI10_15_PRIORITY 6
70#define WB32_IRQ_EXTI16_PRIORITY 6
71#define WB32_IRQ_EXTI17_PRIORITY 6
72#define WB32_IRQ_EXTI18_PRIORITY 6
73#define WB32_IRQ_EXTI19_PRIORITY 6
74
75/*
76 * GPT driver system settings.
77 */
78#define WB32_TIM_MAX_CHANNELS 4
79#define WB32_GPT_USE_TIM1 FALSE
80#define WB32_GPT_USE_TIM2 FALSE
81#define WB32_GPT_USE_TIM3 FALSE
82#define WB32_GPT_USE_TIM4 FALSE
83#define WB32_GPT_TIM1_IRQ_PRIORITY 7
84#define WB32_GPT_TIM2_IRQ_PRIORITY 7
85#define WB32_GPT_TIM3_IRQ_PRIORITY 7
86#define WB32_GPT_TIM4_IRQ_PRIORITY 7
87
88/*
89 * ICU driver system settings.
90 */
91#define WB32_ICU_USE_TIM1 FALSE
92#define WB32_ICU_USE_TIM2 FALSE
93#define WB32_ICU_USE_TIM3 FALSE
94#define WB32_ICU_USE_TIM4 FALSE
95#define WB32_ICU_TIM1_IRQ_PRIORITY 7
96#define WB32_ICU_TIM2_IRQ_PRIORITY 7
97#define WB32_ICU_TIM3_IRQ_PRIORITY 7
98#define WB32_ICU_TIM4_IRQ_PRIORITY 7
99
100/*
101 * PWM driver system settings.
102 */
103#define WB32_PWM_USE_ADVANCED FALSE
104#define WB32_PWM_USE_TIM1 FALSE
105#define WB32_PWM_USE_TIM2 FALSE
106#define WB32_PWM_USE_TIM3 FALSE
107#define WB32_PWM_USE_TIM4 FALSE
108#define WB32_PWM_TIM1_IRQ_PRIORITY 7
109#define WB32_PWM_TIM2_IRQ_PRIORITY 7
110#define WB32_PWM_TIM3_IRQ_PRIORITY 7
111#define WB32_PWM_TIM4_IRQ_PRIORITY 7
112
113/*
114 * I2C driver system settings.
115 */
116#define WB32_I2C_USE_I2C1 FALSE
117#define WB32_I2C_USE_I2C2 FALSE
118#define WB32_I2C_BUSY_TIMEOUT 50
119#define WB32_I2C_I2C1_IRQ_PRIORITY 5
120#define WB32_I2C_I2C2_IRQ_PRIORITY 5
121
122/*
123 * SERIAL driver system settings.
124 */
125#define WB32_SERIAL_USE_UART1 FALSE
126#define WB32_SERIAL_USE_UART2 FALSE
127#define WB32_SERIAL_USE_UART3 FALSE
128#define WB32_SERIAL_USART1_PRIORITY 12
129#define WB32_SERIAL_USART2_PRIORITY 12
130#define WB32_SERIAL_USART3_PRIORITY 12
131
132/*
133 * SPI driver system settings.
134 */
135#define WB32_SPI_USE_QSPI FALSE
136#define WB32_SPI_USE_SPIM2 FALSE
137#define WB32_SPI_USE_SPIS1 FALSE
138#define WB32_SPI_USE_SPIS2 FALSE
139#define WB32_SPI_QSPI_IRQ_PRIORITY 10
140#define WB32_SPI_SPIM2_IRQ_PRIORITY 10
141#define WB32_SPI_SPIS1_IRQ_PRIORITY 10
142#define WB32_SPI_SPIS2_IRQ_PRIORITY 10
143
144/*
145 * ST driver system settings.
146 */
147#define WB32_ST_IRQ_PRIORITY 8
148#define WB32_ST_USE_TIMER 2
149
150/*
151 * UART driver system settings.
152 */
153#define WB32_UART_USE_UART1 FALSE
154#define WB32_UART_USE_UART2 FALSE
155#define WB32_UART_USE_UART3 FALSE
156#define WB32_UART_UART1_IRQ_PRIORITY 12
157#define WB32_UART_UART2_IRQ_PRIORITY 12
158#define WB32_UART_UART3_IRQ_PRIORITY 12
159
160/*
161 * USB driver system settings.
162 */
163#define WB32_USB_USE_USB1 TRUE
164#define WB32_USB_USB1_IRQ_PRIORITY 13
165#define WB32_USB_HOST_WAKEUP_DURATION 10
166
167
168#endif /* MCUCONF_H */
diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h
index ad2f808a9..4e3573660 100644
--- a/platforms/chibios/chibios_config.h
+++ b/platforms/chibios/chibios_config.h
@@ -51,6 +51,18 @@
51# endif 51# endif
52#endif 52#endif
53 53
54// WB32 compatibility
55#if defined(MCU_WB32)
56# define CPU_CLOCK WB32_MAINCLK
57
58# if defined(WB32F3G71xx)
59# define PAL_OUTPUT_TYPE_OPENDRAIN PAL_WB32_OTYPE_OPENDRAIN
60# define PAL_OUTPUT_TYPE_PUSHPULL PAL_WB32_OTYPE_PUSHPULL
61# define PAL_OUTPUT_SPEED_HIGHEST PAL_WB32_OSPEED_HIGH
62# define PAL_PUPDR_FLOATING PAL_WB32_PUPDR_FLOATING
63# endif
64#endif
65
54#if defined(GD32VF103) 66#if defined(GD32VF103)
55/* This chip has the same API as STM32F103, but uses different names for literally the same thing. 67/* This chip has the same API as STM32F103, but uses different names for literally the same thing.
56 * As of 4.7.2021 QMK is tailored to use STM32 defines/names, for compatibility sake 68 * As of 4.7.2021 QMK is tailored to use STM32 defines/names, for compatibility sake
diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c
index 63e85ae87..43591d56f 100644
--- a/platforms/chibios/drivers/i2c_master.c
+++ b/platforms/chibios/drivers/i2c_master.c
@@ -38,6 +38,9 @@ static const I2CConfig i2cconfig = {
38 I2C1_OPMODE, 38 I2C1_OPMODE,
39 I2C1_CLOCK_SPEED, 39 I2C1_CLOCK_SPEED,
40 I2C1_DUTY_CYCLE, 40 I2C1_DUTY_CYCLE,
41#elif defined(WB32F3G71xx)
42 I2C1_OPMODE,
43 I2C1_CLOCK_SPEED,
41#else 44#else
42 // This configures the I2C clock to 400khz assuming a 72Mhz clock 45 // This configures the I2C clock to 400khz assuming a 72Mhz clock
43 // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html 46 // For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c
index c592369dd..dde0bb059 100644
--- a/platforms/chibios/drivers/spi_master.c
+++ b/platforms/chibios/drivers/spi_master.c
@@ -54,6 +54,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
54 return false; 54 return false;
55 } 55 }
56 56
57#ifndef WB32F3G71xx
57 uint16_t roundedDivisor = 2; 58 uint16_t roundedDivisor = 2;
58 while (roundedDivisor < divisor) { 59 while (roundedDivisor < divisor) {
59 roundedDivisor <<= 1; 60 roundedDivisor <<= 1;
@@ -62,6 +63,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
62 if (roundedDivisor < 2 || roundedDivisor > 256) { 63 if (roundedDivisor < 2 || roundedDivisor > 256) {
63 return false; 64 return false;
64 } 65 }
66#endif
65 67
66#if defined(K20x) || defined(KL2x) 68#if defined(K20x) || defined(KL2x)
67 spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1); 69 spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1);
@@ -135,6 +137,37 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) {
135 } 137 }
136 138
137 spiConfig.cpr = (roundedDivisor - 1) >> 1; 139 spiConfig.cpr = (roundedDivisor - 1) >> 1;
140
141#elif defined(WB32F3G71xx)
142 if (!lsbFirst) {
143 osalDbgAssert(lsbFirst != FALSE, "unsupported lsbFirst");
144 }
145
146 if (divisor < 1) {
147 return false;
148 }
149
150 spiConfig.SPI_BaudRatePrescaler = (divisor << 2);
151
152 switch (mode) {
153 case 0:
154 spiConfig.SPI_CPHA = SPI_CPHA_1Edge;
155 spiConfig.SPI_CPOL = SPI_CPOL_Low;
156 break;
157 case 1:
158 spiConfig.SPI_CPHA = SPI_CPHA_2Edge;
159 spiConfig.SPI_CPOL = SPI_CPOL_Low;
160 break;
161 case 2:
162 spiConfig.SPI_CPHA = SPI_CPHA_1Edge;
163 spiConfig.SPI_CPOL = SPI_CPOL_High;
164 break;
165 case 3:
166 spiConfig.SPI_CPHA = SPI_CPHA_2Edge;
167 spiConfig.SPI_CPOL = SPI_CPOL_High;
168 break;
169 }
170
138#else 171#else
139 spiConfig.cr1 = 0; 172 spiConfig.cr1 = 0;
140 173
diff --git a/platforms/chibios/drivers/uart.c b/platforms/chibios/drivers/uart.c
index 297c1892c..d2ea5d641 100644
--- a/platforms/chibios/drivers/uart.c
+++ b/platforms/chibios/drivers/uart.c
@@ -18,7 +18,11 @@
18 18
19#include "quantum.h" 19#include "quantum.h"
20 20
21#if defined(WB32F3G71xx)
22static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_WRDLEN, SD1_STPBIT, SD1_PARITY, SD1_ATFLCT};
23#else
21static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_CR1, SD1_CR2, SD1_CR3}; 24static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_CR1, SD1_CR2, SD1_CR3};
25#endif
22 26
23void uart_init(uint32_t baud) { 27void uart_init(uint32_t baud) {
24 static bool is_initialised = false; 28 static bool is_initialised = false;
diff --git a/platforms/chibios/drivers/uart.h b/platforms/chibios/drivers/uart.h
index 5bc487590..603d51037 100644
--- a/platforms/chibios/drivers/uart.h
+++ b/platforms/chibios/drivers/uart.h
@@ -68,6 +68,22 @@
68# define SD1_CR3 0 68# define SD1_CR3 0
69#endif 69#endif
70 70
71#ifndef SD1_WRDLEN
72# define SD1_WRDLEN 3
73#endif
74
75#ifndef SD1_STPBIT
76# define SD1_STPBIT 0
77#endif
78
79#ifndef SD1_PARITY
80# define SD1_PARITY 0
81#endif
82
83#ifndef SD1_ATFLCT
84# define SD1_ATFLCT 0
85#endif
86
71void uart_init(uint32_t baud); 87void uart_init(uint32_t baud);
72 88
73void uart_write(uint8_t data); 89void uart_write(uint8_t data);
diff --git a/platforms/chibios/flash.mk b/platforms/chibios/flash.mk
index 31f69595d..6ee53172d 100644
--- a/platforms/chibios/flash.mk
+++ b/platforms/chibios/flash.mk
@@ -23,6 +23,20 @@ define EXEC_DFU_UTIL
23 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin 23 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
24endef 24endef
25 25
26
27define EXEC_WB32_DFU_UPDATER
28 if ! wb32-dfu-updater_cli -l | grep -q "Found DFU"; then \
29 printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
30 sleep $(BOOTLOADER_RETRY_TIME) ;\
31 while ! wb32-dfu-updater_cli -l | grep -q "Found DFU"; do \
32 printf "." ;\
33 sleep $(BOOTLOADER_RETRY_TIME) ;\
34 done ;\
35 printf "\n" ;\
36 fi
37 wb32-dfu-updater_cli -D $(BUILD_DIR)/$(TARGET).bin
38endef
39
26dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter 40dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
27 $(call EXEC_DFU_UTIL) 41 $(call EXEC_DFU_UTIL)
28 42
@@ -82,6 +96,8 @@ else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062)
82 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY) 96 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY)
83else ifeq ($(strip $(MCU_FAMILY)),STM32) 97else ifeq ($(strip $(MCU_FAMILY)),STM32)
84 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) 98 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL)
99else ifeq ($(strip $(MCU_FAMILY)),WB32)
100 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_WB32_DFU_UPDATER)
85else ifeq ($(strip $(MCU_FAMILY)),GD32V) 101else ifeq ($(strip $(MCU_FAMILY)),GD32V)
86 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) 102 $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL)
87else 103else
diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk
index 1c8d43007..45e337788 100644
--- a/platforms/chibios/platform.mk
+++ b/platforms/chibios/platform.mk
@@ -141,6 +141,10 @@ ifdef STM32_BOOTLOADER_ADDRESS
141 OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) 141 OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS)
142endif 142endif
143 143
144ifdef WB32_BOOTLOADER_ADDRESS
145 OPT_DEFS += -DWB32_BOOTLOADER_ADDRESS=$(WB32_BOOTLOADER_ADDRESS)
146endif
147
144# Work out if we need to set up the include for the bootloader definitions 148# Work out if we need to set up the include for the bootloader definitions
145ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","") 149ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","")
146 OPT_DEFS += -include $(KEYBOARD_PATH_5)/bootloader_defs.h 150 OPT_DEFS += -include $(KEYBOARD_PATH_5)/bootloader_defs.h