@@ -78,6 +78,11 @@ extern "C" {
78
78
79
79
WfxRsi_t wfx_rsi;
80
80
81
+ // TODO: remove this. Added only to monitor how many watch dog reset have happened during testing.
82
+ #ifdef SLI_SI91X_MCU_INTERFACE
83
+ volatile uint32_t watchdog_reset = 0 ;
84
+ #endif // SLI_SI91X_MCU_INTERFACE
85
+
81
86
/* Declare a variable to hold the data associated with the created event group. */
82
87
StaticEventGroup_t rsiDriverEventGroup;
83
88
@@ -274,42 +279,52 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
274
279
275
280
#if SL_ICD_ENABLED
276
281
277
- #if SLI_SI91X_MCU_INTERFACE
278
- /* *****************************************************************
279
- * @fn sl_wfx_host_si91x_sleep_wakeup()
280
- * @brief
281
- * M4 going to sleep
282
- *
283
- * @param[in] None
284
- * @return
285
- * None
286
- *********************************************************************/
287
- void sl_wfx_host_si91x_sleep_wakeup ()
282
+ #if SI917_M4_SLEEP_ENABLED
283
+ // Required to invoke button press event during sleep as falling edge is not detected
284
+ void invoke_btn_press_event ()
288
285
{
289
- if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY)
286
+ // TODO: should be removed once we are getting the press interrupt for button 0 with sleep
287
+ if (!RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN) && !btn0_pressed)
290
288
{
291
- // TODO: should be removed once we are getting the press interrupt for button 0 with sleep
292
- if (!RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN) && !btn0_pressed)
293
- {
294
- sl_button_on_change (SL_BUTTON_BTN0_NUMBER, BUTTON_PRESSED);
295
- btn0_pressed = true ;
296
- }
297
- if (RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN))
298
- {
299
- #ifdef DISPLAY_ENABLED
300
- // if LCD is enabled, power down the lcd before setting the M4 to sleep
301
- sl_si91x_hardware_setup ();
302
- #endif
303
- btn0_pressed = false ;
304
- /* Configure RAM Usage and Retention Size */
305
- sl_si91x_m4_sleep_wakeup ();
306
- #if SILABS_LOG_ENABLED
307
- silabsInitLog ();
308
- #endif
309
- }
289
+ sl_button_on_change (SL_BUTTON_BTN0_NUMBER, BUTTON_PRESSED);
290
+ btn0_pressed = true ;
291
+ }
292
+ if (RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN))
293
+ {
294
+ btn0_pressed = false ;
310
295
}
311
296
}
312
- #endif // SLI_SI91X_MCU_INTERFACE
297
+
298
+ /* *
299
+ * @brief Checks if the Wi-Fi module is ready for sleep.
300
+ *
301
+ * This function checks if the Wi-Fi module is ready to enter sleep mode.
302
+ *
303
+ * @return true if the Wi-Fi module is ready for sleep, false otherwise.
304
+ */
305
+ bool wfx_is_sleep_ready ()
306
+ {
307
+ // BRD4002A board BTN_PRESS is 0 when pressed, release is 1
308
+ // sli_si91x_is_sleep_ready requires OS Scheduler to be active
309
+ return ((RSI_NPSSGPIO_GetPin (SL_BUTTON_BTN0_PIN) != 0 ) && (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY) &&
310
+ sli_si91x_is_sleep_ready ());
311
+ }
312
+
313
+ /* *
314
+ * @brief Sleeps for a specified duration and then wakes up.
315
+ *
316
+ * This function puts the SI91x host into sleep mode for the specified duration
317
+ * in milliseconds and then wakes it up.
318
+ *
319
+ * @param sleep_time_ms The duration in milliseconds to sleep.
320
+ */
321
+ void sl_wfx_host_si91x_sleep (uint16_t * sleep_time_ms)
322
+ {
323
+ SL_ASSERT (sleep_time_ms != NULL );
324
+ sl_si91x_m4_sleep_wakeup (sleep_time_ms);
325
+ }
326
+
327
+ #endif // SI917_M4_SLEEP_ENABLED
313
328
314
329
/* *****************************************************************
315
330
* @fn wfx_rsi_power_save()
@@ -363,6 +378,13 @@ int32_t wfx_wifi_rsi_init(void)
363
378
SILABS_LOG (" wfx_wifi_rsi_init started" );
364
379
sl_status_t status;
365
380
status = sl_wifi_init (&config, NULL , sl_wifi_default_event_handler);
381
+ #ifdef SLI_SI91X_MCU_INTERFACE
382
+ // TODO: remove this. Added only to monitor how many watch dog reset have happened during testing.
383
+ if ((MCU_FSM->MCU_FSM_WAKEUP_STATUS_REG ) & BIT (5 ))
384
+ {
385
+ watchdog_reset++;
386
+ }
387
+ #endif // SLI_SI91X_MCU_INTERFACE
366
388
if (status != SL_STATUS_OK)
367
389
{
368
390
return status;
0 commit comments