[imxrt1062]refresh rw007 module port document. (#7734)

Co-authored-by: StackYuan <yuanyjyj@outlook.com>
This commit is contained in:
StackYuan 2023-06-27 17:09:45 +08:00 committed by GitHub
parent 53c435212c
commit e95318a266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 89 additions and 50 deletions

View File

@ -157,6 +157,9 @@ The SPI interface provided by the MIMXRT1060-EVK onboard Arduino interface has d
![](./figures/11.png)
Solder works must be done before next step:
![](./figures/18.png)
### 4.1 Configure the onboard SPI peripherals
RW007 supports SPI interface for communication, MIMXRT1060-EVK supports SPI driver, defaults to using polling mode to communicate with RW007 (currently it does not support interrupt and DMA mode to communicate with RW007), the following shows how to use RT-Studio to configure SPI:
@ -174,31 +177,7 @@ Click the RT-Thread Settings option on the left, there is a configuration menu w
![](./figures/12.png)
### 4.4 Modify the RW007 example
Since the default example of the RW007 package is based on the STM32, minor modifications are required on the RT1060-EVK, modify the `rw007_stm32_port.c` file in the example folder in the RW007 package.
Modify the `int wifi_spi_device_init(void)` function, replacing the example with the code given below:
```
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;
}
```
RW007 has been ported into IMXRT1062 platform, the port file is at: `board/ports/rw007_port.c`, Once we select RW007 package, it will join into our project automatically, there is no need to modify any code for simply turn on this module.
### 4.5 After the modification is completed, compile the project and burn the firmware

View File

@ -178,6 +178,9 @@ MIMXRT1060-EVK板载arduino接口提供的SPI接口与SD卡的SDIO接口使用
![](./figures/11.png)
修改图示跳线:
![](./figures/18.png)
### 4.1 配置板载SPI外设
RW007可采用SPI接口通讯MIMXRT1060-EVK支持SPI驱动默认采用轮询的方式与RW007通讯(暂不支持中断与DMA模式与RW007通讯)使用RT-Studio配置SPI的具体配置如下:
@ -196,32 +199,9 @@ RW007可采用SPI接口通讯MIMXRT1060-EVK支持SPI驱动默认采用轮
### 4.4 修改RW007示例
由于RW007软件包的默认示例是基于STM32的示例所以在RT1060-EVK上需进行少量的修改修改RW007软件包中的example文件夹中的rw007_stm32_port.c文件
RW007已经为IMXRT1062平台做了单独适配文件目录在`board/ports/rw007_port.c` 工程会自动加入此文件,因此无需修改即可简单适配
修改`int wifi_spi_device_init(void)`函数,使用下述给出的代码替换原有的示例:
```c
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;
}
```
### 4.5 修改完成后,编译工程,烧录固件。
### 4.5 编译工程,烧录固件。
![](./figures/13.png)

View File

@ -15,6 +15,9 @@ MCUX_Config/dcd.c
if GetDepend(['BSP_USING_TOUCHPAD']):
src += ['ports/touchpad.c']
if GetDepend(['PKG_USING_RW007']):
src += ['ports/rw007_port.c']
CPPPATH = [cwd,cwd + '/MCUX_Config',cwd + '/ports']
# CPPDEFINES = ['CPU_MIMXRT1062DVL6A', 'SKIP_SYSCLK_INIT', 'EVK_MCIMXRM', 'FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1',

View File

@ -0,0 +1,77 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-06-26 StackYuan the first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <drv_gpio.h>
#include <drv_spi.h>
#include <board.h>
#include <spi_wifi_rw007.h>
extern void spi_wifi_isr(int vector);
#define RW007_INT_BUSY_PIN GET_PIN(1, 2)
#define RW007_RST_PIN GET_PIN(1, 3)
#define RW007_CS_PIN GET_PIN(3, 13)
#define RW007_ON_SPI_BUS "spi1"
#define RW007_DEVICE_NAME "wspi"
static void rw007_gpio_init(void)
{
/* Configure IO */
rt_pin_mode(RW007_RST_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(RW007_INT_BUSY_PIN, PIN_MODE_INPUT_PULLDOWN);
/* Reset rw007 and config mode */
rt_pin_write(RW007_RST_PIN, PIN_LOW);
rt_thread_delay(rt_tick_from_millisecond(100));
rt_pin_write(RW007_RST_PIN, PIN_HIGH);
/* Wait rw007 ready(exit busy stat) */
while(!rt_pin_read(RW007_INT_BUSY_PIN))
{
rt_thread_delay(5);
}
rt_thread_delay(rt_tick_from_millisecond(200));
rt_pin_mode(RW007_INT_BUSY_PIN, PIN_MODE_INPUT_PULLUP);
}
int wifi_spi_device_init(void)
{
char sn_version[32];
rw007_gpio_init();
rt_hw_spi_device_attach(RW007_ON_SPI_BUS, RW007_DEVICE_NAME, 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;
}
INIT_APP_EXPORT(wifi_spi_device_init);
static void int_wifi_irq(void * p)
{
((void)p);
spi_wifi_isr(0);
}
void spi_wifi_hw_init(void)
{
rt_pin_attach_irq(RW007_INT_BUSY_PIN, PIN_IRQ_MODE_FALLING, int_wifi_irq, 0);
rt_pin_irq_enable(RW007_INT_BUSY_PIN, RT_TRUE);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 32 KiB