diff --git a/bsp/imx6ull-artpi-smart/drivers/Kconfig b/bsp/imx6ull-artpi-smart/drivers/Kconfig index b4e78d112fdda6d27073fd09f8d589506bb31f01..17ae71e05b5c41996c8064706383a829bc85c755 100644 --- a/bsp/imx6ull-artpi-smart/drivers/Kconfig +++ b/bsp/imx6ull-artpi-smart/drivers/Kconfig @@ -173,4 +173,13 @@ menu "Select ENET Driver" default n endmenu +menu "Select Wifi Driver" + config RT_USING_WIFI_RW007 + bool "Enable wifi RW007" + select BSP_USING_SPI2 + select PKG_USING_RW007 + select RT_USING_WIFI + default n +endmenu + endmenu diff --git a/bsp/imx6ull-artpi-smart/drivers/drv_rw007_port.c b/bsp/imx6ull-artpi-smart/drivers/drv_rw007_port.c new file mode 100644 index 0000000000000000000000000000000000000000..392d75af948e0a0e3388b0529cfcb67004f55f5a --- /dev/null +++ b/bsp/imx6ull-artpi-smart/drivers/drv_rw007_port.c @@ -0,0 +1,79 @@ +#include + +#ifdef PKG_USING_RW007 +#include +#include +#include +#include +#include + +#ifndef PKG_USING_RW007_V201 +#error "please select rw007 v2.0.1 version." +#endif + +#ifdef RW007_USING_STM32_DRIVERS +#error "please select not use example driver, porting by myself." +#endif + +#define RW007_SPI_BUS_NAME "spi2" +#define RW007_CS_PIN GET_PIN(1, 29) /* IOMUXC_UART4_RX_DATA_ECSPI2_SS0 IOMUXC_UART4_RX_DATA_GPIO1_IO29 */ +#define RW007_INT_BUSY_PIN GET_PIN(5, 0) /* IOMUXC_SNVS_SNVS_TAMPER0_GPIO5_IO00 */ +#define RW007_RST_PIN GET_PIN(5, 1) /* IOMUXC_SNVS_SNVS_TAMPER1_GPIO5_IO01 */ + +extern void spi_wifi_isr(int vector); + +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_SPI_BUS_NAME, "rw007", RW007_CS_PIN); + rt_hw_wifi_init("rw007"); + + 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); +} + +#endif /* RW007_USING_STM32_DRIVERS */ diff --git a/components/drivers/wlan/wlan_cmd.c b/components/drivers/wlan/wlan_cmd.c index fead6a8bf233e5406037c67c829443eebdee2114..87ecba15df037b825beb735994c5fbe164755ad5 100644 --- a/components/drivers/wlan/wlan_cmd.c +++ b/components/drivers/wlan/wlan_cmd.c @@ -586,7 +586,7 @@ static int wifi_msh(int argc, char *argv[]) return 0; } -#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) +#if defined(RT_USING_FINSH) FINSH_FUNCTION_EXPORT_ALIAS(wifi_msh, __cmd_wifi, wifi command.); #endif