Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 53 additions & 4 deletions src/platform/silabs/platformAbstraction/WiseMcuSpam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,24 @@
#include "silabs_utils.h"
#endif // SILABS_LOG_ENABLED

#define SOC_PLL_REF_FREQUENCY 40000000 // /* PLL input REFERENCE clock 40MHZ */
// Note: Change this macro to required PLL frequency in hertz
#define PS4_SOC_FREQ 180000000 /* PLL out clock 180MHz */
#define SWITCH_QSPI_TO_SOC_PLL
#define ICACHE_DISABLE
#define DEBUG_DISABLE

/* QSPI clock config params */
#define INTF_PLL_500_CTRL_VALUE 0xD900
#define INTF_PLL_CLK 80000000 /* PLL out clock 80 MHz */

// TODO add includes ?
extern "C" {
#if defined(SL_SI91X_BOARD_INIT)
#include "rsi_board.h"
#endif // SL_SI91X_BOARD_INIT

#include "rsi_rom_clks.h"
#include "sl_si91x_hal_soc_soft_reset.h"

#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
Expand All @@ -57,10 +69,6 @@ const sl_rgb_led_t * ledPinArray[SL_LED_COUNT] = { &led_led0 };
uint8_t ledPinArray[SL_LED_COUNT] = { SL_LED_LED0_PIN, SL_LED_LED1_PIN };
#endif // (defined(SL_MATTER_RGB_LED_ENABLED) && SL_MATTER_RGB_LED_ENABLED)
#endif // ENABLE_WSTK_LEDS

#if CHIP_CONFIG_ENABLE_ICD_SERVER == 0
void soc_pll_config(void);
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
}

#ifdef SL_CATALOG_SYSTEMVIEW_TRACE_PRESENT
Expand All @@ -83,6 +91,41 @@ uint8_t sButtonStates[SL_SI91x_BUTTON_COUNT] = { 0 };
#if CHIP_CONFIG_ENABLE_ICD_SERVER && defined(SL_CATALOG_SIMPLE_BUTTON_PRESENT)
bool btn0_pressed = false;
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && defined(SL_CATALOG_SIMPLE_BUTTON_PRESENT)

#if CHIP_CONFIG_ENABLE_ICD_SERVER == 0
int soc_pll_config(void)
{
int32_t status = RSI_OK;

RSI_CLK_M4SocClkConfig(M4CLK, M4_ULPREFCLK, 0);
// Configures the required registers for 180 Mhz clock in PS4
RSI_PS_PS4SetRegisters();
// Configure the PLL frequency
// Configure the SOC PLL to 180MHz
RSI_CLK_SetSocPllFreq(M4CLK, PS4_SOC_FREQ, SOC_PLL_REF_FREQUENCY);
// Switch M4 clock to PLL clock for speed operations
RSI_CLK_M4SocClkConfig(M4CLK, M4_SOCPLLCLK, 0);

SysTick_Config(SystemCoreClock / configTICK_RATE_HZ);

#ifdef SWITCH_QSPI_TO_SOC_PLL
/* program intf pll to 160Mhz */
SPI_MEM_MAP_PLL(INTF_PLL_500_CTRL_REG9) = INTF_PLL_500_CTRL_VALUE;
status = RSI_CLK_SetIntfPllFreq(M4CLK, INTF_PLL_CLK, SOC_PLL_REF_FREQUENCY);
if (status != RSI_OK)
{
SILABS_LOG("Failed to Config Interface PLL Clock, status:%d", status);
}
else
{
SILABS_LOG("Configured Interface PLL Clock to %d", INTF_PLL_CLK);
}

RSI_CLK_QspiClkConfig(M4CLK, QSPI_INTFPLLCLK, 0, 0, 1);
#endif /* SWITCH_QSPI_TO_SOC_PLL */
return status;
}
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
} // namespace

SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager;
Expand Down Expand Up @@ -212,6 +255,12 @@ extern "C" void sl_button_on_change(uint8_t btn, uint8_t btnAction)
Silabs::GetPlatform().mButtonCallback(btn, btnAction);
}

extern "C" void sl_si91x_button_isr(uint8_t pin, int8_t state)
{
(pin == SL_BUTTON_BTN0_PIN) ? sl_button_on_change(SL_BUTTON_BTN0_NUMBER, state)
: sl_button_on_change(SL_BUTTON_BTN1_NUMBER, state);
}

uint8_t SilabsPlatform::GetButtonState(uint8_t button)
{
return (button < SL_SI91x_BUTTON_COUNT) ? sButtonStates[button] : 0;
Expand Down
1 change: 0 additions & 1 deletion third_party/silabs/SiWx917_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@ template("siwx917_sdk") {
"${matter_support_root}/board-support/si91x/siwx917/${silabs_board}/autogen/sl_si91x_button_instances.c",
"${matter_support_root}/board-support/si91x/siwx917/${silabs_board}/autogen/sl_ulp_timer_init.c",
"${matter_support_root}/board-support/si91x/siwx917/${silabs_board}/main.c",
"${matter_support_root}/board-support/si91x/support/hal/rsi_hal_mcu_m4.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/hardware_drivers/button/src/sl_si91x_button.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sl_si91x_clock_manager.c",
"${wifi_sdk_root}/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sli_si91x_clock_manager.c",
Expand Down
Loading