From 22489280b9ed12953bef4748bd1a4fdd11cbf70d Mon Sep 17 00:00:00 2001 From: KishorSilabs <112456954+KishorSilabs@users.noreply.github.com> Date: Mon, 21 Aug 2023 18:08:48 +0530 Subject: [PATCH] [Silabs] Adds bugfix for building applications on SiWx917 SoC (#28468) * Build Error fix for Window app on CSA for 917 SOC * Added Conditions for 917 SOC * Adds fix for 917SoC button and LED0 issue * Restyled by clang-format * Removed not required ifndef condition for 917 SOC * Removed OTA Requestor changes from scripts file * using release interrupt for button 1 * Restyled by clang-format --------- Co-authored-by: srningap Co-authored-by: Restyled.io --- examples/lighting-app/silabs/src/AppTask.cpp | 2 +- examples/platform/silabs/BaseApplication.cpp | 17 ++++++++--------- examples/platform/silabs/MatterConfig.cpp | 2 +- .../silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c | 3 ++- .../silabs/platformAbstraction/WiseMcuSpam.cpp | 4 ++++ 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/examples/lighting-app/silabs/src/AppTask.cpp b/examples/lighting-app/silabs/src/AppTask.cpp index c3797797644b5b..bb27d8c702bff5 100644 --- a/examples/lighting-app/silabs/src/AppTask.cpp +++ b/examples/lighting-app/silabs/src/AppTask.cpp @@ -40,7 +40,7 @@ #include -#if (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(BRD4325B)) +#if (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917)) #define LIGHT_LED 1 #else #define LIGHT_LED 0 diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 78d31c8acd4b61..f0760d901fda73 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -25,9 +25,8 @@ #include "AppEvent.h" #include "AppTask.h" -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) #include "LEDWidget.h" -#include "sl_simple_led_instances.h" #endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED @@ -79,7 +78,7 @@ #define APP_EVENT_QUEUE_SIZE 10 #define EXAMPLE_VENDOR_ID 0xcafe -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) #define SYSTEM_STATE_LED 0 #endif // ENABLE_WSTK_LEDS #define APP_FUNCTION_BUTTON 0 @@ -101,7 +100,7 @@ TimerHandle_t sLightTimer; TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) LEDWidget sStatusLED; #endif // ENABLE_WSTK_LEDS @@ -236,7 +235,7 @@ CHIP_ERROR BaseApplication::Init() SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) LEDWidget::InitGpio(); sStatusLED.Init(SYSTEM_STATE_LED); #endif // ENABLE_WSTK_LEDS @@ -292,7 +291,7 @@ void BaseApplication::FunctionEventHandler(AppEvent * aEvent) mFunction = kFunction_FactoryReset; -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) // Turn off all LEDs before starting blink to make sure blink is // co-ordinated. sStatusLED.Set(false); @@ -315,7 +314,7 @@ void BaseApplication::FunctionEventHandler(AppEvent * aEvent) bool BaseApplication::ActivateStatusLedPatterns() { bool isPatternSet = false; -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) #ifdef EMBER_AF_PLUGIN_IDENTIFY_SERVER if (gIdentify.mActive) { @@ -417,7 +416,7 @@ void BaseApplication::LightEventHandler() } #endif // CHIP_CONFIG_ENABLE_ICD_SERVER -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) // Update the status LED if factory reset has not been initiated. // // If system has "full connectivity", keep the LED On constantly. @@ -556,7 +555,7 @@ void BaseApplication::StartStatusLEDTimer() void BaseApplication::StopStatusLEDTimer() { -#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) +#if (defined(ENABLE_WSTK_LEDS) && (defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) || defined(SIWX_917))) sStatusLED.Set(false); #endif // ENABLE_WSTK_LEDS diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 36f78aa84839c2..b050abb55e8604 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -172,7 +172,7 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) // WiFi needs to be initialized after Memory Init for some reason #ifdef SL_WIFI - InitWiFi(); + ReturnErrorOnFailure(InitWiFi()); #endif ReturnErrorOnFailure(PlatformMgr().InitChipStack()); diff --git a/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c b/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c index bcedf1c8a52c16..88a9b97f571807 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c +++ b/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c @@ -82,9 +82,10 @@ void IRQ021_Handler(void) RSI_NPSSGPIO_ClrIntr(NPSS_GPIO_0_INTR); RSI_NPSSGPIO_ClrIntr(NPSS_GPIO_2_INTR); // if the btn is not pressed setting the state to 1 - if (RSI_NPSSGPIO_GetPin(NPSS_GPIO_2)) + if (RSI_NPSSGPIO_GetPin(NPSS_GPIO_2) && (!btn1)) { btn1 = 1; + sl_button_on_change(1, 0); } // geting the state of the gpio 2 pin and checking if the btn is already pressed or not if (!RSI_NPSSGPIO_GetPin(NPSS_GPIO_2) && btn1) diff --git a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp index 0eba1701c5dec1..08ca04e00f1039 100644 --- a/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp @@ -20,6 +20,10 @@ #include #include +#if SILABS_LOG_ENABLED +#include "silabs_utils.h" +#endif + // TODO add includes ? extern "C" void RSI_Board_LED_Set(int, bool); extern "C" void RSI_Board_LED_Toggle(int);