diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 111340eeb66e5a..397fab5d482f7d 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -21,10 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -51,10 +48,7 @@ #include -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#endif // ENABLE_WSTK_LEDS - +#define SYSTEM_STATE_LED 0 #define APP_FUNCTION_BUTTON &sl_button_btn0 using namespace chip; diff --git a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp index 2fbad4ed4d3286..d53505b3374775 100644 --- a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp @@ -26,9 +26,7 @@ #include "AppEvent.h" #include "BindingHandler.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #include "LightSwitchMgr.h" diff --git a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp index 4f2aca11f0712b..fab53ca052baf6 100644 --- a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp @@ -26,10 +26,7 @@ #include "AppEvent.h" #include "BindingHandler.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include "LightSwitchMgr.h" diff --git a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp index 8da8003549c216..409890949085dd 100644 --- a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp @@ -36,19 +36,15 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #define APP_ACTION_LED 1 -#endif // ENABLE_WSTK_LEDS using namespace chip; using namespace ::chip::DeviceLayer; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -143,10 +139,8 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS sLightLED.Init(APP_ACTION_LED); sLightLED.Set(LightMgr().IsLightOn()); -#endif // ENABLE_WSTK_LEDS return err; } diff --git a/examples/lighting-app/silabs/efr32/src/AppTask.cpp b/examples/lighting-app/silabs/efr32/src/AppTask.cpp index 1169e09619eb32..58197087f4b2cb 100755 --- a/examples/lighting-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lighting-app/silabs/efr32/src/AppTask.cpp @@ -21,10 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -41,13 +38,11 @@ #include -#ifdef ENABLE_WSTK_LEDS #if defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#define LIGHT_LED &sl_led_led1 +#define LIGHT_LED 1 #else -#define LIGHT_LED &sl_led_led0 +#define LIGHT_LED 0 #endif -#endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT @@ -60,9 +55,7 @@ using namespace ::chip::DeviceLayer; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -157,10 +150,8 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS sLightLED.Init(LIGHT_LED); sLightLED.Set(LightMgr().IsLightOn()); -#endif // ENABLE_WSTK_LEDS // Update the LCD with the Stored value. Show QR Code if not provisioned #ifdef DISPLAY_ENABLED @@ -298,9 +289,7 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) bool lightOn = aAction == LightingManager::ON_ACTION; SILABS_LOG("Turning light %s", (lightOn) ? "On" : "Off") -#ifdef ENABLE_WSTK_LEDS sLightLED.Set(lightOn); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(lightOn); diff --git a/examples/lighting-app/silabs/efr32/src/main.cpp b/examples/lighting-app/silabs/efr32/src/main.cpp index 73d81d7c2979c5..7bfae98d5b397f 100644 --- a/examples/lighting-app/silabs/efr32/src/main.cpp +++ b/examples/lighting-app/silabs/efr32/src/main.cpp @@ -20,7 +20,6 @@ #include #include "AppConfig.h" -#include "init_efrPlatform.h" #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_simple_button_instances.h" #endif @@ -35,11 +34,14 @@ #include #endif +#include + #define BLE_DEV_NAME "SiLabs-Light" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Credentials; +using namespace chip::DeviceLayer::Silabs; #define UNUSED_PARAMETER(a) (a = a) @@ -51,7 +53,8 @@ static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; // ================================================================================ int main(void) { - init_efrPlatform(); + GetPlatform().Init(); + if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp index abc276588bdab6..a85ac491927d3f 100644 --- a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp @@ -24,9 +24,7 @@ #include "EventHandlerLibShell.h" #endif // ENABLE_CHIP_SHELL -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -53,9 +51,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #define LOCK_STATE_LED 1 -#endif // ENABLE_WSTK_LEDS using chip::app::Clusters::DoorLock::DlLockState; using chip::app::Clusters::DoorLock::OperationErrorEnum; @@ -67,9 +63,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace SI917DoorLock::LockInitParams; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -238,11 +232,8 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); @@ -371,9 +362,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); diff --git a/examples/lock-app/silabs/efr32/src/AppTask.cpp b/examples/lock-app/silabs/efr32/src/AppTask.cpp index ef01ebedff6885..ed1b51df6831d4 100644 --- a/examples/lock-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lock-app/silabs/efr32/src/AppTask.cpp @@ -24,10 +24,7 @@ #include "EventHandlerLibShell.h" #endif // ENABLE_CHIP_SHELL -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -53,11 +50,8 @@ #include #include - -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#define LOCK_STATE_LED &sl_led_led1 -#endif // ENABLE_WSTK_LEDS +#define SYSTEM_STATE_LED 0 +#define LOCK_STATE_LED 1 #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LOCK_SWITCH &sl_button_btn1 @@ -72,9 +66,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace EFR32DoorLock::LockInitParams; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -243,11 +235,8 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS // Update the LCD with the Stored value. Show QR Code if not provisioned #ifdef DISPLAY_ENABLED @@ -395,9 +384,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); diff --git a/examples/platform/silabs/SiWx917/LEDWidget.cpp b/examples/platform/silabs/LEDWidget.cpp similarity index 84% rename from examples/platform/silabs/SiWx917/LEDWidget.cpp rename to examples/platform/silabs/LEDWidget.cpp index bb80fa3f9dfcd1..3156a3bdbc8afc 100644 --- a/examples/platform/silabs/SiWx917/LEDWidget.cpp +++ b/examples/platform/silabs/LEDWidget.cpp @@ -20,10 +20,18 @@ #include "LEDWidget.h" #include +#include using namespace ::chip::System; +using namespace chip::DeviceLayer::Silabs; -void LEDWidget::Init(int led) +void LEDWidget::InitGpio(void) +{ + // Sets gpio pin mode for ALL board Leds. + GetPlatform().InitLed(); +} + +void LEDWidget::Init(const uint8_t led) { mLastChangeTimeMS = 0; mBlinkOnTimeMS = 0; @@ -36,14 +44,14 @@ void LEDWidget::Init(int led) void LEDWidget::Invert(void) { - RSI_Board_LED_Toggle(mLed); + GetPlatform().ToggleLed(mLed); mLedStatus = !mLedStatus; } void LEDWidget::Set(bool state) { mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - state ? RSI_Board_LED_Set(mLed, true) : RSI_Board_LED_Set(mLed, false); + GetPlatform().SetLed(state, mLed); mLedStatus = state; } diff --git a/examples/platform/silabs/efr32/LEDWidget.h b/examples/platform/silabs/LEDWidget.h similarity index 92% rename from examples/platform/silabs/efr32/LEDWidget.h rename to examples/platform/silabs/LEDWidget.h index d779cb9d3ef4b6..856c52c47d8209 100644 --- a/examples/platform/silabs/efr32/LEDWidget.h +++ b/examples/platform/silabs/LEDWidget.h @@ -19,14 +19,13 @@ #pragma once -#include "sl_led.h" #include class LEDWidget { public: static void InitGpio(void); - void Init(const sl_led_t * led); + void Init(uint8_t led); void Set(bool state); void Invert(void); void Blink(uint32_t changeRateMS); @@ -37,5 +36,6 @@ class LEDWidget uint64_t mLastChangeTimeMS; uint32_t mBlinkOnTimeMS; uint32_t mBlinkOffTimeMS; - const sl_led_t * mLed; + uint8_t mLed; + bool mLedStatus; }; diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 098829c4cde527..7404436fbc90d8 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -236,6 +236,7 @@ source_set("siwx917-common") { ] sources = [ + "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${wifi_sdk_dir}/dhcp_client.cpp", "${wifi_sdk_dir}/ethernetif.cpp", @@ -252,10 +253,6 @@ source_set("siwx917-common") { sources += [ "BaseApplication.cpp" ] } - if (use_wstk_leds) { - sources += [ "LEDWidget.cpp" ] - } - if (chip_enable_pw_rpc || chip_build_libshell) { sources += [ "uart.cpp" ] } diff --git a/examples/platform/silabs/SiWx917/BaseApplication.cpp b/examples/platform/silabs/SiWx917/BaseApplication.cpp index 4ed8ea273e0a5f..f0dde1ffc39e80 100644 --- a/examples/platform/silabs/SiWx917/BaseApplication.cpp +++ b/examples/platform/silabs/SiWx917/BaseApplication.cpp @@ -25,9 +25,7 @@ #include "AppEvent.h" #include "AppTask.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -68,9 +66,7 @@ #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 #define EXAMPLE_VENDOR_ID 0xcafe -#ifdef ENABLE_WSTK_LEDS #define APP_STATE_LED 0 -#endif // ENABLE_WSTK_LEDS using namespace chip; using namespace ::chip::DeviceLayer; @@ -87,9 +83,7 @@ TimerHandle_t sLightTimer; TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; -#ifdef ENABLE_WSTK_LEDS LEDWidget sStatusLED; -#endif // ENABLE_WSTK_LEDS #ifdef SL_WIFI app::Clusters::NetworkCommissioning::Instance @@ -204,9 +198,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) 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); -#ifdef ENABLE_WSTK_LEDS sStatusLED.Init(APP_STATE_LED); -#endif // ENABLE_WSTK_LEDS ConfigurationMgr().LogDeviceConfig(); @@ -302,7 +294,6 @@ void BaseApplication::LightEventHandler() // the LEDs at an even rate of 100ms. // // Otherwise, blink the LED ON for a very short time. -#ifdef ENABLE_WSTK_LEDS if (mFunction != kFunction_FactoryReset) { if ((gIdentifyptr != nullptr) && (gIdentifyptr->mActive)) @@ -348,7 +339,6 @@ void BaseApplication::LightEventHandler() } sStatusLED.Animate(); -#endif // ENABLE_WSTK_LEDS } void BaseApplication::ButtonHandler(AppEvent * aEvent) @@ -382,13 +372,10 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) break; } -#ifdef ENABLE_WSTK_LEDS // Turn off status LED before starting blink to make sure blink is // co-ordinated. sStatusLED.Set(false); sStatusLED.Blink(500); -#endif // ENABLE_WSTK_LEDS - SILABS_LOG("Factory reset triggering in %d sec release button to cancel", count--); // Delay of 1sec before checking the button status again @@ -397,9 +384,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) if (count > 0) { -#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); -#endif SILABS_LOG("Factory Reset has been Canceled"); // button held past Timeout wait till button is released } @@ -467,9 +452,7 @@ void BaseApplication::StartStatusLEDTimer() void BaseApplication::StopStatusLEDTimer() { -#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); -#endif // ENABLE_WSTK_LEDS if (xTimerStop(sLightTimer, pdMS_TO_TICKS(100)) != pdPASS) { diff --git a/examples/platform/silabs/SiWx917/LEDWidget.h b/examples/platform/silabs/SiWx917/LEDWidget.h deleted file mode 100644 index 596f64af094d7a..00000000000000 --- a/examples/platform/silabs/SiWx917/LEDWidget.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -extern "C" void RSI_Board_LED_Set(int, int); -extern "C" void RSI_Board_LED_Toggle(int); - -class LEDWidget -{ -public: - void Init(int led); - void Set(bool state); - void Invert(void); - void Blink(uint32_t changeRateMS); - void Blink(uint32_t onTimeMS, uint32_t offTimeMS); - void Animate(); - -private: - uint64_t mLastChangeTimeMS; - uint32_t mBlinkOnTimeMS; - uint32_t mBlinkOffTimeMS; - int mLed; - // created a temporary mLedStatus since Led status is not updating from the platform API(RSI_EGPIO_GetPin) - bool mLedStatus; -}; diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 48fb282c8fbb5f..d74792a1cba233 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -280,6 +280,7 @@ source_set("efr32-common") { include_dirs = [ "." ] sources = [ + "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/syscalls_stubs.cpp", "efr32_utils.cpp", @@ -291,10 +292,6 @@ source_set("efr32-common") { sources += [ "BaseApplication.cpp" ] } - if (use_wstk_leds) { - sources += [ "LEDWidget.cpp" ] - } - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli) { sources += [ "uart.cpp" ] } diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index bbb18fc005883a..e29797607f7e35 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -73,7 +73,7 @@ #define EXAMPLE_VENDOR_ID 0xcafe #if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#define SYSTEM_STATE_LED &sl_led_led0 +#define SYSTEM_STATE_LED 0 #endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #define APP_FUNCTION_BUTTON &sl_button_btn0 diff --git a/examples/platform/silabs/efr32/LEDWidget.cpp b/examples/platform/silabs/efr32/LEDWidget.cpp deleted file mode 100644 index 10ffcac363520d..00000000000000 --- a/examples/platform/silabs/efr32/LEDWidget.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LEDWidget.h" - -extern "C" { -#include "sl_simple_led_instances.h" -} - -#include - -using namespace ::chip::System; - -void LEDWidget::InitGpio(void) -{ - // Sets gpio pin mode for ALL board Leds. - sl_simple_led_init_instances(); -} - -void LEDWidget::Init(const sl_led_t * led) -{ - mLastChangeTimeMS = 0; - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - mLed = led; - - Set(false); -} - -void LEDWidget::Invert(void) -{ - if (mLed) - { - sl_led_toggle(mLed); - } -} - -void LEDWidget::Set(bool state) -{ - mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - if (mLed) - { - state ? sl_led_turn_on(mLed) : sl_led_turn_off(mLed); - } -} - -void LEDWidget::Blink(uint32_t changeRateMS) -{ - Blink(changeRateMS, changeRateMS); -} - -void LEDWidget::Blink(uint32_t onTimeMS, uint32_t offTimeMS) -{ - mBlinkOnTimeMS = onTimeMS; - mBlinkOffTimeMS = offTimeMS; - Animate(); -} - -void LEDWidget::Animate() -{ - if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) - { - uint64_t nowMS = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - uint64_t stateDurMS = sl_led_get_state(mLed) ? mBlinkOnTimeMS : mBlinkOffTimeMS; - uint64_t nextChangeTimeMS = mLastChangeTimeMS + stateDurMS; - - if (nextChangeTimeMS < nowMS) - { - Invert(); - mLastChangeTimeMS = nowMS; - } - } -} diff --git a/examples/thermostat/silabs/efr32/src/AppTask.cpp b/examples/thermostat/silabs/efr32/src/AppTask.cpp index 2ccaec5fed2e1c..21cee0c90cc122 100644 --- a/examples/thermostat/silabs/efr32/src/AppTask.cpp +++ b/examples/thermostat/silabs/efr32/src/AppTask.cpp @@ -25,10 +25,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "ThermostatUI.h" diff --git a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h index 0acb38a4b1de22..827e3b120e7992 100644 --- a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h +++ b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h @@ -19,9 +19,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -90,10 +88,8 @@ class WindowAppImpl : public WindowApp TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; -#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp index 108fd77f9f8e37..2d65b5a2117451 100644 --- a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp @@ -203,10 +203,9 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -393,21 +392,19 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -417,22 +414,11 @@ void WindowAppImpl::UpdateLEDs() #endif { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS } + else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } + else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -450,27 +436,23 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS } else { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS } } } @@ -519,10 +501,9 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Animate(); mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/examples/window-app/silabs/efr32/include/WindowAppImpl.h b/examples/window-app/silabs/efr32/include/WindowAppImpl.h index a43f68ed85f6ef..27a26dba9a4399 100644 --- a/examples/window-app/silabs/efr32/include/WindowAppImpl.h +++ b/examples/window-app/silabs/efr32/include/WindowAppImpl.h @@ -19,10 +19,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -85,10 +82,8 @@ class WindowAppImpl : public WindowApp TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; -#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp index 77d3d6800c5d0a..734a4b4bc5d1a3 100644 --- a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp @@ -33,10 +33,6 @@ #endif // QR_CODE_ENABLED #include -#ifdef ENABLE_WSTK_LEDS -#include -#endif // ENABLE_WSTK_LEDS - #include #ifdef SL_WIFI @@ -60,8 +56,8 @@ SilabsLCD slLCD; using namespace chip::app::Clusters::WindowCovering; using namespace chip; using namespace ::chip::DeviceLayer; -#define APP_STATE_LED &sl_led_led0 -#define APP_ACTION_LED &sl_led_led1 +#define APP_STATE_LED 0 +#define APP_ACTION_LED 1 #ifdef SL_WIFI chip::app::Clusters::NetworkCommissioning::Instance @@ -208,11 +204,9 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS LEDWidget::InitGpio(); mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -397,21 +391,17 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { -#ifdef ENABLE_WSTK_LEDS mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { -#ifdef ENABLE_WSTK_LEDS mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -421,22 +411,11 @@ void WindowAppImpl::UpdateLEDs() #endif { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS } + else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } + else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -454,27 +433,23 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS } else { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS } } } @@ -523,10 +498,9 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Animate(); mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp index e0f954e101a90d..007977a6d66639 100644 --- a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp @@ -18,6 +18,12 @@ #include "init_efrPlatform.h" #include +#ifdef ENABLE_WSTK_LEDS +extern "C" { +#include "sl_simple_led_instances.h" +} +#endif + namespace chip { namespace DeviceLayer { namespace Silabs { @@ -31,9 +37,6 @@ CHIP_ERROR SilabsPlatform::Init(void) } #ifdef ENABLE_WSTK_LEDS - -#include "sl_simple_led_instances.h" - void SilabsPlatform::InitLed(void) { sl_simple_led_init_instances(); @@ -54,7 +57,7 @@ bool SilabsPlatform::GetLedState(uint8_t led) { if (led >= SL_SIMPLE_LED_COUNT) { - return 0; + return false; } return sl_led_get_state(SL_SIMPLE_LED_INSTANCE(led)); diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp index 97004960f94d06..816c9a6df4459d 100644 --- a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -37,27 +37,28 @@ CHIP_ERROR SilabsPlatform::Init(void) #ifdef ENABLE_WSTK_LEDS void SilabsPlatform::InitLed(void) { - // TODO ? + // TODO SilabsPlatformAbstractionBase::InitLed(); } CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override { - // TODO add range check ? + // TODO add range check RSI_Board_LED_Set(led, state); return CHIP_NO_ERROR; } bool SilabsPlatform::GetLedState(uint8_t led) { - // TODO ? + // TODO return SilabsPlatformAbstractionBase::GetLedState(led); } CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override { - // TODO add range check ? - RSI_Board_LED_Toggle(led) return CHIP_NO_ERROR; + // TODO add range check + RSI_Board_LED_Toggle(led); + return CHIP_NO_ERROR; } #endif // ENABLE_WSTK_LEDS