| MINI55_BSP V3.02.004 The Board Support Package for Mini55 Series MCU

sys.c
Go to the documentation of this file.
1/**************************************************************************/
12#include "Mini55Series.h"
31 void SYS_ClearResetSrc(uint32_t u32Src)
32{
33 SYS->RSTSTS |= u32Src;
34}
35
42uint32_t SYS_GetBODStatus(void)
43{
44 return (SYS->BODCTL & SYS_BODCTL_BODOUT_Msk)?1:0;
45}
46
51uint32_t SYS_GetResetSrc(void)
52{
53 return (SYS->RSTSTS);
54}
55
61uint32_t SYS_IsRegLocked(void)
62{
63 return !(SYS->REGLCTL & SYS_REGLCTL_REGPROTDIS_Msk);
64}
65
70uint32_t SYS_ReadPDID(void)
71{
72 return SYS->PDID;
73}
74
79 void SYS_ResetChip(void)
80{
81 SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
82}
83
88 void SYS_ResetCPU(void)
89{
90 SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk;
91}
92
108 void SYS_ResetModule(uint32_t u32ModuleIndex)
109{
110 *(volatile uint32_t *)(&(SYS->IPRST0) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff);
111 *(volatile uint32_t *)(&(SYS->IPRST0) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff));
112}
113
132 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel)
133{
134 SYS->BODCTL |= SYS_BODCTL_BODEN_Msk;
135 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODRSTEN_Msk) | i32Mode;
136 SYS->BODCTL = (SYS->BODCTL & ~(SYS_BODCTL_BODVL1_0_Msk|SYS_BODCTL_BODVL2_Msk)) | u32BODLevel;
137}
138
143 void SYS_DisableBOD(void)
144{
145 SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk;
146 SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL1_0_Msk) | SYS_BODCTL_BODVL1_0_Msk;
147}
148
159 void SYS_EnableIRCTrim(uint32_t u32TrimSel,uint32_t u32TrimEnInt)
160{
161 SYS->IRCTIEN = (SYS->IRCTIEN & ~(SYS_IRCTIEN_TFAILIEN_Msk|SYS_IRCTIEN_CLKEIEN_Msk)) | u32TrimEnInt;
162 SYS->IRCTCTL = (SYS->IRCTCTL & ~SYS_IRCTCTL_FREQSEL_Msk)|u32TrimSel;
163}
164
170 void SYS_DisableIRCTrim(void)
171{
172 SYS->IRCTCTL = 0;
173}
174
175
176 /* end of group MINI55_SYS_EXPORTED_FUNCTIONS */
178 /* end of group MINI55_SYS_Driver */
180 /* end of group MINI55_Device_Driver */
182
183/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
Mini55Series.h
Mini55 series peripheral access layer header file. This file contains all the peripheral register's d...
SYS_IRCTIEN_TFAILIEN_Msk
#define SYS_IRCTIEN_TFAILIEN_Msk
Definition: Mini55Series.h:5748
SYS_IPRST0_CPURST_Msk
#define SYS_IPRST0_CPURST_Msk
Definition: Mini55Series.h:5520
SYS_IRCTIEN_CLKEIEN_Msk
#define SYS_IRCTIEN_CLKEIEN_Msk
Definition: Mini55Series.h:5751
SYS_BODCTL_BODEN_Msk
#define SYS_BODCTL_BODEN_Msk
Definition: Mini55Series.h:5556
SYS_IPRST0_CHIPRST_Msk
#define SYS_IPRST0_CHIPRST_Msk
Definition: Mini55Series.h:5517
SYS_BODCTL_BODOUT_Msk
#define SYS_BODCTL_BODOUT_Msk
Definition: Mini55Series.h:5571
SYS_REGLCTL_REGPROTDIS_Msk
#define SYS_REGLCTL_REGPROTDIS_Msk
Definition: Mini55Series.h:5766
SYS_BODCTL_BODVL1_0_Msk
#define SYS_BODCTL_BODVL1_0_Msk
Definition: Mini55Series.h:5559
SYS_BODCTL_BODVL2_Msk
#define SYS_BODCTL_BODVL2_Msk
Definition: Mini55Series.h:5574
SYS_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:88
SYS_GetBODStatus
uint32_t SYS_GetBODStatus(void)
This function get Brown-out detector output status.
Definition: sys.c:42
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:51
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:132
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:108
SYS_EnableIRCTrim
void SYS_EnableIRCTrim(uint32_t u32TrimSel, uint32_t u32TrimEnInt)
This function enable HIRC trim function.
Definition: sys.c:159
SYS_ReadPDID
uint32_t SYS_ReadPDID(void)
This function get product ID.
Definition: sys.c:70
SYS_DisableIRCTrim
void SYS_DisableIRCTrim(void)
This function disable HIRC trim function.
Definition: sys.c:170
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:143
SYS_IsRegLocked
uint32_t SYS_IsRegLocked(void)
This function check register write-protection bit setting.
Definition: sys.c:61
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:79
SYS
#define SYS
Pointer to SYS register structure.
Definition: Mini55Series.h:7009