M4521_BSP V3.02.000
The Board Support Package for M4521
sys.c
Go to the documentation of this file.
1/**************************************************************************/
13#include "M4521.h"
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
46void SYS_ClearResetSrc(uint32_t u32Src)
47{
48 SYS->RSTSTS |= u32Src;
49}
50
58uint32_t SYS_GetBODStatus(void)
59{
60 return ((SYS->BODCTL & SYS_BODCTL_BODOUT_Msk) >> SYS_BODCTL_BODOUT_Pos);
61}
62
69uint32_t SYS_GetResetSrc(void)
70{
71 return (SYS->RSTSTS);
72}
73
81uint32_t SYS_IsRegLocked(void)
82{
83 return !(SYS->REGLCTL & 0x1);
84}
85
92uint32_t SYS_ReadPDID(void)
93{
94 return SYS->PDID;
95}
96
105{
106 SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
107}
108
116void SYS_ResetCPU(void)
117{
118 SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk;
119}
120
148void SYS_ResetModule(uint32_t u32ModuleIndex)
149{
150 /* Generate reset signal to the corresponding module */
151 *(volatile uint32_t *)((uint32_t)&SYS->IPRST0 + (u32ModuleIndex >> 24)) |= 1 << (u32ModuleIndex & 0x00ffffff);
152
153 /* Release corresponding module from reset state */
154 *(volatile uint32_t *)((uint32_t)&SYS->IPRST0 + (u32ModuleIndex >> 24)) &= ~(1 << (u32ModuleIndex & 0x00ffffff));
155}
156
171void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
172{
173 /* Enable Brown-out Detector function */
174 SYS->BODCTL |= SYS_BODCTL_BODEN_Msk;
175
176 /* Enable Brown-out interrupt or reset function */
177 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODRSTEN_Msk) | i32Mode;
178
179 /* Select Brown-out Detector threshold voltage */
180 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL_Msk) | u32BODLevel;
181}
182
191{
192 SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk;
193}
194
195
196 /* end of group SYS_EXPORTED_FUNCTIONS */
198 /* end of group SYS_Driver */
200 /* end of group Standard_Driver */
202
203#ifdef __cplusplus
204}
205#endif
206
207/*** (C) COPYRIGHT 2022 Nuvoton Technology Corp. ***/
#define SYS_IPRST0_CPURST_Msk
Definition: M4521.h:10388
#define SYS_BODCTL_BODEN_Msk
Definition: M4521.h:10460
#define SYS_IPRST0_CHIPRST_Msk
Definition: M4521.h:10385
#define SYS_BODCTL_BODOUT_Pos
Definition: M4521.h:10474
#define SYS_BODCTL_BODOUT_Msk
Definition: M4521.h:10475
#define SYS
Definition: M4521.h:13820
void SYS_ResetCPU(void)
Reset chip with CPU reset.
Definition: sys.c:116
uint32_t SYS_GetBODStatus(void)
Get Brown-out detector output status.
Definition: sys.c:58
uint32_t SYS_GetResetSrc(void)
Get reset status register value.
Definition: sys.c:69
void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
Enable and configure Brown-out detector function.
Definition: sys.c:171
void SYS_ResetModule(uint32_t u32ModuleIndex)
Reset selected module.
Definition: sys.c:148
uint32_t SYS_ReadPDID(void)
Get product ID.
Definition: sys.c:92
void SYS_DisableBOD(void)
Disable Brown-out detector function.
Definition: sys.c:190
uint32_t SYS_IsRegLocked(void)
Check if register is locked nor not.
Definition: sys.c:81
void SYS_ClearResetSrc(uint32_t u32Src)
Clear reset source.
Definition: sys.c:46
void SYS_ResetChip(void)
Reset chip with chip reset.
Definition: sys.c:104