Skip to content

Commit 59ccace

Browse files
committed
first version
1 parent 2aa4510 commit 59ccace

37 files changed

+14400
-0
lines changed

bsp/stm32/stm32f407-spark/.config

+737
Large diffs are not rendered by default.

bsp/stm32/stm32f407-spark/.gitignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
*.pyc
2+
*.map
3+
*.dblite
4+
*.elf
5+
*.bin
6+
*.hex
7+
*.axf
8+
*.exe
9+
*.pdb
10+
*.idb
11+
*.ilk
12+
*.old
13+
build
14+
Debug
15+
documentation/html
16+
packages/
17+
*~
18+
*.o
19+
*.obj
20+
*.out
21+
*.bak
22+
*.dep
23+
*.lib
24+
*.i
25+
*.d
26+
.DS_Stor*
27+
.config 3
28+
.config 4
29+
.config 5
30+
Midea-X1
31+
*.uimg
32+
GPATH
33+
GRTAGS
34+
GTAGS
35+
.vscode
36+
JLinkLog.txt
37+
JLinkSettings.ini
38+
DebugConfig/
39+
RTE/
40+
settings/
41+
*.uvguix*
42+
cconfig.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project>
3+
<configuration id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.553091094" name="Debug">
4+
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5+
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6+
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
7+
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
8+
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-593847343549198934" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT ARM Cross GCC Built-in Compiler Settings " parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
9+
<language-scope id="org.eclipse.cdt.core.gcc"/>
10+
<language-scope id="org.eclipse.cdt.core.g++"/>
11+
</provider>
12+
</extension>
13+
</configuration>
14+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
content-types/enabled=true
2+
content-types/org.eclipse.cdt.core.asmSource/file-extensions=s
3+
eclipse.preferences.version=1

bsp/stm32/stm32f407-spark/Kconfig

+21
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/stm32/stm32f407-spark/README.md

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# STM32F407 星火一号开发板 BSP 说明
2+
3+
## 简介
4+
5+
本文档为 RT-Thread 开发团队为 STM32F407 星火1号开发板提供的 BSP (板级支持包) 说明。
6+
7+
主要内容如下:
8+
9+
- 开发板资源介绍
10+
- BSP 快速上手
11+
- 进阶使用方法
12+
13+
通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
14+
15+
## 开发板介绍
16+
17+
星火号 STM32F407 是RT-THREAD推出的一款基于 ARM Cortex-M4 内核的开发板,最高主频为 168Mhz,该开发板具有丰富的板载资源,可以充分发挥 STM32F407 的芯片性能。
18+
19+
开发板外观如下图所示:
20+
21+
![board](figures/board.png)
22+
23+
该开发板常用 **板载资源** 如下:
24+
25+
- MCU:STM32F407ZGT6,主频 168MHz,1024KB FLASH ,192KB RAM
26+
- 外部 FLASH:W25Q128(SPI,16MB)
27+
- 常用外设
28+
- LED:2个,LED_R(红色,PF12),LED_B(绿色,PF11)
29+
- 按键,4个,KEY_UP(兼具唤醒功能,PIN:PC5),KEY_DOWN(PIN:PC1),KEY_LEFT(PIN:PC0),KEY_RIGHT(PIN:PC4)
30+
- 常用接口:USB 转串口、SD 卡接口、USB SLAVE、USB HOST
31+
- 调试接口,标准ST-LINK
32+
33+
开发板更多详细信息请参考官方文档 [STM32 星火一号开发板介绍](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/hw-board/spark-1/spark-1)
34+
35+
## 外设支持
36+
37+
本 BSP 目前对外设的支持情况如下:
38+
39+
| **板载外设** | **支持情况** | **备注** |
40+
| :------------ | :----------: | :-----------------------------------: |
41+
| USB 转串口(COM1) | 支持 | |
42+
| COM2 | 支持 | 和以太网、PWM 冲突,如需使用该外设,请使用 CubeMX 重新配置 UART2 管脚 |
43+
| COM3 | 支持 | |
44+
| MPU6050 | 支持 | |
45+
| Flash | 支持 | |
46+
| SRAM | 支持 | LVGL 会使用到,但此时不能启用 RT_USING_MEMHEAP_AS_HEAP 内存算法 |
47+
| TFTLCD | 支持 | F407 不带 LTDC 外设,所以需要使用 MCU LCD,而不能直接驱动 RGB 屏幕 |
48+
| LCD-TOUCH | 支持 | 仅测试过 GT9147, 其他触摸驱动需要添加适配 |
49+
| SD卡 | 支持 | 支持FATFS文件系统 |
50+
| W25Q128 | 支持 | 支持LittleFS文件系统 |
51+
| 以太网 | 支持 | |
52+
| WM8978 | 暂不支持 | |
53+
| **片上外设** | **支持情况** | **备注** |
54+
| GPIO | 支持 | PA0, PA1... PH1 ---> PIN: 0, 1...144 |
55+
| UART | 支持 | UART1/2/3 |
56+
| SPI | 支持 | SPI1/2/3 |
57+
| I2C | 支持 | 软件 I2C1, I2C2[仅触摸屏使用] |
58+
| ADC | 支持 | |
59+
| RTC | 支持 | 支持外部晶振和内部低速时钟 |
60+
| WDT | 支持 | |
61+
| FLASH | 支持 | 已适配 [FAL](https://github.com/RT-Thread-packages/fal) |
62+
| PWM | 支持 | |
63+
| USB Device | 支持 | |
64+
| USB Host | 支持 | |
65+
| **扩展模块** | **支持情况** | **备注** |
66+
| ATK-ESP8266 模块 | 支持 | COM3 |
67+
68+
69+
## 使用说明
70+
71+
使用说明分为如下两个章节:
72+
73+
- 快速上手
74+
75+
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
76+
77+
- 进阶使用
78+
79+
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
80+
81+
82+
### 快速上手
83+
84+
本 BSP 为开发者提供 MDK4、MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
85+
86+
#### 硬件连接
87+
88+
使用数据线连接开发板到 PC,打开电源开关。
89+
90+
#### 编译下载
91+
92+
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
93+
94+
> 工程默认配置使用 JLink 下载程序,在通过 JLink 连接开发板的基础上,点击下载按钮即可下载程序到开发板
95+
96+
#### 运行结果
97+
98+
下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,红色 LED 常亮、绿色 LED 会周期性闪烁。
99+
100+
连接开发板对应串口到 PC , 在终端工具里打开相应的串口(115200-8-1-N),复位设备后,可以看到 RT-Thread 的输出信息:
101+
102+
```bash
103+
104+
\ | /
105+
- RT - Thread Operating System
106+
/ | \ 5.0.1 build Jul 4 2023 07:49:10
107+
2006 - 2022 Copyright by RT-Thread team
108+
msh >
109+
```
110+
### 进阶使用
111+
112+
此 BSP 默认只开启了 GPIO 和 串口1 的功能,如果需使用 SD 卡、Flash 等更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
113+
114+
1. 在 bsp 下打开 env 工具。
115+
116+
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
117+
118+
3. 输入`pkgs --update`命令更新软件包。
119+
120+
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
121+
122+
本章节更多详细的介绍请参考 [STM32 系列 BSP 外设驱动使用教程](../docs/STM32系列BSP外设驱动使用教程.md)
123+
124+
## 注意事项
125+
126+
暂无
127+
128+
## 联系人信息
129+
130+
维护人:
131+
132+
- [Supperthomas](https://github.com/supperthomas)

bsp/stm32/stm32f407-spark/SConscript

+15
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/stm32/stm32f407-spark/SConstruct

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 = 'rt-thread.' + rtconfig.TARGET_EXT
19+
20+
DefaultEnvironment(tools=[])
21+
env = Environment(tools = ['mingw'],
22+
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
23+
CC = rtconfig.CC, CFLAGS = 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 in ['iccarm']:
30+
env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
31+
env.Replace(ARFLAGS = [''])
32+
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.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 = 'STM32F4xx_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'), variant_dir='build/libraries/'+stm32_library, duplicate=0))
55+
# include drivers
56+
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript'),variant_dir='build/libraries/'+'HAL_Drivers', duplicate=0))
57+
58+
# make a building
59+
DoBuilding(TARGET, objs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from building import *
2+
import os
3+
4+
cwd = GetCurrentDir()
5+
CPPPATH = [cwd]
6+
src = Glob('*.c')
7+
8+
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
9+
10+
list = os.listdir(cwd)
11+
for item in list:
12+
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
13+
group = group + SConscript(os.path.join(item, 'SConscript'))
14+
15+
Return('group')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2023, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2023-07-06 Supperthomas first version
9+
*/
10+
11+
12+
#include <rtthread.h>
13+
#include <rtdevice.h>
14+
#include <board.h>
15+
16+
/* defined the LED0 pin: PF9 */
17+
#define GPIO_LED_B GET_PIN(F, 11)
18+
#define GPIO_LED_R GET_PIN(F, 12)
19+
int main(void)
20+
{
21+
/* set LED0 pin mode to output */
22+
rt_pin_mode(GPIO_LED_R, PIN_MODE_OUTPUT);
23+
24+
while (1)
25+
{
26+
rt_pin_write(GPIO_LED_R, PIN_HIGH);
27+
rt_thread_mdelay(500);
28+
rt_pin_write(GPIO_LED_R, PIN_LOW);
29+
rt_thread_mdelay(500);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# files format check exclude path, please follow the instructions below to modify;
2+
# If you need to exclude an entire folder, add the folder path in dir_path;
3+
# If you need to exclude a file, add the path to the file in file_path.
4+
5+
dir_path:
6+
- CubeMX_Config

0 commit comments

Comments
 (0)