Skip to content

Commit d55f310

Browse files
committed
add gd32407v-start
1 parent dca7dcb commit d55f310

File tree

102 files changed

+48200
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+48200
-2
lines changed

bsp/gd32/gd32407v-start/.config

Lines changed: 571 additions & 0 deletions
Large diffs are not rendered by default.

bsp/gd32/gd32407v-start/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
mainmenu "RT-Thread Configuration"
2+
3+
config BSP_DIR
4+
string
5+
option env="BSP_ROOT"
6+
default "."
7+
8+
config RTT_DIR
9+
string
10+
option env="RTT_ROOT"
11+
default "../../.."
12+
13+
config PKGS_DIR
14+
string
15+
option env="PKGS_ROOT"
16+
default "packages"
17+
18+
source "$RTT_DIR/Kconfig"
19+
source "$PKGS_DIR/Kconfig"
20+
source "../libraries/Kconfig"
21+
source "board/Kconfig"

bsp/gd32/gd32407v-start/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# GD32407V-START开发板BSP说明
2+
3+
## 简介
4+
5+
GD32407V-STARTL是-兆易创新推出的一款GD32F4XX系列的评估板,最高主频高达168M,该开发板具有丰富的板载资源,可以充分发挥 GD32407V 的芯片性能。
6+
7+
8+
开发板外观如下图所示:
9+
10+
![board](figures/board.jpg)
11+
12+
该开发板常用 **板载资源** 如下:
13+
14+
- GD32407V,主频 168MHz,3072KB FLASH ,192KB RAM
15+
16+
- 常用外设
17+
18+
- LED :3个,LED1 (电源指示灯),LED2(PC6)
19+
- 按键:2个,K1(复位引脚),K2(用户按键,PA0)
20+
21+
- 常用接口:USB 接口
22+
23+
- 调试接口:GD-LINK
24+
25+
26+
27+
## 使用说明
28+
29+
使用说明分为如下两个章节:
30+
31+
- 快速上手
32+
33+
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
34+
35+
- 进阶使用
36+
37+
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
38+
39+
40+
### 快速上手
41+
42+
本 BSP 为开发者提供 MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
43+
44+
#### 硬件连接
45+
46+
使用数据线连接开发板到 PC,使用USB转TTL模块连接PA2(MCU TX)和PA3(MCU RX),打开电源开关。
47+
48+
#### 编译下载
49+
50+
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
51+
52+
> 工程默认配置使用 GD-Link 仿真器下载程序,在通过 GD-Link 连接开发板的基础上,点击下载按钮即可下载程序到开发板
53+
54+
#### 运行结果
55+
56+
下载程序成功之后,系统会自动运行,LED 闪烁。
57+
58+
连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
59+
60+
```bash
61+
\ | /
62+
- RT - Thread Operating System
63+
/ | \ 4.0.4 build Jan 9 2021
64+
2006 - 2021 Copyright by rt-thread team
65+
msh >
66+
```
67+
68+
### 进阶使用
69+
70+
此 BSP 默认只开启了 GPIO 和 串口1的功能,如果需使用高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
71+
72+
1. 在 bsp 下打开 env 工具。
73+
74+
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
75+
76+
3. 输入`pkgs --update`命令更新软件包。
77+
78+
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
79+
80+
## 注意事项
81+
82+
暂无
83+
84+
## 联系人信息
85+
86+
维护人:
87+
88+
- [BruceOu](https://github.com/Ouxiaolong/), 邮箱:<[email protected]>

bsp/gd32/gd32407v-start/SConscript

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# for module compiling
2+
import os
3+
Import('RTT_ROOT')
4+
from building import *
5+
6+
cwd = GetCurrentDir()
7+
objs = []
8+
list = os.listdir(cwd)
9+
10+
for d in list:
11+
path = os.path.join(cwd, d)
12+
if os.path.isfile(os.path.join(path, 'SConscript')):
13+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
14+
15+
Return('objs')

bsp/gd32/gd32407v-start/SConstruct

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import os
2+
import sys
3+
import rtconfig
4+
5+
if os.getenv('RTT_ROOT'):
6+
RTT_ROOT = os.getenv('RTT_ROOT')
7+
else:
8+
RTT_ROOT = os.path.normpath(os.getcwd() + '/../../..')
9+
10+
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
11+
try:
12+
from building import *
13+
except:
14+
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
15+
print(RTT_ROOT)
16+
exit(-1)
17+
18+
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
19+
20+
DefaultEnvironment(tools=[])
21+
env = Environment(tools = ['mingw'],
22+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
23+
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
24+
AR = rtconfig.AR, ARFLAGS = '-rc',
25+
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
26+
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
27+
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
28+
29+
if rtconfig.PLATFORM == 'iar':
30+
env.Replace(CCCOM = ['$CC $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
31+
env.Replace(ARFLAGS = [''])
32+
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rtthread.map')
33+
34+
Export('RTT_ROOT')
35+
Export('rtconfig')
36+
37+
SDK_ROOT = os.path.abspath('./')
38+
39+
if os.path.exists(SDK_ROOT + '/libraries'):
40+
libraries_path_prefix = SDK_ROOT + '/libraries'
41+
else:
42+
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
43+
44+
SDK_LIB = libraries_path_prefix
45+
Export('SDK_LIB')
46+
47+
# prepare building environment
48+
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
49+
50+
stm32_library = 'GD32F4xx_HAL'
51+
rtconfig.BSP_LIBRARY_TYPE = stm32_library
52+
53+
# include libraries
54+
objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
55+
56+
# include drivers
57+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
58+
59+
# make a building
60+
DoBuilding(TARGET, objs)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Import('RTT_ROOT')
2+
Import('rtconfig')
3+
from building import *
4+
5+
cwd = os.path.join(str(Dir('#')), 'applications')
6+
src = Glob('*.c')
7+
CPPPATH = [cwd, str(Dir('#'))]
8+
9+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
10+
11+
Return('group')
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-08-20 BruceOu first implementation
9+
*/
10+
11+
#include <stdio.h>
12+
#include <rtthread.h>
13+
#include <rtdevice.h>
14+
#include <board.h>
15+
16+
/* defined the LED2 pin: PC6 */
17+
#define LED2_PIN GET_PIN(C, 6)
18+
19+
int main(void)
20+
{
21+
int count = 1;
22+
23+
/* set LED2 pin mode to output */
24+
rt_pin_mode(LED2_PIN, PIN_MODE_OUTPUT);
25+
26+
while (count++)
27+
{
28+
rt_pin_write(LED2_PIN, PIN_HIGH);
29+
rt_thread_mdelay(500);
30+
rt_pin_write(LED2_PIN, PIN_LOW);
31+
rt_thread_mdelay(500);
32+
}
33+
34+
return RT_EOK;
35+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
menu "Hardware Drivers Config"
2+
3+
config SOC_GD32407V
4+
bool
5+
select SOC_SERIES_GD32F4
6+
select RT_USING_COMPONENTS_INIT
7+
select RT_USING_USER_MAIN
8+
default y
9+
10+
menu "Onboard Peripheral Drivers"
11+
12+
endmenu
13+
14+
menu "On-chip Peripheral Drivers"
15+
16+
config BSP_USING_GPIO
17+
bool "Enable GPIO"
18+
select RT_USING_PIN
19+
default y
20+
21+
menuconfig BSP_USING_UART
22+
bool "Enable UART"
23+
default y
24+
select RT_USING_SERIAL
25+
if BSP_USING_UART
26+
config BSP_USING_UART1
27+
bool "Enable UART1"
28+
default y
29+
30+
config BSP_UART1_RX_USING_DMA
31+
bool "Enable UART1 RX DMA"
32+
depends on BSP_USING_UART1 && RT_SERIAL_USING_DMA
33+
default n
34+
endif
35+
36+
menuconfig BSP_USING_SPI
37+
bool "Enable SPI BUS"
38+
default n
39+
select RT_USING_SPI
40+
if BSP_USING_SPI
41+
config BSP_USING_SPI1
42+
bool "Enable SPI1 BUS"
43+
default n
44+
45+
config BSP_SPI1_TX_USING_DMA
46+
bool "Enable SPI1 TX DMA"
47+
depends on BSP_USING_SPI1
48+
default n
49+
50+
config BSP_SPI1_RX_USING_DMA
51+
bool "Enable SPI1 RX DMA"
52+
depends on BSP_USING_SPI1
53+
select BSP_SPI1_TX_USING_DMA
54+
default n
55+
endif
56+
57+
menuconfig BSP_USING_I2C1
58+
bool "Enable I2C1 BUS (software simulation)"
59+
default n
60+
select RT_USING_I2C
61+
select RT_USING_I2C_BITOPS
62+
select RT_USING_PIN
63+
if BSP_USING_I2C1
64+
config BSP_I2C1_SCL_PIN
65+
int "i2c1 scl pin number"
66+
range 1 216
67+
default 24
68+
config BSP_I2C1_SDA_PIN
69+
int "I2C1 sda pin number"
70+
range 1 216
71+
default 25
72+
endif
73+
source "../libraries/HAL_Drivers/Kconfig"
74+
75+
endmenu
76+
77+
menu "Board extended module Drivers"
78+
79+
endmenu
80+
81+
endmenu
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import rtconfig
3+
from building import *
4+
5+
Import('SDK_LIB')
6+
7+
cwd = GetCurrentDir()
8+
9+
# add general drivers
10+
src = Split('''
11+
board.c
12+
''')
13+
14+
path = [cwd]
15+
16+
startup_path_prefix = SDK_LIB
17+
18+
if rtconfig.CROSS_TOOL == 'gcc':
19+
src += [startup_path_prefix + '/GD32F4xx_HAL/CMSIS/GD/GD32F4xx/Source/GCC/startup_gd32f4xx.S']
20+
elif rtconfig.CROSS_TOOL == 'keil':
21+
src += [startup_path_prefix + '/GD32F4xx_HAL/CMSIS/GD/GD32F4xx/Source/ARM/startup_gd32f4xx.s']
22+
elif rtconfig.CROSS_TOOL == 'iar':
23+
src += [startup_path_prefix + '/GD32F4xx_HAL/CMSIS/GD/GD32F4xx/Source/IAR/startup_gd32f4xx.s']
24+
25+
CPPDEFINES = ['GD3232F407xx']
26+
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
27+
28+
Return('group')

0 commit comments

Comments
 (0)