From 51c4eea663fd3af18deaaadc289eb5d15fb617c0 Mon Sep 17 00:00:00 2001 From: bhmanda Date: Thu, 5 Dec 2024 00:38:41 +0530 Subject: [PATCH 1/4] Added button and leds macros with led and button code --- examples/platform/silabs/MatterConfig.cpp | 2 ++ .../silabs/SiWx917/SiWxPlatformInterface.h | 5 ++++- .../platformAbstraction/WiseMcuSpam.cpp | 20 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 8d4b67c2d7..1193012851 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -391,7 +391,9 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void) extern "C" void vApplicationIdleHook(void) { #if (SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER) +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT SiWxPlatformInterface::sl_si91x_btn_event_handler(); +#endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT SiWxPlatformInterface::sl_si91x_uart_power_requirement_handler(); #endif } diff --git a/src/platform/silabs/SiWx917/SiWxPlatformInterface.h b/src/platform/silabs/SiWx917/SiWxPlatformInterface.h index 1b654332f1..15dacb874a 100644 --- a/src/platform/silabs/SiWx917/SiWxPlatformInterface.h +++ b/src/platform/silabs/SiWx917/SiWxPlatformInterface.h @@ -30,8 +30,10 @@ extern "C" { #endif #if CHIP_CONFIG_ENABLE_ICD_SERVER #if SLI_SI91X_MCU_INTERFACE +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_si91x_button.h" #include "sl_si91x_button_pin_config.h" +#endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_si91x_driver_gpio.h" #include "sl_si91x_power_manager.h" @@ -70,6 +72,7 @@ namespace SiWxPlatformInterface { #if CHIP_CONFIG_ENABLE_ICD_SERVER #if SLI_SI91X_MCU_INTERFACE +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT /** * @brief Required to invoke button press event during sleep as falling edge is not detected * @param[in] none. @@ -81,7 +84,7 @@ inline void sl_si91x_btn_event_handler() sl_button_on_change(SL_BUTTON_BTN0_NUMBER, (sl_si91x_gpio_get_uulp_npss_pin(SL_BUTTON_BTN0_PIN) == LOW) ? BUTTON_PRESSED : BUTTON_RELEASED); } - +#endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT /** * @brief Required to enable MATTER shell UART with ICD feature flag * @param[in] none. diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp index 1b03de76f3..9a609940b3 100644 --- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp @@ -16,7 +16,6 @@ */ #include -#include #include #include @@ -36,8 +35,13 @@ extern "C" { #include "em_core.h" #include "rsi_board.h" #include "sl_event_handler.h" + +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_si91x_button.h" #include "sl_si91x_button_pin_config.h" +#endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT + +#ifdef ENABLE_WSTK_LEDS #if defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED #include "sl_si91x_rgb_led.h" #include "sl_si91x_rgb_led_config.h" @@ -47,6 +51,7 @@ extern "C" { #include "sl_si91x_led_config.h" #include "sl_si91x_led_instances.h" #endif // defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#endif // ENABLE_WSTK_LEDS #if CHIP_CONFIG_ENABLE_ICD_SERVER == 0 void soc_pll_config(void); @@ -61,6 +66,7 @@ void soc_pll_config(void); #include "uart.h" #endif +#ifdef ENABLE_WSTK_LEDS #if defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED #define SL_LED_COUNT SL_SI91X_RGB_LED_COUNT const sl_rgb_led_t * ledPinArray[SL_LED_COUNT] = { &led_led0 }; @@ -69,12 +75,17 @@ const sl_rgb_led_t * ledPinArray[SL_LED_COUNT] = { &led_led0 }; #define SL_LED_COUNT SL_SI91x_LED_COUNT uint8_t ledPinArray[SL_LED_COUNT] = { SL_LED_LED0_PIN, SL_LED_LED1_PIN }; #endif // defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#endif // ENABLE_WSTK_LEDS namespace chip { namespace DeviceLayer { namespace Silabs { namespace { + +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT uint8_t sButtonStates[SL_SI91x_BUTTON_COUNT] = { 0 }; +#endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT + #if CHIP_CONFIG_ENABLE_ICD_SERVER bool btn0_pressed = false; #endif /* SL_ICD_ENABLED */ @@ -152,6 +163,7 @@ void SilabsPlatform::StartScheduler() vTaskStartScheduler(); } +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT extern "C" void sl_button_on_change(uint8_t btn, uint8_t btnAction) { #if SL_ICD_ENABLED @@ -191,6 +203,12 @@ uint8_t SilabsPlatform::GetButtonState(uint8_t button) { return (button < SL_SI91x_BUTTON_COUNT) ? sButtonStates[button] : 0; } +#else +uint8_t SilabsPlatform::GetButtonState(uint8_t button) +{ + return 0; +} +#endif // SL_CATALOG_SIMPLE_BUTTON_PRESENT CHIP_ERROR SilabsPlatform::FlashInit() { From d75a77fb4d7f429c360484e5488fce15bd14d8d6 Mon Sep 17 00:00:00 2001 From: bhmanda Date: Fri, 6 Dec 2024 00:42:18 +0530 Subject: [PATCH 2/4] Resolved review comments --- .../platformAbstraction/WiseMcuSpam.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp index 9a609940b3..e9105a4915 100644 --- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp @@ -41,18 +41,6 @@ extern "C" { #include "sl_si91x_button_pin_config.h" #endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT -#ifdef ENABLE_WSTK_LEDS -#if defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED -#include "sl_si91x_rgb_led.h" -#include "sl_si91x_rgb_led_config.h" -#include "sl_si91x_rgb_led_instances.h" -#else -#include "sl_si91x_led.h" -#include "sl_si91x_led_config.h" -#include "sl_si91x_led_instances.h" -#endif // defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED -#endif // ENABLE_WSTK_LEDS - #if CHIP_CONFIG_ENABLE_ICD_SERVER == 0 void soc_pll_config(void); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER @@ -68,6 +56,13 @@ void soc_pll_config(void); #ifdef ENABLE_WSTK_LEDS #if defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#include "sl_si91x_rgb_led.h" +#include "sl_si91x_rgb_led_config.h" +#include "sl_si91x_rgb_led_instances.h" +#else +#include "sl_si91x_led.h" +#include "sl_si91x_led_config.h" +#include "sl_si91x_led_instances.h" #define SL_LED_COUNT SL_SI91X_RGB_LED_COUNT const sl_rgb_led_t * ledPinArray[SL_LED_COUNT] = { &led_led0 }; #define SL_RGB_LED_INSTANCE(n) (ledPinArray[n]) From c198cb4f482d0ad04235c2e9e0879a8b9e983a74 Mon Sep 17 00:00:00 2001 From: bhmanda Date: Fri, 6 Dec 2024 00:55:48 +0530 Subject: [PATCH 3/4] Resolved review comments --- .../platformAbstraction/WiseMcuSpam.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp index e9105a4915..d47395e6c7 100644 --- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp @@ -41,6 +41,16 @@ extern "C" { #include "sl_si91x_button_pin_config.h" #endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT +#if defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#include "sl_si91x_rgb_led.h" +#include "sl_si91x_rgb_led_config.h" +#include "sl_si91x_rgb_led_instances.h" +#else +#include "sl_si91x_led.h" +#include "sl_si91x_led_config.h" +#include "sl_si91x_led_instances.h" +#endif //defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED + #if CHIP_CONFIG_ENABLE_ICD_SERVER == 0 void soc_pll_config(void); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER @@ -54,23 +64,14 @@ void soc_pll_config(void); #include "uart.h" #endif -#ifdef ENABLE_WSTK_LEDS -#if defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED -#include "sl_si91x_rgb_led.h" -#include "sl_si91x_rgb_led_config.h" -#include "sl_si91x_rgb_led_instances.h" -#else -#include "sl_si91x_led.h" -#include "sl_si91x_led_config.h" -#include "sl_si91x_led_instances.h" +#if defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED #define SL_LED_COUNT SL_SI91X_RGB_LED_COUNT const sl_rgb_led_t * ledPinArray[SL_LED_COUNT] = { &led_led0 }; #define SL_RGB_LED_INSTANCE(n) (ledPinArray[n]) #else #define SL_LED_COUNT SL_SI91x_LED_COUNT uint8_t ledPinArray[SL_LED_COUNT] = { SL_LED_LED0_PIN, SL_LED_LED1_PIN }; -#endif // defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED -#endif // ENABLE_WSTK_LEDS +#endif //defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED namespace chip { namespace DeviceLayer { From 3240479e18647b7217cfd93429f4ee1cd6a1c8a6 Mon Sep 17 00:00:00 2001 From: bhmanda Date: Thu, 12 Dec 2024 17:11:53 +0530 Subject: [PATCH 4/4] Added separate condition for wstk_leds and rgb led enabled --- .../platformAbstraction/WiseMcuSpam.cpp | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp index d47395e6c7..b3335aa309 100644 --- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp @@ -41,16 +41,6 @@ extern "C" { #include "sl_si91x_button_pin_config.h" #endif //SL_CATALOG_SIMPLE_BUTTON_PRESENT -#if defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED -#include "sl_si91x_rgb_led.h" -#include "sl_si91x_rgb_led_config.h" -#include "sl_si91x_rgb_led_instances.h" -#else -#include "sl_si91x_led.h" -#include "sl_si91x_led_config.h" -#include "sl_si91x_led_instances.h" -#endif //defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED - #if CHIP_CONFIG_ENABLE_ICD_SERVER == 0 void soc_pll_config(void); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER @@ -64,14 +54,22 @@ void soc_pll_config(void); #include "uart.h" #endif -#if defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#ifdef ENABLE_WSTK_LEDS +#if defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#include "sl_si91x_rgb_led.h" +#include "sl_si91x_rgb_led_config.h" +#include "sl_si91x_rgb_led_instances.h" #define SL_LED_COUNT SL_SI91X_RGB_LED_COUNT -const sl_rgb_led_t * ledPinArray[SL_LED_COUNT] = { &led_led0 }; +const sl_rgb_led_t *ledPinArray[SL_LED_COUNT] = { &led_led0 }; #define SL_RGB_LED_INSTANCE(n) (ledPinArray[n]) #else -#define SL_LED_COUNT SL_SI91x_LED_COUNT +#include "sl_si91x_led.h" +#include "sl_si91x_led_config.h" +#include "sl_si91x_led_instances.h" +#define SL_LED_COUNT SL_SI91X_LED_COUNT uint8_t ledPinArray[SL_LED_COUNT] = { SL_LED_LED0_PIN, SL_LED_LED1_PIN }; -#endif //defined(ENABLE_WSTK_LEDS) && defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED +#endif // SL_MATTER_RGB_LED_ENABLED +#endif // ENABLE_WSTK_LEDS namespace chip { namespace DeviceLayer {