Skip to content

Commit 7f27e6c

Browse files
committed
boards/gd32vf103c-start: new board
This adds support for the GD32VF103C-START, the official "starter board" for the GD32VF103C MCU by the MCU vendor.
1 parent 9fbb23b commit 7f27e6c

File tree

10 files changed

+576
-0
lines changed

10 files changed

+576
-0
lines changed

boards/gd32vf103c-start/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MODULE = board
2+
3+
include $(RIOTBASE)/Makefile.base
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ifneq (,$(filter saul_default,$(USEMODULE)))
2+
USEMODULE += saul_gpio
3+
endif
4+
5+
include $(RIOTBOARD)/common/gd32v/Makefile.dep
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CPU_MODEL = gd32vf103cbt6
2+
3+
# Put defined MCU peripherals here (in alphabetical order)
4+
FEATURES_PROVIDED += periph_adc
5+
FEATURES_PROVIDED += periph_i2c
6+
FEATURES_PROVIDED += periph_pwm
7+
FEATURES_PROVIDED += periph_spi
8+
FEATURES_PROVIDED += periph_timer
9+
FEATURES_PROVIDED += periph_uart
10+
FEATURES_PROVIDED += periph_usbdev
11+
FEATURES_PROVIDED += sdcard_spi
12+
13+
# Other features provided by the board (in alphabetical order)
14+
FEATURES_PROVIDED += arduino_analog
15+
FEATURES_PROVIDED += arduino_i2c
16+
FEATURES_PROVIDED += arduino_pins
17+
FEATURES_PROVIDED += arduino_pwm
18+
FEATURES_PROVIDED += arduino_shield_uno
19+
FEATURES_PROVIDED += arduino_spi
20+
FEATURES_PROVIDED += arduino_uart
21+
FEATURES_PROVIDED += highlevel_stdio
22+
FEATURES_PROVIDED += tinyusb_device
23+
24+
include $(RIOTBOARD)/common/gd32v/Makefile.features
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PORT_LINUX ?= /dev/ttyACM0
2+
PROGRAMMER ?= openocd
3+
OPENOCD_DEBUG_ADAPTER ?= dap
4+
OPENOCD_TRANSPORT := default
5+
6+
# Only consider TTYs matching the following filter when auto-selecting the TTY
7+
# with `MOST_RECENT_PORT=1`.
8+
TTY_BOARD_FILTER := --driver 'ch341' --model 'USB2.0-Serial'
9+
10+
include $(RIOTBOARD)/common/gd32v/Makefile.include
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
adapter speed 10000
2+
source [find target/gd32vf103.cfg]

boards/gd32vf103c-start/doc.txt

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**
2+
@defgroup boards_gd32vf103c_start GD32VF103C-START
3+
@ingroup boards
4+
@brief Support for the GD32VF103C-START board
5+
@author Marian Buschsieweke
6+
7+
## Overview
8+
9+
The GD32VF103C-START development board is an official starter kit by GigaDevice
10+
for the GD32VF103CBT6 MCU, despite the lack of official documentation. It
11+
featrures:
12+
13+
- GD32VF103CBT6 RISC-V MCU @108MHz
14+
- On-Board GD-Link Programmer/Debugger (middle mini-USB connector)
15+
- USB-OTG (left mini-USB connector)
16+
- Integrated USB to UART bridge (right mini-USB connector)
17+
- 1 user LED
18+
- 1 user Button
19+
- 1 reset button
20+
- Arduino UNO compatible pin headers (except ISP header)
21+
22+
![Image of the GD32VF103C-START board](https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/a0ac2faf9bde45b176f1e8b315ffb1b8a9096166/boards/riscv/gd32vf103c_starter/doc/img/gd32vf103c_starter.jpg)
23+
24+
@warning The analog pins are labeled A1 - A6 rather than A0 - A5, as would
25+
be the correct Arduino naming. The Arduino pin mapping uses the
26+
correct Arduino naming, so that apps written for other boards
27+
expecting Arduino UNO compatible shields remain compatible.
28+
29+
## Hardware
30+
31+
| MCU | GD32VF103CBT6 | Supported |
32+
|:----------------- |:----------------------------------------- | --------- |
33+
| Family | RISC-V with ECLIC | |
34+
| Vendor | GigaDevice | |
35+
| RAM | 32 KiB | |
36+
| Flash | 128 KiB | |
37+
| Frequency | 108 MHz | |
38+
| Power Modes | 3 (Sleep, Deep Sleep, Standby) | yes |
39+
| GPIOs | 37 | yes |
40+
| Timers | 5 x 16-bit timer | yes |
41+
| RTC | 1 x 32-bit counter, 20-bit prescaler | yes |
42+
| WDT | 2 x 12-bit counter, 3-bit prescaler | yes |
43+
| ADC | 2 x 12-bit units, 16 channels @ 1 Msps | yes |
44+
| DAC | 2 x 12-bit channel | yes |
45+
| UART | - | yes |
46+
| USART | 3 | yes |
47+
| SPI | 3 | yes |
48+
| I2C | 2 x Fast Mode 400 kHz | yes |
49+
| I2S | 2 | no |
50+
| CAN | 2 x CAN 2.0B with up to 1 Mbps | no |
51+
| PWM | 6 Channels | yes |
52+
| USB | 1 x USB FS OTG (+ GD-Link + UART bridge) | yes |
53+
| Vcc | 3.0V - 3.6V | |
54+
| Datasheet | [Datasheet][gd32vf103c-datasheet] | |
55+
| User Manual | [User Manual][gd32vf103c-manual] | |
56+
| Board Manual | [Board Manual][gd32vf103c-board-manual] | |
57+
58+
[gd32vf103c-datasheet]: https://web.archive.org/web/20240117072854/https://gd32mcu.com/data/documents/datasheet/GD32VF103_Datasheet_Rev1.6.pdf
59+
[gd32vf103c-manual]: https://web.archive.org/web/20240117073025/https://gd32mcu.com/data/documents/userManual/GD32VF103_User_Manual_Rev1.5.pdf
60+
[gd32vf103c-board-manual]: https://web.archive.org/web/20240117072723/https://en.maritex.com.pl/product/attachment/154626/6f28fdabafb9dff852537ced7bc0aa71
61+
62+
## Flashing
63+
64+
@warning Flashing seems to fail with some Arduino UNO compatible boards
65+
attached. Remove them and try again.
66+
67+
By default, flashing is done via OpenOCD using the GD-Link programmer/debugger
68+
using:
69+
70+
```
71+
make BOARD=gd32vf103c-start -C path/to/app flash
72+
```
73+
74+
It is also possible to flash via DFU-Util:
75+
76+
1. Connect a mini USB cable to the USB connector labeled OTG.
77+
2. Power the board (e.g. by connecting a second mini USB cable to the GD-Link
78+
programmer/debugger, even though we won't use it)
79+
3. Enter the DFU bootloader by placing the jumper on JP4 (below BOOT) in
80+
position H. Press the reset button afterwards.
81+
4. Run `make BOARD=gd32vf103c-start PROGRAMMER=dfu-util -C path/to/app flash`
82+
5. Restore the JP4 jumper to position L. Afterwards press the reset button
83+
again
84+
85+
## Connecting to the Serial Output
86+
87+
By default RIOT's uses UART for `stdio`. To access that, connect a mini USB
88+
cable to the connector labeled "USART". In addition a jumper needs to be
89+
placed on JP2 in the "Usart" position; otherwise RIOT's TXD is not connected
90+
to the RXD of the integrated USB UART bridge. Afterwards just run:
91+
92+
```
93+
make BOARD=gd32vf103c-start -C path/to/app term
94+
```
95+
96+
Alternatively, `stdio_cdc_acm` can be used. In this case the mini USB cable
97+
needs to be connected to the USB connector labeled OTG.
98+
99+
@note It is safe to keep the jumper at JP2 in "Usart" position or even
100+
remove the jumper with RIOT. PA9 is still used as UART/TXD and VBUS
101+
sensing is disabled anyway.
102+
103+
*/
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*
2+
* Copyright (C) 2024 Marian Buschsieweke
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser
5+
* General Public License v2.1. See the file LICENSE in the top level
6+
* directory for more details.
7+
*/
8+
9+
/**
10+
* @ingroup boards_gd32vf103c_start
11+
* @{
12+
*
13+
* @file
14+
* @brief Mapping from MCU pins to Arduino pins
15+
*
16+
* You can use the defines in this file for simplified interaction with the
17+
* Arduino specific pin numbers.
18+
*
19+
* @author Marian Buschsieweke <[email protected]>
20+
*/
21+
22+
#ifndef ARDUINO_IOMAP_H
23+
#define ARDUINO_IOMAP_H
24+
25+
#include "macros/units.h"
26+
#include "periph/adc.h"
27+
#include "periph/gpio.h"
28+
#include "periph/pwm.h"
29+
#include "periph_conf.h"
30+
31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
35+
/**
36+
* @name Arduino's UART devices
37+
* @{
38+
*/
39+
#define ARDUINO_UART_D0D1 UART_DEV(0)
40+
/** @} */
41+
42+
/**
43+
* @name Arduino's SPI buses
44+
* @{
45+
*/
46+
/**
47+
* @brief SPI_DEV(0) is connected to D11/D12/D13
48+
*/
49+
#define ARDUINO_SPI_D11D12D13 SPI_DEV(0)
50+
/** @} */
51+
52+
/**
53+
* @name Arduino's I2C buses
54+
* @{
55+
*/
56+
/**
57+
* @brief The first I2C bus is where shields for the Arduino UNO expect it
58+
*/
59+
#define ARDUINO_I2C_UNO I2C_DEV(0)
60+
/** @} */
61+
62+
/**
63+
* @brief Mapping of MCU pins to Arduino pins
64+
* @{
65+
*/
66+
#define ARDUINO_PIN_0 GPIO_PIN(PORT_A, 10)
67+
#define ARDUINO_PIN_1 GPIO_PIN(PORT_A, 9)
68+
#define ARDUINO_PIN_2 GPIO_PIN(PORT_B, 4)
69+
#define ARDUINO_PIN_3 GPIO_PIN(PORT_B, 5)
70+
#define ARDUINO_PIN_4 GPIO_PIN(PORT_B, 6)
71+
#define ARDUINO_PIN_5 GPIO_PIN(PORT_B, 7)
72+
#define ARDUINO_PIN_6 GPIO_PIN(PORT_B, 8)
73+
#define ARDUINO_PIN_7 GPIO_PIN(PORT_B, 9)
74+
75+
#define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 1)
76+
#define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 0)
77+
#define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 12)
78+
#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 15)
79+
#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 14)
80+
#define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 13)
81+
#define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 11)
82+
#define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 10)
83+
84+
#define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 1)
85+
#define ARDUINO_PIN_17 GPIO_PIN(PORT_A, 2)
86+
#define ARDUINO_PIN_18 GPIO_PIN(PORT_A, 3)
87+
#define ARDUINO_PIN_19 GPIO_PIN(PORT_B, 4)
88+
#define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 5)
89+
#define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 6)
90+
91+
#define ARDUINO_PIN_LAST 21
92+
/** @} */
93+
94+
/**
95+
* @name Aliases for analog pins
96+
* @warning Silkscreen label is A1 - A6 instead of A0 - A5. We stick with
97+
* Arduino UNO labeling here so that e.g. board independent drivers
98+
* for shields can be provided.
99+
* @{
100+
*/
101+
#define ARDUINO_PIN_A0 ARDUINO_PIN_16
102+
#define ARDUINO_PIN_A1 ARDUINO_PIN_17
103+
#define ARDUINO_PIN_A2 ARDUINO_PIN_18
104+
#define ARDUINO_PIN_A3 ARDUINO_PIN_19
105+
#define ARDUINO_PIN_A4 ARDUINO_PIN_20
106+
#define ARDUINO_PIN_A5 ARDUINO_PIN_21
107+
/** @} */
108+
109+
/**
110+
* @name Mapping of Arduino analog pins to RIOT ADC lines
111+
* @{
112+
*/
113+
#define ARDUINO_A0 ADC_LINE(0)
114+
#define ARDUINO_A1 ADC_LINE(1)
115+
#define ARDUINO_A2 ADC_LINE(2)
116+
#define ARDUINO_A3 ADC_LINE(3)
117+
#define ARDUINO_A4 ADC_LINE(4)
118+
#define ARDUINO_A5 ADC_LINE(5)
119+
120+
#define ARDUINO_ANALOG_PIN_LAST 5
121+
/** @} */
122+
123+
/**
124+
* @name Mapping of Arduino pins to RIOT PWM dev and channel pairs
125+
* @{
126+
*/
127+
/**
128+
* @brief PWM frequency
129+
*/
130+
#define ARDUINO_PWM_FREQU KHZ(100)
131+
132+
#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0)
133+
#define ARDUINO_PIN_3_PWM_CHAN 0
134+
135+
#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(1)
136+
#define ARDUINO_PIN_5_PWM_CHAN 0
137+
138+
#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(1)
139+
#define ARDUINO_PIN_6_PWM_CHAN 1
140+
141+
#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0)
142+
#define ARDUINO_PIN_9_PWM_CHAN 1
143+
/** @} */
144+
145+
#ifdef __cplusplus
146+
}
147+
#endif
148+
149+
#endif /* ARDUINO_IOMAP_H */
150+
/** @} */
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2024 Marian Buschsieweke
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser
5+
* General Public License v2.1. See the file LICENSE in the top level
6+
* directory for more details.
7+
*/
8+
9+
/**
10+
* @ingroup boards_gd32vf103c_start
11+
* @{
12+
*
13+
* @file
14+
* @brief Board specific definitions for the GD32VF103C-START board
15+
*
16+
* @author Marian Buschsieweke <[email protected]>
17+
*/
18+
19+
#ifndef BOARD_H
20+
#define BOARD_H
21+
22+
#include "board_common.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/**
29+
* @name Button pin definitions
30+
* @{
31+
*/
32+
#define BTN0_PIN GPIO_PIN(PORT_A, 0)
33+
#define BTN0_MODE GPIO_IN_PU
34+
#define BTN0_INT_FLANK GPIO_FALLING
35+
/** @} */
36+
37+
/**
38+
* @name LED (on-board) configuration
39+
* @{
40+
*/
41+
#define LED0_PIN GPIO_PIN(PORT_A, 7)
42+
#define LED0_MASK (1 << 7)
43+
#define LED0_ON (GPIOA->BC = LED0_MASK)
44+
#define LED0_OFF (GPIOA->BOP = LED0_MASK)
45+
#define LED0_TOGGLE (GPIOA->OCTL ^= LED0_MASK)
46+
/** @} */
47+
48+
#ifdef __cplusplus
49+
}
50+
#endif
51+
52+
#endif /* BOARD_H */
53+
/** @} */

0 commit comments

Comments
 (0)