diff --git a/bsp/imxrt/imxrt1060-nxp-evk/README.md b/bsp/imxrt/imxrt1060-nxp-evk/README.md index 3209a38cf5..b14030bbde 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/README.md +++ b/bsp/imxrt/imxrt1060-nxp-evk/README.md @@ -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 diff --git a/bsp/imxrt/imxrt1060-nxp-evk/README_zh.md b/bsp/imxrt/imxrt1060-nxp-evk/README_zh.md index 2ffc7d55de..f42f59f561 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/README_zh.md +++ b/bsp/imxrt/imxrt1060-nxp-evk/README_zh.md @@ -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) diff --git a/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript b/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript index 628a013806..31def24745 100644 --- a/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript +++ b/bsp/imxrt/imxrt1060-nxp-evk/board/SConscript @@ -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', diff --git a/bsp/imxrt/imxrt1060-nxp-evk/board/ports/rw007_port.c b/bsp/imxrt/imxrt1060-nxp-evk/board/ports/rw007_port.c new file mode 100644 index 0000000000..f0407cd38b --- /dev/null +++ b/bsp/imxrt/imxrt1060-nxp-evk/board/ports/rw007_port.c @@ -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 +#include +#include +#include +#include +#include + +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); +} \ No newline at end of file diff --git a/bsp/imxrt/imxrt1060-nxp-evk/figures/18.jpg b/bsp/imxrt/imxrt1060-nxp-evk/figures/18.jpg new file mode 100644 index 0000000000..b0f4396bd0 Binary files /dev/null and b/bsp/imxrt/imxrt1060-nxp-evk/figures/18.jpg differ diff --git a/bsp/imxrt/imxrt1060-nxp-evk/figures/9.png b/bsp/imxrt/imxrt1060-nxp-evk/figures/9.png index 6e0baf9cdc..13e5eea450 100644 Binary files a/bsp/imxrt/imxrt1060-nxp-evk/figures/9.png and b/bsp/imxrt/imxrt1060-nxp-evk/figures/9.png differ diff --git a/bsp/imxrt/imxrt1060-nxp-evk/figures/9_en.png b/bsp/imxrt/imxrt1060-nxp-evk/figures/9_en.png index 14e5ea0dbc..899849ae82 100644 Binary files a/bsp/imxrt/imxrt1060-nxp-evk/figures/9_en.png and b/bsp/imxrt/imxrt1060-nxp-evk/figures/9_en.png differ