From caf350a14866661547da9ebcf71a6323e6ef6399 Mon Sep 17 00:00:00 2001 From: shgutte <102281713+shgutte@users.noreply.github.com> Date: Tue, 19 Sep 2023 16:44:38 +0530 Subject: [PATCH] [SILABS] [RS917] Added support for Wi-Fi SDK 3.1.0 for 917 NCP (#28943) * Added changes for 917 NCP brignup * Added changes for 917 ncp * Resolved build errors for 917 NCP * Resolved build errors for 917 NCP * added changes in efr32_sdk.gni for wifi sdk * Build errors resolved * Fixed NCP build errors * Added fix for sl wifi init * Added BLE defines in efr32_sdk.gni * Added changes for the 917 NCP * Added changes 917 NCP * Added chnages for NCP rx buffer * changes for 917 NCP mode * Updated wifi sdk commit * removed the commented code * Removed the commented code and required changes for SDk 3.0 * Added changes for RS9116 build * Added fix for RS9116 build issue * Removed the unused code * Fixed warning changes for the 917 ncp * Added licence for the file * Added changes for the SOC and NCP * Removed the sl_wifi_if duplicate file * Added changes related to efr32_sdk * Added changes for define * Added changes for rs9116 and SOC error * Added wifi component for 917 NCP * Fixeed the hardfault for 917 NCP * Removed EFR32 MG12 for the SI917 * Restyled by whitespace * Added changes for the comments * Added chnages for sdk 3.1.0 * Adds wifi-sdk 3.1.0 and required changes for it * Added SOC and Common flash fixes * Added changes for retyle commit * Added restyle changes * Added changes for the third party silabs sdk * Restyled by gn * Added changes for the rs9117 NCP file * Added changes according to CSA comment * Restyled by gn * Added func return type * Added micro changes for the command buffer time --------- Co-authored-by: bhmanda-silabs Co-authored-by: Restyled.io Co-authored-by: srningap --- .../silabs/SiWx917/SiWx917/sl_wifi_if.c | 156 ++++++++++-------- examples/platform/silabs/efr32/BUILD.gn | 5 +- .../silabs/efr32/rs911x/hal/efx_spi.c | 50 +++++- .../efr32/rs911x/hal/rsi_hal_mcu_interrupt.c | 12 ++ .../efr32/rs911x/hal/sl_board_configuration.h | 47 ++++++ .../platform/silabs/efr32/rs911x/rs9117.gni | 99 +++++------ .../platform/silabs/efr32/rs911x/sl_wifi_if.c | 1 + .../silabs/efr32/rs911x/sl_wlan_config.h | 109 ++++++++++++ .../silabs/efr32/rs911x/wfx_rsi_host.c | 1 - .../silabs/SiWx917/wifi/ethernetif.cpp | 2 +- .../silabs/SiWx917/wifi/wfx_host_events.h | 2 +- src/platform/silabs/efr32/wifi/ethernetif.cpp | 90 +++++++++- .../silabs/efr32/wifi/wfx_host_events.h | 19 ++- src/platform/silabs/rs911x/BLEManagerImpl.cpp | 2 +- src/platform/silabs/rs911x/rsi_ble_config.h | 13 +- src/platform/silabs/rs911x/wfx_sl_ble_init.c | 2 - src/platform/silabs/rs911x/wfx_sl_ble_init.h | 2 +- third_party/silabs/efr32_sdk.gni | 66 ++++++-- 18 files changed, 524 insertions(+), 154 deletions(-) create mode 100644 examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h create mode 120000 examples/platform/silabs/efr32/rs911x/sl_wifi_if.c create mode 100644 examples/platform/silabs/efr32/rs911x/sl_wlan_config.h diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c index 8f738e36159dc6..6b7801e1fac3cc 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c @@ -35,7 +35,7 @@ #include "task.h" #include "wfx_host_events.h" -#include "rsi_ble_config.h" +#include "ble_config.h" #include "dhcp_client.h" #include "lwip/nd6.h" @@ -66,7 +66,7 @@ bool is_wifi_disconnection_event = false; /* Declare a variable to hold connection time intervals */ uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS; volatile bool scan_results_complete = false; -#define WIFI_SCAN_TIMEOUT 10000 // WiFi Scan interval +#define WIFI_SCAN_TIMEOUT_TICK 10000 extern osSemaphoreId_t sl_rs_ble_init_sem; @@ -89,13 +89,12 @@ volatile sl_status_t callback_status = SL_STATUS_OK; int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap) { sl_status_t status = SL_STATUS_OK; - uint8_t rssi = 0; + int32_t rssi = 0; ap->security = wfx_rsi.sec.security; ap->chan = wfx_rsi.ap_chan; memcpy(&ap->bssid[0], &wfx_rsi.ap_mac.octet[0], BSSID_MAX_STR_LEN); sl_wifi_get_signal_strength(SL_WIFI_CLIENT_INTERFACE, &rssi); ap->rssi = rssi; - return status; } @@ -182,12 +181,9 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t /* * Join was complete - Do the DHCP */ - SILABS_LOG("Join Completed %c: Join Event received with %u bytes payload\n", *result, result_length); + SILABS_LOG("join_callback_handler: join completed."); + SILABS_LOG("%c: Join Event received with %u bytes payload\n", *result, result_length); xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_CONN); - wfx_rsi.join_retries = 0; - retryInterval = WLAN_MIN_RETRY_TIMER_MS; - if (is_wifi_disconnection_event) - is_wifi_disconnection_event = false; callback_status = SL_STATUS_OK; return SL_STATUS_OK; } @@ -234,12 +230,12 @@ int32_t wfx_rsi_power_save() *****************************************************************************************/ int32_t wfx_wifi_rsi_init(void) { + SILABS_LOG("wfx_wifi_rsi_init started"); sl_status_t status; status = sl_wifi_init(&config, default_wifi_event_handler); if (status != SL_STATUS_OK) { SILABS_LOG("wfx_wifi_rsi_init failed %x", status); - return status; } return status; } @@ -252,9 +248,19 @@ int32_t wfx_wifi_rsi_init(void) * @return * None *****************************************************************************************/ -static int32_t wfx_rsi_init(void) +static sl_status_t wfx_rsi_init(void) { sl_status_t status; + +#ifndef RSI_M4_INTERFACE + status = wfx_wifi_rsi_init(); + if (status != SL_STATUS_OK) + { + SILABS_LOG("wfx_rsi_init failed %x", status); + return status; + } +#endif + status = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, (sl_mac_address_t *) &wfx_rsi.sta_mac.octet[0]); if (status != SL_STATUS_OK) { @@ -269,13 +275,18 @@ static int32_t wfx_rsi_init(void) } /************************************************************************************* - * @fn sl_status_t scan_callback_handler + * @fn void wfx_show_err(char *msg) * @brief - * scan callback handler + * driver shows error message * @param[in] msg * @return - * sl_status_t + * None *****************************************************************************************/ +void wfx_show_err(char * msg) +{ + SILABS_LOG("wfx_show_err: message: %d", msg); +} + sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_result, uint32_t result_length, void * arg) { if (CHECK_IF_EVENT_FAILED(event)) @@ -291,7 +302,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * } wfx_rsi.sec.security = WFX_SEC_UNSPECIFIED; wfx_rsi.ap_chan = scan_result->scan_info[0].rf_channel; - memcpy(&wfx_rsi.ap_mac.octet[0], scan_result->scan_info[0].bssid[0], BSSID_MAX_STR_LEN); + memcpy(&wfx_rsi.ap_mac.octet, scan_result->scan_info[0].bssid, BSSID_MAX_STR_LEN); switch (scan_result->scan_info[0].security_mode) { case SL_WIFI_OPEN: @@ -323,15 +334,6 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_results_complete = true; return SL_STATUS_OK; } - -/************************************************************************************* - * @fn sl_status_t show_scan_results - * @brief - * driver shows scan results - * @param[in] msg - * @return - * sl_status_t - *****************************************************************************************/ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) { ARGS_CHECK_NULL_POINTER(scan_result); @@ -339,10 +341,9 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) wfx_wifi_scan_result_t ap; if (wfx_rsi.dev_state & WFX_RSI_ST_STA_CONNECTED) { - for (x = 0; x < scan_result->scan_count; x++) + for (x = 0; x < (int) scan_result->scan_count; x++) { strcpy(&ap.ssid[0], (char *) &scan_result->scan_info[x].ssid); - uint8_t * bssid = (uint8_t *) &scan_result->scan_info[x].bssid; if (wfx_rsi.scan_ssid) { SILABS_LOG("SCAN SSID: %s , ap scan: %s", wfx_rsi.scan_ssid, ap.ssid); @@ -373,15 +374,6 @@ sl_status_t show_scan_results(sl_wifi_scan_result_t * scan_result) } return SL_STATUS_OK; } - -/************************************************************************************* - * @fn bg_scan_callback_handler - * @brief - * scan for wifi events in background - * @param[in] - * @return - * SL_STATUS_OK - *****************************************************************************************/ sl_status_t bg_scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t * result, uint32_t result_length, void * arg) { callback_status = show_scan_results(result); @@ -409,13 +401,12 @@ static void wfx_rsi_save_ap_info() // translation if (SL_STATUS_IN_PROGRESS == status) { const uint32_t start = osKernelGetTickCount(); - while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT) + while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT_TICK) { osThreadYield(); } status = scan_results_complete ? callback_status : SL_STATUS_TIMEOUT; } - return status; } /******************************************************************************************** @@ -425,9 +416,9 @@ static void wfx_rsi_save_ap_info() // translation * @return * None **********************************************************************************************/ -static void wfx_rsi_do_join(void) +static sl_status_t wfx_rsi_do_join(void) { - int32_t status; + sl_status_t status = SL_STATUS_OK; sl_wifi_security_t connect_security_mode; switch (wfx_rsi.sec.security) { @@ -445,8 +436,8 @@ static void wfx_rsi_do_join(void) connect_security_mode = SL_WIFI_OPEN; break; default: - SILABS_LOG("%s: error: unknown security type."); - return; + SILABS_LOG("error: unknown security type."); + return status; } if (wfx_rsi.dev_state & (WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED)) @@ -466,12 +457,7 @@ static void wfx_rsi_do_join(void) */ wfx_rsi.dev_state |= WFX_RSI_ST_STA_CONNECTING; - status = sl_wifi_set_join_callback(join_callback_handler, NULL); - if (SL_STATUS_OK != status) - { - SILABS_LOG(" Set Join Callback fail "); - return status; - } + sl_wifi_set_join_callback(join_callback_handler, NULL); /* Try to connect Wifi with given Credentials * untill there is a success or maximum number of tries allowed @@ -487,6 +473,7 @@ static void wfx_rsi_do_join(void) status = sl_net_set_credential(id, SL_NET_WIFI_PSK, &wfx_rsi.sec.passkey[0], strlen(wfx_rsi.sec.passkey)); if (SL_STATUS_OK != status) { + SILABS_LOG("wfx_rsi_do_join: RSI callback register join failed with status: %02x", status); return status; } @@ -509,21 +496,18 @@ static void wfx_rsi_do_join(void) } else { - if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN) + while (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN) { SILABS_LOG("%s: failed. retry: %d", __func__, wfx_rsi.join_retries); + wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++); + if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN) + xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); SILABS_LOG("%s: starting JOIN to %s after %d tries\n", __func__, (char *) &wfx_rsi.sec.ssid[0], wfx_rsi.join_retries); - wfx_rsi.join_retries += 1; - wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING | WFX_RSI_ST_STA_CONNECTED); - if (wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT) - { - xEventGroupSetBits(wfx_rsi.events, WFX_EVT_STA_START_JOIN); - } - wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries); } } } + return status; } /********************************************************************************* @@ -543,10 +527,10 @@ void wfx_rsi_task(void * arg) TickType_t last_dhcp_poll, now; struct netif * sta_netif; (void) arg; - uint32_t rsi_status = wfx_rsi_init(); - if (rsi_status != RSI_SUCCESS) + sl_status_t status = wfx_rsi_init(); + if (status != RSI_SUCCESS) { - SILABS_LOG("%s: error: wfx_rsi_init with status: %02x", __func__, rsi_status); + SILABS_LOG("wfx_rsi_task: error: wfx_rsi_init with status: %02x", status); return; } wfx_lwip_start(); @@ -554,7 +538,7 @@ void wfx_rsi_task(void * arg) sta_netif = wfx_get_netif(SL_WFX_STA_INTERFACE); wfx_started_notify(); - SILABS_LOG("%s: starting event wait", __func__); + SILABS_LOG("wfx_rsi_task: starting event wait"); for (;;) { /* @@ -604,6 +588,14 @@ void wfx_rsi_task(void * arg) hasNotifiedIPV4 = false; } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ + /* + * Checks if the IPv6 event has been notified, if not invoke the nd6_tmr, + * which starts the duplicate address detectation. + */ + if (!hasNotifiedIPV6) + { + nd6_tmr(); + } /* Checks if the assigned IPv6 address is preferred by evaluating * the first block of IPv6 address ( block 0) */ @@ -625,7 +617,7 @@ void wfx_rsi_task(void * arg) // saving the AP related info wfx_rsi_save_ap_info(); // Joining to the network - wfx_rsi_do_join(); + status = wfx_rsi_do_join(); } if (flags & WFX_EVT_STA_CONN) { @@ -664,9 +656,8 @@ void wfx_rsi_task(void * arg) if (!(wfx_rsi.dev_state & WFX_RSI_ST_SCANSTARTED)) { SILABS_LOG("%s: start SSID scan", __func__); - int x; sl_wifi_scan_configuration_t wifi_scan_configuration = { 0 }; - wfx_wifi_scan_result_t ap; + // TODO: Add scan logic sl_wifi_advanced_scan_configuration_t advanced_scan_configuration = { 0 }; int32_t status; @@ -676,23 +667,16 @@ void wfx_rsi_task(void * arg) advanced_scan_configuration.trigger_level_change = ADV_RSSI_TOLERANCE_THRESHOLD; advanced_scan_configuration.enable_multi_probe = ADV_MULTIPROBE; status = sl_wifi_set_advanced_scan_configuration(&advanced_scan_configuration); - VERIFY_STATUS_AND_RETURN(status); /* Terminate with end of scan which is no ap sent back */ wifi_scan_configuration.type = SL_WIFI_SCAN_TYPE_ADV_SCAN; wifi_scan_configuration.periodic_scan_interval = ADV_SCAN_PERIODICITY; - - status = sl_wifi_set_scan_callback(bg_scan_callback_handler, NULL); - if (SL_STATUS_OK != status) - { - return status; - } - + sl_wifi_set_scan_callback(bg_scan_callback_handler, NULL); status = sl_wifi_start_scan(SL_WIFI_CLIENT_2_4GHZ_INTERFACE, NULL, &wifi_scan_configuration); if (SL_STATUS_IN_PROGRESS == status) { printf("Scanning...\r\n"); const uint32_t start = osKernelGetTickCount(); - while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT) + while (!scan_results_complete && (osKernelGetTickCount() - start) <= WIFI_SCAN_TIMEOUT_TICK) { osThreadYield(); } @@ -740,6 +724,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip) } #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ +#if !EXP_BOARD /* * WARNING - Taken from RSI and broken up * This is my own RSI stuff for not copying code and allocating an extra @@ -763,13 +748,14 @@ void * wfx_rsi_alloc_pkt(uint16_t data_length) /* Confirm if packet is allocated */ status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + data_length, - SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME); + SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS); if (packet == NULL) { return SL_STATUS_ALLOCATION_FAILED; } return (void *) packet; } +#endif /******************************************************************************************** * @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off) @@ -788,3 +774,29 @@ void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off) pkt = (sl_si91x_packet_t *) p; memcpy(((char *) pkt->data) + off, buf, len); } + +#if !EXP_BOARD +/******************************************************************************************** + * @fn int32_t wfx_rsi_send_data(void *p, uint16_t len) + * @brief + * Driver send a data + * @param[in] p: + * @param[in] len: + * @return + * None + **********************************************************************************************/ +int32_t wfx_rsi_send_data(void * p, uint16_t len) +{ + int32_t status; + sl_wifi_buffer_t * buffer; + buffer = (sl_wifi_buffer_t *) p; + + if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME)) + { + SILABS_LOG("*ERR*EN-RSI:Send fail"); + return ERR_IF; + } + return status; +} + +#endif diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index ec7091ad50dada..477ecf1214b0bf 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -62,10 +62,13 @@ if (chip_enable_wifi) { assert(use_rs9116 || use_wf200 || use_SiWx917) import("${chip_root}/src/platform/silabs/wifi_args.gni") - if (use_rs9116 || use_SiWx917) { + if (use_rs9116) { wiseconnect_sdk_root = "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" import("rs911x/rs911x.gni") + } else if (use_SiWx917) { + wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" + import("rs911x/rs9117.gni") } if (use_wf200) { import("wf200/wf200.gni") diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index 62b14e0bd34b51..aff756aad8888a 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -51,11 +51,26 @@ #include "wfx_host_events.h" #include "wfx_rsi.h" +#ifdef CHIP_9117 +#include "cmsis_os2.h" +#include "sl_board_configuration.h" +#include "sl_net.h" +#include "sl_si91x_driver.h" +#include "sl_si91x_types.h" +#include "sl_wifi_callback_framework.h" +#include "sl_wifi_constants.h" +#include "sl_wifi_types.h" +#else #include "rsi_board_configuration.h" #include "rsi_driver.h" +#endif + #include "sl_device_init_dpll.h" #include "sl_device_init_hfxo.h" +#define DEFAULT_SPI_TRASFER_MODE 0 +// Macro to drive semaphore block minimun timer in milli seconds +#define RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS (50) #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" #endif @@ -72,6 +87,8 @@ StaticSemaphore_t xEfxSpiIntfSemaBuffer; static SemaphoreHandle_t spiTransferLock; static TaskHandle_t spiInitiatorTaskHandle = NULL; +static uint32_t dummy_buffer; /* Used for DMA - when results don't matter */ + #if defined(EFR32MG12) #include "sl_spidrv_exp_config.h" extern SPIDRV_Handle_t sl_spidrv_exp_handle; @@ -174,6 +191,18 @@ void rsi_hal_board_init(void) sl_wfx_host_reset_chip(); } +// wifi-sdk +sl_status_t sl_si91x_host_bus_init(void) +{ + rsi_hal_board_init(); + return SL_STATUS_OK; +} + +void sl_si91x_host_enable_high_speed_bus() +{ + // dummy function for wifi-sdk +} + #if defined(EFR32MG24) void SPIDRV_SetBaudrate(uint32_t baudrate) @@ -342,11 +371,12 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint */ if (xlen <= MIN_XLEN || (tx_buf == NULL && rx_buf == NULL)) { - return RSI_ERROR_INVALID_PARAM; + rx_buf = (uint8_t *) &dummy_buffer; + tx_buf = (uint8_t *) &dummy_buffer; } (void) mode; // currently not used; - rsi_error_t rsiError = RSI_ERROR_NONE; + error_t rsiError = RSI_ERROR_NONE; xSemaphoreTake(spiTransferLock, portMAX_DELAY); @@ -398,3 +428,19 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint #endif /* EFR32MG24 */ return rsiError; } + +/********************************************************************* + * @fn int16_t rsi_spi_transfer(uint8_t *tx_buf, uint8_t *rx_buf, uint16_t xlen, uint8_t mode) + * @brief + * Do a SPI transfer - Mode is 8/16 bit - But every 8 bit is aligned + * @param[in] tx_buf: + * @param[in] rx_buf: + * @param[in] xlen: + * @param[in] mode: + * @return + * None + **************************************************************************/ +sl_status_t sl_si91x_host_spi_transfer(const void * tx_buf, void * rx_buf, uint16_t xlen) +{ + return (rsi_spi_transfer((uint8_t *) tx_buf, rx_buf, xlen, DEFAULT_SPI_TRASFER_MODE)); +} diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c index b8edbd71cace76..b57bd9cf988f4f 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_interrupt.c @@ -38,8 +38,16 @@ #include "wfx_host_events.h" #include "wfx_rsi.h" +#if (SIWX_917 | EXP_BOARD) +#include "sl_board_configuration.h" + +#include "sl_si91x_host_interface.h" + +void gpio_interrupt(uint8_t interrupt_number); +#else #include "rsi_board_configuration.h" #include "rsi_driver.h" +#endif typedef void (*UserIntCallBack_t)(void); UserIntCallBack_t call_back, gpio_callback; @@ -52,9 +60,13 @@ void rsi_gpio_irq_cb(uint8_t irqnum) { if (irqnum != SL_WFX_HOST_PINOUT_SPI_IRQ) return; +#if (SIWX_917 | EXP_BOARD) + sl_si91x_host_set_bus_event(NCP_HOST_BUS_RX_EVENT); +#else GPIO_IntClear(1 << SL_WFX_HOST_PINOUT_SPI_IRQ); if (call_back != NULL) (*call_back)(); +#endif } /*===================================================*/ diff --git a/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h b/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h new file mode 100644 index 00000000000000..232a61eaa5a756 --- /dev/null +++ b/examples/platform/silabs/efr32/rs911x/hal/sl_board_configuration.h @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _RSI_BOARD_CONFIGURATION_H_ +#define _RSI_BOARD_CONFIGURATION_H_ + +typedef struct +{ + unsigned char port; + unsigned char pin; +} sl_pin_t; + +#define PIN(port_id, pin_id) \ + (sl_pin_t) { .port = gpioPort##port_id, .pin = pin_id } + +#define PACKET_PENDING_INT_PRI 3 + +#if defined(EFR32MG24_BRD4186C) || defined(BRD4186C) +#include "brd4186c.h" +#elif defined(EFR32MG24_BRD4187C) || defined(BRD4187C) +#include "brd4187c.h" +#else +#error "Need SPI Pins" +#endif /* EFR32MG12_BRD4161A */ +#if EXP_BOARD && (defined(EFR32MG24_BRD4187C) || defined(BRD4187C) || defined(EFR32MG24_BRD4186C) || defined(BRD4186C)) +#define RESET_PIN PIN(A, 6) +#define INTERRUPT_PIN PIN(A, 7) +#define SLEEP_CONFIRM_PIN PIN(A, 5) /* Exp hdr 7 */ +#define SL_WFX_HOST_PINOUT_SPI_IRQ 5 +#endif + +#define NETWORK_INTERFACE_VALID(x) (x == SL_NET_DEFAULT_WIFI_CLIENT_INTERFACE) || (x == SL_NET_DEFAULT_WIFI_AP_INTERFACE) +#endif /* _RSI_BOARD_CONFIGURATION_H_ */ \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/rs9117.gni b/examples/platform/silabs/efr32/rs911x/rs9117.gni index 9f7b895a660650..3aa5e3e775b999 100644 --- a/examples/platform/silabs/efr32/rs911x/rs9117.gni +++ b/examples/platform/silabs/efr32/rs911x/rs9117.gni @@ -2,63 +2,70 @@ import("//build_overrides/chip.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" wifi_sdk_dir = "${chip_root}/src/platform/silabs/efr32/wifi" -wisemcu_sdk_root = "${chip_root}/third_party/silabs/wisemcu-wifi-bt-sdk" +wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" rs911x_src_plat = [ - "${examples_plat_dir}/rs911x/rsi_if.c", + "${examples_plat_dir}/rs911x/sl_wifi_if.c", "${examples_plat_dir}/rs911x/wfx_rsi_host.c", "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_interrupt.c", - "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_ioports.c", - "${examples_plat_dir}/rs911x/hal/rsi_hal_mcu_timer.c", "${examples_plat_dir}/rs911x/hal/efx_spi.c", "${wifi_sdk_dir}/wfx_notify.cpp", ] -# -# All the stuff from wiseconnect -# -rs911x_src_sapi = [ - "${wisemcu_sdk_root}/sapi/wlan/rsi_wlan_apis.c", - "${wisemcu_sdk_root}/sapi/common/rsi_apis_non_rom.c", - "${wisemcu_sdk_root}/sapi/common/rsi_apis_rom.c", - "${wisemcu_sdk_root}/sapi/common/rsi_common_apis.c", - "${wisemcu_sdk_root}/sapi/common/rsi_device_init_apis.c", - "${wisemcu_sdk_root}/sapi/driver/device_interface/spi/rsi_spi_frame_rd_wr.c", - "${wisemcu_sdk_root}/sapi/driver/device_interface/spi/rsi_spi_functs.c", - "${wisemcu_sdk_root}/sapi/driver/device_interface/spi/rsi_spi_iface_init.c", - "${wisemcu_sdk_root}/sapi/driver/device_interface/spi/rsi_spi_mem_rd_wr.c", - "${wisemcu_sdk_root}/sapi/driver/device_interface/spi/rsi_spi_reg_rd_wr.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_common.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_device_init.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_driver_event_handlers.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_driver.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_events_rom.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_events.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_iap.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_nwk_rom.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_nwk.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_pkt_mgmt_rom.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_pkt_mgmt.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_queue_rom.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_queue.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_scheduler_rom.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_scheduler.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_setregion_countryinfo.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_timer.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_utils_rom.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_utils.c", - "${wisemcu_sdk_root}/sapi/driver/rsi_wlan.c", - "${wisemcu_sdk_root}/sapi/rtos/freertos_wrapper/rsi_os_wrapper.c", +rs911x_inc_plat = [ + "${examples_plat_dir}/rs911x", + "${examples_plat_dir}/rs911x/hal", + "${wifi_sdk_root}/components/si91x/ble/inc", + + # si91x component + "${wifi_sdk_root}/components/si91x/inc", + "${wifi_sdk_root}/components/si91x/memory", + "${wifi_sdk_root}/components/si91x/sl_net/inc", + + # wifi component + "${wifi_sdk_root}/components/protocol/wifi/inc", + + # si91x_support component + "${wifi_sdk_root}/components/si91x_support/inc", + + # wifi_resources component + "${wifi_sdk_root}/resources/certificates", + "${wifi_sdk_root}/resources/defaults", + "${wifi_sdk_root}/resources/other", + + # network_manager component + "${wifi_sdk_root}/components/service/network_manager/inc", - # Apparently - the rsi library needs this (though we may not use use it) - "${wisemcu_sdk_root}/sapi/network/socket/rsi_socket.c", - "${wisemcu_sdk_root}/sapi/network/socket/rsi_socket_rom.c", + "${wifi_sdk_root}/components/protocol/wifi/si91x", ] rs911x_cflags = [ "-Wno-empty-body" ] +rs911x_src_sapi = [ + "${wifi_sdk_root}/components/si91x/src/sl_si91x_driver.c", + "${wifi_sdk_root}/components/si91x/spi_interface/sl_si91x_spi_driver.c", + "${wifi_sdk_root}/components/si91x/src/sl_rsi_utility.c", + "${wifi_sdk_root}/components/si91x/src/sl_si91x_callback_framework.c", + "${wifi_sdk_root}/components/si91x/threading/sli_si91x_multithreaded.c", + "${wifi_sdk_root}/components/si91x/sl_net/src/sl_net_si91x.c", + "${wifi_sdk_root}/components/si91x/sl_net/src/sl_net_rsi_utility.c", + "${wifi_sdk_root}/components/si91x/sl_net/src/sl_net_si91x_integration_handler.c", -rs911x_inc_plat = [ - "${examples_plat_dir}/rs911x", - "${examples_plat_dir}/rs911x/hal", - "${wisemcu_sdk_root}/sapi/include", + # wifi component + "${wifi_sdk_root}/components/protocol/wifi/src/sl_wifi_callback_framework.c", + "${wifi_sdk_root}/components/protocol/wifi/si91x/sl_wifi.c", + + # basic_network_manager component + "${wifi_sdk_root}/components/service/network_manager/src/sl_net_basic_credentials.c", + "${wifi_sdk_root}/components/service/network_manager/src/sl_net_basic_profiles.c", + + # si91x_basic_buffers component + "${wifi_sdk_root}/components/si91x/memory/malloc_buffers.c", + + # si91x_support component + "${wifi_sdk_root}/components/si91x_support/src/sl_utility.c", + + # network_manager component + "${wifi_sdk_root}/components/service/network_manager/src/sl_net_basic_certificate_store.c", + "${wifi_sdk_root}/components/service/network_manager/src/sl_net.c", + "${wifi_sdk_root}/components/si91x/platforms/efx32/efx32_ncp_host.c", ] diff --git a/examples/platform/silabs/efr32/rs911x/sl_wifi_if.c b/examples/platform/silabs/efr32/rs911x/sl_wifi_if.c new file mode 120000 index 00000000000000..eae406da321152 --- /dev/null +++ b/examples/platform/silabs/efr32/rs911x/sl_wifi_if.c @@ -0,0 +1 @@ +../../SiWx917/SiWx917/sl_wifi_if.c \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/sl_wlan_config.h b/examples/platform/silabs/efr32/rs911x/sl_wlan_config.h new file mode 100644 index 00000000000000..91acde1ecbcb2a --- /dev/null +++ b/examples/platform/silabs/efr32/rs911x/sl_wlan_config.h @@ -0,0 +1,109 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RSI_CONFIG_H +#define RSI_CONFIG_H + +#include "ble_config.h" +#include "sl_wifi_device.h" + +//! Enable feature +#define RSI_ENABLE 1 +//! Disable feature +#define RSI_DISABLE 0 + +static const sl_wifi_device_configuration_t config = { + .boot_option = LOAD_NWP_FW, + .mac_address = NULL, + .band = SL_SI91X_WIFI_BAND_2_4GHZ, + .region_code = US, + .boot_config = { .oper_mode = SL_SI91X_CLIENT_MODE, + .coex_mode = SL_SI91X_WLAN_BLE_MODE, + .feature_bit_map = +#ifdef RSI_M4_INTERFACE + (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE), +#else + (SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_AGGREGATION), +#endif + .tcp_ip_feature_bit_map = (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | + SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_BYPASS +#ifdef ipv6_FEATURE_REQUIRED + | SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 +#endif + | SL_SI91X_TCP_IP_FEAT_ICMP | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID), + .custom_feature_bit_map = (SL_SI91X_FEAT_CUSTOM_FEAT_EXTENTION_VALID | RSI_CUSTOM_FEATURE_BIT_MAP), + .ext_custom_feature_bit_map = ( +#ifdef CHIP_917 + (RSI_EXT_CUSTOM_FEATURE_BIT_MAP) +#else // defaults +#ifdef RSI_M4_INTERFACE + (SL_SI91X_EXT_FEAT_256K_MODE | RSI_EXT_CUSTOM_FEATURE_BIT_MAP) +#else + (SL_SI91X_EXT_FEAT_384K_MODE | RSI_EXT_CUSTOM_FEATURE_BIT_MAP) +#endif +#endif + | (SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE) +#if (defined A2DP_POWER_SAVE_ENABLE) + | SL_SI91X_EXT_FEAT_XTAL_CLK_ENABLE(2) +#endif + ), + .bt_feature_bit_map = (RSI_BT_FEATURE_BITMAP +#if (RSI_BT_GATT_ON_CLASSIC) + | SL_SI91X_BT_ATT_OVER_CLASSIC_ACL /* to support att over classic acl link */ +#endif + ), +#ifdef RSI_PROCESS_MAX_RX_DATA + .ext_tcp_ip_feature_bit_map = + (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID | SL_SI91X_EXT_TCP_MAX_RECV_LENGTH), +#else + .ext_tcp_ip_feature_bit_map = (RSI_EXT_TCPIP_FEATURE_BITMAP | SL_SI91X_CONFIG_FEAT_EXTENTION_VALID), +#endif + //! ENABLE_BLE_PROTOCOL in bt_feature_bit_map + .ble_feature_bit_map = + ((SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | + SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) | + SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | + SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC)) | + SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENTION_VALID | SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) | + SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE +#if RSI_BLE_GATT_ASYNC_ENABLE + | SL_SI91X_BLE_GATT_ASYNC_ENABLE +#endif + ), + + .ble_ext_feature_bit_map = ((SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | + SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES)) +#if RSI_BLE_INDICATE_CONFIRMATION_FROM_HOST + | SL_SI91X_BLE_INDICATE_CONFIRMATION_FROM_HOST // indication response from app +#endif +#if RSI_BLE_MTU_EXCHANGE_FROM_HOST + | SL_SI91X_BLE_MTU_EXCHANGE_FROM_HOST // MTU Exchange request initiation from app +#endif +#if RSI_BLE_SET_SCAN_RESP_DATA_FROM_HOST + | (SL_SI91X_BLE_SET_SCAN_RESP_DATA_FROM_HOST) // Set SCAN Resp Data from app +#endif +#if RSI_BLE_DISABLE_CODED_PHY_FROM_HOST + | (SL_SI91X_BLE_DISABLE_CODED_PHY_FROM_HOST) // Disable Coded PHY from app +#endif +#if BLE_SIMPLE_GATT + | SL_SI91X_BLE_GATT_INIT +#endif + ), + .config_feature_bit_map = (SL_SI91X_FEAT_SLEEP_GPIO_SEL_BITMAP | RSI_CONFIG_FEATURE_BITMAP) } +}; + +#endif \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index 4b75a7b0c30411..c12e4749b21040 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -32,7 +32,6 @@ #include "event_groups.h" #include "task.h" -#include "rsi_error.h" #include "wfx_host_events.h" #include "wfx_rsi.h" diff --git a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp index bc38b874948eb2..0cc0061c6d9b81 100644 --- a/src/platform/silabs/SiWx917/wifi/ethernetif.cpp +++ b/src/platform/silabs/SiWx917/wifi/ethernetif.cpp @@ -217,7 +217,7 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) /* Confirm if packet is allocated */ status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + framelength, - SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME); + SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS); VERIFY_STATUS_AND_RETURN(status); if (packet == NULL) { diff --git a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h index c63f358774902f..e153a12c0461ae 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_host_events.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_host_events.h @@ -32,7 +32,7 @@ #include "sl_status.h" -#define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME 1000 +#define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS 1000 /* Wi-Fi events*/ #define SL_WFX_STARTUP_IND_ID (1) #define SL_WFX_CONNECT_IND_ID (2) diff --git a/src/platform/silabs/efr32/wifi/ethernetif.cpp b/src/platform/silabs/efr32/wifi/ethernetif.cpp index 8b231c4e8b7898..a7173f38e23e91 100644 --- a/src/platform/silabs/efr32/wifi/ethernetif.cpp +++ b/src/platform/silabs/efr32/wifi/ethernetif.cpp @@ -31,7 +31,24 @@ #include "FreeRTOS.h" #include "event_groups.h" #include "task.h" +#if (SIWX_917 | EXP_BOARD) +#ifdef __cplusplus +extern "C" { +#endif +#include "cmsis_os2.h" +#include "sl_board_configuration.h" +#include "sl_net.h" +#include "sl_si91x_driver.h" +#include "sl_si91x_host_interface.h" +#include "sl_si91x_types.h" +#include "sl_wifi_callback_framework.h" +#include "sl_wifi_constants.h" +#include "sl_wifi_types.h" +#ifdef __cplusplus +} #endif +#endif // (SIWX_917 | EXP_BOARD) +#endif // WF200_WIFI #include "wfx_host_events.h" #include "wifi_config.h" @@ -333,10 +350,18 @@ static SemaphoreHandle_t ethout_sem; ******************************************************************************/ static err_t low_level_output(struct netif * netif, struct pbuf * p) { - void * rsipkt; +#if (SIWX_917 | EXP_BOARD) + sl_wifi_buffer_t * buffer; + sl_si91x_packet_t * packet; + sl_status_t status = SL_STATUS_OK; +#else + void * packet; +#endif struct pbuf * q; uint16_t framelength; - +#ifdef WIFI_DEBUG_ENABLED + SILABS_LOG("LWIP : low_level_output"); +#endif if (xSemaphoreTake(ethout_sem, portMAX_DELAY) != pdTRUE) { return ERR_IF; @@ -351,14 +376,26 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) return ERR_IF; } /* Confirm if packet is allocated */ - rsipkt = wfx_rsi_alloc_pkt(); - if (!rsipkt) +#if (SIWX_917 | EXP_BOARD) + status = sl_si91x_allocate_command_buffer(&buffer, (void **) &packet, sizeof(sl_si91x_packet_t) + p->len, + SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS); + VERIFY_STATUS_AND_RETURN(status); + if (packet == NULL) +#else // RS9116 + packet = wfx_rsi_alloc_pkt(); + if (!packet) +#endif // SIWX_917 { SILABS_LOG("EN-RSI:No buf"); xSemaphoreGive(ethout_sem); +#if (SIWX_917 | EXP_BOARD) + return SL_STATUS_ALLOCATION_FAILED; + } + memset(packet->desc, 0, sizeof(packet->desc)); +#else // RS9116 return ERR_IF; } - +#endif // SIWX_917 #ifdef WIFI_DEBUG_ENABLED uint8_t * b = (uint8_t *) p->payload; SILABS_LOG("EN-RSI: Out [%02x:%02x:%02x:%02x:%02x:%02x][%02x:%02x:%02x:%02x:%02x:%02x]type=%02x%02x", b[0], b[1], b[2], b[3], @@ -367,22 +404,28 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) /* Generate the packet */ for (q = p, framelength = 0; q != NULL; q = q->next) { - wfx_rsi_pkt_add_data(rsipkt, (uint8_t *) (q->payload), (uint16_t) q->len, framelength); + wfx_rsi_pkt_add_data(packet, (uint8_t *) (q->payload), (uint16_t) q->len, framelength); framelength += q->len; } if (framelength < LWIP_FRAME_ALIGNMENT) { /* Add junk data to the end for frame alignment if framelength is less than 60 */ - wfx_rsi_pkt_add_data(rsipkt, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - framelength, framelength); + wfx_rsi_pkt_add_data(packet, (uint8_t *) (p->payload), LWIP_FRAME_ALIGNMENT - framelength, framelength); } #ifdef WIFI_DEBUG_ENABLED SILABS_LOG("EN-RSI: Sending %d", framelength); #endif +#if (SIWX_917 | EXP_BOARD) + packet->length = p->len & 0xFFF; + packet->command = RSI_SEND_RAW_DATA; + if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, 1000)) +#else /* forward the generated packet to RSI to * send the data over wifi network */ - if (wfx_rsi_send_data(rsipkt, framelength)) + if (wfx_rsi_send_data(packet, framelength)) +#endif { SILABS_LOG("*ERR*EN-RSI:Send fail"); xSemaphoreGive(ethout_sem); @@ -397,8 +440,9 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) return ERR_OK; } +#if (SIWX_917 | EXP_BOARD) /***************************************************************************** - * @fn void wfx_host_received_sta_frame_cb(uint8_t *buf, int len) + * @fn void sl_si91x_host_process_data_frame(uint8_t *buf, int len) * @brief * host received frame cb * @@ -409,6 +453,33 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) * @return * None ******************************************************************************/ +sl_status_t sl_si91x_host_process_data_frame(sl_wifi_interface_t interface, sl_wifi_buffer_t * buffer) +{ + void * packet; + struct netif * ifp; + sl_si91x_packet_t * rsi_pkt; + packet = sl_si91x_host_get_buffer_data(buffer, 0, NULL); + rsi_pkt = (sl_si91x_packet_t *) packet; + /* get the network interface for STATION interface, + * and forward the received frame buffer to LWIP + */ + if ((ifp = wfx_get_netif(SL_WFX_STA_INTERFACE)) != (struct netif *) 0) + { + low_level_input(ifp, rsi_pkt->data, rsi_pkt->length); + } + return SL_STATUS_OK; +} +#else + +/***************************************************************************** + * @fn void wfx_host_received_sta_frame_cb(uint8_t *buf, int len) + * @brief + * host received frame cb + * + @@ -409,17 +430,21 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) + * @return + * None + ******************************************************************************/ void wfx_host_received_sta_frame_cb(uint8_t * buf, int len) { struct netif * ifp; @@ -421,6 +492,7 @@ void wfx_host_received_sta_frame_cb(uint8_t * buf, int len) low_level_input(ifp, buf, len); } } +#endif #endif /* RS911x - with LWIP */ diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 4fe2d5a96f6cb7..4070cf4ea93700 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -98,6 +98,14 @@ typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s #include "wfx_msgs.h" +#if (SIWX_917 | EXP_BOARD) +#include "sl_si91x_types.h" +#include "sl_status.h" +#include "sl_wifi_constants.h" + +#define SL_WIFI_ALLOCATE_COMMAND_BUFFER_WAIT_TIME_MS 1000 +#endif + /* Wi-Fi events*/ #define SL_WFX_STARTUP_IND_ID 1 #define SL_WFX_CONNECT_IND_ID 2 @@ -350,13 +358,16 @@ void wfx_ip_changed_notify(int got_ip); #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ void wfx_ipv6_notify(int got_ip); +#if !(SIWX_917 | EXP_BOARD) +void * wfx_rsi_alloc_pkt(void); +#endif + #ifdef RS911X_WIFI /* RSI Power Save */ #if SL_ICD_ENABLED sl_status_t wfx_power_save(); #endif /* SL_ICD_ENABLED */ /* RSI for LWIP */ -void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); int32_t wfx_rsi_send_data(void * p, uint16_t len); #endif /* RS911X_WIFI */ @@ -368,6 +379,12 @@ void sl_wfx_host_gpio_init(void); sl_status_t sl_wfx_host_process_event(sl_wfx_generic_message_t * event_payload); #endif +#if (SIWX_917 | EXP_BOARD) +void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin); +sl_status_t sl_si91x_driver_send_data_packet(sl_si91x_queue_type_t queue_type, sl_wifi_buffer_t * buffer, uint32_t wait_time); +sl_status_t sl_si91x_allocate_command_buffer(sl_wifi_buffer_t ** host_buffer, void ** buffer, uint32_t requested_buffer_size, + uint32_t wait_duration_ms); +#endif void wfx_retry_interval_handler(bool is_wifi_disconnection_event, uint16_t retryJoin); #ifdef __cplusplus diff --git a/src/platform/silabs/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/rs911x/BLEManagerImpl.cpp index d7477b1fa7b494..a1f627bfc03f2a 100644 --- a/src/platform/silabs/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/rs911x/BLEManagerImpl.cpp @@ -42,7 +42,7 @@ extern "C" { #include "wfx_host_events.h" #include "wfx_rsi.h" #include "wfx_sl_ble_init.h" -#ifndef SIWX_917 +#if !(SIWX_917 | EXP_BOARD) #include #endif #include diff --git a/src/platform/silabs/rs911x/rsi_ble_config.h b/src/platform/silabs/rs911x/rsi_ble_config.h index 60b64ff12ab17d..07f50b9528f253 100644 --- a/src/platform/silabs/rs911x/rsi_ble_config.h +++ b/src/platform/silabs/rs911x/rsi_ble_config.h @@ -19,7 +19,7 @@ #define RSI_BLE_CONFIG_H #include "rsi_ble_apis.h" -#ifdef SIWX_917 +#if (SIWX_917 | EXP_BOARD) #include "rsi_user.h" #else #include @@ -90,7 +90,7 @@ #ifdef RSI_M4_INTERFACE #define RSI_BLE_MAX_NBR_ATT_REC (20) -#ifdef SIWX_917 +#if (SIWX_917 | EXP_BOARD) #define RSI_BLE_MAX_NBR_PERIPHERALS (1) #else #define RSI_BLE_MAX_NBR_SLAVES (1) @@ -100,7 +100,7 @@ #else #define RSI_BLE_MAX_NBR_ATT_REC (80) -#ifdef SIWX_917 +#if (SIWX_917 | EXP_BOARD) #define RSI_BLE_MAX_NBR_PERIPHERALS (3) #else #define RSI_BLE_MAX_NBR_SLAVES (3) @@ -111,8 +111,9 @@ #define RSI_BLE_MAX_NBR_ATT_SERV (10) -#ifdef SIWX_917 +#if (SIWX_917 | EXP_BOARD) #define RSI_BLE_MAX_NBR_CENTRALS (1) +#define FRONT_END_SWITCH_SEL2 BIT(30) #else #define RSI_BLE_MAX_NBR_MASTERS (1) #endif @@ -263,13 +264,13 @@ #define BLE_ATT_REC_SIZE (500) #define NO_OF_VAL_ATT (5) //! Attribute value count -#ifdef SIWX_917 +#if (SIWX_917 | EXP_BOARD) #define RSI_FEATURE_BIT_MAP \ (SL_SI91X_FEAT_ULP_GPIO_BASED_HANDSHAKE | SL_SI91X_FEAT_DEV_TO_HOST_ULP_GPIO_1) //! To set wlan feature select bit map #define RSI_TCP_IP_FEATURE_BIT_MAP \ (SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT) //! TCP/IP feature select bitmap for selecting TCP/IP features #define RSI_CUSTOM_FEATURE_BIT_MAP SL_SI91X_FEAT_CUSTOM_FEAT_EXTENTION_VALID //! To set custom feature select bit map -#ifdef CHIP_9117 +#ifdef CHIP_917 #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP \ (SL_SI91X_EXT_FEAT_LOW_POWER_MODE | SL_SI91X_EXT_FEAT_XTAL_CLK_ENABLE(1) | RAM_LEVEL_NWP_BASIC_MCU_ADV | \ SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0) diff --git a/src/platform/silabs/rs911x/wfx_sl_ble_init.c b/src/platform/silabs/rs911x/wfx_sl_ble_init.c index 376fc4321dcd57..b0e1e2378ef341 100644 --- a/src/platform/silabs/rs911x/wfx_sl_ble_init.c +++ b/src/platform/silabs/rs911x/wfx_sl_ble_init.c @@ -185,7 +185,6 @@ int32_t rsi_ble_app_get_event(void) */ void rsi_ble_app_set_event(uint32_t event_num) { - SILABS_LOG("%s: starting", __func__); event_msg.ble_app_event_map |= BIT(event_num); osSemaphoreRelease(sl_ble_event_sem); return; @@ -209,7 +208,6 @@ void rsi_gatt_add_attribute_to_list(rsi_ble_t * p_val, uint16_t handle, uint16_t { if ((p_val->DATA_ix + data_len) >= BLE_ATT_REC_SIZE) { //! Check for max data length for the characteristic value - SILABS_LOG("\r\n no data memory for att rec values \r\n"); return; } diff --git a/src/platform/silabs/rs911x/wfx_sl_ble_init.h b/src/platform/silabs/rs911x/wfx_sl_ble_init.h index 73e29e7fc4d485..2c124f4549caa1 100644 --- a/src/platform/silabs/rs911x/wfx_sl_ble_init.h +++ b/src/platform/silabs/rs911x/wfx_sl_ble_init.h @@ -42,7 +42,7 @@ #include #include #include -#ifndef SIWX_917 +#if !(SIWX_917 | EXP_BOARD) #include #include #include diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 8ecd5ff4db53cd..0c743ddcd83b39 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -21,8 +21,10 @@ import("${chip_root}/src/app/icd/icd.gni") import("${chip_root}/src/lib/lib.gni") import("silabs_board.gni") -if (use_rs9116 || use_SiWx917) { +if (use_rs9116) { wifi_sapi_root = "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" +} else if (use_SiWx917) { + wifi_sdk_root = "${chip_root}/third_party/silabs/wifi_sdk" } declare_args() { @@ -195,6 +197,28 @@ template("efr32_sdk") { "${sl_ot_efr32_root}", ] + if (use_SiWx917) { + _include_dirs += [ + "${wifi_sdk_root}/components/si91x/inc", + "${wifi_sdk_root}/components/si91x/memory", + "${wifi_sdk_root}/components/si91x/sl_net/inc", + + # wifi component + "${wifi_sdk_root}/components/protocol/wifi/inc", + + # si91x_support component + "${wifi_sdk_root}/components/si91x_support/inc", + + # wifi_resources component + "${wifi_sdk_root}/resources/certificates", + "${wifi_sdk_root}/resources/defaults", + "${wifi_sdk_root}/resources/other", + + # network_manager component + "${wifi_sdk_root}/components/service/network_manager/inc", + ] + } + if (silabs_family != "mgm24") { _include_dirs += [ "${efr32_sdk_root}/platform/radio/rail_lib/hal", @@ -203,7 +227,11 @@ template("efr32_sdk") { } if (chip_enable_ble_rs911x) { - _include_dirs += [ "${wifi_sapi_root}/sapi/include" ] + if (use_rs9116) { + _include_dirs += [ "${wifi_sapi_root}/sapi/include" ] + } else { + _include_dirs += [ "${wifi_sdk_root}/components/si91x/ble/inc" ] + } _include_dirs += [ "${chip_root}/src/platform/silabs/rs911x" ] } @@ -255,7 +283,11 @@ template("efr32_sdk") { } if (chip_enable_ble_rs911x) { - defines += [ "RSI_BLE_ENABLE=1" ] + defines += [ + "RSI_BLE_ENABLE=1", + "BLE_ENABLE=1", + "RSI_LITTLE_ENDIAN=1", + ] } if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { @@ -284,7 +316,9 @@ template("efr32_sdk") { if (use_SiWx917) { defines += [ "EXP_BOARD=1", - "CHIP_9117=1", + "CHIP_917", + "CHIP_9117", + "SL_WIFI_COMPONENT_INCLUDED", ] } else if (use_wf200) { defines += [ @@ -703,12 +737,24 @@ template("efr32_sdk") { } if (chip_enable_ble_rs911x) { - sources += [ - "${wifi_sapi_root}/sapi/bluetooth/rsi_ble_gap_apis.c", - "${wifi_sapi_root}/sapi/bluetooth/rsi_ble_gatt_apis.c", - "${wifi_sapi_root}/sapi/bluetooth/rsi_bt_common_apis.c", - "${wifi_sapi_root}/sapi/driver/rsi_bt_ble.c", - ] + if (use_rs9116) { + sources += [ + "${wifi_sapi_root}/sapi/bluetooth/rsi_ble_gap_apis.c", + "${wifi_sapi_root}/sapi/bluetooth/rsi_ble_gatt_apis.c", + "${wifi_sapi_root}/sapi/bluetooth/rsi_bt_common_apis.c", + "${wifi_sapi_root}/sapi/driver/rsi_bt_ble.c", + ] + } else { + sources += [ + "${wifi_sdk_root}/components/si91x/ble/src/rsi_ble_gap_apis.c", + "${wifi_sdk_root}/components/si91x/ble/src/rsi_ble_gatt_apis.c", + "${wifi_sdk_root}/components/si91x/ble/src/rsi_bt_ble.c", + "${wifi_sdk_root}/components/si91x/ble/src/rsi_bt_common_apis.c", + "${wifi_sdk_root}/components/si91x/ble/src/rsi_common_apis.c", + "${wifi_sdk_root}/components/si91x/ble/src/rsi_utils.c", + "${wifi_sdk_root}/components/si91x/ble/src/sl_si91x_ble.c", + ] + } } else { sources += [ "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_mbedtls_context.c",