Skip to content

Commit ef72416

Browse files
committed
wiseconnect: Adding M4 soft reset
Origin: Silicon Labs WiseConnect SDK License: Zlib URL: https://github.com/siliconlabs/wiseconnect Commit: db28bd581082517ca2342467fa4f59c6b9b30cd0 Version: v3.5.0-rc4 Purpose: Adding M4 SoC soft reset source files to enable use of the reset API following the firmware upgrade process. Signed-off-by: Rahul Gurram <[email protected]>
1 parent 42f84e9 commit ef72416

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/***************************************************************************/ /**
2+
* @file sl_si91x_hal_soc_soft_reset.h
3+
* @brief SoC soft reset API
4+
*******************************************************************************
5+
* # License
6+
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
7+
*******************************************************************************
8+
*
9+
* SPDX-License-Identifier: Zlib
10+
*
11+
* The licensor of this software is Silicon Laboratories Inc.
12+
*
13+
* This software is provided 'as-is', without any express or implied
14+
* warranty. In no event will the authors be held liable for any damages
15+
* arising from the use of this software.
16+
*
17+
* Permission is granted to anyone to use this software for any purpose,
18+
* including commercial applications, and to alter it and redistribute it
19+
* freely, subject to the following restrictions:
20+
*
21+
* 1. The origin of this software must not be misrepresented; you must not
22+
* claim that you wrote the original software. If you use this software
23+
* in a product, an acknowledgment in the product documentation would be
24+
* appreciated but is not required.
25+
* 2. Altered source versions must be plainly marked as such, and must not be
26+
* misrepresented as being the original software.
27+
* 3. This notice may not be removed or altered from any source distribution.
28+
*
29+
******************************************************************************/
30+
31+
#ifndef __SL_SI91X_HAL_SOC_SOFT_RESET__
32+
#define __SL_SI91X_HAL_SOC_SOFT_RESET__
33+
34+
#include "rsi_qspi.h"
35+
36+
/** @cond DOXYGEN_IGNORE */
37+
#define M4_QSPI_AES_CONFIG *(volatile uint32 *)0x120000C8
38+
#define AES_QSPI_KEY_SIZE BIT(16)
39+
#define AES_QSPI_KEY_LENGTH BIT(11)
40+
/** @endcond */
41+
42+
/**
43+
* \addtogroup SOFT_RESET_FUNCTIONS Soft Reset
44+
* \ingroup COMMON_SECTION_FUNCTIONS
45+
* @{ */
46+
47+
/**
48+
* @brief To perform a Nested Vectored Interrupt Controller (NVIC) soft reset on the Si91X SoC.
49+
*
50+
* @details This function initiates a system reset request to reset the SoC.
51+
* It resets the M4 core and the Network Processor (NWP) of the Si91X SoC, bringing the system back to its initial state.
52+
*
53+
* @note Ensure that all necessary data is saved before calling this function because it will reset the NVIC and potentially disrupt ongoing processes.
54+
*/
55+
void sl_si91x_soc_nvic_reset(void);
56+
57+
/** @} */
58+
59+
#endif
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/***************************************************************************/ /**
2+
* @file sl_si91x_hal_soft_reset.c
3+
* @brief SoC soft reset API
4+
*******************************************************************************
5+
* # License
6+
* <b>Copyright 2023 Silicon Laboratories Inc. www.silabs.com</b>
7+
*******************************************************************************
8+
*
9+
* SPDX-License-Identifier: Zlib
10+
*
11+
* The licensor of this software is Silicon Laboratories Inc.
12+
*
13+
* This software is provided 'as-is', without any express or implied
14+
* warranty. In no event will the authors be held liable for any damages
15+
* arising from the use of this software.
16+
*
17+
* Permission is granted to anyone to use this software for any purpose,
18+
* including commercial applications, and to alter it and redistribute it
19+
* freely, subject to the following restrictions:
20+
*
21+
* 1. The origin of this software must not be misrepresented; you must not
22+
* claim that you wrote the original software. If you use this software
23+
* in a product, an acknowledgment in the product documentation would be
24+
* appreciated but is not required.
25+
* 2. Altered source versions must be plainly marked as such, and must not be
26+
* misrepresented as being the original software.
27+
* 3. This notice may not be removed or altered from any source distribution.
28+
*
29+
******************************************************************************/
30+
#include "rsi_wwdt.h"
31+
#include "cmsis_os2.h"
32+
#include "sl_si91x_hal_soc_soft_reset.h"
33+
34+
/*
35+
*
36+
* @brief This API is used to do soc NVIC reset with the debug module disabled.
37+
* @param None
38+
* @return None
39+
*/
40+
void sl_si91x_soc_nvic_reset(void)
41+
{
42+
/*Changing the lf fsm clock to 32KHz RC */
43+
RSI_PS_FsmLfClkSel(KHZ_RC_CLK_SEL);
44+
/*Upon Reset key size is 16 by default in case of inline encryption */
45+
/*Store key length bit (32 Bytes) in BBFF if device security is with 32 Bytes key*/
46+
if (M4_QSPI_AES_CONFIG & AES_QSPI_KEY_SIZE) {
47+
M4_BBFF_STORAGE1 |= AES_QSPI_KEY_LENGTH;
48+
}
49+
__asm volatile("cpsid i" ::: "memory");
50+
/*Data Synchronization Barrier */
51+
__DSB();
52+
/*Instruction Synchronization Barrier */
53+
__ISB();
54+
/*Power Down the Debug Module */
55+
RSI_PS_M4ssPeriPowerDown(M4SS_PWRGATE_ULP_M4_DEBUG_FPU);
56+
/*Set the SYSRESETREQ bit in the AIRCR register to initiate a system reset */
57+
SCB->AIRCR = (0x5FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk;
58+
/*Ensure the instruction is not optimized out */
59+
/*Data Synchronization Barrier */
60+
__DSB();
61+
/*Instruction Synchronization Barrier */
62+
__ISB();
63+
/*Wait for the reset to occur */
64+
while (1) {
65+
/* Infinite loop to keep the program running until the reset happens */
66+
}
67+
}

0 commit comments

Comments
 (0)