Skip to content

Commit

Permalink
917 changes to support sdk update
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Aug 15, 2024
1 parent 78e3f5c commit df863b1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 93 deletions.
2 changes: 1 addition & 1 deletion examples/platform/silabs/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ extern uint32_t SystemCoreClock;
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP 70
#define configPRE_SLEEP_PROCESSING(x)
#define configPOST_SLEEP_PROCESSING(x)
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x) sl_si91x_pre_supress_ticks_and_sleep(&x)
#define configPRE_SUPPRESS_TICKS_AND_SLEEP_PROCESSING(x)
#else
#define configUSE_TICKLESS_IDLE 0
#endif // SL_CATALOG_POWER_MANAGER_PRESENT
Expand Down
98 changes: 29 additions & 69 deletions examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* limitations under the License.
*/

/*
* This file implements the interface to the wifi sdk
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -23,38 +27,45 @@
#include "sl_matter_wifi_config.h"
#endif // SL_MATTER_GN_BUILD

#include "FreeRTOS.h"
#include "ble_config.h"
#include "dhcp_client.h"
#include "event_groups.h"
#include "sl_board_configuration.h"
#include "sl_status.h"
#include "task.h"
#include "wfx_host_events.h"
#include "wfx_rsi.h"
#include <app/icd/server/ICDServerConfig.h>
#include <inet/IPAddress.h>
#include <lib/support/logging/CHIPLogging.h>

#include "FreeRTOS.h"
#include "event_groups.h"
#include "sl_board_configuration.h"
extern "C" {
#include "sl_net.h"
#include "sl_si91x_driver.h"
#include "sl_si91x_host_interface.h"
#include "sl_si91x_m4_ps.h"
#include "sl_si91x_types.h"
#include "sl_wifi.h"
#include "sl_wifi_callback_framework.h"
#include "sl_wifi_constants.h"
#include "sl_wifi_types.h"
#include "sl_wlan_config.h"
#include "wfx_host_events.h"
#if SL_MBEDTLS_USE_TINYCRYPT
#include "sl_si91x_constants.h"
#include "sl_si91x_trng.h"
#endif // SL_MBEDTLS_USE_TINYCRYPT
}
#include "task.h"

#if (EXP_BOARD)
#include "rsi_bt_common_apis.h"
#endif

#include "ble_config.h"

#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE
#include "rsi_rom_power_save.h"
#include "sl_si91x_button_pin_config.h"
#if DISPLAY_ENABLED
#include "sl_memlcd.h"
#endif // DISPLAY_ENABLED
extern "C" {
#include "sl_si91x_driver.h"
#include "sl_si91x_m4_ps.h"
}
#include "sl_si91x_power_manager.h"

namespace {
// TODO: should be removed once we are getting the press interrupt for button 0 with sleep
Expand All @@ -67,9 +78,6 @@ bool ps_requirement_added = false;
} // namespace
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI91X_MCU_INTERFACE

#include "dhcp_client.h"
#include "wfx_host_events.h"
#include "wfx_rsi.h"
#define ADV_SCAN_THRESHOLD -40
#define ADV_RSSI_TOLERANCE_THRESHOLD 5
#define ADV_ACTIVE_SCAN_DURATION 15
Expand All @@ -79,17 +87,9 @@ bool ps_requirement_added = false;

// TODO: Confirm that this value works for size and timing
#define WFX_QUEUE_SIZE 10
extern "C" {
#include "sl_net.h"
#include "sl_si91x_host_interface.h"
#include "sl_wifi.h"
#include "sl_wifi_callback_framework.h"
#include "wfx_host_events.h"
#if SL_MBEDTLS_USE_TINYCRYPT
#include "sl_si91x_constants.h"
#include "sl_si91x_trng.h"
#endif // SL_MBEDTLS_USE_TINYCRYPT
}

// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else.
#define WIFI_SCAN_TIMEOUT_TICK 10000

WfxRsi_t wfx_rsi;

Expand All @@ -109,20 +109,9 @@ bool is_wifi_disconnection_event = false;
uint32_t retryInterval = WLAN_MIN_RETRY_TIMER_MS;
volatile bool scan_results_complete = false;
volatile bool bg_scan_results_complete = false;

// TODO: Figure out why we actually need this, we are already handling failure and retries somewhere else.
#define WIFI_SCAN_TIMEOUT_TICK 10000

extern osSemaphoreId_t sl_rs_ble_init_sem;

/*
* This file implements the interface to the wifi sdk
*/

static wfx_wifi_scan_ext_t temp_reset;

volatile sl_status_t callback_status = SL_STATUS_OK;

// Scan semaphore
static osSemaphoreId_t sScanSemaphore;
// DHCP Poll timer
Expand Down Expand Up @@ -319,28 +308,6 @@ void sl_si91x_invoke_btn_press_event()
}
#endif // ENABLE_CHIP_SHELL
}

/******************************************************************
* @fn sl_app_sleep_ready()
* @brief
* Called from the supress ticks from tickless to check if it
* is ok to go to sleep
* @param[in] None
* @return
* None
*********************************************************************/
uint32_t sl_app_sleep_ready()
{
if (wfx_rsi.dev_state & WFX_RSI_ST_SLEEP_READY)
{
#if DISPLAY_ENABLED
// Powering down the LCD
sl_memlcd_power_on(NULL, false);
#endif /* DISPLAY_ENABLED */
return true;
}
return false;
}
#endif // SLI_SI91X_MCU_INTERFACE

/******************************************************************
Expand Down Expand Up @@ -370,14 +337,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_
ChipLogError(DeviceLayer, "sl_wifi_set_performance_profile failed: 0x%lx", static_cast<uint32_t>(status));
return status;
}
if (sl_si91x_wifi_state == HIGH_PERFORMANCE)
{
wfx_rsi.dev_state &= ~(WFX_RSI_ST_SLEEP_READY);
}
else
{
wfx_rsi.dev_state |= WFX_RSI_ST_SLEEP_READY;
}

return status;
}
#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */
Expand Down Expand Up @@ -687,7 +647,7 @@ static sl_status_t wfx_rsi_do_join(void)
case WFX_SEC_WPA3:
ap.security = SL_WIFI_WPA3_TRANSITION;
#else
ap.security = SL_WIFI_WPA_WPA2_MIXED;
ap.security = SL_WIFI_WPA_WPA2_MIXED;
#endif // WIFI_ENABLE_SECURITY_WPA3_TRANSITION
break;
case WFX_SEC_NONE:
Expand Down
14 changes: 12 additions & 2 deletions examples/platform/silabs/display/demo-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "glib.h"
#include "sl_component_catalog.h"
#include "sl_memlcd.h"
#include <app/icd/server/ICDServerConfig.h>
#if SL_WIFI && !SLI_SI91X_MCU_INTERFACE
#include "spi_multiplex.h"
#endif // SL_WIFI && !SLI_SI91X_MCU_INTERFACE
Expand Down Expand Up @@ -106,9 +107,12 @@ void demoUIInit(GLIB_Context_t * context)
sl_status_t updateDisplay(void)
{
sl_status_t status = SL_STATUS_OK;
#if SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED && DISPLAY_ENABLED

#if SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER
// In sleep, memlcd will not be retained so re-initialize MEMLCD interface after sleep wakeup
sl_memlcd_post_wakeup_init();
#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED && DISPLAY_ENABLED
#endif // SLI_SI91X_MCU_INTERFACE && SL_ICD_ENABLED && CHIP_CONFIG_ENABLE_ICD_SERVER

#if SL_LCDCTRL_MUX
status = sl_wfx_host_pre_lcd_spi_transfer();
if (status != SL_STATUS_OK)
Expand All @@ -123,6 +127,12 @@ sl_status_t updateDisplay(void)
return status;
#endif // SL_LCDCTRL_MUX

#if SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER
// MEMLCD is not a UULP component and not available in sleep so powering down before sleep and need to be re-initialized after
// sleep-wakeup
sl_memlcd_power_on(NULL, false);
#endif // SLI_SI91X_MCU_INTERFACE && CHIP_CONFIG_ENABLE_ICD_SERVER

return SL_STATUS_OK;
}

Expand Down
1 change: 0 additions & 1 deletion examples/platform/silabs/wfx_rsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ typedef enum
WFX_RSI_ST_STA_READY = (WFX_RSI_ST_STA_CONNECTED | WFX_RSI_ST_STA_DHCP_DONE),
WFX_RSI_ST_STARTED = (1 << 9), /* RSI task started */
WFX_RSI_ST_SCANSTARTED = (1 << 10), /* Scan Started */
WFX_RSI_ST_SLEEP_READY = (1 << 11) /* Notify the M4 to go to sleep*/
} WfxStateType_e;

typedef struct WfxEvent_s
Expand Down
20 changes: 0 additions & 20 deletions third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,8 @@ import("silabs_board.gni")
examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917"

declare_args() {
# Enable the Alarm Based Wakeup for 917 SoC when sleep is enabled
si91x_alarm_based_periodic_wakeup = false

# Periodic time at which the 917 SoC should wakeup
si91x_alarm_periodic_time = 30

# option to select the crypto library
sl_si91x_crypto_flavor = "tinycrypt"

# enable 917 SoC M4 sleep wakeup
si917_m4_sleep_enabled = false
}

# Defines an siwx917 SDK build target.
Expand Down Expand Up @@ -325,17 +316,6 @@ template("siwx917_sdk") {
"SL_SI91X_POWER_MANAGER_UC_AVAILABLE=1",
"SL_SI91X_TICKLESS_MODE=1",
]

if (si91x_alarm_based_periodic_wakeup) {
defines += [ "ALARM_PERIODIC_TIME=${si91x_alarm_periodic_time}" ]
}

if (si917_m4_sleep_enabled) {
defines += [
"SI917_M4_SLEEP_ENABLED=1",
"XTAL_OFF",
]
}
}

if (sl_uart_log_output) {
Expand Down

0 comments on commit df863b1

Please sign in to comment.