| NUC029FAE BSP V3.01.002 The Board Support Package for NUC029FAE

sys.h
Go to the documentation of this file.
1 /**************************************************************************/
12 #ifndef __SYS_H__
13 #define __SYS_H__
14
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19
31 /*---------------------------------------------------------------------------------------------------------*/
32 /* Module Reset Control Resister constant definitions. */
33 /*---------------------------------------------------------------------------------------------------------*/
34 #define CHIP_RST ((0x0<<24) | SYS_IPRSTC1_CPU_RST_Pos )
35 #define CPU_RST ((0x0<<24) | SYS_IPRSTC1_CHIP_RST_Pos )
36 #define ADC_RST ((0x4<<24) | SYS_IPRSTC2_ADC_RST_Pos )
37 #define ACMP_RST ((0x4<<24) | SYS_IPRSTC2_ACMP_RST_Pos )
38 #define PWM_RST ((0x4<<24) | SYS_IPRSTC2_PWM_RST_Pos )
39 #define UART_RST ((0x4<<24) | SYS_IPRSTC2_UART_RST_Pos )
40 #define SPI_RST ((0x4<<24) | SYS_IPRSTC2_SPI_RST_Pos )
41 #define I2C_RST ((0x4<<24) | SYS_IPRSTC2_I2C_RST_Pos )
42 #define TMR1_RST ((0x4<<24) | SYS_IPRSTC2_TMR1_RST_Pos )
43 #define TMR0_RST ((0x4<<24) | SYS_IPRSTC2_TMR0_RST_Pos )
44 #define GPIO_RST ((0x4<<24) | SYS_IPRSTC2_GPIO_RST_Pos )
47 /*---------------------------------------------------------------------------------------------------------*/
48 /* Brown Out Detector Threshold Voltage Selection constant definitions. */
49 /*---------------------------------------------------------------------------------------------------------*/
50 #define SYS_BODCR_BOD_RST_EN (1UL<<SYS_BODCR_BOD_RSTEN_Pos)
51 #define SYS_BODCR_BOD_INTERRUPT_EN (0UL<<SYS_BODCR_BOD_RSTEN_Pos)
52 #define SYS_BODCR_BOD_DISABLE (3UL<<SYS_BODCR_BOD_VL_Pos)
53 #define SYS_BODCR_BOD_VL_4_4V (3UL<<SYS_BODCR_BOD_VL_Pos)
54 #define SYS_BODCR_BOD_VL_3_7V (2UL<<SYS_BODCR_BOD_VL_Pos)
55 #define SYS_BODCR_BOD_VL_2_7V (1UL<<SYS_BODCR_BOD_VL_Pos)
56 #define SYS_BODCR_BOD_VL_2_2V (0UL<<SYS_BODCR_BOD_VL_Pos)
59 /*---------------------------------------------------------------------------------------------------------*/
60 /* Multi-Function constant definitions. */
61 /*---------------------------------------------------------------------------------------------------------*/
62 #define SYS_MFP_TYPE_Msk(bit) (1UL << ((bit) +16))
63 #define SYS_MFP_ALT_Msk(bit) (1UL << ((bit) + 8))
64 #define SYS_MFP_MFP_Msk(bit) (1UL << ((bit) ))
66 #define SYS_MFP_P00_GPIO 0x00000000UL
67 #define SYS_MFP_P00_CTS 0x00000100UL
68 #define SYS_MFP_P00_TXD 0x00000101UL
69 #define SYS_MFP_P00_Msk 0x01000101UL
71 #define SYS_MFP_P01_GPIO 0x00000000UL
72 #define SYS_MFP_P01_SPISS 0x00000002UL
73 #define SYS_MFP_P01_RTS 0x00000200UL
74 #define SYS_MFP_P01_RXD 0x00000202UL
75 #define SYS_MFP_P01_Msk 0x02000202UL
77 #define SYS_MFP_P04_GPIO 0x00000000UL
78 #define SYS_MFP_P04_SPISS 0x00001000UL
79 #define SYS_MFP_P04_PWM5 0x00001010UL
80 #define SYS_MFP_P04_Msk 0x00001010UL
82 #define SYS_MFP_P05_GPIO 0x00000000UL
83 #define SYS_MFP_P05_MOSI 0x00002000UL
84 #define SYS_MFP_P05_Msk 0x00002020UL
86 #define SYS_MFP_P06_GPIO 0x00000000UL
87 #define SYS_MFP_P06_MISO 0x00004000UL
88 #define SYS_MFP_P06_Msk 0x00004040UL
90 #define SYS_MFP_P07_GPIO 0x00000000UL
91 #define SYS_MFP_P07_SPICLK 0x00008000UL
92 #define SYS_MFP_P07_Msk 0x00008080UL
94 #define SYS_MFP_P10_GPIO 0x00000000UL
95 #define SYS_MFP_P10_AIN1 0x00000001UL
96 #define SYS_MFP_P10_CPP0 0x00000101UL
97 #define SYS_MFP_P10_Msk 0x00000101UL
99 #define SYS_MFP_P12_GPIO 0x00000000UL
100 #define SYS_MFP_P12_AIN2 0x00000004UL
101 #define SYS_MFP_P12_RXD 0x00000400UL
102 #define SYS_MFP_P12_CPP0 0x00000404UL
103 #define SYS_MFP_P12_Msk 0x00000404UL
105 #define SYS_MFP_P13_GPIO 0x00000000UL
106 #define SYS_MFP_P13_AIN3 0x00000008UL
107 #define SYS_MFP_P13_TXD 0x00000800UL
108 #define SYS_MFP_P13_CPP0 0x00000808UL
109 #define SYS_MFP_P13_Msk 0x00000808UL
111 #define SYS_MFP_P14_GPIO 0x00000000UL
112 #define SYS_MFP_P14_AIN4 0x00000010UL
113 #define SYS_MFP_P14_CPN0 0x00001010UL
114 #define SYS_MFP_P14_Msk 0x00001010UL
116 #define SYS_MFP_P15_GPIO 0x00000000UL
117 #define SYS_MFP_P15_AIN5 0x00000020UL
118 #define SYS_MFP_P15_CPP0 0x00002020UL
119 #define SYS_MFP_P15_Msk 0x00002020UL
121 #define SYS_MFP_P22_GPIO 0x00000000UL
122 #define SYS_MFP_P22_PWM0 0x00000400UL
123 #define SYS_MFP_P22_Msk 0x00000404UL
125 #define SYS_MFP_P23_GPIO 0x00000000UL
126 #define SYS_MFP_P23_PWM1 0x00000800UL
127 #define SYS_MFP_P23_Msk 0x00000808UL
129 #define SYS_MFP_P24_GPIO 0x00000000UL
130 #define SYS_MFP_P24_PWM2 0x00001000UL
131 #define SYS_MFP_P24_Msk 0x00001010UL
133 #define SYS_MFP_P25_GPIO 0x00000000UL
134 #define SYS_MFP_P25_PWM3 0x00002000UL
135 #define SYS_MFP_P25_Msk 0x00002020UL
137 #define SYS_MFP_P26_GPIO 0x00000000UL
138 #define SYS_MFP_P26_PWM4 0x00004000UL
139 #define SYS_MFP_P26_CPO1 0x00004040UL
140 #define SYS_MFP_P26_Msk 0x00004040UL
142 #define SYS_MFP_P30_GPIO 0x00000000UL
143 #define SYS_MFP_P30_CPN1 0x00000100UL
144 #define SYS_MFP_P30_AIN6 0x00000101UL
145 #define SYS_MFP_P30_Msk 0x00000101UL
147 #define SYS_MFP_P31_GPIO 0x00000000UL
148 #define SYS_MFP_P31_CPP1 0x00000200UL
149 #define SYS_MFP_P31_AIN7 0x00000202UL
150 #define SYS_MFP_P31_Msk 0x00000202UL
152 #define SYS_MFP_P32_GPIO 0x00000000UL
153 #define SYS_MFP_P32_INT0 0x00000004UL
154 #define SYS_MFP_P32_T0EX 0x00000400UL
155 #define SYS_MFP_P32_STADC 0x00000404UL
156 #define SYS_MFP_P32_CPP1 0x01000000UL
157 #define SYS_MFP_P32_Msk 0x01000404UL
159 #define SYS_MFP_P34_GPIO 0x00000000UL
160 #define SYS_MFP_P34_T0 0x00000010UL
161 #define SYS_MFP_P34_SDA 0x00001000UL
162 #define SYS_MFP_P34_CPP1 0x00001010UL
163 #define SYS_MFP_P34_Msk 0x00001010UL
165 #define SYS_MFP_P35_GPIO 0x00000000UL
166 #define SYS_MFP_P35_T1 0x00000020UL
167 #define SYS_MFP_P35_SCL 0x00002000UL
168 #define SYS_MFP_P35_CPP1 0x00002020UL
169 #define SYS_MFP_P35_Msk 0x00002020UL
171 #define SYS_MFP_P36_GPIO 0x00000000UL
172 #define SYS_MFP_P36_T1EX 0x00000040UL
173 #define SYS_MFP_P36_CKO 0x00004000UL
174 #define SYS_MFP_P36_CPO0 0x00004040UL
175 #define SYS_MFP_P36_Msk 0x00004040UL
177 #define SYS_MFP_P46_GPIO 0x00000000UL
178 #define SYS_MFP_P46_ICE_CLK 0x00000040UL
179 #define SYS_MFP_P46_Msk 0x00004040UL
181 #define SYS_MFP_P47_GPIO 0x00000000UL
182 #define SYS_MFP_P47_ICE_DAT 0x00000080UL
183 #define SYS_MFP_P47_Msk 0x00008080UL
185 #define SYS_MFP_P50_GPIO 0x00000000UL
186 #define SYS_MFP_P50_XTAL1 0x00000001UL
187 #define SYS_MFP_P50_Msk 0x00000101UL
189 #define SYS_MFP_P51_GPIO 0x00000000UL
190 #define SYS_MFP_P51_XTAL2 0x00000002UL
191 #define SYS_MFP_P51_Msk 0x00000202UL
193 #define SYS_MFP_P52_GPIO 0x00000000UL
194 #define SYS_MFP_P52_INT1 0x00000004UL
195 #define SYS_MFP_P52_Msk 0x00000404UL
197 #define SYS_MFP_P53_GPIO 0x00000000UL
198 #define SYS_MFP_P53_AIN0 0x00000008UL
199 #define SYS_MFP_P53_Msk 0x00000808UL
201 #define SYS_MFP_P54_GPIO 0x00000000UL
202 #define SYS_MFP_P54_Msk 0x00001010UL
204 #define SYS_MFP_P55_GPIO 0x00000000UL
205 #define SYS_MFP_P55_Msk 0x00002020UL
209 /* end of group NUC029FAE_SYS_EXPORTED_CONSTANTS */
210
214 #define SYS_CLEAR_BOD_INT_FLAG() (SYS->BODCR |= SYS_BODCR_BOD_INTF_Msk)
215 #define SYS_CLEAR_BOD_LPM() (SYS->BODCR &= ~SYS_BODCR_BOD_LPM_Msk)
216 #define SYS_DISABLE_BOD() (SYS->BODCR |= SYS_BODCR_BOD_DISABLE)
217 #define SYS_ENABLE_BOD() (SYS->BODCR = (SYS->BODCR & ~SYS_BODCR_BOD_VL_Msk) | SYS_BODCR_BOD_VL_3_7V)
218 #define SYS_GET_BOD_INT_FLAG() (SYS->BODCR & SYS_BODCR_BOD_INTF_Msk)
219 #define SYS_GET_BOD_OUTPUT() (SYS->BODCR & SYS_BODCR_BOD_OUT_Msk)
220 #define SYS_DISABLE_BOD_RST() (SYS->BODCR &= ~SYS_BODCR_BOD_RSTEN_Msk)
221 #define SYS_ENABLE_BOD_RST() (SYS->BODCR |= SYS_BODCR_BOD_RSTEN_Msk)
222 #define SYS_SET_BOD_LPM() (SYS->BODCR |= SYS_BODCR_BOD_LPM_Msk)
223 #define SYS_SET_BOD_LEVEL(u32Level) (SYS->BODCR = (SYS->BODCR & ~SYS_BODCR_BOD_VL_Msk) | u32Level)
224 #define SYS_IS_BOD_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_BOD_Msk)
225 #define SYS_IS_CPU_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_CPU_Msk)
227 #define SYS_IS_POR_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_POR_Msk)
228 #define SYS_IS_RSTPIN_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_RESET_Msk)
229 #define SYS_IS_SYSTEM_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_MCU_Msk)
230 #define SYS_IS_WDT_RST() (SYS->RSTSRC & SYS_RSTSRC_RSTS_WDT_Msk)
231 #define SYS_DISABLE_POR() (SYS->PORCR = 0x5AA5)
232 #define SYS_ENABLE_POR() (SYS->PORCR = 0)
233 #define SYS_CLEAR_RST_SOURCE(u32RstSrc) (SYS->RSTSRC | u32RstSrc )
236 void SYS_ClearResetSrc(uint32_t u32Src);
237 uint32_t SYS_GetBODStatus(void);
238 uint32_t SYS_GetResetSrc(void);
239 uint32_t SYS_IsRegLocked(void);
240 void SYS_LockReg(void);
241 void SYS_UnlockReg(void);
242 uint32_t SYS_ReadPDID(void);
243 void SYS_ResetChip(void);
244 void SYS_ResetCPU(void);
245 void SYS_ResetModule(uint32_t u32ModuleIndex);
246 void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel);
247 void SYS_DisableBOD(void);
248 /* end of group NUC029FAE_SYS_EXPORTED_FUNCTIONS */
250 /* end of group NUC029FAE_SYS_Driver */
252 /* end of group NUC029FAE_Device_Driver */
254
255 #ifdef __cplusplus
256 }
257 #endif
258
259 #endif //__SYS_H__
SYS_GetResetSrc
uint32_t SYS_GetResetSrc(void)
This function get the system reset source register value.
Definition: sys.c:51
SYS_DisableBOD
void SYS_DisableBOD(void)
This function disable BOD function.
Definition: sys.c:165
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:154
SYS_ResetModule
void SYS_ResetModule(uint32_t u32ModuleIndex)
This function reset selected modules.
Definition: sys.c:134
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_ResetCPU
void SYS_ResetCPU(void)
This function reset CPU.
Definition: sys.c:113
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_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