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

sys.c
Go to the documentation of this file.
1 /**************************************************************************/
13 #include "Nano100Series.h"
32 void SYS_ClearResetSrc(uint32_t u32Src)
33 {
34 SYS->RST_SRC |= u32Src;
35 }
36
45 uint32_t SYS_GetBODStatus()
46 {
47 return (SYS->BODSTS);
48 }
49
55 uint32_t SYS_GetResetSrc(void)
56 {
57 return (SYS->RST_SRC);
58 }
59
66 uint32_t SYS_IsRegLocked(void)
67 {
68 return !(SYS->RegLockAddr & SYS_RegLockAddr_RegUnLock_Msk);
69 }
70
76 uint32_t SYS_ReadPDID(void)
77 {
78 return SYS->PDID;
79 }
80
86 void SYS_ResetChip(void)
87 {
88 SYS->IPRST_CTL1 |= SYS_IPRST_CTL1_CHIP_RST_Msk;
89 }
90
96 void SYS_ResetCPU(void)
97 {
98 SYS->IPRST_CTL1 |= SYS_IPRST_CTL1_CPU_RST_Msk;
99 }
100
130 void SYS_ResetModule(uint32_t u32ModuleIndex)
131 {
132 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST_CTL1) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
133 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST_CTL1) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
134 }
135
151 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
152 {
153 SYS->BODCTL = (SYS->BODCTL & ~0xFFF) | (i32Mode | u32BODLevel);
154 }
155
161 void SYS_DisableBOD(void)
162 {
163 SYS->BODCTL = SYS->BODCTL & ~(SYS_BODCTL_BOD25_EN_Msk | SYS_BODCTL_BOD20_EN_Msk | SYS_BODCTL_BOD17_EN_Msk);
164 }
165
178 void SYS_EnableIRCTrim(uint32_t u32TrimSel,uint32_t u32TrimEnInt)
179 {
180 SYS->IRCTRIMIEN = (SYS->IRCTRIMIEN & ~(SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk|SYS_IRCTRIMIEN_32K_ERR_IEN_Msk)) | u32TrimEnInt;
181 SYS->IRCTRIMCTL = (SYS->IRCTRIMCTL & ~SYS_IRCTRIMCTL_TRIM_SEL_Msk)|u32TrimSel;
182 }
183
189 void SYS_DisableIRCTrim(void)
190 {
191 SYS->IRCTRIMCTL = 0;
192 }
193
194
195
196
197
198 /* end of group NANO100_SYS_EXPORTED_FUNCTIONS */
200 /* end of group NANO100_SYS_Driver */
202 /* end of group NANO100_Device_Driver */
204
205 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
SYS_BODCTL_BOD20_EN_Msk
#define SYS_BODCTL_BOD20_EN_Msk
Definition: Nano100Series.h:3670
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:76
SYS_ClearResetSrc
void SYS_ClearResetSrc(uint32_t u32Src)
This function clear the selected system reset source.
Definition: sys.c:32
SYS_EnableIRCTrim
void SYS_EnableIRCTrim(uint32_t u32TrimSel, uint32_t u32TrimEnInt)
This function enable HIRC trim function.
Definition: sys.c:178
SYS_RegLockAddr_RegUnLock_Msk
#define SYS_RegLockAddr_RegUnLock_Msk
Definition: Nano100Series.h:3742
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:66
SYS_BODCTL_BOD25_EN_Msk
#define SYS_BODCTL_BOD25_EN_Msk
Definition: Nano100Series.h:3673
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:45
SYS_IRCTRIMIEN_32K_ERR_IEN_Msk
#define SYS_IRCTRIMIEN_32K_ERR_IEN_Msk
Definition: Nano100Series.h:3730
Nano100Series.h
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk
#define SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk
Definition: Nano100Series.h:3727
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:161
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:151
SYS_IPRST_CTL1_CHIP_RST_Msk
#define SYS_IPRST_CTL1_CHIP_RST_Msk
Definition: Nano100Series.h:3331
SYS_BODCTL_BOD17_EN_Msk
#define SYS_BODCTL_BOD17_EN_Msk
Definition: Nano100Series.h:3667
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:96
SYS_IRCTRIMCTL_TRIM_SEL_Msk
#define SYS_IRCTRIMCTL_TRIM_SEL_Msk
Definition: Nano100Series.h:3718
SYS_ResetChip
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:86
SYS_DisableIRCTrim
void SYS_DisableIRCTrim(void)
This function disable HIRC trim function.
Definition: sys.c:189
SYS_IPRST_CTL1_CPU_RST_Msk
#define SYS_IPRST_CTL1_CPU_RST_Msk
Definition: Nano100Series.h:3334
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:130
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:55
SYS
#define SYS
Pointer to SYS register structure.
Definition: Nano100Series.h:10120