| NUC029FAE BSP V3.01.002 The Board Support Package for NUC029FAE

sys.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include "NUC029FAE.h"
31 void SYS_ClearResetSrc(uint32_t u32Src)
32 {
33 SYS->RSTSRC |= u32Src;
34 }
35
42 uint32_t SYS_GetBODStatus(void)
43 {
44 return (SYS->BODCTL & SYS_BODCR_BOD_OUT_Msk)?1:0;
45 }
46
51 uint32_t SYS_GetResetSrc(void)
52 {
53 return (SYS->RSTSRC);
54 }
55
61 uint32_t SYS_IsRegLocked(void)
62 {
63 return (SYS->RegLockAddr & SYS_RegLockAddr_RegUnLock_Msk);
64 }
65
71 void SYS_LockReg(void)
72 {
73 SYS->RegLockAddr = 0;
74 }
75
81 void SYS_UnlockReg(void)
82 {
83 while(SYS->RegLockAddr != SYS_RegLockAddr_RegUnLock_Msk)
84 {
85 SYS->RegLockAddr = 0x59;
86 SYS->RegLockAddr = 0x16;
87 SYS->RegLockAddr = 0x88;
88 }
89 }
90
95 uint32_t SYS_ReadPDID(void)
96 {
97 return SYS->PDID;
98 }
99
104 void SYS_ResetChip(void)
105 {
106 SYS->IPRSTC1 |= SYS_IPRSTC1_CHIP_RST_Msk;
107 }
108
113 void SYS_ResetCPU(void)
114 {
115 SYS->IPRSTC1 |= SYS_IPRSTC1_CPU_RST_Msk;
116 }
117
134 void SYS_ResetModule(uint32_t u32ModuleIndex)
135 {
136 *(volatile uint32_t *)(&(SYS->IPRSTC1) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
137 *(volatile uint32_t *)(&(SYS->IPRSTC1) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
138 }
139
154 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
155 {
156 SYS->BODCTL |= SYS_BODCR_BOD_VL_EXT_Msk;
157 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_RSTEN_Msk) | i32Mode;
158 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_VL_Msk) | u32BODLevel;
159 }
160
165 void SYS_DisableBOD(void)
166 {
167 SYS->BODCTL &= ~SYS_BODCR_BOD_VL_EXT_Msk;
168 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_VL_Msk) | SYS_BODCR_BOD_DISABLE ;
169 }
170
171
172 /* end of group NUC029FAE_SYS_EXPORTED_FUNCTIONS */
174 /* end of group NUC029FAE_SYS_Driver */
176 /* end of group NUC029FAE_Device_Driver */
178
179 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
NUC029FAE.h
NUC029FAE peripheral access layer header file. This file contains all the peripheral register's defin...
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:51
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:165
SYS_BODCR_BOD_DISABLE
#define SYS_BODCR_BOD_DISABLE
Definition: sys.h:52
SYS
#define SYS
Pointer to SYS register structure.
Definition: NUC029FAE.h:3227
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:154
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:134
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:61
SYS_LockReg
void SYS_LockReg(void)
This function enable register write-protection function.
Definition: sys.c:71
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:113
SYS_ClearResetSrc
void SYS_ClearResetSrc(uint32_t u32Src)
This function clear the selected system reset source.
Definition: sys.c:31
SYS_UnlockReg
void SYS_UnlockReg(void)
This function disable register write-protection function.
Definition: sys.c:81
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:95
SYS_ResetChip
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:104
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:42