@@ -29,6 +29,8 @@ extern "C" {
29
29
#include " em_core.h"
30
30
#include " rsi_board.h"
31
31
#include " sl_event_handler.h"
32
+ #include " sl_si91x_button.h"
33
+ #include " sl_si91x_button_pin_config.h"
32
34
#include " sl_si91x_led.h"
33
35
#include " sl_si91x_led_config.h"
34
36
void soc_pll_config (void );
@@ -45,6 +47,11 @@ void soc_pll_config(void);
45
47
namespace chip {
46
48
namespace DeviceLayer {
47
49
namespace Silabs {
50
+ #if SL_ICD_ENABLED
51
+ namespace {
52
+ bool btn0_pressed = false ;
53
+ }
54
+ #endif /* SL_ICD_ENABLED */
48
55
49
56
SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager ;
50
57
SilabsPlatform::SilabsButtonCb SilabsPlatform::mButtonCallback = nullptr ;
@@ -56,7 +63,7 @@ CHIP_ERROR SilabsPlatform::Init(void)
56
63
// TODO: Setting the highest priority for SVCall_IRQn to avoid the HardFault issue
57
64
NVIC_SetPriority (SVCall_IRQn, CORE_INTERRUPT_HIGHEST_PRIORITY);
58
65
59
- #if !CHIP_CONFIG_ENABLE_ICD_SERVER
66
+ #ifndef SL_ICD_ENABLED
60
67
// Configuration the clock rate
61
68
soc_pll_config ();
62
69
#endif
@@ -110,6 +117,27 @@ void SilabsPlatform::StartScheduler()
110
117
extern " C" {
111
118
void sl_button_on_change (uint8_t btn, uint8_t btnAction)
112
119
{
120
+ #if SL_ICD_ENABLED
121
+ // This is to make sure we get a one-press and one-release event for the button
122
+ // Hardware modification will be required for this to work permanently
123
+ // Currently the btn0 is pull-up resistor due to which is sends a release event on every wakeup
124
+ if (btn == SL_BUTTON_BTN0_NUMBER)
125
+ {
126
+ if (btnAction == BUTTON_PRESSED)
127
+ {
128
+ btn0_pressed = true ;
129
+ }
130
+ else if ((btnAction == BUTTON_RELEASED) && (btn0_pressed == false ))
131
+ {
132
+ // if the btn was not pressed and only a release event came, ignore it
133
+ return ;
134
+ }
135
+ else if ((btnAction == BUTTON_RELEASED) && (btn0_pressed == true ))
136
+ {
137
+ btn0_pressed = false ;
138
+ }
139
+ }
140
+ #endif /* SL_ICD_ENABLED */
113
141
if (Silabs::GetPlatform ().mButtonCallback == nullptr )
114
142
{
115
143
return ;
0 commit comments