From 4ce116dae0831c3069c418a131775b7ee55584c9 Mon Sep 17 00:00:00 2001 From: Shicheng Chu <1468559561@qq.com> Date: Tue, 9 May 2023 09:51:58 +0800 Subject: [PATCH] [bsp][lpc55sxx]add: rw007_lpc55sxx_port.c (#7450) --- .../lpc55s69_nxp_evk/board/SConscript | 5 +- .../lpc55s69_nxp_evk/board/ports/rw007_port.c | 74 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 bsp/lpc55sxx/lpc55s69_nxp_evk/board/ports/rw007_port.c diff --git a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/SConscript b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/SConscript index c816455827..a296866d9b 100644 --- a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/SConscript +++ b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/SConscript @@ -9,7 +9,10 @@ MCUX_Config/board/clock_config.c MCUX_Config/board/pin_mux.c """) -CPPPATH = [cwd,cwd + '/MCUX_Config/board'] +if GetDepend(['PKG_USING_RW007']): + src += ['ports/rw007_port.c'] + +CPPPATH = [cwd, cwd + '/MCUX_Config/board'] CPPDEFINES = ['DEBUG'] group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES) diff --git a/bsp/lpc55sxx/lpc55s69_nxp_evk/board/ports/rw007_port.c b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/ports/rw007_port.c new file mode 100644 index 0000000000..f7c5e5e8f5 --- /dev/null +++ b/bsp/lpc55sxx/lpc55s69_nxp_evk/board/ports/rw007_port.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2023-05-06 ChuShicheng the first version + */ + +#include +#include +#include +#include +#include +#include + +extern void spi_wifi_isr(int vector); + +#define RW007_INT_BUSY_PIN GET_PINS(1, 5) +#define RW007_RST_PIN GET_PINS(1, 8) + +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("spi8", "wspi", GET_PINS(1, 1)); + 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); +}