M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
sys.c
Go to the documentation of this file.
1/**************************************************************************/
9#include "NuMicro.h"
10
11#ifdef __cplusplus
12extern "C"
13{
14#endif
15
42void SYS_ClearResetSrc(uint32_t u32Src)
43{
44 SYS->RSTSTS |= u32Src;
45}
46
54uint32_t SYS_GetBODStatus(void)
55{
56 return ((SYS->BODCTL & SYS_BODCTL_BODOUT_Msk) >> SYS_BODCTL_BODOUT_Pos);
57}
58
65uint32_t SYS_GetResetSrc(void)
66{
67 return (SYS->RSTSTS);
68}
69
77uint32_t SYS_IsRegLocked(void)
78{
79 return !(SYS->REGLCTL & 0x1);
80}
81
88uint32_t SYS_ReadPDID(void)
89{
90 return SYS->PDID;
91}
92
101{
102 SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
103}
104
112void SYS_ResetCPU(void)
113{
114 SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk;
115}
116
144void SYS_ResetModule(uint32_t u32ModuleIndex)
145{
146 /* Generate reset signal to the corresponding module */
147 *(volatile uint32_t *)((uint32_t)&SYS->IPRST0 + (u32ModuleIndex >> 24)) |= 1 << (u32ModuleIndex & 0x00ffffff);
148
149 /* Release corresponding module from reset state */
150 *(volatile uint32_t *)((uint32_t)&SYS->IPRST0 + (u32ModuleIndex >> 24)) &= ~(1 << (u32ModuleIndex & 0x00ffffff));
151}
152
167void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
168{
169 /* Enable Brown-out Detector function */
170 SYS->BODCTL |= SYS_BODCTL_BODEN_Msk;
171
172 /* Enable Brown-out interrupt or reset function */
173 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODRSTEN_Msk) | i32Mode;
174
175 /* Select Brown-out Detector threshold voltage */
176 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL_Msk) | u32BODLevel;
177}
178
187{
188 SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk;
189}
190
191
192 /* end of group SYS_EXPORTED_FUNCTIONS */
194 /* end of group SYS_Driver */
196 /* end of group Standard_Driver */
198
199#ifdef __cplusplus
200}
201#endif
202
#define SYS_IPRST0_CPURST_Msk
Definition: M471M_R1_S.h:10384
#define SYS_BODCTL_BODEN_Msk
Definition: M471M_R1_S.h:10456
#define SYS_IPRST0_CHIPRST_Msk
Definition: M471M_R1_S.h:10381
#define SYS_BODCTL_BODOUT_Pos
Definition: M471M_R1_S.h:10470
#define SYS_BODCTL_BODOUT_Msk
Definition: M471M_R1_S.h:10471
NuMicro peripheral access layer header file.
#define SYS
Definition: M471M_R1_S.h:13816
void SYS_ResetCPU(void)
Reset chip with CPU reset.
Definition: sys.c:112
uint32_t SYS_GetBODStatus(void)
Get Brown-out detector output status.
Definition: sys.c:54
uint32_t SYS_GetResetSrc(void)
Get reset status register value.
Definition: sys.c:65
void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
Enable and configure Brown-out detector function.
Definition: sys.c:167
void SYS_ResetModule(uint32_t u32ModuleIndex)
Reset selected module.
Definition: sys.c:144
uint32_t SYS_ReadPDID(void)
Get product ID.
Definition: sys.c:88
void SYS_DisableBOD(void)
Disable Brown-out detector function.
Definition: sys.c:186
uint32_t SYS_IsRegLocked(void)
Check if register is locked nor not.
Definition: sys.c:77
void SYS_ClearResetSrc(uint32_t u32Src)
Clear reset source.
Definition: sys.c:42
void SYS_ResetChip(void)
Reset chip with chip reset.
Definition: sys.c:100