Skip to content

Commit 2396b90

Browse files
[Silabs][SiWx917] Getting the button pressed and button release in sync in sleep wakeup for btn0 (#32458)
* fixing the btn0 for 917soc sleepy * Restyled by clang-format * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent d3e3d97 commit 2396b90

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp

+29-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ extern "C" {
2929
#include "em_core.h"
3030
#include "rsi_board.h"
3131
#include "sl_event_handler.h"
32+
#include "sl_si91x_button.h"
33+
#include "sl_si91x_button_pin_config.h"
3234
#include "sl_si91x_led.h"
3335
#include "sl_si91x_led_config.h"
3436
void soc_pll_config(void);
@@ -45,6 +47,11 @@ void soc_pll_config(void);
4547
namespace chip {
4648
namespace DeviceLayer {
4749
namespace Silabs {
50+
#if SL_ICD_ENABLED
51+
namespace {
52+
bool btn0_pressed = false;
53+
}
54+
#endif /* SL_ICD_ENABLED */
4855

4956
SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager;
5057
SilabsPlatform::SilabsButtonCb SilabsPlatform::mButtonCallback = nullptr;
@@ -56,7 +63,7 @@ CHIP_ERROR SilabsPlatform::Init(void)
5663
// TODO: Setting the highest priority for SVCall_IRQn to avoid the HardFault issue
5764
NVIC_SetPriority(SVCall_IRQn, CORE_INTERRUPT_HIGHEST_PRIORITY);
5865

59-
#if !CHIP_CONFIG_ENABLE_ICD_SERVER
66+
#ifndef SL_ICD_ENABLED
6067
// Configuration the clock rate
6168
soc_pll_config();
6269
#endif
@@ -110,6 +117,27 @@ void SilabsPlatform::StartScheduler()
110117
extern "C" {
111118
void sl_button_on_change(uint8_t btn, uint8_t btnAction)
112119
{
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 */
113141
if (Silabs::GetPlatform().mButtonCallback == nullptr)
114142
{
115143
return;

0 commit comments

Comments
 (0)