NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
sys.c
Go to the documentation of this file.
1/*************************************************************************/
13#include "NUC472_442.h"
39void SYS_ClearResetSrc(uint32_t u32RstSrc)
40{
41 SYS->RSTSTS |= u32RstSrc;
42}
43
51{
52 return (SYS->BODCTL & SYS_BODCTL_BODOUT_Msk);
53}
54
59uint32_t SYS_GetResetSrc(void)
60{
61 return (SYS->RSTSTS);
62}
63
69uint32_t SYS_IsRegLocked(void)
70{
71 return !(SYS->REGLCTL & SYS_REGLCTL_REGLCTL_Msk);
72}
73
79void SYS_LockReg(void)
80{
81 SYS->REGLCTL = 0;
82}
83
84
90void SYS_UnlockReg(void)
91{
92 while(SYS->REGLCTL != SYS_REGLCTL_REGLCTL_Msk)
93 {
94 SYS->REGLCTL = 0x59;
95 SYS->REGLCTL = 0x16;
96 SYS->REGLCTL = 0x88;
97 }
98}
99
104uint32_t SYS_ReadPDID(void)
105{
106 return SYS->PDID;
107}
108
114{
115 SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
116}
117
122void SYS_ResetCPU(void)
123{
124 SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk;
125}
126
179void SYS_ResetModule(uint32_t u32ModuleIndex)
180{
181 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST0) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
182 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST0) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
183}
184
200void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
201{
203 SYS->BODCTL |=(i32Mode|u32BODLevel|SYS_BODCTL_BODEN_Msk);
204}
205
211{
212 SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk;
213}
214
215
216 /* end of group NUC472_442_SYS_EXPORTED_FUNCTIONS */
218 /* end of group NUC472_442_SYS_Driver */
220 /* end of group NUC472_442_Device_Driver */
222
223/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
224
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define SYS_REGLCTL_REGLCTL_Msk
Definition: NUC472_442.h:24874
#define SYS_IPRST0_CPURST_Msk
Definition: NUC472_442.h:24214
#define SYS_BODCTL_BODEN_Msk
Definition: NUC472_442.h:24355
#define SYS_IPRST0_CHIPRST_Msk
Definition: NUC472_442.h:24211
#define SYS_BODCTL_BODRSTEN_Msk
Definition: NUC472_442.h:24361
#define SYS_BODCTL_BODVL_Msk
Definition: NUC472_442.h:24358
#define SYS_BODCTL_BODOUT_Msk
Definition: NUC472_442.h:24370
#define SYS
Definition: NUC472_442.h:28797
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:122
void SYS_LockReg(void)
This function enable register write-protection function.
Definition: sys.c:79
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:59
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:200
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:179
void SYS_ClearResetSrc(uint32_t u32Src)
This function clear the selected system reset source.
Definition: sys.c:39
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:104
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:50
void SYS_UnlockReg(void)
This function disable register write-protection function.
Definition: sys.c:90
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:210
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:69
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:113