| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

sys.c
Go to the documentation of this file.
1/*************************************************************************/
13#include "NUC472_442.h"
39 void SYS_ClearResetSrc(uint32_t u32RstSrc)
40{
41 SYS->RSTSTS |= u32RstSrc;
42}
43
50uint32_t SYS_GetBODStatus()
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
79 void SYS_LockReg(void)
80{
81 SYS->REGLCTL = 0;
82}
83
84
90 void 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
113 void SYS_ResetChip(void)
114{
115 SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
116}
117
122 void SYS_ResetCPU(void)
123{
124 SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk;
125}
126
179 void 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
200 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
201{
202 SYS->BODCTL &= ~(SYS_BODCTL_BODVL_Msk|SYS_BODCTL_BODRSTEN_Msk);
203 SYS->BODCTL |=(i32Mode|u32BODLevel|SYS_BODCTL_BODEN_Msk);
204}
205
210 void SYS_DisableBOD(void)
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_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
SYS_REGLCTL_REGLCTL_Msk
#define SYS_REGLCTL_REGLCTL_Msk
Definition: NUC472_442.h:24874
SYS_IPRST0_CPURST_Msk
#define SYS_IPRST0_CPURST_Msk
Definition: NUC472_442.h:24214
SYS_BODCTL_BODEN_Msk
#define SYS_BODCTL_BODEN_Msk
Definition: NUC472_442.h:24355
SYS_IPRST0_CHIPRST_Msk
#define SYS_IPRST0_CHIPRST_Msk
Definition: NUC472_442.h:24211
SYS_BODCTL_BODRSTEN_Msk
#define SYS_BODCTL_BODRSTEN_Msk
Definition: NUC472_442.h:24361
SYS_BODCTL_BODVL_Msk
#define SYS_BODCTL_BODVL_Msk
Definition: NUC472_442.h:24358
SYS_BODCTL_BODOUT_Msk
#define SYS_BODCTL_BODOUT_Msk
Definition: NUC472_442.h:24370
SYS
#define SYS
Definition: NUC472_442.h:28797
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:122
SYS_LockReg
void SYS_LockReg(void)
This function enable register write-protection function.
Definition: sys.c:79
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:59
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:200
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:179
SYS_ClearResetSrc
void SYS_ClearResetSrc(uint32_t u32Src)
This function clear the selected system reset source.
Definition: sys.c:39
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:104
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:50
SYS_UnlockReg
void SYS_UnlockReg(void)
This function disable register write-protection function.
Definition: sys.c:90
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:210
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:69
SYS_ResetChip
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:113