Skip to content

Commit d1a4360

Browse files
Update 917 apis for wifi sdk 3.3.0
1 parent ca68e09 commit d1a4360

File tree

10 files changed

+198
-276
lines changed

10 files changed

+198
-276
lines changed

examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp

+55-115
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "silabs_utils.h"
2323
#include "sl_status.h"
24+
#include <app/icd/server/ICDServerConfig.h>
2425

2526
#include "FreeRTOS.h"
2627
#include "event_groups.h"
@@ -39,9 +40,12 @@ extern "C" {
3940

4041
#include "ble_config.h"
4142

42-
#if SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE
43+
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
4344
#include "rsi_rom_power_save.h"
4445
#include "sl_si91x_button_pin_config.h"
46+
#if DISPLAY_ENABLED
47+
#include "sl_memlcd.h"
48+
#endif // DISPLAY_ENABLED
4549
extern "C" {
4650
#include "sl_si91x_driver.h"
4751
#include "sl_si91x_m4_ps.h"
@@ -50,7 +54,7 @@ extern "C" {
5054
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
5155
#define BUTTON_PRESSED 1
5256
bool btn0_pressed = false;
53-
#endif // SL_ICD_ENABLED && SLI_SI91X_MCU_INTERFACE
57+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
5458

5559
#include "dhcp_client.h"
5660
#include "wfx_host_events.h"
@@ -70,19 +74,14 @@ extern "C" {
7074
#include "sl_wifi.h"
7175
#include "sl_wifi_callback_framework.h"
7276
#include "wfx_host_events.h"
73-
#if TINYCRYPT_PRIMITIVES
77+
#if SLI_SI91X_MCU_INTERFACE
7478
#include "sl_si91x_trng.h"
7579
#define TRNGKEY_SIZE 4
76-
#endif // TINYCRYPT_PRIMITIVES
77-
}
80+
#endif // SLI_SI91X_MCU_INTERFACE
81+
} // extern "C" {
7882

7983
WfxRsi_t wfx_rsi;
8084

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-
8685
/* Declare a variable to hold the data associated with the created event group. */
8786
StaticEventGroup_t rsiDriverEventGroup;
8887

@@ -246,10 +245,9 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
246245
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTING);
247246
if (SL_WIFI_CHECK_IF_EVENT_FAILED(event))
248247
{
249-
SILABS_LOG("F: Join Event received with %u bytes payload\n", result_length);
250248
callback_status = *(sl_status_t *) result;
249+
SILABS_LOG("join_callback_handler: failed: 0x%X", callback_status);
251250
wfx_rsi.dev_state &= ~(WFX_RSI_ST_STA_CONNECTED);
252-
is_wifi_disconnection_event = true;
253251
wfx_retry_interval_handler(is_wifi_disconnection_event, wfx_rsi.join_retries++);
254252
if (is_wifi_disconnection_event || wfx_rsi.join_retries <= WFX_RSI_CONFIG_MAX_JOIN)
255253
{
@@ -262,26 +260,22 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
262260
* Join was complete - Do the DHCP
263261
*/
264262
memset(&temp_reset, 0, sizeof(wfx_wifi_scan_ext_t));
265-
SILABS_LOG("join_callback_handler: join completed.");
266-
SILABS_LOG("%c: Join Event received with %u bytes payload\n", *result, result_length);
263+
SILABS_LOG("join_callback_handler: success");
267264

268265
WfxEvent.eventType = WFX_EVT_STA_CONN;
269266
WfxPostEvent(&WfxEvent);
270267
wfx_rsi.join_retries = 0;
271268
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
272-
if (is_wifi_disconnection_event)
273-
{
274-
is_wifi_disconnection_event = false;
275-
}
276-
callback_status = SL_STATUS_OK;
269+
// Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection
270+
is_wifi_disconnection_event = true;
271+
callback_status = SL_STATUS_OK;
277272
return SL_STATUS_OK;
278273
}
279274

280-
#if SL_ICD_ENABLED
281-
282-
#if SI917_M4_SLEEP_ENABLED
275+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
276+
#if SLI_SI91X_MCU_INTERFACE
283277
// Required to invoke button press event during sleep as falling edge is not detected
284-
void invoke_btn_press_event()
278+
void sl_si91x_invoke_btn_press_event()
285279
{
286280
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
287281
if (!RSI_NPSSGPIO_GetPin(SL_BUTTON_BTN0_PIN) && !btn0_pressed)
@@ -295,36 +289,28 @@ void invoke_btn_press_event()
295289
}
296290
}
297291

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)
292+
/******************************************************************
293+
* @fn sl_app_sleep_ready()
294+
* @brief
295+
* Called from the supress ticks from tickless to check if it
296+
* is ok to go to sleep
297+
* @param[in] None
298+
* @return
299+
* None
300+
*********************************************************************/
301+
uint32_t sl_app_sleep_ready()
322302
{
323-
SL_ASSERT(sleep_time_ms != NULL);
324-
sl_si91x_m4_sleep_wakeup(sleep_time_ms);
303+
if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY)
304+
{
305+
#if DISPLAY_ENABLED
306+
// Powering down the LCD
307+
sl_memlcd_power_on(NULL, false);
308+
#endif /* DISPLAY_ENABLED */
309+
return true;
310+
}
311+
return false;
325312
}
326-
327-
#endif // SI917_M4_SLEEP_ENABLED
313+
#endif // SLI_SI91X_MCU_INTERFACE
328314

329315
/******************************************************************
330316
* @fn wfx_rsi_power_save()
@@ -363,7 +349,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_
363349
}
364350
return status;
365351
}
366-
#endif /* SL_ICD_ENABLED */
352+
#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
367353

368354
/*************************************************************************************
369355
* @fn static int32_t wfx_wifi_rsi_init(void)
@@ -378,13 +364,6 @@ int32_t wfx_wifi_rsi_init(void)
378364
SILABS_LOG("wfx_wifi_rsi_init started");
379365
sl_status_t status;
380366
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
388367
if (status != SL_STATUS_OK)
389368
{
390369
return status;
@@ -449,15 +428,15 @@ static sl_status_t wfx_rsi_init(void)
449428
return status;
450429
}
451430
#else // For SoC
452-
#if SL_ICD_ENABLED
431+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
453432
uint8_t xtal_enable = 1;
454433
status = sl_si91x_m4_ta_secure_handshake(SL_SI91X_ENABLE_XTAL, 1, &xtal_enable, 0, NULL);
455434
if (status != SL_STATUS_OK)
456435
{
457436
SILABS_LOG("Failed to bring m4_ta_secure_handshake: 0x%lx\r\n", status);
458437
return status;
459438
}
460-
#endif /* SL_ICD_ENABLED */
439+
#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
461440
#endif /* SLI_SI91X_MCU_INTERFACE */
462441

463442
sl_wifi_firmware_version_t version = { 0 };
@@ -477,7 +456,7 @@ static sl_status_t wfx_rsi_init(void)
477456
return status;
478457
}
479458

480-
#ifdef TINYCRYPT_PRIMITIVES
459+
#ifdef SLI_SI91X_MCU_INTERFACE
481460
const uint32_t trngKey[TRNGKEY_SIZE] = { 0x16157E2B, 0xA6D2AE28, 0x8815F7AB, 0x3C4FCF09 };
482461

483462
// To check the Entropy of TRNG and verify TRNG functioning.
@@ -495,7 +474,7 @@ static sl_status_t wfx_rsi_init(void)
495474
SILABS_LOG("TRNG Key Programming Failed");
496475
return status;
497476
}
498-
#endif // TINYCRYPT_PRIMITIVES
477+
#endif // SLI_SI91X_MCU_INTERFACE
499478

500479
wfx_rsi.events = xEventGroupCreateStatic(&rsiDriverEventGroup);
501480
wfx_rsi.dev_state |= WFX_RSI_ST_DEV_READY;
@@ -520,12 +499,13 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
520499
{
521500
if (SL_WIFI_CHECK_IF_EVENT_FAILED(event))
522501
{
523-
callback_status = *(sl_status_t *) scan_result;
502+
callback_status = *(sl_status_t *) scan_result;
503+
SILABS_LOG("scan_callback_handler: failed: 0x%X", callback_status);
524504
scan_results_complete = true;
525505
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
526506
wfx_rsi.sec.security = WFX_SEC_WPA3;
527507
#else
528-
wfx_rsi.sec.security = WFX_SEC_WPA2;
508+
wfx_rsi.sec.security = WFX_SEC_WPA2;
529509
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
530510

531511
osSemaphoreRelease(sScanSemaphore);
@@ -541,9 +521,9 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
541521
break;
542522
case SL_WIFI_WPA:
543523
case SL_WIFI_WPA_ENTERPRISE:
544-
case SL_WIFI_WPA_WPA2_MIXED:
545524
wfx_rsi.sec.security = WFX_SEC_WPA;
546525
break;
526+
case SL_WIFI_WPA_WPA2_MIXED:
547527
case SL_WIFI_WPA2:
548528
case SL_WIFI_WPA2_ENTERPRISE:
549529
wfx_rsi.sec.security = WFX_SEC_WPA2;
@@ -556,7 +536,7 @@ sl_status_t scan_callback_handler(sl_wifi_event_t event, sl_wifi_scan_result_t *
556536
case SL_WIFI_WPA3:
557537
wfx_rsi.sec.security = WFX_SEC_WPA3;
558538
#else
559-
wfx_rsi.sec.security = WFX_SEC_WPA2;
539+
wfx_rsi.sec.security = WFX_SEC_WPA2;
560540
#endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */
561541
break;
562542
default:
@@ -661,14 +641,18 @@ static sl_status_t wfx_rsi_do_join(void)
661641
connect_security_mode = SL_WIFI_WEP;
662642
break;
663643
case WFX_SEC_WPA:
664-
case WFX_SEC_WPA2:
665644
connect_security_mode = SL_WIFI_WPA_WPA2_MIXED;
666645
break;
646+
case WFX_SEC_WPA2:
667647
#if WIFI_ENABLE_SECURITY_WPA3_TRANSITION
648+
connect_security_mode = SL_WIFI_WPA3_TRANSITION;
649+
break;
668650
case WFX_SEC_WPA3:
669651
connect_security_mode = SL_WIFI_WPA3_TRANSITION;
652+
#else
653+
connect_security_mode = SL_WIFI_WPA_WPA2_MIXED;
654+
#endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION
670655
break;
671-
#endif /*WIFI_ENABLE_SECURITY_WPA3_TRANSITION*/
672656
case WFX_SEC_NONE:
673657
connect_security_mode = SL_WIFI_OPEN;
674658
break;
@@ -695,14 +679,14 @@ static sl_status_t wfx_rsi_do_join(void)
695679

696680
sl_wifi_set_join_callback(join_callback_handler, NULL);
697681

698-
#if SL_ICD_ENABLED
682+
#if CHIP_CONFIG_ENABLE_ICD_SERVER
699683
// Setting the listen interval to 0 which will set it to DTIM interval
700684
sl_wifi_listen_interval_t sleep_interval = { .listen_interval = 0 };
701685
status = sl_wifi_set_listen_interval(SL_WIFI_CLIENT_INTERFACE, sleep_interval);
702686

703687
sl_wifi_advanced_client_configuration_t client_config = { .max_retry_attempts = 5 };
704688
sl_wifi_set_advanced_client_configuration(SL_WIFI_CLIENT_INTERFACE, &client_config);
705-
#endif // SL_ICD_ENABLED
689+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
706690
/* Try to connect Wifi with given Credentials
707691
* untill there is a success or maximum number of tries allowed
708692
*/
@@ -1006,47 +990,3 @@ void wfx_dhcp_got_ipv4(uint32_t ip)
1006990
wfx_rsi.dev_state |= WFX_RSI_ST_STA_READY;
1007991
}
1008992
#endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */
1009-
1010-
/********************************************************************************************
1011-
* @fn void wfx_rsi_pkt_add_data(void *p, uint8_t *buf, uint16_t len, uint16_t off)
1012-
* @brief
1013-
* add the data into packet
1014-
* @param[in] p:
1015-
* @param[in] buf:
1016-
* @param[in] len:
1017-
* @param[in] off:
1018-
* @return
1019-
* None
1020-
**********************************************************************************************/
1021-
void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off)
1022-
{
1023-
sl_si91x_packet_t * pkt;
1024-
pkt = (sl_si91x_packet_t *) p;
1025-
memcpy(((char *) pkt->data) + off, buf, len);
1026-
}
1027-
1028-
#if !EXP_BOARD
1029-
/********************************************************************************************
1030-
* @fn int32_t wfx_rsi_send_data(void *p, uint16_t len)
1031-
* @brief
1032-
* Driver send a data
1033-
* @param[in] p:
1034-
* @param[in] len:
1035-
* @return
1036-
* None
1037-
**********************************************************************************************/
1038-
int32_t wfx_rsi_send_data(void * p, uint16_t len)
1039-
{
1040-
int32_t status;
1041-
sl_wifi_buffer_t * buffer;
1042-
buffer = (sl_wifi_buffer_t *) p;
1043-
1044-
if (sl_si91x_driver_send_data_packet(SI91X_WLAN_CMD_QUEUE, buffer, RSI_SEND_RAW_DATA_RESPONSE_WAIT_TIME))
1045-
{
1046-
SILABS_LOG("*ERR*EN-RSI:Send fail");
1047-
return ERR_IF;
1048-
}
1049-
return status;
1050-
}
1051-
1052-
#endif

examples/platform/silabs/display/lcd.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "glib.h"
2727

2828
#if (SLI_SI91X_MCU_INTERFACE)
29-
#include "rsi_chip.h"
29+
#include "sl_memlcd.h"
3030
#endif
3131

3232
#ifdef QR_CODE_ENABLED
@@ -67,10 +67,7 @@ CHIP_ERROR SilabsLCD::Init(uint8_t * name, bool initialState)
6767

6868
/* Enable the memory lcd */
6969
#if (SLI_SI91X_MCU_INTERFACE)
70-
RSI_NPSSGPIO_InputBufferEn(SL_BOARD_ENABLE_DISPLAY_PIN, 1U);
71-
RSI_NPSSGPIO_SetPinMux(SL_BOARD_ENABLE_DISPLAY_PIN, 0);
72-
RSI_NPSSGPIO_SetDir(SL_BOARD_ENABLE_DISPLAY_PIN, 0);
73-
RSI_NPSSGPIO_SetPin(SL_BOARD_ENABLE_DISPLAY_PIN, 1U);
70+
sl_memlcd_display_enable();
7471
#else
7572
status = sl_board_enable_display();
7673
if (status != SL_STATUS_OK)

src/platform/silabs/CHIPMem-Platform.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ bool MemoryInternalCheckPointer(const void * p, size_t min_size)
147147
} // namespace Platform
148148
} // namespace chip
149149

150-
extern "C" __WEAK void memMonitoringTrackAlloc(void * ptr, size_t size) {}
151-
extern "C" __WEAK void memMonitoringTrackFree(void * ptr, size_t size) {}
150+
extern "C" __attribute__((weak)) void memMonitoringTrackAlloc(void * ptr, size_t size) {}
151+
extern "C" __attribute__((weak)) void memMonitoringTrackFree(void * ptr, size_t size) {}
152152

153153
#endif // CHIP_CONFIG_MEMORY_MGMT_PLATFORM

0 commit comments

Comments
 (0)