Skip to content

Commit bcf1b80

Browse files
[Silabs] merge LEDWidget (project-chip#26222)
* Silabs merge LEDWidget * Fix CI
1 parent fe07225 commit bcf1b80

File tree

23 files changed

+61
-311
lines changed

23 files changed

+61
-311
lines changed

examples/chef/efr32/src/AppTask.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
#include "AppConfig.h"
2222
#include "AppEvent.h"
2323

24-
#ifdef ENABLE_WSTK_LEDS
2524
#include "LEDWidget.h"
26-
#include "sl_simple_led_instances.h"
27-
#endif // ENABLE_WSTK_LEDS
2825

2926
#ifdef DISPLAY_ENABLED
3027
#include "lcd.h"
@@ -51,10 +48,7 @@
5148

5249
#include <platform/CHIPDeviceLayer.h>
5350

54-
#ifdef ENABLE_WSTK_LEDS
55-
#define SYSTEM_STATE_LED &sl_led_led0
56-
#endif // ENABLE_WSTK_LEDS
57-
51+
#define SYSTEM_STATE_LED 0
5852
#define APP_FUNCTION_BUTTON &sl_button_btn0
5953

6054
using namespace chip;

examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
#include "AppEvent.h"
2727
#include "BindingHandler.h"
2828

29-
#ifdef ENABLE_WSTK_LEDS
3029
#include "LEDWidget.h"
31-
#endif // ENABLE_WSTK_LEDS
3230

3331
#include "LightSwitchMgr.h"
3432

examples/light-switch-app/silabs/efr32/src/AppTask.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
#include "AppEvent.h"
2727
#include "BindingHandler.h"
2828

29-
#ifdef ENABLE_WSTK_LEDS
3029
#include "LEDWidget.h"
31-
#include "sl_simple_led_instances.h"
32-
#endif // ENABLE_WSTK_LEDS
3330

3431
#include "LightSwitchMgr.h"
3532

examples/lighting-app/silabs/SiWx917/src/AppTask.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,15 @@
3636

3737
#include <platform/CHIPDeviceLayer.h>
3838

39-
#ifdef ENABLE_WSTK_LEDS
4039
#include "LEDWidget.h"
4140
#define APP_ACTION_LED 1
42-
#endif // ENABLE_WSTK_LEDS
4341

4442
using namespace chip;
4543
using namespace ::chip::DeviceLayer;
4644

4745
namespace {
4846

49-
#ifdef ENABLE_WSTK_LEDS
5047
LEDWidget sLightLED;
51-
#endif // ENABLE_WSTK_LEDS
5248

5349
EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
5450

@@ -143,10 +139,8 @@ CHIP_ERROR AppTask::Init()
143139

144140
LightMgr().SetCallbacks(ActionInitiated, ActionCompleted);
145141

146-
#ifdef ENABLE_WSTK_LEDS
147142
sLightLED.Init(APP_ACTION_LED);
148143
sLightLED.Set(LightMgr().IsLightOn());
149-
#endif // ENABLE_WSTK_LEDS
150144

151145
return err;
152146
}

examples/lighting-app/silabs/efr32/src/AppTask.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@
2121
#include "AppConfig.h"
2222
#include "AppEvent.h"
2323

24-
#ifdef ENABLE_WSTK_LEDS
2524
#include "LEDWidget.h"
26-
#include "sl_simple_led_instances.h"
27-
#endif // ENABLE_WSTK_LEDS
2825

2926
#include <app/clusters/identify-server/identify-server.h>
3027
#include <app/clusters/on-off-server/on-off-server.h>
@@ -41,13 +38,11 @@
4138

4239
#include <platform/CHIPDeviceLayer.h>
4340

44-
#ifdef ENABLE_WSTK_LEDS
4541
#if defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT)
46-
#define LIGHT_LED &sl_led_led1
42+
#define LIGHT_LED 1
4743
#else
48-
#define LIGHT_LED &sl_led_led0
44+
#define LIGHT_LED 0
4945
#endif
50-
#endif // ENABLE_WSTK_LEDS
5146

5247
#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
5348

@@ -60,9 +55,7 @@ using namespace ::chip::DeviceLayer;
6055

6156
namespace {
6257

63-
#ifdef ENABLE_WSTK_LEDS
6458
LEDWidget sLightLED;
65-
#endif // ENABLE_WSTK_LEDS
6659

6760
EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
6861

@@ -157,10 +150,8 @@ CHIP_ERROR AppTask::Init()
157150

158151
LightMgr().SetCallbacks(ActionInitiated, ActionCompleted);
159152

160-
#ifdef ENABLE_WSTK_LEDS
161153
sLightLED.Init(LIGHT_LED);
162154
sLightLED.Set(LightMgr().IsLightOn());
163-
#endif // ENABLE_WSTK_LEDS
164155

165156
// Update the LCD with the Stored value. Show QR Code if not provisioned
166157
#ifdef DISPLAY_ENABLED
@@ -298,9 +289,7 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor)
298289
bool lightOn = aAction == LightingManager::ON_ACTION;
299290
SILABS_LOG("Turning light %s", (lightOn) ? "On" : "Off")
300291

301-
#ifdef ENABLE_WSTK_LEDS
302292
sLightLED.Set(lightOn);
303-
#endif // ENABLE_WSTK_LEDS
304293

305294
#ifdef DISPLAY_ENABLED
306295
sAppTask.GetLCD().WriteDemoUI(lightOn);

examples/lighting-app/silabs/efr32/src/main.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <AppTask.h>
2121

2222
#include "AppConfig.h"
23-
#include "init_efrPlatform.h"
2423
#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
2524
#include "sl_simple_button_instances.h"
2625
#endif
@@ -35,11 +34,14 @@
3534
#include <credentials/examples/DeviceAttestationCredsExample.h>
3635
#endif
3736

37+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
38+
3839
#define BLE_DEV_NAME "SiLabs-Light"
3940
using namespace ::chip;
4041
using namespace ::chip::Inet;
4142
using namespace ::chip::DeviceLayer;
4243
using namespace ::chip::Credentials;
44+
using namespace chip::DeviceLayer::Silabs;
4345

4446
#define UNUSED_PARAMETER(a) (a = a)
4547

@@ -51,7 +53,8 @@ static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
5153
// ================================================================================
5254
int main(void)
5355
{
54-
init_efrPlatform();
56+
GetPlatform().Init();
57+
5558
if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR)
5659
appError(CHIP_ERROR_INTERNAL);
5760

examples/lock-app/silabs/SiWx917/src/AppTask.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
#include "EventHandlerLibShell.h"
2525
#endif // ENABLE_CHIP_SHELL
2626

27-
#ifdef ENABLE_WSTK_LEDS
2827
#include "LEDWidget.h"
29-
#endif // ENABLE_WSTK_LEDS
3028

3129
#ifdef DISPLAY_ENABLED
3230
#include "lcd.h"
@@ -53,9 +51,7 @@
5351

5452
#include <platform/CHIPDeviceLayer.h>
5553

56-
#ifdef ENABLE_WSTK_LEDS
5754
#define LOCK_STATE_LED 1
58-
#endif // ENABLE_WSTK_LEDS
5955

6056
using chip::app::Clusters::DoorLock::DlLockState;
6157
using chip::app::Clusters::DoorLock::OperationErrorEnum;
@@ -67,9 +63,7 @@ using namespace ::chip::DeviceLayer::Internal;
6763
using namespace SI917DoorLock::LockInitParams;
6864

6965
namespace {
70-
#ifdef ENABLE_WSTK_LEDS
7166
LEDWidget sLockLED;
72-
#endif // ENABLE_WSTK_LEDS
7367

7468
EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
7569
} // namespace
@@ -238,11 +232,8 @@ CHIP_ERROR AppTask::Init()
238232

239233
LockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
240234

241-
#ifdef ENABLE_WSTK_LEDS
242-
// Initialize LEDs
243235
sLockLED.Init(LOCK_STATE_LED);
244236
sLockLED.Set(state.Value() == DlLockState::kUnlocked);
245-
#endif // ENABLE_WSTK_LEDS
246237

247238
chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast<intptr_t>(nullptr));
248239

@@ -371,9 +362,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
371362
{
372363
bool locked = (aAction == LockManager::LOCK_ACTION);
373364
SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock");
374-
#ifdef ENABLE_WSTK_LEDS
375365
sLockLED.Set(!locked);
376-
#endif // ENABLE_WSTK_LEDS
377366

378367
#ifdef DISPLAY_ENABLED
379368
sAppTask.GetLCD().WriteDemoUI(locked);

examples/lock-app/silabs/efr32/src/AppTask.cpp

+2-15
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@
2424
#include "EventHandlerLibShell.h"
2525
#endif // ENABLE_CHIP_SHELL
2626

27-
#ifdef ENABLE_WSTK_LEDS
2827
#include "LEDWidget.h"
29-
#include "sl_simple_led_instances.h"
30-
#endif // ENABLE_WSTK_LEDS
3128

3229
#ifdef DISPLAY_ENABLED
3330
#include "lcd.h"
@@ -53,11 +50,8 @@
5350
#include <lib/support/CodeUtils.h>
5451

5552
#include <platform/CHIPDeviceLayer.h>
56-
57-
#ifdef ENABLE_WSTK_LEDS
58-
#define SYSTEM_STATE_LED &sl_led_led0
59-
#define LOCK_STATE_LED &sl_led_led1
60-
#endif // ENABLE_WSTK_LEDS
53+
#define SYSTEM_STATE_LED 0
54+
#define LOCK_STATE_LED 1
6155

6256
#define APP_FUNCTION_BUTTON &sl_button_btn0
6357
#define APP_LOCK_SWITCH &sl_button_btn1
@@ -72,9 +66,7 @@ using namespace ::chip::DeviceLayer::Internal;
7266
using namespace EFR32DoorLock::LockInitParams;
7367

7468
namespace {
75-
#ifdef ENABLE_WSTK_LEDS
7669
LEDWidget sLockLED;
77-
#endif // ENABLE_WSTK_LEDS
7870

7971
EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
8072
} // namespace
@@ -243,11 +235,8 @@ CHIP_ERROR AppTask::Init()
243235

244236
LockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
245237

246-
#ifdef ENABLE_WSTK_LEDS
247-
// Initialize LEDs
248238
sLockLED.Init(LOCK_STATE_LED);
249239
sLockLED.Set(state.Value() == DlLockState::kUnlocked);
250-
#endif // ENABLE_WSTK_LEDS
251240

252241
// Update the LCD with the Stored value. Show QR Code if not provisioned
253242
#ifdef DISPLAY_ENABLED
@@ -395,9 +384,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor)
395384
{
396385
bool locked = (aAction == LockManager::LOCK_ACTION);
397386
SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock");
398-
#ifdef ENABLE_WSTK_LEDS
399387
sLockLED.Set(!locked);
400-
#endif // ENABLE_WSTK_LEDS
401388

402389
#ifdef DISPLAY_ENABLED
403390
sAppTask.GetLCD().WriteDemoUI(locked);

examples/platform/silabs/SiWx917/LEDWidget.cpp examples/platform/silabs/LEDWidget.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@
2020
#include "LEDWidget.h"
2121

2222
#include <platform/CHIPDeviceLayer.h>
23+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
2324

2425
using namespace ::chip::System;
26+
using namespace chip::DeviceLayer::Silabs;
2527

26-
void LEDWidget::Init(int led)
28+
void LEDWidget::InitGpio(void)
29+
{
30+
// Sets gpio pin mode for ALL board Leds.
31+
GetPlatform().InitLed();
32+
}
33+
34+
void LEDWidget::Init(const uint8_t led)
2735
{
2836
mLastChangeTimeMS = 0;
2937
mBlinkOnTimeMS = 0;
@@ -36,14 +44,14 @@ void LEDWidget::Init(int led)
3644

3745
void LEDWidget::Invert(void)
3846
{
39-
RSI_Board_LED_Toggle(mLed);
47+
GetPlatform().ToggleLed(mLed);
4048
mLedStatus = !mLedStatus;
4149
}
4250

4351
void LEDWidget::Set(bool state)
4452
{
4553
mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0;
46-
state ? RSI_Board_LED_Set(mLed, true) : RSI_Board_LED_Set(mLed, false);
54+
GetPlatform().SetLed(state, mLed);
4755
mLedStatus = state;
4856
}
4957

examples/platform/silabs/efr32/LEDWidget.h examples/platform/silabs/LEDWidget.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@
1919

2020
#pragma once
2121

22-
#include "sl_led.h"
2322
#include <stdint.h>
2423

2524
class LEDWidget
2625
{
2726
public:
2827
static void InitGpio(void);
29-
void Init(const sl_led_t * led);
28+
void Init(uint8_t led);
3029
void Set(bool state);
3130
void Invert(void);
3231
void Blink(uint32_t changeRateMS);
@@ -37,5 +36,6 @@ class LEDWidget
3736
uint64_t mLastChangeTimeMS;
3837
uint32_t mBlinkOnTimeMS;
3938
uint32_t mBlinkOffTimeMS;
40-
const sl_led_t * mLed;
39+
uint8_t mLed;
40+
bool mLedStatus;
4141
};

examples/platform/silabs/SiWx917/BUILD.gn

+1-4
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ source_set("siwx917-common") {
236236
]
237237

238238
sources = [
239+
"${silabs_common_plat_dir}/LEDWidget.cpp",
239240
"${silabs_common_plat_dir}/heap_4_silabs.c",
240241
"${wifi_sdk_dir}/dhcp_client.cpp",
241242
"${wifi_sdk_dir}/ethernetif.cpp",
@@ -252,10 +253,6 @@ source_set("siwx917-common") {
252253
sources += [ "BaseApplication.cpp" ]
253254
}
254255

255-
if (use_wstk_leds) {
256-
sources += [ "LEDWidget.cpp" ]
257-
}
258-
259256
if (chip_enable_pw_rpc || chip_build_libshell) {
260257
sources += [ "uart.cpp" ]
261258
}

0 commit comments

Comments
 (0)