diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 7ddc56e4b494fb..3c06058a7cb0a9 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -330,7 +330,6 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void) extern "C" void vApplicationIdleHook(void) { #if (SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER) - sl_si91x_invoke_btn_press_event(); sl_si91x_uart_power_requirement_handler(); #endif } diff --git a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp index f5585e66779207..3d820d09ccb1a7 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp +++ b/examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp @@ -67,14 +67,13 @@ extern "C" { #if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE #include "rsi_rom_power_save.h" +#include "sl_gpio_board.h" +#include "sl_si91x_button.h" #include "sl_si91x_button_pin_config.h" +#include "sl_si91x_driver_gpio.h" #include "sl_si91x_power_manager.h" - namespace { -// TODO: should be removed once we are getting the press interrupt for button 0 with sleep -#define BUTTON_PRESSED 1 -bool btn0_pressed = false; - +bool sl_btn0_pressed = false; #ifdef ENABLE_CHIP_SHELL bool ps_requirement_added = false; #endif // ENABLE_CHIP_SHELL @@ -267,24 +266,33 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t #if CHIP_CONFIG_ENABLE_ICD_SERVER #if SLI_SI91X_MCU_INTERFACE // Required to invoke button press event during sleep as falling edge is not detected -void sl_si91x_invoke_btn_press_event(void) +void gpio_uulp_pin_interrupt_callback(uint32_t pin_intr) { - // TODO: should be removed once we are getting the press interrupt for button 0 with sleep - if (!RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) && !btn0_pressed) + // UULP_GPIO_2 is used to detect the button 0 press + VerifyOrReturn(pin_intr == RTE_UULP_GPIO_2_PIN, ChipLogError(DeviceLayer, "invalid pin interrupt: %ld", pin_intr)); + sl_status_t status = SL_STATUS_OK; + while (sl_si91x_gpio_get_uulp_npss_pin(pin_intr) == LOW && sl_btn0_pressed) + ; // button was pressed + + if (sl_si91x_gpio_get_uulp_npss_pin(pin_intr) == LOW && !(sl_btn0_pressed)) { + status = sl_si91x_gpio_driver_mask_uulp_npss_interrupt(BIT(pin_intr)); + sl_btn0_pressed = true; + VerifyOrReturn(status == SL_STATUS_OK, ChipLogError(DeviceLayer, "failed to mask interrupt: %ld", status)); sl_button_on_change(SL_BUTTON_BTN0_NUMBER, BUTTON_PRESSED); - btn0_pressed = true; } - if (RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN)) + else if (sl_si91x_gpio_get_uulp_npss_pin(pin_intr) == HIGH) { - btn0_pressed = false; + sl_btn0_pressed = false; + sl_button_on_change(SL_BUTTON_BTN0_NUMBER, BUTTON_RELEASED); } } + void sl_si91x_uart_power_requirement_handler(void) { #ifdef ENABLE_CHIP_SHELL // Checking the UULP PIN 1 status to reinit the UART and not allow the device to go to sleep - if (RSI_NPSSGPIO_GetPin(RTE_UULP_GPIO_1_PIN)) + if (sl_si91x_gpio_driver_mask_uulp_npss_interrupt(RTE_UULP_GPIO_1_PIN)) { if (!ps_requirement_added) { diff --git a/examples/platform/silabs/wfx_rsi.h b/examples/platform/silabs/wfx_rsi.h index 65b1c54e4660ec..960b0716789d5c 100644 --- a/examples/platform/silabs/wfx_rsi.h +++ b/examples/platform/silabs/wfx_rsi.h @@ -106,8 +106,9 @@ int32_t wfx_rsi_disconnect(); int32_t wfx_wifi_rsi_init(void); #if CHIP_CONFIG_ENABLE_ICD_SERVER #if SLI_SI91X_MCU_INTERFACE -void sl_si91x_invoke_btn_press_event(); void sl_si91x_uart_power_requirement_handler(); +// this is callback from the Wiseconnect SDK +void gpio_uulp_pin_interrupt_callback(uint32_t pin_intr); #endif // SLI_SI91X_MCU_INTERFACE #if SLI_SI917 int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state); diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index d338ea7d0a9162..d993206611cabe 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -309,6 +309,8 @@ template("siwx917_sdk") { "SL_SI91X_NPSS_GPIO_BTN_HANDLER=1", "SL_SI91X_POWER_MANAGER_UC_AVAILABLE=1", "SL_SI91X_TICKLESS_MODE=1", + "SL_ENABLE_GPIO_WAKEUP_SOURCE=1", + "ENABLE_NPSS_GPIO_2=1", ] }