| Nano100BN Series BSP V3.03.002 The Board Support Package for Nano100BN 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
44 uint32_t SYS_GetBODStatus()
45 {
46 return (SYS->BODSTS);
47 }
48
54 uint32_t SYS_GetResetSrc(void)
55 {
56 return (SYS->RST_SRC);
57 }
58
65 uint32_t SYS_IsRegLocked(void)
66 {
67 return !(SYS->RegLockAddr & SYS_RegLockAddr_RegUnLock_Msk);
68 }
69
75 uint32_t SYS_ReadPDID(void)
76 {
77 return SYS->PDID;
78 }
79
85 void SYS_ResetChip(void)
86 {
87 SYS->IPRST_CTL1 |= SYS_IPRST_CTL1_CHIP_RST_Msk;
88 }
89
95 void SYS_ResetCPU(void)
96 {
97 SYS->IPRST_CTL1 |= SYS_IPRST_CTL1_CPU_RST_Msk;
98 }
99
129 void SYS_ResetModule(uint32_t u32ModuleIndex)
130 {
131 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST_CTL1) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
132 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST_CTL1) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
133 }
134
150 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
151 {
152 SYS->BODCTL = (SYS->BODCTL & ~0xFFF) | (i32Mode | u32BODLevel);
153 }
154
160 void SYS_DisableBOD(void)
161 {
162 SYS->BODCTL = SYS->BODCTL & ~(SYS_BODCTL_BOD25_EN_Msk | SYS_BODCTL_BOD20_EN_Msk | SYS_BODCTL_BOD17_EN_Msk);
163 }
164
177 void SYS_EnableIRCTrim(uint32_t u32TrimSel,uint32_t u32TrimEnInt)
178 {
179 SYS->IRCTRIMIEN = (SYS->IRCTRIMIEN & ~(SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk|SYS_IRCTRIMIEN_32K_ERR_IEN_Msk)) | u32TrimEnInt;
180 SYS->IRCTRIMCTL = (SYS->IRCTRIMCTL & ~SYS_IRCTRIMCTL_TRIM_SEL_Msk)|u32TrimSel;
181 }
182
188 void SYS_DisableIRCTrim(void)
189 {
190 SYS->IRCTRIMCTL = 0;
191 }
192 /* end of group NANO100_SYS_EXPORTED_FUNCTIONS */
194 /* end of group NANO100_SYS_Driver */
196 /* end of group NANO100_Device_Driver */
198
199 /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
SYS_BODCTL_BOD20_EN_Msk
#define SYS_BODCTL_BOD20_EN_Msk
Definition: Nano100Series.h:3317
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:75
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:177
SYS_RegLockAddr_RegUnLock_Msk
#define SYS_RegLockAddr_RegUnLock_Msk
Definition: Nano100Series.h:3401
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:65
SYS_BODCTL_BOD25_EN_Msk
#define SYS_BODCTL_BOD25_EN_Msk
Definition: Nano100Series.h:3320
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:44
SYS_IRCTRIMIEN_32K_ERR_IEN_Msk
#define SYS_IRCTRIMIEN_32K_ERR_IEN_Msk
Definition: Nano100Series.h:3389
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:3386
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:160
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:150
SYS_IPRST_CTL1_CHIP_RST_Msk
#define SYS_IPRST_CTL1_CHIP_RST_Msk
Definition: Nano100Series.h:2972
SYS_BODCTL_BOD17_EN_Msk
#define SYS_BODCTL_BOD17_EN_Msk
Definition: Nano100Series.h:3314
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:95
SYS_IRCTRIMCTL_TRIM_SEL_Msk
#define SYS_IRCTRIMCTL_TRIM_SEL_Msk
Definition: Nano100Series.h:3374
SYS_ResetChip
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:85
SYS_DisableIRCTrim
void SYS_DisableIRCTrim(void)
This function disable HIRC trim function.
Definition: sys.c:188
SYS_IPRST_CTL1_CPU_RST_Msk
#define SYS_IPRST_CTL1_CPU_RST_Msk
Definition: Nano100Series.h:2975
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:129
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:54
SYS
#define SYS
Pointer to SYS register structure.
Definition: Nano100Series.h:11692