|
| 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