[stm32][NUCLEO-STM32U575ZI] update readme
combine the beginner guide with the readme.md file
This commit is contained in:
parent
99204ab8bf
commit
6368e7ef35
|
@ -1,6 +1,6 @@
|
|||
# NUCLEO-STM32U575ZI-Q- BSP Introduction
|
||||
# Part I : NUCLEO-STM32U575ZI-Q- BSP Introduction
|
||||
|
||||
[中文](README_zh.md)
|
||||
**English** | [中文](README_zh.md)
|
||||
|
||||
## MCU: STM32U575ZI @110MHz, 2048 KB FLASH, 786 KB RAM
|
||||
|
||||
|
@ -150,3 +150,168 @@ The devices offer eight packages from 48 to 169 pins.
|
|||
## Maintained By
|
||||
|
||||
[liukang](https://github.com/liukangcc)
|
||||
|
||||
|
||||
# Part II : NUCLEO-STM32U575ZI-Q Getting Started Guide
|
||||
|
||||
NUCLEO-U575ZI-Q Getting Started Guide is introduced by using the example of SPI1 driving RW007 module to realize the introduction of NUCLEO-U575ZI-Q.
|
||||
|
||||
## Preparatory Work
|
||||
|
||||
Before NUCLEO-U575ZI-Q driver RW007 runs, the following preparations are essential, and you will need:
|
||||
|
||||
> 1.NUCLEO-U575ZI-Q
|
||||
> 2.RW007 WiFi module
|
||||
> 3.Mini-USB Connecting cable (connecting the development board with the computer)
|
||||
> 4.ENV Compile build environment([Installation instructions](https://www.rt-thread.org/document/site/#/development-tools/env/env))
|
||||
> 5.common software(git,Keil5,STM32CubeMX,Serial debugging, etc)
|
||||
|
||||
## Start on the Road
|
||||
|
||||
RT-Thread contains RW007 software package, so users don't need to write their own drivers. Taking SPI mode as an example, this paper introduces how to drive RW007 module on NUCLEO-U575ZI-Q, and complete basic WiFi functions such as AP scanning and connection.
|
||||
|
||||
## Hardware connection
|
||||
|
||||
Thanks to the Arduino interface on Nucleo, just plug RW007 into the development board, and the hardware connection between them can be completed.
|
||||
|
||||
![](figures/board1.png)
|
||||
|
||||
According to the following schematic diagram, the corresponding table between IO interfaces and functions can be found as follows:
|
||||
|
||||
![](figures/Schematic_diagram.png)
|
||||
|
||||
|STM32 pin name | pin serial number |Arduino Interface serial number|function |
|
||||
|PA5 | 5 |D13 |BOOT0/CLK |
|
||||
|PA6 | 6 |D12 |MISO |
|
||||
|PA7 | 7 |D11 |MOSI |
|
||||
|PD14 | 62 |D10 |BOOT1/CS |
|
||||
|PD15 | 63 |D9 |INT/BUSY |
|
||||
|PF12 | 92 |D8 |RESET |
|
||||
|
||||
## STM32 BSP Deploy(Menuconfig)
|
||||
### 1.Download RT-Thread Source Code
|
||||
|
||||
GitHub link:[https://github.com/RT-Thread/rt-thread](https://github.com/RT-Thread/rt-thread)
|
||||
Open the 'rt-thread\bsp\stm32' directory and you will see the development board model supported by rt-thread. It is not difficult to get RT-Thread running on STM32, but bsp needs to be configured briefly before compiling the kernel components.The bsp used in this experiment was stm32u575-st-nucleo.
|
||||
|
||||
### 2.The SPI Initializer is Configured Through CubeMX
|
||||
|
||||
In general, the pin assignment of STM32 series can open the CubeMX project corresponding to the CubeMX_Config.ioc in the board\ CubeMX_Config directory in BSP, configure SPI1, generate code, and save and exit.
|
||||
|
||||
![](figures/CubeMX.png)
|
||||
|
||||
### 3. Configure the RW007 Package Through Menuconfig
|
||||
|
||||
Go to the rt-thread\ bsp\ stm32\ stm32u575-st-nucleo folder, right-click to open the ENV window (provided that the ENV environment has been built under Windows), and type menuconfig to configure the system:
|
||||
|
||||
#### 3.1 Turn on the SPI Device
|
||||
The communication between the development board and the module depends on the SPI device. The SPI driver has been implemented in bsp and can be used as long as it is opened in the setting. Go to `On-chip Peripheral Drivers` under `On-chip Peripheral-> `, check the `Enable SPI BUS-- >` option, press enter to enter, and further select `Enable SPI1 BUS` to complete the configuration:
|
||||
|
||||
![](figures/menuconfig1.png)
|
||||
![](figures/menuconfig2.png)
|
||||
![](figures/menuconfig3.png)
|
||||
![](figures/menuconfig4.png)
|
||||
|
||||
If there is no configuration for the corresponding spi in the menuconfig in the bsp, you can increase the configuration of the corresponding spi by modifying the Kconfig file. Add the configuration of SPI1 to the path of Kconfig under board/Kconfig, `menu "On-chip Peripheral Drivers" `.
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI BUS"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 BUS"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_TX_USING_DMA
|
||||
bool "Enable SPI1 TX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_USING_DMA
|
||||
bool "Enable SPI1 RX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_SPI1_TX_USING_DMA
|
||||
default n
|
||||
|
||||
endif
|
||||
|
||||
#### 3.2 Configure the RW007 Package.
|
||||
|
||||
RT-Thread provides supporting driver support for RW007 modules in the form of software packages. The default options of the system do not include software packages. Users need to enable them manually: return to the Menuconfig main interface through the Esc key, enter `RT-Thread online packages-- > `, `IoT-internet of things->`, `Wi-Fi-- > `, and check the `rw007: SPI WIFI rw007 driver-- >` option:
|
||||
![](figures/menuconfig5.png)
|
||||
RW007 package Github repository link:[RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
|
||||
Then press Enter key to further set the parameters of the software package, complete the configuration of SPI bus and IO, change the bus device name `RW007 BUS NAME` to spi1, then configure SPI to control IO, and fill in each pin number according to the serial number of the following figure:
|
||||
![](figures/menuconfig6.png)
|
||||
|
||||
#### 3.3 Open the WiFi framework.
|
||||
|
||||
The RW007 driver uses WLAN-related APIs. Click the following options to open the WiFi framework: `RT-Thread Components-- > `, `Device Drivers-- >`, `Using WiFi-- > `, and check `Using Wi-Fi framework`:
|
||||
|
||||
![](figures/menuconfig7.png)
|
||||
|
||||
#### 3.4 Save Menuconfig configuration.
|
||||
|
||||
After completing the above three steps, the bsp configuration is complete, but the most important step is not to be omitted. Save the Menuconfig configuration: press the Esc key all the way to exit, and select Yes in the Save prompt window to confirm.
|
||||
|
||||
### 4. Modify part of the project code.
|
||||
|
||||
Open the project and replace the content of the `wifi_spi_device_init (void) `function in the `wifi_spi_device_init port.c` file with the following code:
|
||||
|
||||
int wifi_spi_device_init(void)
|
||||
{
|
||||
char sn_version[32];
|
||||
|
||||
rw007_gpio_init();
|
||||
rt_hw_spi_device_attach(RW007_SPI_BUS_NAME, "wspi", RW007_CS_PIN);
|
||||
rt_hw_wifi_init("wspi");
|
||||
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
|
||||
|
||||
rw007_sn_get(sn_version);
|
||||
rt_kprintf("\nrw007 sn: [%s]\n", sn_version);
|
||||
rw007_version_get(sn_version);
|
||||
rt_kprintf("rw007 ver: [%s]\n\n", sn_version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
### 5. Compile and Download the Project.
|
||||
|
||||
Use the Build button of the toolbar to compile the project. 0Error (s) indicates that the compilation is successful. Connect the development board to the computer, and then click the Download button to download the firmware to the development board.
|
||||
|
||||
## Running and Testing Module Functions.
|
||||
|
||||
After downloading the program, it can automatically reset and run, open the serial port tool (recommended to use XShell and other interactive terminals), and set the parameter to 1152008-1mi N. If the system starts normally and there is no problem with the communication between the development board and the module, you will see the following initialization print message:
|
||||
|
||||
![](figures/result1.png)
|
||||
When rw007 sn and rw007 ver can output normally without garbled code, the RW007 driver is successful!
|
||||
|
||||
Wifi networking test.
|
||||
|
||||
Enter the wifi scan command in shell to search for wifi:
|
||||
|
||||
![](figures/result2.png)
|
||||
|
||||
Connection Target wifi Test:
|
||||
|
||||
![](figures/result3.png)
|
||||
The figure above shows that wifi successfully connects to the hotspot Meet.
|
||||
At this point, the basic environment of `STM32U575- NUCLEO` is built and tested!
|
||||
|
||||
|
||||
## References:
|
||||
|
||||
1. [STM32F401 Nucleo-64 uses SPI to drive RW007](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using?id=rw007)
|
||||
2. [STM32U575-NUCLEO Schematic Download](https://www.st.com/resource/en/schematic_pack/mb1549-u575ziq-c03_schematic.pdf)
|
||||
|
||||
## Matters Needing Attention:
|
||||
|
||||
1. It is best to use a newer version of MDK, and this experiment was carried out under the MDK5.36 version.
|
||||
2. Please choose the latest version of the RW007 software package, otherwise the version will not be compatible and the project will report an error. If you have not selected the latest version of the RW007 package, download the RW007 package in the link below and replace the file in `bsp\ stm32\ stm32u575-st-nucleo\ packages\ rw007- xxx`! (however, the above step of modifying part of the project code is also necessary. If the content of the `wifi_spi_device_init (void) `function in the project `wifi_spi_device_init port.c` file is the same as that given, it can be ignored! ).
|
||||
RW007 package Github repository link: [RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
3. At present, in this experimental test, it is found that RW007 will time out, and a suitable solution has not been found, but it does not affect the normal use of RW007 module.
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# NUCLEO-U575ZI-Q 开发板 BSP 说明
|
||||
# 第一部分:NUCLEO-U575ZI-Q 开发板 BSP 说明
|
||||
|
||||
[English](README.md) | **中文**
|
||||
|
||||
## 简介
|
||||
|
||||
|
@ -109,3 +111,146 @@ msh >
|
|||
|
||||
- [liukang](https://github.com/liukangcc)
|
||||
|
||||
# 第二部分:NUCLEO-U575ZI-Q 上手指南
|
||||
|
||||
NUCLEO-U575ZI-Q 上手指南是通过使用 SPI1 驱动 RW007 模块实例进行介绍,实现 NUCLEO-U575ZI-Q 入门
|
||||
|
||||
## 准备工作
|
||||
在 NUCLEO-U575ZI-Q 驱动`RW007`畅快跑起来之前,以下准备工作必不可少,你将需要:
|
||||
|
||||
> 1.NUCLEO-U575ZI-Q 开发板
|
||||
> 2.RW007 WiFi 模块
|
||||
> 3.Mini-USB 连接线(连接开发板与电脑)
|
||||
> 4.ENV 编译构建环境([安装使用说明](https://www.rt-thread.org/document/site/#/development-tools/env/env))
|
||||
> 5.开发常用软件(git、Keil5、STM32CubeMX、串口调试等)
|
||||
|
||||
## 开始上路
|
||||
RT-Thread 包含了 RW007 的软件包,用户无需自己编写驱动程序,下面以 SPI 模式为例,介绍如何在 NUCLEO-U575ZI-Q 上驱动 RW007 模块,并完成 AP 扫描、连接等基本 WiFi 功能。
|
||||
|
||||
## 硬件连接
|
||||
得益于 Nucleo 上的 Arduino 接口,只需把 RW007 往开发板上一插,即可完成了两者的硬件连接。
|
||||
|
||||
![](figures/board1.png)
|
||||
|
||||
根据下面原理图可查找各 IO 接口与功能之间的对应关系表如下:
|
||||
|
||||
![](figures/Schematic_diagram.png)
|
||||
|
||||
|STM32引脚名 | 封装管脚序号 |Arduino接口序号| 功能 |
|
||||
|PA5 | 5 |D13 |BOOT0/CLK |
|
||||
|PA6 | 6 |D12 |MISO |
|
||||
|PA7 | 7 |D11 |MOSI |
|
||||
|PD14 | 62 |D10 |BOOT1/CS |
|
||||
|PD15 | 63 |D9 |INT/BUSY |
|
||||
|PF12 | 92 |D8 |RESET |
|
||||
|
||||
## STM32 bsp 配置(Menuconfig)
|
||||
### 1.下载 RT-Thread源码
|
||||
GitHub链接:[https://github.com/RT-Thread/rt-thread](https://github.com/RT-Thread/rt-thread)
|
||||
打开 `rt-thread\bsp\stm32` 目录,能看到 RT-Thread 所支持的开发板型号,把 RT-Thread 在 STM32 上跑起来并不是一件难事,但在编译内核组件之前,要对 bsp 进行简单配置。本次实验所使用的 bsp 为 stm32u575-st-nucleo。
|
||||
|
||||
### 2.通过 CubeMX 配置 SPI 初始化程序
|
||||
一般 STM32 系列的引脚分配可以通过对应 BSP 中board\CubeMX_Config目录下的CubeMX_Config.ioc打开 CubeMX 工程,进行配置 SPI1,并生成代码,保存退出即可 。
|
||||
![](figures/CubeMX.png)
|
||||
|
||||
### 3.通过menuconfig配置 RW007 软件包
|
||||
进入 rt-thread\bsp\stm32\stm32u575-st-nucleo 文件夹,右键打开 ENV 窗口(前提是已在 Windows 下搭好 ENV 环境),输入 menuconfig 进行系统配置:
|
||||
|
||||
#### 3.1开启 SPI 设备
|
||||
开发板与模块的通讯依赖 SPI 设备,在 bsp 中已经实现了 SPI 驱动,只需在设置中打开即可使用。 进入 `Hardware Drivers Config --->` 下的 `On-chip Peripheral Drivers`,勾选 `Enable SPI BUS --->` 选项,并按回车键进入,进一步选中 `Enable SPI1 BUS`,完成配置:
|
||||
![](figures/menuconfig1.png)
|
||||
![](figures/menuconfig2.png)
|
||||
![](figures/menuconfig3.png)
|
||||
![](figures/menuconfig4.png)
|
||||
|
||||
如果在 bsp 中的 menuconfig 中没有对应 spi的配置,可以通过修改 Kconfig文件增加对应spi的配置。 Kconfig 的路径在board/Kconfig ,`menu "On-chip Peripheral Drivers"`下面添加 SPI1的配置。
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI BUS"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 BUS"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_TX_USING_DMA
|
||||
bool "Enable SPI1 TX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_USING_DMA
|
||||
bool "Enable SPI1 RX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_SPI1_TX_USING_DMA
|
||||
default n
|
||||
|
||||
endif
|
||||
|
||||
#### 3.2配置 RW007 软件包
|
||||
RT-Thread 通过软件包的形式,对 RW007 模块提供配套驱动支持,系统默认选项不包含软件包,用户需手动开启:通过 Esc 键回到 Menuconfig 主界面,依次进入 `RT-Thread online packages --->` 、`IoT - internet of things --->`、`Wi-Fi --->`,勾选 `rw007: SPI WIFI rw007 driver --->` 选项:
|
||||
![](figures/menuconfig5.png)
|
||||
RW007 软件包 Github 仓库链接:[RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
|
||||
紧接着按下 Enter 键进一步设置软件包参数,完成 SPI 总线和 IO 的配置,更改总线设备名称 RW007 BUS NAME 为 spi1,然后配置 SPI 控制 IO,各管脚号依次按下图序号填入:
|
||||
![](figures/menuconfig6.png)
|
||||
|
||||
#### 3.3开启 WiFi 框架
|
||||
RW007 驱动使用了 WLAN 相关的接口,按以下选项路径打开 WiFi 框架:`RT-Thread Components --->`、`Device Drivers --->`、`Using WiFi --->`,勾选 `Using Wi-Fi framework`:
|
||||
![](figures/menuconfig7.png)
|
||||
|
||||
#### 3.4保存 Menuconfig 配置
|
||||
完成了上面的 3 步,bsp 配置算大功告成了,但最最重要的一步不能漏,保存 Menuconfig 配置:直接一路狂按 Esc 键退出,在保存提示窗口中选择 Yes 确认即可。
|
||||
|
||||
### 4.修改部分工程代码
|
||||
打开工程,将 `rw007_stm32_port.c` 文件中 `wifi_spi_device_init(void)` 函数内容替换成下面的代码:
|
||||
|
||||
int wifi_spi_device_init(void)
|
||||
{
|
||||
char sn_version[32];
|
||||
|
||||
rw007_gpio_init();
|
||||
rt_hw_spi_device_attach(RW007_SPI_BUS_NAME, "wspi", RW007_CS_PIN);
|
||||
rt_hw_wifi_init("wspi");
|
||||
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
|
||||
|
||||
rw007_sn_get(sn_version);
|
||||
rt_kprintf("\nrw007 sn: [%s]\n", sn_version);
|
||||
rw007_version_get(sn_version);
|
||||
rt_kprintf("rw007 ver: [%s]\n\n", sn_version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
### 5.编译、下载工程
|
||||
|
||||
使用工具栏的 Build 按钮编译工程,出现 0 Error(s) 表示编译成功,将开发板连接电脑,再点击 Download 按钮下载固件到开发板
|
||||
|
||||
## 运行、测试模块功能
|
||||
下载完程序便能自动复位运行,打开串口工具(推荐使用 XShell 等交互型终端),设置参数为 115200 8-1-N。若系统启动正常,且开发板与模块间的通讯也没有问题,会看到如下初始化打印信息:
|
||||
![](figures/result1.png)
|
||||
rw007 sn 与 rw007 ver 可以正常输出无乱码时,RW007驱动成功!!!
|
||||
|
||||
wifi联网测试
|
||||
在shell中输入 wifi scan 命令搜索wifi:
|
||||
![](figures/result2.png)
|
||||
|
||||
连接目标wifi测试:
|
||||
![](figures/result3.png)
|
||||
上图可见wifi成功连接热点Meet。
|
||||
至此`STM32U575-NUCLEO`的基础环境便搭建测试完毕!!!
|
||||
|
||||
|
||||
## 参考资料:
|
||||
1. [STM32F401 Nucleo-64使用SPI驱动RW007](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using?id=rw007)
|
||||
2. [STM32U575-NUCLEO原理图下载](https://www.st.com/resource/en/schematic_pack/mb1549-u575ziq-c03_schematic.pdf)
|
||||
|
||||
## 注意事项:
|
||||
1. MDK版本最好使用比较新的版本的,本次实验是在MDK5.36版本下进行的。
|
||||
2. RW007软件包请选用最新版本的,否则会出现版本不兼容的问题,导致工程报错。若未选择最新版本的RW007软件包,就把下面链接里面的RW007软件包下载,替换掉`bsp\stm32\stm32u575-st-nucleo\packages\rw007-xxx`里面的文件即可!(但上述修改部分工程代码这一步也是要做的,如果工程`rw007_stm32_port.c`文件中`wifi_spi_device_init(void)`函数内容与所给内容相同可忽略!)
|
||||
RW007 软件包 Github 仓库链接:[RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
3. 目前,在本实验测试中发现RW007会出现超时现象,还未找到合适的解决方案,但并不影响RW007模块的正常使用。
|
||||
|
||||
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
#STM32U575-NUCLEO Getting Started Guide
|
||||
|
||||
STM32U575-NUCLEO Getting Started Guide is introduced by using the example of SPI1 driving RW007 module to realize the introduction of STM32U575-NUCLEO.
|
||||
|
||||
##Preparatory Work
|
||||
|
||||
Before STM32U575-NUCLEO driver RW007 runs, the following preparations are essential, and you will need:
|
||||
|
||||
> 1.STM32U575-NUCLEO
|
||||
2.RW007 WiFi module
|
||||
3.Mini-USB Connecting cable (connecting the development board with the computer)
|
||||
4.ENV Compile build environment([Installation instructions](https://www.rt-thread.org/document/site/#/development-tools/env/env))
|
||||
5.common software(git,Keil5,STM32CubeMX,Serial debugging, etc)
|
||||
|
||||
##Start on the Road
|
||||
|
||||
RT-Thread contains RW007 software package, so users don't need to write their own drivers. Taking SPI mode as an example, this paper introduces how to drive RW007 module on STM32U575-NUCLEO, and complete basic WiFi functions such as AP scanning and connection.
|
||||
|
||||
## Hardware connection
|
||||
|
||||
Thanks to the Arduino interface on Nucleo, just plug RW007 into the development board, and the hardware connection between them can be completed.
|
||||
|
||||
![](figures/board1.png)
|
||||
|
||||
According to the following schematic diagram, the corresponding table between IO interfaces and functions can be found as follows:
|
||||
|
||||
![](figures/Schematic_diagram.png)
|
||||
|
||||
|STM32 pin name | pin serial number |Arduino Interface serial number|function |
|
||||
|PA5 | 5 |D13 |BOOT0/CLK |
|
||||
|PA6 | 6 |D12 |MISO |
|
||||
|PA7 | 7 |D11 |MOSI |
|
||||
|PD14 | 62 |D10 |BOOT1/CS |
|
||||
|PD15 | 63 |D9 |INT/BUSY |
|
||||
|PF12 | 92 |D8 |RESET |
|
||||
|
||||
##STM32 BSP Deploy(Menuconfig)
|
||||
###1.Download RT-Thread Source Code
|
||||
|
||||
GitHub link:[https://github.com/RT-Thread/rt-thread](https://github.com/RT-Thread/rt-thread)
|
||||
Open the 'rt-thread\bsp\stm32' directory and you will see the development board model supported by rt-thread. It is not difficult to get RT-Thread running on STM32, but bsp needs to be configured briefly before compiling the kernel components.The bsp used in this experiment was stm32u575-st-nucleo.
|
||||
|
||||
###2.The SPI Initializer is Configured Through CubeMX
|
||||
|
||||
In general, the pin assignment of STM32 series can open the CubeMX project corresponding to the CubeMX_Config.ioc in the board\ CubeMX_Config directory in BSP, configure SPI1, generate code, and save and exit.
|
||||
|
||||
![](figures/CubeMX.png)
|
||||
|
||||
###3. Configure the RW007 Package Through Menuconfig
|
||||
|
||||
Go to the rt-thread\ bsp\ stm32\ stm32u575-st-nucleo folder, right-click to open the ENV window (provided that the ENV environment has been built under Windows), and type menuconfig to configure the system:
|
||||
|
||||
3.1 The communication between the development board and the module depends on the SPI device. The SPI driver has been implemented in bsp and can be used as long as it is opened in the setting. Go to `On-chip Peripheral Drivers` under `On-chip Peripheral-> `, check the `Enable SPI BUS-- >` option, press enter to enter, and further select `Enable SPI1 BUS` to complete the configuration:
|
||||
|
||||
![](figures/menuconfig1.png)
|
||||
![](figures/menuconfig2.png)
|
||||
![](figures/menuconfig3.png)
|
||||
![](figures/menuconfig4.png)
|
||||
|
||||
If there is no configuration for the corresponding spi in the menuconfig in the bsp, you can increase the configuration of the corresponding spi by modifying the Kconfig file. Add the configuration of SPI1 to the path of Kconfig under board/Kconfig, `menu "On-chip Peripheral Drivers" `.
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI BUS"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 BUS"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_TX_USING_DMA
|
||||
bool "Enable SPI1 TX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_USING_DMA
|
||||
bool "Enable SPI1 RX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_SPI1_TX_USING_DMA
|
||||
default n
|
||||
|
||||
endif
|
||||
|
||||
3.2 Configure the RW007 Package.
|
||||
|
||||
RT-Thread provides supporting driver support for RW007 modules in the form of software packages. The default options of the system do not include software packages. Users need to enable them manually: return to the Menuconfig main interface through the Esc key, enter `RT-Thread online packages-- > `, `IoT-internet of things->`, `Wi-Fi-- > `, and check the `rw007: SPI WIFI rw007 driver-- >` option:
|
||||
![](figures/menuconfig5.png)
|
||||
RW007 package Github repository link:[RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
|
||||
Then press Enter key to further set the parameters of the software package, complete the configuration of SPI bus and IO, change the bus device name `RW007 BUS NAME` to spi1, then configure SPI to control IO, and fill in each pin number according to the serial number of the following figure:
|
||||
![](figures/menuconfig6.png)
|
||||
|
||||
3.3 Open the WiFi framework.
|
||||
|
||||
The RW007 driver uses WLAN-related APIs. Click the following options to open the WiFi framework: `RT-Thread Components-- > `, `Device Drivers-- >`, `Using WiFi-- > `, and check `Using Wi-Fi framework`:
|
||||
|
||||
![](figures/menuconfig7.png)
|
||||
|
||||
3.4 Save Menuconfig configuration.
|
||||
|
||||
After completing the above three steps, the bsp configuration is complete, but the most important step is not to be omitted. Save the Menuconfig configuration: press the Esc key all the way to exit, and select Yes in the Save prompt window to confirm.
|
||||
|
||||
###4. Modify part of the project code.
|
||||
|
||||
Open the project and replace the content of the `wifi_spi_device_init (void) `function in the `wifi_spi_device_init port.c` file with the following code:
|
||||
|
||||
int wifi_spi_device_init(void)
|
||||
{
|
||||
char sn_version[32];
|
||||
|
||||
rw007_gpio_init();
|
||||
rt_hw_spi_device_attach(RW007_SPI_BUS_NAME, "wspi", RW007_CS_PIN);
|
||||
rt_hw_wifi_init("wspi");
|
||||
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
|
||||
|
||||
rw007_sn_get(sn_version);
|
||||
rt_kprintf("\nrw007 sn: [%s]\n", sn_version);
|
||||
rw007_version_get(sn_version);
|
||||
rt_kprintf("rw007 ver: [%s]\n\n", sn_version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
###5. Compile and Download the Project.
|
||||
|
||||
Use the Build button of the toolbar to compile the project. 0Error (s) indicates that the compilation is successful. Connect the development board to the computer, and then click the Download button to download the firmware to the development board.
|
||||
|
||||
## Running and Testing Module Functions.
|
||||
|
||||
After downloading the program, it can automatically reset and run, open the serial port tool (recommended to use XShell and other interactive terminals), and set the parameter to 1152008-1mi N. If the system starts normally and there is no problem with the communication between the development board and the module, you will see the following initialization print message:
|
||||
|
||||
![](figures/result1.png)
|
||||
When rw007 sn and rw007 ver can output normally without garbled code, the RW007 driver is successful!
|
||||
|
||||
Wifi networking test.
|
||||
|
||||
Enter the wifi scan command in shell to search for wifi:
|
||||
|
||||
![](figures/result2.png)
|
||||
|
||||
Connection Target wifi Test:
|
||||
|
||||
![](figures/result3.png)
|
||||
The figure above shows that wifi successfully connects to the hotspot Meet.
|
||||
At this point, the basic environment of `STM32U575- NUCLEO` is built and tested!
|
||||
|
||||
|
||||
## References:
|
||||
|
||||
1. [STM32F401 Nucleo-64 uses SPI to drive RW007](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using?id=rw007)
|
||||
2. [STM32U575-NUCLEO Schematic Download](https://www.st.com/resource/en/schematic_pack/mb1549-u575ziq-c03_schematic.pdf)
|
||||
|
||||
## Matters Needing Attention:
|
||||
|
||||
1. It is best to use a newer version of MDK, and this experiment was carried out under the MDK5.36 version.
|
||||
2. Please choose the latest version of the RW007 software package, otherwise the version will not be compatible and the project will report an error. If you have not selected the latest version of the RW007 package, download the RW007 package in the link below and replace the file in `bsp\ stm32\ stm32u575-st-nucleo\ packages\ rw007- xxx`! (however, the above step of modifying part of the project code is also necessary. If the content of the `wifi_spi_device_init (void) `function in the project `wifi_spi_device_init port.c` file is the same as that given, it can be ignored! ).
|
||||
RW007 package Github repository link: [RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
3. At present, in this experimental test, it is found that RW007 will time out, and a suitable solution has not been found, but it does not affect the normal use of RW007 module.
|
|
@ -1,140 +0,0 @@
|
|||
#STM32U575-NUCLEO 上手指南
|
||||
|
||||
STM32U575-NUCLEO 上手指南是通过使用 SPI1 驱动 RW007 模块实例进行介绍,实现 STM32U575-NUCLEO 入门
|
||||
|
||||
##准备工作
|
||||
在 STM32U575-NUCLEO 驱动`RW007`畅快跑起来之前,以下准备工作必不可少,你将需要:
|
||||
|
||||
> 1.STM32U575-NUCLEO 开发板
|
||||
2.RW007 WiFi 模块
|
||||
3.Mini-USB 连接线(连接开发板与电脑)
|
||||
4.ENV 编译构建环境([安装使用说明](https://www.rt-thread.org/document/site/#/development-tools/env/env))
|
||||
5.开发常用软件(git、Keil5、STM32CubeMX、串口调试等)
|
||||
|
||||
##开始上路
|
||||
RT-Thread 包含了 RW007 的软件包,用户无需自己编写驱动程序,下面以 SPI 模式为例,介绍如何在 STM32U575-NUCLEO 上驱动 RW007 模块,并完成 AP 扫描、连接等基本 WiFi 功能。
|
||||
|
||||
##硬件连接
|
||||
得益于 Nucleo 上的 Arduino 接口,只需把 RW007 往开发板上一插,即可完成了两者的硬件连接。
|
||||
|
||||
![](figures/board1.png)
|
||||
|
||||
根据下面原理图可查找各 IO 接口与功能之间的对应关系表如下:
|
||||
|
||||
![](figures/Schematic_diagram.png)
|
||||
|
||||
|STM32引脚名 | 封装管脚序号 |Arduino接口序号| 功能 |
|
||||
|PA5 | 5 |D13 |BOOT0/CLK |
|
||||
|PA6 | 6 |D12 |MISO |
|
||||
|PA7 | 7 |D11 |MOSI |
|
||||
|PD14 | 62 |D10 |BOOT1/CS |
|
||||
|PD15 | 63 |D9 |INT/BUSY |
|
||||
|PF12 | 92 |D8 |RESET |
|
||||
|
||||
##STM32 bsp 配置(Menuconfig)
|
||||
###1.下载 RT-Thread源码
|
||||
GitHub链接:[https://github.com/RT-Thread/rt-thread](https://github.com/RT-Thread/rt-thread)
|
||||
打开 `rt-thread\bsp\stm32` 目录,能看到 RT-Thread 所支持的开发板型号,把 RT-Thread 在 STM32 上跑起来并不是一件难事,但在编译内核组件之前,要对 bsp 进行简单配置。本次实验所使用的 bsp 为 stm32u575-st-nucleo。
|
||||
|
||||
###2.通过 CubeMX 配置 SPI 初始化程序
|
||||
一般 STM32 系列的引脚分配可以通过对应 BSP 中board\CubeMX_Config目录下的CubeMX_Config.ioc打开 CubeMX 工程,进行配置 SPI1,并生成代码,保存退出即可 。
|
||||
![](figures/CubeMX.png)
|
||||
|
||||
###3.通过menuconfig配置 RW007 软件包
|
||||
进入 rt-thread\bsp\stm32\stm32u575-st-nucleo 文件夹,右键打开 ENV 窗口(前提是已在 Windows 下搭好 ENV 环境),输入 menuconfig 进行系统配置:
|
||||
|
||||
3.1开发板与模块的通讯依赖 SPI 设备,在 bsp 中已经实现了 SPI 驱动,只需在设置中打开即可使用。 进入 `Hardware Drivers Config --->` 下的 `On-chip Peripheral Drivers`,勾选 `Enable SPI BUS --->` 选项,并按回车键进入,进一步选中 `Enable SPI1 BUS`,完成配置:
|
||||
![](figures/menuconfig1.png)
|
||||
![](figures/menuconfig2.png)
|
||||
![](figures/menuconfig3.png)
|
||||
![](figures/menuconfig4.png)
|
||||
|
||||
如果在 bsp 中的 menuconfig 中没有对应 spi的配置,可以通过修改 Kconfig文件增加对应spi的配置。 Kconfig 的路径在board/Kconfig ,`menu "On-chip Peripheral Drivers"`下面添加 SPI1的配置。
|
||||
|
||||
menuconfig BSP_USING_SPI
|
||||
bool "Enable SPI BUS"
|
||||
default n
|
||||
select RT_USING_SPI
|
||||
if BSP_USING_SPI
|
||||
config BSP_USING_SPI1
|
||||
bool "Enable SPI1 BUS"
|
||||
default n
|
||||
|
||||
config BSP_SPI1_TX_USING_DMA
|
||||
bool "Enable SPI1 TX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
default n
|
||||
|
||||
config BSP_SPI1_RX_USING_DMA
|
||||
bool "Enable SPI1 RX DMA"
|
||||
depends on BSP_USING_SPI1
|
||||
select BSP_SPI1_TX_USING_DMA
|
||||
default n
|
||||
|
||||
endif
|
||||
|
||||
3.2配置 RW007 软件包
|
||||
RT-Thread 通过软件包的形式,对 RW007 模块提供配套驱动支持,系统默认选项不包含软件包,用户需手动开启:通过 Esc 键回到 Menuconfig 主界面,依次进入 `RT-Thread online packages --->` 、`IoT - internet of things --->`、`Wi-Fi --->`,勾选 `rw007: SPI WIFI rw007 driver --->` 选项:
|
||||
![](figures/menuconfig5.png)
|
||||
RW007 软件包 Github 仓库链接:[RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
|
||||
紧接着按下 Enter 键进一步设置软件包参数,完成 SPI 总线和 IO 的配置,更改总线设备名称 RW007 BUS NAME 为 spi1,然后配置 SPI 控制 IO,各管脚号依次按下图序号填入:
|
||||
![](figures/menuconfig6.png)
|
||||
|
||||
3.3开启 WiFi 框架
|
||||
RW007 驱动使用了 WLAN 相关的接口,按以下选项路径打开 WiFi 框架:`RT-Thread Components --->`、`Device Drivers --->`、`Using WiFi --->`,勾选 `Using Wi-Fi framework`:
|
||||
![](figures/menuconfig7.png)
|
||||
|
||||
3.4保存 Menuconfig 配置
|
||||
完成了上面的 3 步,bsp 配置算大功告成了,但最最重要的一步不能漏,保存 Menuconfig 配置:直接一路狂按 Esc 键退出,在保存提示窗口中选择 Yes 确认即可。
|
||||
|
||||
###4.修改部分工程代码
|
||||
打开工程,将 `rw007_stm32_port.c` 文件中 `wifi_spi_device_init(void)` 函数内容替换成下面的代码:
|
||||
|
||||
int wifi_spi_device_init(void)
|
||||
{
|
||||
char sn_version[32];
|
||||
|
||||
rw007_gpio_init();
|
||||
rt_hw_spi_device_attach(RW007_SPI_BUS_NAME, "wspi", RW007_CS_PIN);
|
||||
rt_hw_wifi_init("wspi");
|
||||
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
|
||||
|
||||
rw007_sn_get(sn_version);
|
||||
rt_kprintf("\nrw007 sn: [%s]\n", sn_version);
|
||||
rw007_version_get(sn_version);
|
||||
rt_kprintf("rw007 ver: [%s]\n\n", sn_version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
###5.编译、下载工程
|
||||
|
||||
使用工具栏的 Build 按钮编译工程,出现 0 Error(s) 表示编译成功,将开发板连接电脑,再点击 Download 按钮下载固件到开发板
|
||||
|
||||
##运行、测试模块功能
|
||||
下载完程序便能自动复位运行,打开串口工具(推荐使用 XShell 等交互型终端),设置参数为 115200 8-1-N。若系统启动正常,且开发板与模块间的通讯也没有问题,会看到如下初始化打印信息:
|
||||
![](figures/result1.png)
|
||||
rw007 sn 与 rw007 ver 可以正常输出无乱码时,RW007驱动成功!!!
|
||||
|
||||
wifi联网测试
|
||||
在shell中输入 wifi scan 命令搜索wifi:
|
||||
![](figures/result2.png)
|
||||
|
||||
连接目标wifi测试:
|
||||
![](figures/result3.png)
|
||||
上图可见wifi成功连接热点Meet。
|
||||
至此`STM32U575-NUCLEO`的基础环境便搭建测试完毕!!!
|
||||
|
||||
|
||||
##参考资料:
|
||||
1. [STM32F401 Nucleo-64使用SPI驱动RW007](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/application-note/packages/rw007_module_using/an0034-rw007-module-using?id=rw007)
|
||||
2. [STM32U575-NUCLEO原理图下载](https://www.st.com/resource/en/schematic_pack/mb1549-u575ziq-c03_schematic.pdf)
|
||||
|
||||
##注意事项:
|
||||
1. MDK版本最好使用比较新的版本的,本次实验是在MDK5.36版本下进行的。
|
||||
2. RW007软件包请选用最新版本的,否则会出现版本不兼容的问题,导致工程报错。若未选择最新版本的RW007软件包,就把下面链接里面的RW007软件包下载,替换掉`bsp\stm32\stm32u575-st-nucleo\packages\rw007-xxx`里面的文件即可!(但上述修改部分工程代码这一步也是要做的,如果工程`rw007_stm32_port.c`文件中`wifi_spi_device_init(void)`函数内容与所给内容相同可忽略!)
|
||||
RW007 软件包 Github 仓库链接:[RT-Thread-packages/rw007: RW007 (SPI Wi-Fi module) driver for RT-Thread](https://github.com/RT-Thread-packages/rw007)
|
||||
3. 目前,在本实验测试中发现RW007会出现超时现象,还未找到合适的解决方案,但并不影响RW007模块的正常使用。
|
Loading…
Reference in New Issue