From 4efec986bbdae514e7aac182e2172c0b4534e45d Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Tue, 7 Mar 2023 15:39:42 +0530 Subject: [PATCH 01/17] enabling the sleepy device for EFR32 and rs911x combo --- .../silabs/efr32/rs911x/hal/efx_spi.c | 14 +++ .../efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 109 ++++++++++-------- .../platform/silabs/efr32/rs911x/rsi_if.c | 17 +++ .../silabs/efr32/rs911x/rsi_wlan_config.h | 16 ++- src/platform/silabs/ConnectivityManagerImpl.h | 8 +- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 24 ++++ third_party/silabs/efr32_sdk.gni | 6 +- 7 files changed, 140 insertions(+), 54 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index b053e57486767e..ff6fa7a3bddb59 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -52,6 +52,10 @@ #include "sl_device_init_dpll.h" #include "sl_device_init_hfxo.h" +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) +#include "sl_power_manager.h" +#endif + StaticSemaphore_t xEfxSpiIntfSemaBuffer; static SemaphoreHandle_t spi_sem; @@ -184,6 +188,10 @@ static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void xSemaphoreGiveFromISR(spi_sem, &xHigherPriorityTaskWoken); portYIELD_FROM_ISR(xHigherPriorityTaskWoken); +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_remove_em_requirement(SL_POWER_MANAGER_EM1); +#endif + return true; } @@ -205,6 +213,9 @@ static void receiveDMA(uint8_t * rx_buf, uint16_t xlen) * The xmit can be dummy data (no src increment for tx) */ dummy_data = 0; +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); +#endif DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, (void *) rx_buf, (void *) &(MY_USART->RXDATA), true, xlen, dmadrvDataSize1, rx_dma_complete, NULL); @@ -248,6 +259,9 @@ static void transmitDMA(uint8_t * rx_buf, uint8_t * tx_buf, uint16_t xlen) /* DEBUG */ rx_buf[0] = 0xAA; rx_buf[1] = 0x55; } +#if defined(SL_CATALOG_POWER_MANAGER_PRESENT) + sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); +#endif DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, buf, (void *) &(MY_USART->RXDATA), srcinc, xlen, dmadrvDataSize1, rx_dma_complete, buf); // Start transmit DMA. diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index 1ff5bc5fedf4f2..7385f973a7d7a7 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -40,7 +40,7 @@ #include "rsi_board_configuration.h" #include "rsi_driver.h" - +#define RSI_HAL_LP_SLEEP_CONFIRM_PIN 6 /*===========================================================*/ /** * @fn void rsi_hal_config_gpio(uint8_t gpio_number,uint8_t mode,uint8_t value) @@ -61,15 +61,16 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) CMU_ClockEnable(cmuClock_GPIO, true); - // WFX_RSI_LOG ("RSI: CFG GPIO: 0x%x", gpio_number); - switch (gpio_number) - { - case RSI_HAL_RESET_PIN: - GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET); - break; - default: - break; - } + switch(gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); break; +#ifndef LOGGING_STATS + case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0); break; +#endif + case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, 1); break; + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1);break; + default: break; + } } /*===========================================================*/ @@ -81,19 +82,20 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) * @return none * @description This API is used to drives or makes the host gpio value high. */ -void rsi_hal_set_gpio(uint8_t gpio_number) -{ - // WFX_RSI_LOG ("RSI: SET GPIO: 0x%x", gpio_number); - switch (gpio_number) - { - case RSI_HAL_RESET_PIN: - GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); - break; - default: - break; - } +void rsi_hal_set_gpio(uint8_t gpio_number) { + switch(gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); break; +#ifndef LOGGING_STATS + case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); break; +#else + case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); break; +#endif + case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, 1); break; + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1);break; + default: break; + } } - /*===========================================================*/ /** * @fn uint8_t rsi_hal_get_gpio(void) @@ -103,22 +105,22 @@ void rsi_hal_set_gpio(uint8_t gpio_number) * @return gpio pin value * @description This API is used to configure get the gpio pin value. */ -uint8_t rsi_hal_get_gpio(uint8_t gpio_number) -{ - // WFX_RSI_LOG ("RSI: GET GPIO: 0x%x", gpio_number); - switch (gpio_number) - { - case RSI_HAL_RESET_PIN: - return GPIO_PinInGet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); - case RSI_HAL_MODULE_INTERRUPT_PIN: - return GPIO_PinInGet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin); - default: - break; - } - - return 0; +uint8_t rsi_hal_get_gpio(uint8_t gpio_number) { + switch(gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); +#ifndef LOGGING_STATS + case RSI_HAL_WAKEUP_INDICATION_PIN: return GPIO_PinInGet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); +#else + case RSI_HAL_WAKEUP_INDICATION_PIN: return GPIO_PinInGet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); +#endif + case RSI_HAL_RESET_PIN: return GPIO_PinInGet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); + case RSI_HAL_MODULE_INTERRUPT_PIN: return GPIO_PinInGet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin); + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); + default: break; + } + return 0; } - /*===========================================================*/ /** * @fn void rsi_hal_set_gpio(uint8_t gpio_number) @@ -128,14 +130,25 @@ uint8_t rsi_hal_get_gpio(uint8_t gpio_number) * @return none * @description This API is used to drives or makes the host gpio value low. */ -void rsi_hal_clear_gpio(uint8_t gpio_number) -{ - // WFX_RSI_LOG ("RSI: CLR GPIO: 0x%x", gpio_number); - switch (gpio_number) - { - case RSI_HAL_RESET_PIN: - return GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); - default: - break; - } -} +void rsi_hal_clear_gpio(uint8_t gpio_number) { + switch(gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: + GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); break; +#ifndef LOGGING_STATS + //fall through + case RSI_HAL_WAKEUP_INDICATION_PIN: + GPIO_PinOutClear(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); break; +#else + //fall through + case RSI_HAL_WAKEUP_INDICATION_PIN: + GPIO_PinOutClear(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); break; +#endif + //fall through + case RSI_HAL_RESET_PIN: GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); break; + //fall through + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); break; + //fall through + default: break; + } +} \ No newline at end of file diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 460e9ecd9b7505..2da1a4b6ccf4e4 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -654,6 +654,15 @@ void wfx_rsi_task(void * arg) { wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr); hasNotifiedIPV4 = true; +#if CHIP_DEVICE_CONFIG_ENABLE_SED + // enabling the power save mode for RS9116 if sleepy device is enabled + rsi_status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) { + WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", status); + return status; + } + WFX_RSI_LOG("Powersave Config Success"); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); @@ -673,6 +682,14 @@ void wfx_rsi_task(void * arg) { wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; +#if CHIP_DEVICE_CONFIG_ENABLE_SED + // enabling the power save mode for RS9116 if sleepy device is enabled + rsi_status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (rsi_status != RSI_SUCCESS) { + WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", rsi_status); + } + WFX_RSI_LOG("Powersave Config Success"); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); diff --git a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h index 4f31bdc622698c..948d1026ac6c53 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h +++ b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h @@ -57,15 +57,23 @@ #ifdef RSI_M4_INTERFACE #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_256K_MODE | EXT_FEAT_IEEE_80211W) #else +#ifdef CHIP_9117 +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W) +#else #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) -#endif +#endif /* CHIP_9117 */ +#endif /* WIFI_ENABLE_SECURITY_WPA3 */ #else #ifdef RSI_M4_INTERFACE #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_256K_MODE #else +#ifdef CHIP_9117 +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_448K_M4SS_256K +#else #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_384K_MODE -#endif -#endif +#endif /* CHIP_9117 */ +#endif /* RSI_M4_INTERFACE */ +#endif /* WIFI_ENABLE_SECURITY_WPA3 */ //! To set Extended TCPIP feature select bit map #define RSI_EXT_TCPIP_FEATURE_BITMAP (/*EXT_FEAT_HTTP_OTAF_SUPPORT |*/ EXT_TCP_IP_SSL_16K_RECORD) @@ -309,7 +317,7 @@ //! Power save command parameters /*=======================================================================*/ //! set handshake type of power mode -#define RSI_HAND_SHAKE_TYPE MSG_BASED +#define RSI_HAND_SHAKE_TYPE GPIO_BASED //! 0 - LP, 1- ULP mode with RAM retention and 2 - ULP with Non RAM retention #define RSI_SELECT_LP_OR_ULP_MODE RSI_ULP_WITH_RAM_RET diff --git a/src/platform/silabs/ConnectivityManagerImpl.h b/src/platform/silabs/ConnectivityManagerImpl.h index 6e2540fa300cab..fd464a65c84720 100644 --- a/src/platform/silabs/ConnectivityManagerImpl.h +++ b/src/platform/silabs/ConnectivityManagerImpl.h @@ -105,7 +105,13 @@ class ConnectivityManagerImpl final : public ConnectivityManager, bool _CanStartWiFiScan(); void _OnWiFiScanDone(); void _OnWiFiStationProvisionChange(); -#endif +#if CHIP_DEVICE_CONFIG_ENABLE_SED + ConnectivityManager::SEDIntervalsConfig mIntervalsConfig; + CHIP_ERROR _GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & intervalsConfig); + CHIP_ERROR _SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig); + CHIP_ERROR _RequestSEDActiveMode(bool onOff, bool delayIdle = false); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ +#endif /* CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION */ // ===== Members for internal use by the following friends. friend ConnectivityManager & ConnectivityMgr(void); diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index deb2df49e1dbca..7f70b97c0f92b8 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -220,6 +220,30 @@ void ConnectivityManagerImpl::_OnWiFiStationProvisionChange() DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); } +#if CHIP_DEVICE_CONFIG_ENABLE_SED +CHIP_ERROR ConnectivityManagerImpl::_GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & SEDIntervalsConfig) +{ + // For now Wi-Fi uses DTIM power save mode + SEDIntervalsConfig.ActiveIntervalMS = + chip::System::Clock::Milliseconds32(50); + SEDIntervalsConfig.IdleIntervalMS = + chip::System::Clock::Milliseconds32(300); + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig) +{ + // not required + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_RequestSEDActiveMode(bool onOff, bool delayIdle) +{ + // not required + return CHIP_NO_ERROR; +} +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + // == == == == == == == == == == ConnectivityManager Private Methods == == == == == == == == == == void ConnectivityManagerImpl::DriveStationState() diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 24add51f0e7280..a947e47a2dac2f 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -218,7 +218,11 @@ template("efr32_sdk") { if (use_SiWx917) { #Added this flag only for SiwX917 NCP board #TODO: Remove when rsi_wlan_ext_stats gets implemented using Wisemcu SDK - defines += [ "SiWx917_WIFI" ] + defines += [ + "SiWx917_WIFI", + "EXP_BOARD=1", + "CHIP_9117=1", + ] } else if (use_wf200) { defines += [ "SL_HEAP_SIZE=24576", From 796ab65a327213bc466e37dc254bc53c8f4f2cd1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 Mar 2023 10:14:19 +0000 Subject: [PATCH 02/17] Restyled by whitespace --- examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index 7385f973a7d7a7..3ada2ee3e33d13 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -151,4 +151,4 @@ void rsi_hal_clear_gpio(uint8_t gpio_number) { //fall through default: break; } -} \ No newline at end of file +} From 71511c4056bb76395fb8296f87bee3573049baba Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 Mar 2023 10:14:20 +0000 Subject: [PATCH 03/17] Restyled by clang-format --- .../efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 128 ++++++++++++------ .../platform/silabs/efr32/rs911x/rsi_if.c | 6 +- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 6 +- 3 files changed, 89 insertions(+), 51 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index 3ada2ee3e33d13..8b558f18fc059f 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -61,16 +61,25 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) CMU_ClockEnable(cmuClock_GPIO, true); - switch(gpio_number) - { - case RSI_HAL_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); break; + switch (gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: + GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + break; #ifndef LOGGING_STATS - case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0); break; + case RSI_HAL_WAKEUP_INDICATION_PIN: + GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0); + break; #endif - case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, 1); break; - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1);break; - default: break; - } + case RSI_HAL_RESET_PIN: + GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, 1); + break; + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: + GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + break; + default: + break; + } } /*===========================================================*/ @@ -82,19 +91,31 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) * @return none * @description This API is used to drives or makes the host gpio value high. */ -void rsi_hal_set_gpio(uint8_t gpio_number) { - switch(gpio_number) - { - case RSI_HAL_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); break; +void rsi_hal_set_gpio(uint8_t gpio_number) +{ + switch (gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: + GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + break; #ifndef LOGGING_STATS - case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); break; + case RSI_HAL_WAKEUP_INDICATION_PIN: + GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); + break; #else - case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); break; + case RSI_HAL_WAKEUP_INDICATION_PIN: + GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); + break; #endif - case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, 1); break; - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1);break; - default: break; - } + case RSI_HAL_RESET_PIN: + GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, 1); + break; + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: + GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + break; + default: + break; + } } /*===========================================================*/ /** @@ -105,21 +126,29 @@ void rsi_hal_set_gpio(uint8_t gpio_number) { * @return gpio pin value * @description This API is used to configure get the gpio pin value. */ -uint8_t rsi_hal_get_gpio(uint8_t gpio_number) { - switch(gpio_number) - { - case RSI_HAL_SLEEP_CONFIRM_PIN: return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); +uint8_t rsi_hal_get_gpio(uint8_t gpio_number) +{ + switch (gpio_number) + { + case RSI_HAL_SLEEP_CONFIRM_PIN: + return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); #ifndef LOGGING_STATS - case RSI_HAL_WAKEUP_INDICATION_PIN: return GPIO_PinInGet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); + case RSI_HAL_WAKEUP_INDICATION_PIN: + return GPIO_PinInGet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); #else - case RSI_HAL_WAKEUP_INDICATION_PIN: return GPIO_PinInGet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); + case RSI_HAL_WAKEUP_INDICATION_PIN: + return GPIO_PinInGet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); #endif - case RSI_HAL_RESET_PIN: return GPIO_PinInGet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); - case RSI_HAL_MODULE_INTERRUPT_PIN: return GPIO_PinInGet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin); - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); - default: break; - } - return 0; + case RSI_HAL_RESET_PIN: + return GPIO_PinInGet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); + case RSI_HAL_MODULE_INTERRUPT_PIN: + return GPIO_PinInGet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin); + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: + return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); + default: + break; + } + return 0; } /*===========================================================*/ /** @@ -130,25 +159,34 @@ uint8_t rsi_hal_get_gpio(uint8_t gpio_number) { * @return none * @description This API is used to drives or makes the host gpio value low. */ -void rsi_hal_clear_gpio(uint8_t gpio_number) { - switch(gpio_number) - { +void rsi_hal_clear_gpio(uint8_t gpio_number) +{ + switch (gpio_number) + { case RSI_HAL_SLEEP_CONFIRM_PIN: - GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); break; + GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); + break; #ifndef LOGGING_STATS - //fall through + // fall through case RSI_HAL_WAKEUP_INDICATION_PIN: - GPIO_PinOutClear(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); break; + GPIO_PinOutClear(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); + break; #else - //fall through + // fall through case RSI_HAL_WAKEUP_INDICATION_PIN: - GPIO_PinOutClear(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); break; + GPIO_PinOutClear(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); + break; #endif - //fall through - case RSI_HAL_RESET_PIN: GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); break; - //fall through - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); break; - //fall through - default: break; - } + // fall through + case RSI_HAL_RESET_PIN: + GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); + break; + // fall through + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: + GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); + break; + // fall through + default: + break; + } } diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 2da1a4b6ccf4e4..197a0e98aaf328 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -657,7 +657,8 @@ void wfx_rsi_task(void * arg) #if CHIP_DEVICE_CONFIG_ENABLE_SED // enabling the power save mode for RS9116 if sleepy device is enabled rsi_status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) { + if (status != RSI_SUCCESS) + { WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", status); return status; } @@ -685,7 +686,8 @@ void wfx_rsi_task(void * arg) #if CHIP_DEVICE_CONFIG_ENABLE_SED // enabling the power save mode for RS9116 if sleepy device is enabled rsi_status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (rsi_status != RSI_SUCCESS) { + if (rsi_status != RSI_SUCCESS) + { WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", rsi_status); } WFX_RSI_LOG("Powersave Config Success"); diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 7f70b97c0f92b8..6fd67f1b9b6e9f 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -224,10 +224,8 @@ void ConnectivityManagerImpl::_OnWiFiStationProvisionChange() CHIP_ERROR ConnectivityManagerImpl::_GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & SEDIntervalsConfig) { // For now Wi-Fi uses DTIM power save mode - SEDIntervalsConfig.ActiveIntervalMS = - chip::System::Clock::Milliseconds32(50); - SEDIntervalsConfig.IdleIntervalMS = - chip::System::Clock::Milliseconds32(300); + SEDIntervalsConfig.ActiveIntervalMS = chip::System::Clock::Milliseconds32(50); + SEDIntervalsConfig.IdleIntervalMS = chip::System::Clock::Milliseconds32(300); return CHIP_NO_ERROR; } From fe16ac97a08f7268cb930bd06a55defd45c25c79 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 Mar 2023 10:14:20 +0000 Subject: [PATCH 04/17] Restyled by gn --- third_party/silabs/efr32_sdk.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index a947e47a2dac2f..bb2182e4b4ffb6 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -218,7 +218,7 @@ template("efr32_sdk") { if (use_SiWx917) { #Added this flag only for SiwX917 NCP board #TODO: Remove when rsi_wlan_ext_stats gets implemented using Wisemcu SDK - defines += [ + defines += [ "SiWx917_WIFI", "EXP_BOARD=1", "CHIP_9117=1", From de42b60b8bd91c616e73ec9ac094756d7d2a4479 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Wed, 8 Mar 2023 16:47:45 +0530 Subject: [PATCH 05/17] addressing review comments --- .../silabs/efr32/rs911x/hal/rsi_hal.h | 1 + .../efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 35 ++++++------------- .../platform/silabs/efr32/rs911x/rsi_if.c | 34 +++++++++++------- 3 files changed, 33 insertions(+), 37 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h index 4e195433edc57f..d6a85e28331600 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal.h @@ -27,6 +27,7 @@ #define RSI_HAL_SLEEP_CONFIRM_PIN 2 #define RSI_HAL_WAKEUP_INDICATION_PIN 3 #define RSI_HAL_MODULE_INTERRUPT_PIN 4 +#define RSI_HAL_LP_SLEEP_CONFIRM_PIN 6 //! Timer related macros //! Macro to configure timer type in single shot diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index 8b558f18fc059f..c31824fbc99736 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -40,7 +40,6 @@ #include "rsi_board_configuration.h" #include "rsi_driver.h" -#define RSI_HAL_LP_SLEEP_CONFIRM_PIN 6 /*===========================================================*/ /** * @fn void rsi_hal_config_gpio(uint8_t gpio_number,uint8_t mode,uint8_t value) @@ -64,18 +63,16 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) switch (gpio_number) { case RSI_HAL_SLEEP_CONFIRM_PIN: - GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: + GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); break; #ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: - GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, 0); + GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, PINOUT_CLEAR); break; #endif case RSI_HAL_RESET_PIN: - GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, 1); - break; - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: - GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET); break; default: break; @@ -96,22 +93,20 @@ void rsi_hal_set_gpio(uint8_t gpio_number) switch (gpio_number) { case RSI_HAL_SLEEP_CONFIRM_PIN: - GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: + GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); break; #ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: - GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); + GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, PINOUT_SET); break; #else case RSI_HAL_WAKEUP_INDICATION_PIN: - GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, 1); + GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, PINOUT_SET); break; #endif case RSI_HAL_RESET_PIN: - GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, 1); - break; - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: - GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, 1); + GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); break; default: break; @@ -131,6 +126,7 @@ uint8_t rsi_hal_get_gpio(uint8_t gpio_number) switch (gpio_number) { case RSI_HAL_SLEEP_CONFIRM_PIN: + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); #ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: @@ -143,8 +139,6 @@ uint8_t rsi_hal_get_gpio(uint8_t gpio_number) return GPIO_PinInGet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); case RSI_HAL_MODULE_INTERRUPT_PIN: return GPIO_PinInGet(WFX_INTERRUPT_PIN.port, WFX_INTERRUPT_PIN.pin); - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: - return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); default: break; } @@ -164,28 +158,21 @@ void rsi_hal_clear_gpio(uint8_t gpio_number) switch (gpio_number) { case RSI_HAL_SLEEP_CONFIRM_PIN: + case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); break; #ifndef LOGGING_STATS - // fall through case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinOutClear(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); break; #else - // fall through case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinOutClear(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); break; #endif - // fall through case RSI_HAL_RESET_PIN: GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); break; - // fall through - case RSI_HAL_LP_SLEEP_CONFIRM_PIN: - GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); - break; - // fall through default: break; } diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 197a0e98aaf328..03d2f3b358b9f8 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -192,6 +192,25 @@ int32_t wfx_rsi_disconnect() return status; } +/****************************************************************** + * @fn wfx_rsi_power_save() + * @brief + * Setting the RS911x in DTIM sleep based mode + * + * @param[in] None + * @return + * None + *********************************************************************/ +void wfx_rsi_power_save() +{ + int32_t status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) + { + WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", status); + return; + } + WFX_RSI_LOG("Powersave Config Success"); +} /****************************************************************** * @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len) * @brief @@ -656,13 +675,7 @@ void wfx_rsi_task(void * arg) hasNotifiedIPV4 = true; #if CHIP_DEVICE_CONFIG_ENABLE_SED // enabling the power save mode for RS9116 if sleepy device is enabled - rsi_status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", status); - return status; - } - WFX_RSI_LOG("Powersave Config Success"); + wfx_rsi_power_save(); #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { @@ -685,12 +698,7 @@ void wfx_rsi_task(void * arg) hasNotifiedIPV6 = true; #if CHIP_DEVICE_CONFIG_ENABLE_SED // enabling the power save mode for RS9116 if sleepy device is enabled - rsi_status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (rsi_status != RSI_SUCCESS) - { - WFX_RSI_LOG("Powersave Config Failed, Error Code : 0x%lX", rsi_status); - } - WFX_RSI_LOG("Powersave Config Success"); + wfx_rsi_power_save(); #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { From b3dbbeadf5ed01ab3e3aa79f5ed48a15d2532057 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Tue, 14 Mar 2023 20:48:55 +0530 Subject: [PATCH 06/17] 917 modifications and addressing some review comments --- examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h | 4 ++-- src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp | 4 +--- third_party/silabs/matter_support | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h index 948d1026ac6c53..402ece3ef20ff8 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h +++ b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h @@ -58,7 +58,7 @@ #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_256K_MODE | EXT_FEAT_IEEE_80211W) #else #ifdef CHIP_9117 -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W) +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) #else #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) #endif /* CHIP_9117 */ @@ -68,7 +68,7 @@ #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_256K_MODE #else #ifdef CHIP_9117 -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_448K_M4SS_256K +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) #else #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_384K_MODE #endif /* CHIP_9117 */ diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 6fd67f1b9b6e9f..6b6c5ae4e1b521 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -223,9 +223,7 @@ void ConnectivityManagerImpl::_OnWiFiStationProvisionChange() #if CHIP_DEVICE_CONFIG_ENABLE_SED CHIP_ERROR ConnectivityManagerImpl::_GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & SEDIntervalsConfig) { - // For now Wi-Fi uses DTIM power save mode - SEDIntervalsConfig.ActiveIntervalMS = chip::System::Clock::Milliseconds32(50); - SEDIntervalsConfig.IdleIntervalMS = chip::System::Clock::Milliseconds32(300); + // For now Wi-Fi uses DTIM power save mode so it varies from AP to AP return CHIP_NO_ERROR; } diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 844c91a6647d2a..46133678d495c3 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 844c91a6647d2ab81eb18de7697ff4e65cceb525 +Subproject commit 46133678d495c30044f99c92c7570bf443c011e3 From 33b9ed31b776b429181e7287d55f492da095cec0 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Tue, 14 Mar 2023 20:57:26 +0530 Subject: [PATCH 07/17] Adding comments on the DMA transactions --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index ff6fa7a3bddb59..c29d85dca444e2 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -166,7 +166,8 @@ void rsi_hal_board_init(void) *@fn static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void *userParam) * *@brief - * complete dma + * DMA transfer completion callback. Called by the DMA interrupt handler. + * This is being set in the tx/rx of the DMA * * @param[in] channel: * @param[in] sequenceNO: sequence number @@ -216,6 +217,8 @@ static void receiveDMA(uint8_t * rx_buf, uint16_t xlen) #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); #endif + + // Start receive DMA DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, (void *) rx_buf, (void *) &(MY_USART->RXDATA), true, xlen, dmadrvDataSize1, rx_dma_complete, NULL); @@ -262,6 +265,8 @@ static void transmitDMA(uint8_t * rx_buf, uint8_t * tx_buf, uint16_t xlen) #if defined(SL_CATALOG_POWER_MANAGER_PRESENT) sl_power_manager_add_em_requirement(SL_POWER_MANAGER_EM1); #endif + + // Start receive DMA DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, buf, (void *) &(MY_USART->RXDATA), srcinc, xlen, dmadrvDataSize1, rx_dma_complete, buf); // Start transmit DMA. From 0e31397ac9d66eb3413e5c6d16571b1c42c0c064 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 14 Mar 2023 15:27:58 +0000 Subject: [PATCH 08/17] Restyled by clang-format --- examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h index 402ece3ef20ff8..8baa90479aa591 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h +++ b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h @@ -58,7 +58,8 @@ #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_256K_MODE | EXT_FEAT_IEEE_80211W) #else #ifdef CHIP_9117 -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP \ + (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) #else #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) #endif /* CHIP_9117 */ From 2ed9e5424a75221fba94785762e853425bd9386a Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Wed, 15 Mar 2023 09:56:50 +0530 Subject: [PATCH 09/17] modifying the function signature --- examples/platform/silabs/efr32/rs911x/hal/efx_spi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index c29d85dca444e2..a6a9f29d38ee8a 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -163,7 +163,7 @@ void rsi_hal_board_init(void) } /***************************************************************************** - *@fn static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void *userParam) + *@fn static bool tx_rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void *userParam) * *@brief * DMA transfer completion callback. Called by the DMA interrupt handler. @@ -176,7 +176,7 @@ void rsi_hal_board_init(void) * @return * None ******************************************************************************/ -static bool rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void * userParam) +static bool tx_rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void * userParam) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; // uint8_t *buf = (void *)userParam; @@ -220,7 +220,7 @@ static void receiveDMA(uint8_t * rx_buf, uint16_t xlen) // Start receive DMA DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, (void *) rx_buf, (void *) &(MY_USART->RXDATA), true, xlen, - dmadrvDataSize1, rx_dma_complete, NULL); + dmadrvDataSize1, tx_rx_dma_complete, NULL); // Start transmit DMA. DMADRV_MemoryPeripheral(tx_dma_channel, MY_USART_TX_SIGNAL, (void *) &(MY_USART->TXDATA), (void *) &(dummy_data), false, xlen, @@ -268,7 +268,7 @@ static void transmitDMA(uint8_t * rx_buf, uint8_t * tx_buf, uint16_t xlen) // Start receive DMA DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, buf, (void *) &(MY_USART->RXDATA), srcinc, xlen, dmadrvDataSize1, - rx_dma_complete, buf); + tx_rx_dma_complete, buf); // Start transmit DMA. DMADRV_MemoryPeripheral(tx_dma_channel, MY_USART_TX_SIGNAL, (void *) &(MY_USART->TXDATA), (void *) tx_buf, true, xlen, dmadrvDataSize1, NULL, NULL); @@ -308,7 +308,7 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint * receiveDMA() and transmitDMA() are asynchronous * Our application design assumes that this function is synchronous * To make it synchronous, we wait to re-acquire the semaphore before exiting this function - * rx_dma_complete() gives back the semaphore when the SPI transfer is done + * tx_rx_dma_complete() gives back the semaphore when the SPI transfer is done */ if (xSemaphoreTake(spi_sem, pdMS_TO_TICKS(RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS)) == pdTRUE) { From cfbeec19430a6311022b4fdabdfdc2fcb473533c Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 16 Mar 2023 09:49:22 +0530 Subject: [PATCH 10/17] switch case modifications as per the suggestions --- .../silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index c31824fbc99736..8ba330390f5fdb 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -66,10 +66,12 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); break; -#ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: +#ifndef LOGGING_STATS GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, PINOUT_CLEAR); break; +#else + GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, PINOUT_CLEAR); #endif case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET); @@ -96,12 +98,11 @@ void rsi_hal_set_gpio(uint8_t gpio_number) case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinModeSet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); break; -#ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: +#ifndef LOGGING_STATS GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, PINOUT_SET); break; #else - case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, PINOUT_SET); break; #endif @@ -128,11 +129,10 @@ uint8_t rsi_hal_get_gpio(uint8_t gpio_number) case RSI_HAL_SLEEP_CONFIRM_PIN: case RSI_HAL_LP_SLEEP_CONFIRM_PIN: return GPIO_PinInGet(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); -#ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: +#ifndef LOGGING_STATS return GPIO_PinInGet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); #else - case RSI_HAL_WAKEUP_INDICATION_PIN: return GPIO_PinInGet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); #endif case RSI_HAL_RESET_PIN: @@ -161,12 +161,11 @@ void rsi_hal_clear_gpio(uint8_t gpio_number) case RSI_HAL_LP_SLEEP_CONFIRM_PIN: GPIO_PinOutClear(WFX_SLEEP_CONFIRM_PIN.port, WFX_SLEEP_CONFIRM_PIN.pin); break; -#ifndef LOGGING_STATS case RSI_HAL_WAKEUP_INDICATION_PIN: +#ifndef LOGGING_STATS GPIO_PinOutClear(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); break; #else - case RSI_HAL_WAKEUP_INDICATION_PIN: GPIO_PinOutClear(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); break; #endif From 7577f3d03a6902ae934be6ef456c0de984f6665a Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 16 Mar 2023 09:51:37 +0530 Subject: [PATCH 11/17] bugfix switch case missed break --- examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index 8ba330390f5fdb..2109c70a2eb3e3 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -72,6 +72,7 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) break; #else GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, PINOUT_CLEAR); + break; #endif case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET); From af13a6dbd5d751aa7d7bba8b5cad4da80727a2b4 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 16 Mar 2023 19:15:12 +0530 Subject: [PATCH 12/17] addressing review comments --- src/platform/silabs/CHIPDevicePlatformConfig.h | 5 +++++ src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 30cfcf437f5b13..ef11e47d1a2820 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -61,6 +61,11 @@ #define CHIP_DEVICE_CONFIG_ENABLE_IPV4 0 #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ +#ifdef CHIP_DEVICE_CONFIG_ENABLE_SED +#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL chip::System::Clock::Milliseconds32(300) +#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL chip::System::Clock::Milliseconds32(10) +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + #endif /* SL_WIFI */ // ========== Platform-specific Configuration ========= diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index 6b6c5ae4e1b521..ffddb027c617b4 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -224,19 +224,22 @@ void ConnectivityManagerImpl::_OnWiFiStationProvisionChange() CHIP_ERROR ConnectivityManagerImpl::_GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & SEDIntervalsConfig) { // For now Wi-Fi uses DTIM power save mode so it varies from AP to AP + // TODO: Change this to DTIM read from DUT once it is done. For now hardcoding it + SEDIntervalsConfig.ActiveIntervalMS = CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL; + SEDIntervalsConfig.IdleIntervalMS = CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL; return CHIP_NO_ERROR; } CHIP_ERROR ConnectivityManagerImpl::_SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig) { // not required - return CHIP_NO_ERROR; + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } CHIP_ERROR ConnectivityManagerImpl::_RequestSEDActiveMode(bool onOff, bool delayIdle) { // not required - return CHIP_NO_ERROR; + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ From 505ead7a66c4846eb710c0b2365c5492574dc5b6 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 16 Mar 2023 13:45:53 +0000 Subject: [PATCH 13/17] Restyled by clang-format --- src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index ffddb027c617b4..c7335e6a230155 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -226,7 +226,7 @@ CHIP_ERROR ConnectivityManagerImpl::_GetSEDIntervalsConfig(ConnectivityManager:: // For now Wi-Fi uses DTIM power save mode so it varies from AP to AP // TODO: Change this to DTIM read from DUT once it is done. For now hardcoding it SEDIntervalsConfig.ActiveIntervalMS = CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL; - SEDIntervalsConfig.IdleIntervalMS = CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL; + SEDIntervalsConfig.IdleIntervalMS = CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL; return CHIP_NO_ERROR; } From 98908bee217d7fa0ea72294068490384f33cb6d6 Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 16 Mar 2023 23:16:42 +0530 Subject: [PATCH 14/17] addressing review comments --- .../silabs/efr32/rs911x/hal/efx_spi.c | 10 +++---- .../silabs/efr32/rs911x/rsi_wlan_config.h | 30 +++++++------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c index a6a9f29d38ee8a..193604a72e1929 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c +++ b/examples/platform/silabs/efr32/rs911x/hal/efx_spi.c @@ -163,7 +163,7 @@ void rsi_hal_board_init(void) } /***************************************************************************** - *@fn static bool tx_rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void *userParam) + *@fn static bool dma_complete_cb(unsigned int channel, unsigned int sequenceNo, void *userParam) * *@brief * DMA transfer completion callback. Called by the DMA interrupt handler. @@ -176,7 +176,7 @@ void rsi_hal_board_init(void) * @return * None ******************************************************************************/ -static bool tx_rx_dma_complete(unsigned int channel, unsigned int sequenceNo, void * userParam) +static bool dma_complete_cb(unsigned int channel, unsigned int sequenceNo, void * userParam) { BaseType_t xHigherPriorityTaskWoken = pdFALSE; // uint8_t *buf = (void *)userParam; @@ -220,7 +220,7 @@ static void receiveDMA(uint8_t * rx_buf, uint16_t xlen) // Start receive DMA DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, (void *) rx_buf, (void *) &(MY_USART->RXDATA), true, xlen, - dmadrvDataSize1, tx_rx_dma_complete, NULL); + dmadrvDataSize1, dma_complete_cb, NULL); // Start transmit DMA. DMADRV_MemoryPeripheral(tx_dma_channel, MY_USART_TX_SIGNAL, (void *) &(MY_USART->TXDATA), (void *) &(dummy_data), false, xlen, @@ -268,7 +268,7 @@ static void transmitDMA(uint8_t * rx_buf, uint8_t * tx_buf, uint16_t xlen) // Start receive DMA DMADRV_PeripheralMemory(rx_dma_channel, MY_USART_RX_SIGNAL, buf, (void *) &(MY_USART->RXDATA), srcinc, xlen, dmadrvDataSize1, - tx_rx_dma_complete, buf); + dma_complete_cb, buf); // Start transmit DMA. DMADRV_MemoryPeripheral(tx_dma_channel, MY_USART_TX_SIGNAL, (void *) &(MY_USART->TXDATA), (void *) tx_buf, true, xlen, dmadrvDataSize1, NULL, NULL); @@ -308,7 +308,7 @@ int16_t rsi_spi_transfer(uint8_t * tx_buf, uint8_t * rx_buf, uint16_t xlen, uint * receiveDMA() and transmitDMA() are asynchronous * Our application design assumes that this function is synchronous * To make it synchronous, we wait to re-acquire the semaphore before exiting this function - * tx_rx_dma_complete() gives back the semaphore when the SPI transfer is done + * dma_complete_cb() gives back the semaphore when the SPI transfer is done */ if (xSemaphoreTake(spi_sem, pdMS_TO_TICKS(RSI_SEM_BLOCK_MIN_TIMER_VALUE_MS)) == pdTRUE) { diff --git a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h index 8baa90479aa591..fa2cb5ce10d5f4 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h +++ b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h @@ -54,26 +54,18 @@ //! To set Extended custom feature select bit map #if WIFI_ENABLE_SECURITY_WPA3 -#ifdef RSI_M4_INTERFACE -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_256K_MODE | EXT_FEAT_IEEE_80211W) + #ifdef CHIP_9117 + #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP \ + (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) + #else + #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) + #endif /* CHIP_9117 */ #else -#ifdef CHIP_9117 -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP \ - (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) -#else -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) -#endif /* CHIP_9117 */ -#endif /* WIFI_ENABLE_SECURITY_WPA3 */ -#else -#ifdef RSI_M4_INTERFACE -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_256K_MODE -#else -#ifdef CHIP_9117 -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) -#else -#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_384K_MODE -#endif /* CHIP_9117 */ -#endif /* RSI_M4_INTERFACE */ + #ifdef CHIP_9117 + #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) + #else + #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_384K_MODE + #endif /* CHIP_9117 */ #endif /* WIFI_ENABLE_SECURITY_WPA3 */ //! To set Extended TCPIP feature select bit map From 251f6951acc78e60bff5c850b169e4760627610a Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Thu, 16 Mar 2023 23:23:36 +0530 Subject: [PATCH 15/17] restyle changes --- .../silabs/efr32/rs911x/rsi_wlan_config.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h index fa2cb5ce10d5f4..f52419301e4aaa 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h +++ b/examples/platform/silabs/efr32/rs911x/rsi_wlan_config.h @@ -54,18 +54,18 @@ //! To set Extended custom feature select bit map #if WIFI_ENABLE_SECURITY_WPA3 - #ifdef CHIP_9117 - #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP \ - (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) - #else - #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) - #endif /* CHIP_9117 */ +#ifdef CHIP_9117 +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP \ + (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_IEEE_80211W | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) #else - #ifdef CHIP_9117 - #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) - #else - #define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_384K_MODE - #endif /* CHIP_9117 */ +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_384K_MODE | EXT_FEAT_IEEE_80211W) +#endif /* CHIP_9117 */ +#else +#ifdef CHIP_9117 +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP (EXT_FEAT_448K_M4SS_256K | EXT_FEAT_LOW_POWER_MODE | EXT_FEAT_XTAL_CLK_ENABLE) +#else +#define RSI_EXT_CUSTOM_FEATURE_BIT_MAP EXT_FEAT_384K_MODE +#endif /* CHIP_9117 */ #endif /* WIFI_ENABLE_SECURITY_WPA3 */ //! To set Extended TCPIP feature select bit map From 9d7467f6cf1843713bf3f5be886df791f33b309f Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Fri, 17 Mar 2023 10:17:51 +0530 Subject: [PATCH 16/17] Addressing review comments --- .../silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c index 2109c70a2eb3e3..6ea20caf48a018 100644 --- a/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c +++ b/examples/platform/silabs/efr32/rs911x/hal/rsi_hal_mcu_ioports.c @@ -69,11 +69,10 @@ void rsi_hal_config_gpio(uint8_t gpio_number, uint8_t mode, uint8_t value) case RSI_HAL_WAKEUP_INDICATION_PIN: #ifndef LOGGING_STATS GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, PINOUT_CLEAR); - break; #else GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeWiredOrPullDown, PINOUT_CLEAR); - break; #endif + break; case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModePushPull, PINOUT_SET); break; @@ -102,11 +101,10 @@ void rsi_hal_set_gpio(uint8_t gpio_number) case RSI_HAL_WAKEUP_INDICATION_PIN: #ifndef LOGGING_STATS GPIO_PinModeSet(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin, gpioModeInput, PINOUT_SET); - break; #else GPIO_PinModeSet(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin, gpioModeInput, PINOUT_SET); - break; #endif + break; case RSI_HAL_RESET_PIN: GPIO_PinModeSet(WFX_RESET_PIN.port, WFX_RESET_PIN.pin, gpioModeWiredOrPullDown, PINOUT_SET); break; @@ -165,11 +163,10 @@ void rsi_hal_clear_gpio(uint8_t gpio_number) case RSI_HAL_WAKEUP_INDICATION_PIN: #ifndef LOGGING_STATS GPIO_PinOutClear(WAKE_INDICATOR_PIN.port, WAKE_INDICATOR_PIN.pin); - break; #else GPIO_PinOutClear(LOGGING_WAKE_INDICATOR_PIN.port, LOGGING_WAKE_INDICATOR_PIN.pin); - break; #endif + break; case RSI_HAL_RESET_PIN: GPIO_PinOutClear(WFX_RESET_PIN.port, WFX_RESET_PIN.pin); break; From d6ff6b7cc6e1e85a10a88e87b131689b33707e5f Mon Sep 17 00:00:00 2001 From: Chirag Bansal Date: Mon, 20 Mar 2023 19:25:06 +0530 Subject: [PATCH 17/17] sleepy devices when rs9116 ble is in use --- examples/platform/silabs/efr32/rs911x/rsi_if.c | 6 ++++++ .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 18 ++++++++++++++++++ .../silabs/efr32/rs911x/rsi_ble_config.h | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 03d2f3b358b9f8..88bc13fd4288e7 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -674,8 +674,11 @@ void wfx_rsi_task(void * arg) wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr); hasNotifiedIPV4 = true; #if CHIP_DEVICE_CONFIG_ENABLE_SED +#ifndef RSI_BLE_ENABLE // enabling the power save mode for RS9116 if sleepy device is enabled + // if BLE is used on the rs9116 then powersave config is done after ble disconnect event wfx_rsi_power_save(); +#endif /* RSI_BLE_ENABLE */ #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { @@ -697,8 +700,11 @@ void wfx_rsi_task(void * arg) wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; #if CHIP_DEVICE_CONFIG_ENABLE_SED +#ifndef RSI_BLE_ENABLE // enabling the power save mode for RS9116 if sleepy device is enabled + // if BLE is used on the rs9116 then powersave config is done after ble disconnect event wfx_rsi_power_save(); +#endif /* RSI_BLE_ENABLE */ #endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index 4ba427c84c8811..c931ee7f35dba7 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -719,6 +719,24 @@ void BLEManagerImpl::HandleConnectionCloseEvent(uint16_t reason) ChipLogProgress(DeviceLayer, "Disconnect Event for handle : %d", connHandle); +#if CHIP_DEVICE_CONFIG_ENABLE_SED + int32_t status; + status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) + { + WFX_RSI_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); + return; + } + + status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) + { + WFX_RSI_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status); + return; + } + WFX_RSI_LOG("Powersave Config Success"); +#endif + if (RemoveConnection(connHandle)) { ChipDeviceEvent event; diff --git a/src/platform/silabs/efr32/rs911x/rsi_ble_config.h b/src/platform/silabs/efr32/rs911x/rsi_ble_config.h index e743bc27309c07..e2bf5b05b36158 100644 --- a/src/platform/silabs/efr32/rs911x/rsi_ble_config.h +++ b/src/platform/silabs/efr32/rs911x/rsi_ble_config.h @@ -241,7 +241,7 @@ //! Power save command parameters /*=======================================================================*/ //! set handshake type of power mode -//#define RSI_HAND_SHAKE_TYPE GPIO_BASED +#define RSI_HAND_SHAKE_TYPE GPIO_BASED #define BLE_ATT_REC_SIZE 500 #define NO_OF_VAL_ATT 5 //! Attribute value count