| MINI58_BSP V3.01.003 The Board Support Package for Mini58 Series MCU

sys.c
Go to the documentation of this file.
1/**************************************************************************/
12#include "Mini58Series.h"
31 void SYS_ClearResetSrc(uint32_t u32Src)
32{
33 SYS->RSTSTS |= u32Src;
34}
35
42uint32_t SYS_GetBODStatus(void)
43{
44 return (SYS->BODCTL & SYS_BODCTL_BODOUT_Msk)?1:0;
45}
46
51uint32_t SYS_GetResetSrc(void)
52{
53 return (SYS->RSTSTS);
54}
55
61uint32_t SYS_IsRegLocked(void)
62{
63 return !(SYS->REGLCTL & SYS_REGLCTL_REGLCTL_Msk);
64}
65
70uint32_t SYS_ReadPDID(void)
71{
72 return SYS->PDID;
73}
74
79 void SYS_ResetChip(void)
80{
81 SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
82}
83
88 void SYS_ResetCPU(void)
89{
90 SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk;
91}
92
109 void SYS_ResetModule(uint32_t u32ModuleIndex)
110{
111 *(volatile uint32_t *)(&(SYS->IPRST0) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
112 *(volatile uint32_t *)(&(SYS->IPRST0) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
113}
114
129 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
130{
131 SYS->BODCTL |= SYS_BODCTL_BODEN_Msk;
132 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODRSTEN_Msk) | i32Mode;
133 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL_Msk) | u32BODLevel;
134}
135
140 void SYS_DisableBOD(void)
141{
142 SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk;
143 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL_Msk) | SYS_BODCTL_BODVL_Msk ;
144}
145
146
147 /* end of group Mini58_SYS_EXPORTED_FUNCTIONS */
149 /* end of group Mini58_SYS_Driver */
151 /* end of group Mini58_Device_Driver */
153
154/*** (C) COPYRIGHT 2022 Nuvoton Technology Corp. ***/
Mini58Series.h
Mini58 series peripheral access layer header file. This file contains all the peripheral register's d...
SYS_REGLCTL_REGLCTL_Msk
#define SYS_REGLCTL_REGLCTL_Msk
Definition: Mini58Series.h:10305
SYS_IPRST0_CPURST_Msk
#define SYS_IPRST0_CPURST_Msk
Definition: Mini58Series.h:10092
SYS_BODCTL_BODEN_Msk
#define SYS_BODCTL_BODEN_Msk
Definition: Mini58Series.h:10128
SYS_IPRST0_CHIPRST_Msk
#define SYS_IPRST0_CHIPRST_Msk
Definition: Mini58Series.h:10089
SYS_BODCTL_BODVL_Msk
#define SYS_BODCTL_BODVL_Msk
Definition: Mini58Series.h:10131
SYS_BODCTL_BODOUT_Msk
#define SYS_BODCTL_BODOUT_Msk
Definition: Mini58Series.h:10143
SYS
#define SYS
Pointer to SYS register structure.
Definition: Mini58Series.h:11729
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:88
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:42
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:51
SYS_EnableBOD
void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
This function configure BOD function. Configure BOD reset or interrupt mode and set Brown-out voltage...
Definition: sys.c:129
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:109
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:70
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:140
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:61
SYS_ClearResetSrc
void SYS_ClearResetSrc(uint32_t u32Src)
This function clear the selected system reset source.
Definition: sys.c:31
SYS_ResetChip
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:79