From c9dc9271278334bc4fafd24e0bd715564f2c512a Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:58:38 -0400 Subject: [PATCH] [Silabs] Typing Event, state and wfx_rsi (#32546) * Added event enum for events and states, added a typedef for the wfi_rsi struct and changed name so the variable is not named like the type * Converted new type to PascalCase --- .../silabs/SiWx917/SiWx917/sl_wifi_if.c | 2 +- .../platform/silabs/SiWx917/SiWx917/wfx_rsi.h | 53 +++++++++++-------- .../platform/silabs/efr32/rs911x/rsi_if.c | 2 +- .../platform/silabs/efr32/rs911x/wfx_rsi.h | 6 +-- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c index 79ead87460de26..c0cde4d20d3316 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.c @@ -68,7 +68,7 @@ bool btn0_pressed = false; #define TRNGKEY_SIZE 4 #endif // SLI_SI91X_MCU_INTERFACE -struct wfx_rsi wfx_rsi; +WfxRsi_t wfx_rsi; /* Declare a variable to hold the data associated with the created event group. */ StaticEventGroup_t rsiDriverEventGroup; diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h index 998b3ac1ef5d7a..c7642485025815 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h @@ -33,30 +33,37 @@ * Various events fielded by the wfx_rsi task * Make sure that we only use 8 bits (otherwise freeRTOS - may need some changes) */ -#define WFX_EVT_STA_CONN (0x01) -#define WFX_EVT_STA_DISCONN (0x02) -#define WFX_EVT_AP_START (0x04) -#define WFX_EVT_AP_STOP (0x08) -#define WFX_EVT_SCAN (0x10) /* This is used as scan result and start */ -#define WFX_EVT_STA_START_JOIN (0x20) -#define WFX_EVT_STA_DO_DHCP (0x40) -#define WFX_EVT_STA_DHCP_DONE (0x80) +typedef enum +{ + WFX_EVT_STA_CONN = (1 << 0), + WFX_EVT_STA_DISCONN = (1 << 1), + WFX_EVT_AP_START = (1 << 2), + WFX_EVT_AP_STOP = (1 << 3), + WFX_EVT_SCAN = (1 << 4), /* This is used as scan result and start */ + WFX_EVT_STA_START_JOIN = (1 << 5), + WFX_EVT_STA_DO_DHCP = (1 << 6), + WFX_EVT_STA_DHCP_DONE = (1 << 7) +} WfxEventType_e; -#define WFX_RSI_ST_DEV_READY (0x01) -#define WFX_RSI_ST_AP_READY (0x02) -#define WFX_RSI_ST_STA_PROVISIONED (0x04) -#define WFX_RSI_ST_STA_CONNECTING (0x08) -#define WFX_RSI_ST_STA_CONNECTED (0x10) -#define WFX_RSI_ST_STA_DHCP_DONE (0x40) /* Requested to do DHCP after conn */ -#define WFX_RSI_ST_STA_MODE (0x80) /* Enable Station Mode */ -#define WFX_RSI_ST_AP_MODE (0x100) /* Enable AP Mode */ -#define WFX_RSI_ST_STA_READY (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE) -#define WFX_RSI_ST_STARTED (0x200) /* RSI task started */ -#define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */ -#define WFX_RSI_ST_SLEEP_READY (0x800) /* Notify the M4 to go to sleep*/ +typedef enum +{ + WFX_RSI_ST_DEV_READY = (1 << 0), + WFX_RSI_ST_AP_READY = (1 << 1), + WFX_RSI_ST_STA_PROVISIONED = (1 << 2), + WFX_RSI_ST_STA_CONNECTING = (1 << 3), + WFX_RSI_ST_STA_CONNECTED = (1 << 4), + WFX_RSI_ST_STA_DHCP_DONE = (1 << 6), /* Requested to do DHCP after conn */ + WFX_RSI_ST_STA_MODE = (1 << 7), /* Enable Station Mode */ + WFX_RSI_ST_AP_MODE = (1 << 8), /* Enable AP Mode */ + WFX_RSI_ST_STA_READY = (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE), + WFX_RSI_ST_STARTED = (1 << 9), /* RSI task started */ + WFX_RSI_ST_SCANSTARTED = (1 << 10), /* Scan Started */ + WFX_RSI_ST_SLEEP_READY = (1 << 11) /* Notify the M4 to go to sleep*/ +} WfxStateType_e; -struct wfx_rsi +typedef struct wfx_rsi_s { + // TODO: Change tp WfxEventType_e once the event queue is implemented EventGroupHandle_t events; TaskHandle_t drv_task; TaskHandle_t wlan_task; @@ -77,9 +84,9 @@ struct wfx_rsi sl_wfx_mac_address_t ap_bssid; /* To which our STA is connected */ uint16_t join_retries; uint8_t ip4_addr[4]; /* Not sure if this is enough */ -}; +} WfxRsi_t; -extern struct wfx_rsi wfx_rsi; +extern WfxRsi_t wfx_rsi; #ifdef __cplusplus extern "C" { #endif diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index d229251a7a5cf9..00efeee09a4efb 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -866,4 +866,4 @@ int32_t wfx_rsi_send_data(void * p, uint16_t len) return status; } -struct wfx_rsi wfx_rsi; +WfxRsi_t wfx_rsi; diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index 07217056cef11b..86591df72d36d3 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -53,7 +53,7 @@ #define WFX_RSI_ST_SCANSTARTED (0x400) /* Scan Started */ #define WFX_RSI_ST_SLEEP_READY (0x800) /* Notify the M4 to go to sleep*/ -struct wfx_rsi +typedef struct wfx_rsi_s { EventGroupHandle_t events; TaskHandle_t drv_task; @@ -76,9 +76,9 @@ struct wfx_rsi sl_wfx_mac_address_t ap_bssid; /* To which our STA is connected */ uint16_t join_retries; uint8_t ip4_addr[4]; /* Not sure if this is enough */ -}; +} WfxRsi_t; -extern struct wfx_rsi wfx_rsi; +extern WfxRsi_t wfx_rsi; #ifdef __cplusplus extern "C" { #endif