From 10615692e2b38c28b96e6a9f4137a4c86fe60860 Mon Sep 17 00:00:00 2001 From: chbansal Date: Tue, 27 Aug 2024 13:13:14 +0530 Subject: [PATCH] fixing the build for rs9116 --- .../platform/silabs/efr32/rs911x/rsi_if.c | 40 ++++++++++------- .../silabs/efr32/rs911x/wfx_rsi_host.cpp | 43 +++++++++---------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index f0121285383d00..7ca5c11f3e5e27 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -55,14 +55,17 @@ #define WFX_QUEUE_SIZE 10 -/* Rsi driver Task will use as its stack */ -StackType_t driverRsiTaskStack[WFX_RSI_WLAN_TASK_SZ] = { 0 }; - -/* Structure that will hold the TCB of the wfxRsi Task being created. */ -StaticTask_t driverRsiTaskBuffer; - -/* Declare a variable to hold the data associated with the created event group. */ -StaticEventGroup_t rsiDriverEventGroup; +#define kDrvTaskSize 2048 // Example size, adjust as needed + +static uint8_t drvStack[kDrvTaskSize]; +static osThread_t sDrvTaskControlBlock; +osThreadAttr_t kDrvTaskAttr = { .name = "drv_rsi", + .attr_bits = osThreadDetached, + .cb_mem = &sDrvTaskControlBlock, + .cb_size = osThreadCbSize, + .stack_mem = drvStack, + .stack_size = kDrvTaskSize, + .priority = osPriorityHigh }; bool hasNotifiedIPV6 = false; #if (CHIP_DEVICE_CONFIG_ENABLE_IPV4) @@ -83,6 +86,10 @@ static osMessageQueueId_t sWifiEventQueue = NULL; static uint8_t wfx_rsi_drv_buf[WFX_RSI_BUF_SZ]; static wfx_wifi_scan_ext_t temp_reset; +static void rsi_wireless_driver_task_wrapper(void *argument) { + rsi_wireless_driver_task(); +} + static void DHCPTimerEventHandler(void * arg) { WfxEvent_t event; @@ -359,15 +366,16 @@ static int32_t wfx_rsi_init(void) } SILABS_LOG("wfx_rsi_init: start wireless drv task", __func__); /* - * Create the driver task + * Create the driver thread */ - wfx_rsi.drv_task = xTaskCreateStatic((TaskFunction_t) rsi_wireless_driver_task, "rsi_drv", WFX_RSI_WLAN_TASK_SZ, NULL, - WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer); - if (NULL == wfx_rsi.drv_task) - { - SILABS_LOG("wfx_rsi_init: error: rsi_wireless_driver_task failed", __func__); - return RSI_ERROR_INVALID_PARAM; - } + wfx_rsi.drv_thread = osThreadNew(rsi_wireless_driver_task_wrapper, NULL, &kDrvTaskAttr); + // wfx_rsi.drv_task = xTaskCreateStatic((TaskFunction_t) rsi_wireless_driver_task, "rsi_drv", WFX_RSI_WLAN_TASK_SZ, NULL, + // WLAN_TASK_PRIORITY, driverRsiTaskStack, &driverRsiTaskBuffer); + // if (NULL == wfx_rsi.drv_task) + // { + // SILABS_LOG("wfx_rsi_init: error: rsi_wireless_driver_task failed", __func__); + // return RSI_ERROR_INVALID_PARAM; + // } #if (RSI_BLE_ENABLE) if ((status = rsi_wireless_init(OPER_MODE_0, RSI_OPERMODE_WLAN_BLE)) != RSI_SUCCESS) diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp index 8d92c0e3dc5c3e..3b5cf7c8099487 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.cpp @@ -19,27 +19,27 @@ #include #include -#include "em_bus.h" -#include "em_cmu.h" -#include "em_gpio.h" -#include "em_ldma.h" -#include "em_usart.h" -#include "sl_status.h" - -#include "silabs_utils.h" - #include "FreeRTOS.h" #include "event_groups.h" +#include "silabs_utils.h" +#include "sl_status.h" #include "task.h" - #include "wfx_host_events.h" #include "wfx_rsi.h" -/* wfxRsi Task will use as its stack */ -StackType_t wfxRsiTaskStack[WFX_RSI_TASK_SZ] = { 0 }; +#include -/* Structure that will hold the TCB of the wfxRsi Task being created. */ -StaticTask_t wfxRsiTaskBuffer; +// Thread for the WLAN RSI +constexpr uint32_t kWlanTaskSize = 2048; +static uint8_t wlanStack[kWlanTaskSize]; +static osThread_t sWlanTaskControlBlock; +constexpr osThreadAttr_t kWlanTaskAttr = { .name = "wlan_rsi", + .attr_bits = osThreadDetached, + .cb_mem = &sWlanTaskControlBlock, + .cb_size = osThreadCbSize, + .stack_mem = wlanStack, + .stack_size = kWlanTaskSize, + .priority = osPriorityAboveNormal7 }; /********************************************************************* * @fn sl_status_t wfx_wifi_start(void) @@ -52,21 +52,20 @@ StaticTask_t wfxRsiTaskBuffer; ***********************************************************************/ sl_status_t wfx_wifi_start(void) { - if (wfx_rsi.dev_state & WFX_RSI_ST_STARTED) - { + if (wfx_rsi.dev_state & WFX_RSI_ST_STARTED) { return SL_STATUS_OK; } wfx_rsi.dev_state |= WFX_RSI_ST_STARTED; + SILABS_LOG("%s: starting..", __func__); + /* * Create the Wifi driver task */ - wfx_rsi.wlan_task = xTaskCreateStatic(wfx_rsi_task, "wfx_rsi", WFX_RSI_TASK_SZ, NULL, WLAN_DRIVER_TASK_PRIORITY, - wfxRsiTaskStack, &wfxRsiTaskBuffer); + // Creating a Wi-Fi driver thread + wfx_rsi.wlan_thread = osThreadNew(wfx_rsi_task, NULL, &kWlanTaskAttr); + + VerifyOrReturnError(wfx_rsi.wlan_thread != NULL, SL_STATUS_FAIL); - if (NULL == wfx_rsi.wlan_task) - { - return SL_STATUS_FAIL; - } return SL_STATUS_OK; }