| NANO102/112 BSP V3.04.000 The Board Support Package for Nano102/112 Series

sys.c
Go to the documentation of this file.
1/**************************************************************************/
13#include "Nano1X2Series.h"
32 void SYS_ClearResetSrc(uint32_t u32Src)
33{
34 SYS->RST_SRC |= u32Src;
35}
36
44uint32_t SYS_GetBODStatus()
45{
46 return (SYS->BODSTS);
47}
48
54uint32_t SYS_GetResetSrc(void)
55{
56 return (SYS->RST_SRC);
57}
58
65uint32_t SYS_IsRegLocked(void)
66{
67 return !(SYS->RegLockAddr & SYS_RegLockAddr_RegUnLock_Msk);
68}
69
75uint32_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
125 void SYS_ResetModule(uint32_t u32ModuleIndex)
126{
127 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST_CTL1) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
128 *(volatile uint32_t *)((uint32_t)&(SYS->IPRST_CTL1) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
129}
130
146 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
147{
148 SYS->BODCTL = (SYS->BODCTL & ~0xFFF) | (i32Mode | u32BODLevel);
149}
150
156 void SYS_DisableBOD(void)
157{
158 SYS->BODCTL = SYS->BODCTL & ~(SYS_BODCTL_BOD25_EN_Msk | SYS_BODCTL_BOD20_EN_Msk | SYS_BODCTL_BOD17_EN_Msk);
159}
160
173 void SYS_EnableIRCTrim(uint32_t u32TrimSel,uint32_t u32TrimEnInt)
174{
175 SYS->IRCTRIMIEN = (SYS->IRCTRIMIEN & ~(SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk|SYS_IRCTRIMIEN_32K_ERR_IEN_Msk)) | u32TrimEnInt;
176 SYS->IRCTRIMCTL = (SYS->IRCTRIMCTL & ~SYS_IRCTRIMCTL_TRIM_SEL_Msk)|u32TrimSel;
177}
178
184 void SYS_DisableIRCTrim(void)
185{
186 SYS->IRCTRIMCTL = 0;
187}
188 /* end of group NANO1X2_SYS_EXPORTED_FUNCTIONS */
190 /* end of group NANO1X2_SYS_Driver */
192 /* end of group NANO1X2_Device_Driver */
194
195/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
Nano1X2Series.h
Nano102/112 peripheral access layer header file. This file contains all the peripheral register's def...
SYS_BODCTL_BOD17_EN_Msk
#define SYS_BODCTL_BOD17_EN_Msk
Definition: Nano1X2Series.h:3948
SYS_RegLockAddr_RegUnLock_Msk
#define SYS_RegLockAddr_RegUnLock_Msk
Definition: Nano1X2Series.h:4062
SYS_IPRST_CTL1_CHIP_RST_Msk
#define SYS_IPRST_CTL1_CHIP_RST_Msk
Definition: Nano1X2Series.h:3642
SYS_BODCTL_BOD20_EN_Msk
#define SYS_BODCTL_BOD20_EN_Msk
Definition: Nano1X2Series.h:3951
SYS_IRCTRIMIEN_32K_ERR_IEN_Msk
#define SYS_IRCTRIMIEN_32K_ERR_IEN_Msk
Definition: Nano1X2Series.h:4050
SYS_IPRST_CTL1_CPU_RST_Msk
#define SYS_IPRST_CTL1_CPU_RST_Msk
Definition: Nano1X2Series.h:3645
SYS_BODCTL_BOD25_EN_Msk
#define SYS_BODCTL_BOD25_EN_Msk
Definition: Nano1X2Series.h:3954
SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk
#define SYS_IRCTRIMIEN_TRIM_FAIL_IEN_Msk
Definition: Nano1X2Series.h:4047
SYS
#define SYS
Pointer to SYS register structure.
Definition: Nano1X2Series.h:10650
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:95
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:54
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:146
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:125
SYS_EnableIRCTrim
void SYS_EnableIRCTrim(uint32_t u32TrimSel, uint32_t u32TrimEnInt)
This function enable HIRC trim function.
Definition: sys.c:173
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:75
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:44
SYS_DisableIRCTrim
void SYS_DisableIRCTrim(void)
This function disable HIRC trim function.
Definition: sys.c:184
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:156
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:65
SYS_ClearResetSrc
void SYS_ClearResetSrc(uint32_t u32Src)
This function clear the selected system reset source.
Definition: sys.c:32
SYS_ResetChip
void SYS_ResetChip(void)
This function reset chip.
Definition: sys.c:85