Skip to content

Commit b96c5c5

Browse files
committed
Enabling sleepy for 917soc with power manager
1 parent 58536ba commit b96c5c5

File tree

7 files changed

+51
-80
lines changed

7 files changed

+51
-80
lines changed

examples/platform/silabs/FreeRTOSConfig.h

+14-13
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ extern "C" {
110110
#ifdef SLI_SI91X_MCU_INTERFACE
111111
#include "si91x_device.h"
112112
extern uint32_t SystemCoreClock;
113+
#if SL_ICD_ENABLED
114+
#include "sl_si91x_m4_ps.h"
115+
#endif // SL_ICD_ENABLED
113116
#else // For EFR32
114117
#include "RTE_Components.h"
115118
#include CMSIS_device_header
@@ -141,21 +144,18 @@ extern uint32_t SystemCoreClock;
141144
/* Energy saving modes. */
142145
#if defined(SL_CATALOG_POWER_MANAGER_PRESENT)
143146
#define configUSE_TICKLESS_IDLE 1
144-
#elif SL_ICD_ENABLED && SI917_M4_SLEEP_ENABLED
147+
#elif (SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED)
145148
#define configUSE_TICKLESS_IDLE 1
146149
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 70
147-
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) vTaskPreSuppressTicksAndSleepProcessing(&x)
148-
#define configPRE_SLEEP_PROCESSING(x) sl_wfx_host_si91x_sleep(&x)
149-
#define configPOST_SLEEP_PROCESSING(x) sl_si91x_post_sleep_update_ticks(&x)
150+
#define configPRE_SLEEP_PROCESSING(x)
151+
#define configPOST_SLEEP_PROCESSING(x)
152+
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) sl_si91x_pre_supress_ticks_and_sleep(&x)
150153
#else
151154
#define configUSE_TICKLESS_IDLE 0
152155
#endif // SL_CATALOG_POWER_MANAGER_PRESENT
153156

154-
#if defined(SLI_SI91X_MCU_INTERFACE)
155-
#define configTICK_RATE_HZ (1000)
156-
#else
157157
#define configTICK_RATE_HZ (1024)
158-
#endif // SLI_SI91X_MCU_INTERFACE
158+
159159
/* Definition used by Keil to replace default system clock source. */
160160
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 1
161161

@@ -175,7 +175,11 @@ extern uint32_t SystemCoreClock;
175175

176176
/* Software timer related definitions. */
177177
#define configUSE_TIMERS (1)
178+
#ifdef SLI_SI917
179+
#define configTIMER_TASK_PRIORITY (55) /* Highest priority */
180+
#else
178181
#define configTIMER_TASK_PRIORITY (40) /* Highest priority */
182+
#endif // SLI_SI917
179183
#define configTIMER_QUEUE_LENGTH (10)
180184
#define configTIMER_TASK_STACK_DEPTH (1024)
181185

@@ -211,11 +215,8 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
211215
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (0)
212216
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG (1) /* See into vPortSuppressTicksAndSleep source code for explanation */
213217
#define configMAX_PRIORITIES (56)
214-
#if SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED
215-
#define configMINIMAL_STACK_SIZE (1024) /* Number of words to use for Idle and Timer stacks */
216-
#else // For EFR32
217-
#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */
218-
#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED
218+
#define configMINIMAL_STACK_SIZE (320) /* Number of words to use for Idle and Timer stacks */
219+
219220
#ifdef HEAP_MONITORING
220221
#define configMAX_TASK_NAME_LEN (24)
221222
#else

examples/platform/silabs/MatterConfig.cpp

+4-61
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@
4343

4444
#ifdef SLI_SI91X_MCU_INTERFACE
4545
#include "wfx_rsi.h"
46-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
47-
#include "rsi_m4.h"
48-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
49-
#endif // SLI_SI91X_MCU_INTERFACE
46+
#endif /* SLI_SI91X_MCU_INTERFACE */
5047

5148
#include <crypto/CHIPCryptoPAL.h>
5249
// If building with the EFR32-provided crypto backend, we can use the
@@ -356,63 +353,9 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void)
356353
// ================================================================================
357354
// FreeRTOS Callbacks
358355
// ================================================================================
359-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
360-
static bool is_sleep_ready = false;
361-
void vTaskPreSuppressTicksAndSleepProcessing(uint16_t * xExpectedIdleTime)
362-
{
363-
// pointer check
364-
if (xExpectedIdleTime == NULL)
365-
{
366-
return;
367-
}
368-
369-
if (!is_sleep_ready)
370-
{
371-
*xExpectedIdleTime = 0;
372-
}
373-
else
374-
{
375-
// a preliminary check of the expected idle time is performed without making M4 inactive
376-
if (*xExpectedIdleTime >= configEXPECTED_IDLE_TIME_BEFORE_SLEEP)
377-
{
378-
// Indicate M4 is Inactive
379-
P2P_STATUS_REG &= ~M4_is_active;
380-
// Waiting for one more clock cycle to make sure M4 H/W Register is updated
381-
P2P_STATUS_REG;
382-
383-
// TODO: This delay is added to sync between M4 and TA. It should be removed once the logic is moved to wifi SDK
384-
for (uint8_t delay = 0; delay < 10; delay++)
385-
{
386-
__ASM("NOP");
387-
}
388-
// Checking if TA has already triggered a packet to M4
389-
// RX_BUFFER_VALID will be cleared by TA if any packet is triggered
390-
if ((P2P_STATUS_REG & TA_wakeup_M4) || (P2P_STATUS_REG & M4_wakeup_TA) || (!(M4SS_P2P_INTR_SET_REG & RX_BUFFER_VALID)))
391-
{
392-
P2P_STATUS_REG |= M4_is_active;
393-
*xExpectedIdleTime = 0;
394-
}
395-
else
396-
{
397-
M4SS_P2P_INTR_CLR_REG = RX_BUFFER_VALID;
398-
M4SS_P2P_INTR_CLR_REG;
399-
400-
TASS_P2P_INTR_MASK_SET = (TX_PKT_TRANSFER_DONE_INTERRUPT | RX_PKT_TRANSFER_DONE_INTERRUPT |
401-
TA_WRITING_ON_COMM_FLASH | NWP_DEINIT_IN_COMM_FLASH
402-
#ifdef SL_SI91X_SIDE_BAND_CRYPTO
403-
| SIDE_BAND_CRYPTO_DONE
404-
#endif
405-
);
406-
}
407-
}
408-
}
409-
}
410-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
411356
extern "C" void vApplicationIdleHook(void)
412357
{
413-
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
414-
invoke_btn_press_event();
415-
// is_sleep_ready is required since wfx_is_sleep_ready() is not FreeRTOS scheduler agnostic
416-
is_sleep_ready = wfx_is_sleep_ready();
417-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SI917_M4_SLEEP_ENABLED
358+
#if (SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER)
359+
sl_si91x_invoke_btn_press_event();
360+
#endif
418361
}

examples/platform/silabs/SiWx917/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ source_set("siwx917-common") {
216216
public_configs = [
217217
":siwx917-common-config",
218218
"${efr32_sdk_build_root}:silabs_config",
219+
":chip_examples_project_config",
219220
]
220221

221222
include_dirs = [

examples/platform/silabs/wfx_rsi.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <event_groups.h>
2020
#include <wfx_host_events.h>
21+
#include <app/icd/server/ICDServerConfig.h>
2122

2223
#ifndef RSI_BLE_ENABLE
2324
#define RSI_BLE_ENABLE (1)
@@ -112,8 +113,10 @@ int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info);
112113
int32_t wfx_rsi_reset_count();
113114
int32_t wfx_rsi_disconnect();
114115
int32_t wfx_wifi_rsi_init(void);
115-
#if SL_ICD_ENABLED
116-
void sl_wfx_host_si91x_sleep_wakeup();
116+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
117+
#if SLI_SI91X_MCU_INTERFACE
118+
void sl_si91x_invoke_btn_press_event();
119+
#endif // SLI_SI91X_MCU_INTERFACE
117120
#if SLI_SI917
118121
int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_si91x_performance_profile_t sl_si91x_wifi_state);
119122
#else

src/lwip/silabs/lwipopts-rs911x.h

+4
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@
158158
#define DEFAULT_UDP_RECVMBOX_SIZE 6
159159
#define DEFAULT_TCP_RECVMBOX_SIZE 6
160160

161+
#if SL_ICD_ENABLED
162+
#define SL_LWIP_MLD6_TIMERS_ONDEMAND 1
163+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
164+
161165
#ifdef LWIP_DEBUG
162166

163167
#define MEMP_OVERFLOW_CHECK (0)

src/lwip/silabs/lwipopts-wf200.h

+4
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@
159159
#define DEFAULT_UDP_RECVMBOX_SIZE 6
160160
#define DEFAULT_TCP_RECVMBOX_SIZE 6
161161

162+
#if SL_ICD_ENABLED
163+
#define SL_LWIP_MLD6_TIMERS_ONDEMAND 1
164+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
165+
162166
#ifdef LWIP_DEBUG
163167

164168
#define MEMP_OVERFLOW_CHECK (0)

third_party/silabs/SiWx917_sdk.gni

+19-4
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ template("siwx917_sdk") {
152152
"${wifi_sdk_root}/components/device/silabs/si91x/wireless/firmware_upgrade",
153153
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/hal/inc",
154154
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/inc",
155+
156+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/inc",
155157
]
156158

157159
if (use_system_view) {
@@ -303,9 +305,9 @@ template("siwx917_sdk") {
303305
"SL_ACTIVE_MODE_DURATION_MS=${sl_active_mode_duration_ms}",
304306
"SL_IDLE_MODE_DURATION_S=${sl_idle_mode_duration_s}",
305307
"SL_ICD_SUPPORTED_CLIENTS_PER_FABRIC=${sl_icd_supported_clients_per_fabric}",
306-
"SL_SI91X_MCU_WIRELESS_BASED_WAKEUP=1",
307-
"SL_SI91X_MCU_BUTTON_BASED_WAKEUP=1",
308-
"SL_SI91X_MCU_ALARM_BASED_WAKEUP=1",
308+
"SL_SI91X_NPSS_GPIO_BTN_HANDLER=1",
309+
"SL_SI91X_POWER_MANAGER_UC_AVAILABLE=1",
310+
"SL_SI91X_TICKLESS_MODE=1",
309311
]
310312

311313
if (si91x_alarm_based_periodic_wakeup) {
@@ -412,6 +414,7 @@ template("siwx917_sdk") {
412414
"${wifi_sdk_root}/components/board/silabs/src/rsi_board.c",
413415
"${wifi_sdk_root}/components/common/src/sl_utility.c",
414416
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c",
417+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_ps_ram_func.c",
415418
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/rsi_system_config.c",
416419
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/chip/src/system_si91x.c",
417420
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/core/common/src/rsi_debug.c",
@@ -571,9 +574,21 @@ template("siwx917_sdk") {
571574

572575
if (chip_enable_icd_server) {
573576
sources += [
577+
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_power_manager_handler.c",
578+
"${sdk_support_root}/matter/si91x/siwx917/BRD4338A/autogen/sl_si91x_power_manager_wakeup_handler.c",
579+
574580
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/sl_si91x_m4_ps.c",
575-
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_rtc.c",
576581
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_time_period.c",
582+
583+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sl_si91x_power_manager.c",
584+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sli_si91x_power_manager.c",
585+
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/power_manager/src/sli_si91x_power_manager_wakeup_init.c",
586+
"${wifi_sdk_root}/third_party/silicon_labs/freertos/src/sl_si91x_low_power_tickless_mode.c",
587+
588+
# "${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer.c",
589+
# "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/sleeptimer/src/sl_sleeptimer_hal_si91x_sysrtc.c",
590+
591+
# "${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_sysrtc.c",
577592
]
578593
}
579594
public_deps = [

0 commit comments

Comments
 (0)