| Mini51 BSP V3.02.002 The Board Support Package for Mini51 Series

sys.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include "Mini51Series.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
132 void SYS_ResetModule(uint32_t u32ModuleIndex)
133 {
134 *(volatile uint32_t *)(&(SYS->IPRSTC1) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
135 *(volatile uint32_t *)(&(SYS->IPRSTC1) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
136 }
137
152 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
153 {
154 SYS->BODCTL |= SYS_BODCR_BOD_VL_EXT_Msk;
155 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_RSTEN_Msk) | i32Mode;
156 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_VL_Msk) | u32BODLevel;
157 }
158
163 void SYS_DisableBOD(void)
164 {
165 SYS->BODCTL &= ~SYS_BODCR_BOD_VL_EXT_Msk;
166 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCR_BOD_VL_Msk) | SYS_BODCR_BOD_DISABLE ;
167 }
168
169
170 /* end of group MINI51_SYS_EXPORTED_FUNCTIONS */
172 /* end of group MINI51_SYS_Driver */
174 /* end of group MINI51_Device_Driver */
176
177 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
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:152
SYS_BODCR_BOD_RSTEN_Msk
#define SYS_BODCR_BOD_RSTEN_Msk
Definition: Mini51Series.h:2778
Mini51Series.h
Mini51 series peripheral access layer header file. This file contains all the peripheral register's d...
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_RegLockAddr_RegUnLock_Msk
#define SYS_RegLockAddr_RegUnLock_Msk
Definition: Mini51Series.h:2958
SYS_BODCR_BOD_DISABLE
#define SYS_BODCR_BOD_DISABLE
Definition: sys.h:50
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:104
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:42
SYS
#define SYS
Pointer to SYS register structure.
Definition: Mini51Series.h:9936
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:113
SYS_IPRSTC1_CPU_RST_Msk
#define SYS_IPRSTC1_CPU_RST_Msk
Definition: Mini51Series.h:2742
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_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:132
SYS_BODCR_BOD_OUT_Msk
#define SYS_BODCR_BOD_OUT_Msk
Definition: Mini51Series.h:2787
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:51
SYS_BODCR_BOD_VL_Msk
#define SYS_BODCR_BOD_VL_Msk
Definition: Mini51Series.h:2775
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:163
SYS_IPRSTC1_CHIP_RST_Msk
#define SYS_IPRSTC1_CHIP_RST_Msk
Definition: Mini51Series.h:2739
SYS_BODCR_BOD_VL_EXT_Msk
#define SYS_BODCR_BOD_VL_EXT_Msk
Definition: Mini51Series.h:2772