NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
gpio.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __GPIO_H__
13#define __GPIO_H__
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
20
32#define GPIO_PIN_MAX 16
34/*---------------------------------------------------------------------------------------------------------*/
35/* MODE Constant Definitions */
36/*---------------------------------------------------------------------------------------------------------*/
37#define GPIO_MODE_INPUT 0x0UL
38#define GPIO_MODE_OUTPUT 0x1UL
39#define GPIO_MODE_OPEN_DRAIN 0x2UL
40#define GPIO_MODE_QUASI 0x3UL
42/*---------------------------------------------------------------------------------------------------------*/
43/* GPIO Interrupt Type Constant Definitions */
44/*---------------------------------------------------------------------------------------------------------*/
45#define GPIO_INT_RISING 0x00010000UL
46#define GPIO_INT_FALLING 0x00000001UL
47#define GPIO_INT_BOTH_EDGE 0x00010001UL
48#define GPIO_INT_HIGH 0x01010000UL
49#define GPIO_INT_LOW 0x01000001UL
51/*---------------------------------------------------------------------------------------------------------*/
52/* IMD Constant Definitions */
53/*---------------------------------------------------------------------------------------------------------*/
54#define GPIO_IMD_EDGE 0UL
55#define GPIO_IMD_LEVEL 1UL
57/*---------------------------------------------------------------------------------------------------------*/
58/* DBCTL Constant Definitions */
59/*---------------------------------------------------------------------------------------------------------*/
60#define GPIO_DBCTL_ICLK_ON 0x00000020UL
61#define GPIO_DBCTL_ICLK_OFF 0x00000000UL
63#define GPIO_DBCTL_DBCLKSRC_IRC10K 0x00000010UL
64#define GPIO_DBCTL_DBCLKSRC_HCLK 0x00000000UL
66#define GPIO_DBCTL_DBCLKSEL_1 0x00000000UL
67#define GPIO_DBCTL_DBCLKSEL_2 0x00000001UL
68#define GPIO_DBCTL_DBCLKSEL_4 0x00000002UL
69#define GPIO_DBCTL_DBCLKSEL_8 0x00000003UL
70#define GPIO_DBCTL_DBCLKSEL_16 0x00000004UL
71#define GPIO_DBCTL_DBCLKSEL_32 0x00000005UL
72#define GPIO_DBCTL_DBCLKSEL_64 0x00000006UL
73#define GPIO_DBCTL_DBCLKSEL_128 0x00000007UL
74#define GPIO_DBCTL_DBCLKSEL_256 0x00000008UL
75#define GPIO_DBCTL_DBCLKSEL_512 0x00000009UL
76#define GPIO_DBCTL_DBCLKSEL_1024 0x0000000AUL
77#define GPIO_DBCTL_DBCLKSEL_2048 0x0000000BUL
78#define GPIO_DBCTL_DBCLKSEL_4096 0x0000000CUL
79#define GPIO_DBCTL_DBCLKSEL_8192 0x0000000DUL
80#define GPIO_DBCTL_DBCLKSEL_16384 0x0000000EUL
81#define GPIO_DBCTL_DBCLKSEL_32768 0x0000000FUL
97#define GPIO_PIN_ADDR(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2))))
98#define PA0 GPIO_PIN_ADDR(0, 0)
99#define PA1 GPIO_PIN_ADDR(0, 1)
100#define PA2 GPIO_PIN_ADDR(0, 2)
101#define PA3 GPIO_PIN_ADDR(0, 3)
102#define PA4 GPIO_PIN_ADDR(0, 4)
103#define PA5 GPIO_PIN_ADDR(0, 5)
104#define PA6 GPIO_PIN_ADDR(0, 6)
105#define PA7 GPIO_PIN_ADDR(0, 7)
106#define PA8 GPIO_PIN_ADDR(0, 8)
107#define PA9 GPIO_PIN_ADDR(0, 9)
108#define PA10 GPIO_PIN_ADDR(0, 10)
109#define PA11 GPIO_PIN_ADDR(0, 11)
110#define PA12 GPIO_PIN_ADDR(0, 12)
111#define PA13 GPIO_PIN_ADDR(0, 13)
112#define PA14 GPIO_PIN_ADDR(0, 14)
113#define PA15 GPIO_PIN_ADDR(0, 15)
115#define PB0 GPIO_PIN_ADDR(1, 0)
116#define PB1 GPIO_PIN_ADDR(1, 1)
117#define PB2 GPIO_PIN_ADDR(1, 2)
118#define PB3 GPIO_PIN_ADDR(1, 3)
119#define PB4 GPIO_PIN_ADDR(1, 4)
120#define PB5 GPIO_PIN_ADDR(1, 5)
121#define PB6 GPIO_PIN_ADDR(1, 6)
122#define PB7 GPIO_PIN_ADDR(1, 7)
123#define PB8 GPIO_PIN_ADDR(1, 8)
124#define PB9 GPIO_PIN_ADDR(1, 9)
125#define PB10 GPIO_PIN_ADDR(1, 10)
126#define PB11 GPIO_PIN_ADDR(1, 11)
127#define PB12 GPIO_PIN_ADDR(1, 12)
128#define PB13 GPIO_PIN_ADDR(1, 13)
129#define PB14 GPIO_PIN_ADDR(1, 14)
130#define PB15 GPIO_PIN_ADDR(1, 15)
132#define PC0 GPIO_PIN_ADDR(2, 0)
133#define PC1 GPIO_PIN_ADDR(2, 1)
134#define PC2 GPIO_PIN_ADDR(2, 2)
135#define PC3 GPIO_PIN_ADDR(2, 3)
136#define PC4 GPIO_PIN_ADDR(2, 4)
137#define PC5 GPIO_PIN_ADDR(2, 5)
138#define PC6 GPIO_PIN_ADDR(2, 6)
139#define PC7 GPIO_PIN_ADDR(2, 7)
140#define PC8 GPIO_PIN_ADDR(2, 8)
141#define PC9 GPIO_PIN_ADDR(2, 9)
142#define PC10 GPIO_PIN_ADDR(2, 10)
143#define PC11 GPIO_PIN_ADDR(2, 11)
144#define PC12 GPIO_PIN_ADDR(2, 12)
145#define PC13 GPIO_PIN_ADDR(2, 13)
146#define PC14 GPIO_PIN_ADDR(2, 14)
147#define PC15 GPIO_PIN_ADDR(2, 15)
149#define PD0 GPIO_PIN_ADDR(3, 0)
150#define PD1 GPIO_PIN_ADDR(3, 1)
151#define PD2 GPIO_PIN_ADDR(3, 2)
152#define PD3 GPIO_PIN_ADDR(3, 3)
153#define PD4 GPIO_PIN_ADDR(3, 4)
154#define PD5 GPIO_PIN_ADDR(3, 5)
155#define PD6 GPIO_PIN_ADDR(3, 6)
156#define PD7 GPIO_PIN_ADDR(3, 7)
157#define PD8 GPIO_PIN_ADDR(3, 8)
158#define PD9 GPIO_PIN_ADDR(3, 9)
159#define PD10 GPIO_PIN_ADDR(3, 10)
160#define PD11 GPIO_PIN_ADDR(3, 11)
161#define PD12 GPIO_PIN_ADDR(3, 12)
162#define PD13 GPIO_PIN_ADDR(3, 13)
163#define PD14 GPIO_PIN_ADDR(3, 14)
164#define PD15 GPIO_PIN_ADDR(3, 15)
166#define PE0 GPIO_PIN_ADDR(4, 0)
167#define PE1 GPIO_PIN_ADDR(4, 1)
168#define PE2 GPIO_PIN_ADDR(4, 2)
169#define PE3 GPIO_PIN_ADDR(4, 3)
170#define PE4 GPIO_PIN_ADDR(4, 4)
171#define PE5 GPIO_PIN_ADDR(4, 5)
172#define PE6 GPIO_PIN_ADDR(4, 6)
173#define PE7 GPIO_PIN_ADDR(4, 7)
174#define PE8 GPIO_PIN_ADDR(4, 8)
175#define PE9 GPIO_PIN_ADDR(4, 9)
176#define PE10 GPIO_PIN_ADDR(4, 10)
177#define PE11 GPIO_PIN_ADDR(4, 11)
178#define PE12 GPIO_PIN_ADDR(4, 12)
179#define PE13 GPIO_PIN_ADDR(4, 13)
180#define PE14 GPIO_PIN_ADDR(4, 14)
181#define PE15 GPIO_PIN_ADDR(4, 15)
183#define PF0 GPIO_PIN_ADDR(5, 0)
184#define PF1 GPIO_PIN_ADDR(5, 1)
185#define PF2 GPIO_PIN_ADDR(5, 2)
186#define PF3 GPIO_PIN_ADDR(5, 3)
187#define PF4 GPIO_PIN_ADDR(5, 4)
188#define PF5 GPIO_PIN_ADDR(5, 5)
189#define PF6 GPIO_PIN_ADDR(5, 6)
190#define PF7 GPIO_PIN_ADDR(5, 7)
191#define PF8 GPIO_PIN_ADDR(5, 8)
192#define PF9 GPIO_PIN_ADDR(5, 9)
193#define PF10 GPIO_PIN_ADDR(5, 10)
194#define PF11 GPIO_PIN_ADDR(5, 11)
195#define PF12 GPIO_PIN_ADDR(5, 12)
196#define PF13 GPIO_PIN_ADDR(5, 13)
197#define PF14 GPIO_PIN_ADDR(5, 14)
198#define PF15 GPIO_PIN_ADDR(5, 15)
200#define PG0 GPIO_PIN_ADDR(6, 0)
201#define PG1 GPIO_PIN_ADDR(6, 1)
202#define PG2 GPIO_PIN_ADDR(6, 2)
203#define PG3 GPIO_PIN_ADDR(6, 3)
204#define PG4 GPIO_PIN_ADDR(6, 4)
205#define PG5 GPIO_PIN_ADDR(6, 5)
206#define PG6 GPIO_PIN_ADDR(6, 6)
207#define PG7 GPIO_PIN_ADDR(6, 7)
208#define PG8 GPIO_PIN_ADDR(6, 8)
209#define PG9 GPIO_PIN_ADDR(6, 9)
210#define PG10 GPIO_PIN_ADDR(6, 10)
211#define PG11 GPIO_PIN_ADDR(6, 11)
212#define PG12 GPIO_PIN_ADDR(6, 12)
213#define PG13 GPIO_PIN_ADDR(6, 13)
214#define PG14 GPIO_PIN_ADDR(6, 14)
215#define PG15 GPIO_PIN_ADDR(6, 15)
217#define PH0 GPIO_PIN_ADDR(7, 0)
218#define PH1 GPIO_PIN_ADDR(7, 1)
219#define PH2 GPIO_PIN_ADDR(7, 2)
220#define PH3 GPIO_PIN_ADDR(7, 3)
221#define PH4 GPIO_PIN_ADDR(7, 4)
222#define PH5 GPIO_PIN_ADDR(7, 5)
223#define PH6 GPIO_PIN_ADDR(7, 6)
224#define PH7 GPIO_PIN_ADDR(7, 7)
225#define PH8 GPIO_PIN_ADDR(7, 8)
226#define PH9 GPIO_PIN_ADDR(7, 9)
227#define PH10 GPIO_PIN_ADDR(7, 10)
228#define PH11 GPIO_PIN_ADDR(7, 11)
229#define PH12 GPIO_PIN_ADDR(7, 12)
230#define PH13 GPIO_PIN_ADDR(7, 13)
231#define PH14 GPIO_PIN_ADDR(7, 14)
232#define PH15 GPIO_PIN_ADDR(7, 15)
234#define PI0 GPIO_PIN_ADDR(8, 0)
235#define PI1 GPIO_PIN_ADDR(8, 1)
236#define PI2 GPIO_PIN_ADDR(8, 2)
237#define PI3 GPIO_PIN_ADDR(8, 3)
238#define PI4 GPIO_PIN_ADDR(8, 4)
239#define PI5 GPIO_PIN_ADDR(8, 5)
240#define PI6 GPIO_PIN_ADDR(8, 6)
241#define PI7 GPIO_PIN_ADDR(8, 7)
242#define PI8 GPIO_PIN_ADDR(8, 8)
243#define PI9 GPIO_PIN_ADDR(8, 9)
244#define PI10 GPIO_PIN_ADDR(8, 10)
245#define PI11 GPIO_PIN_ADDR(8, 11)
246#define PI12 GPIO_PIN_ADDR(8, 12)
247#define PI13 GPIO_PIN_ADDR(8, 13)
248#define PI14 GPIO_PIN_ADDR(8, 14)
249#define PI15 GPIO_PIN_ADDR(8, 15) /* end of group NUC472_442_GPIO_EXPORTED_CONSTANTS */
252
267#define GPIO_CLR_INT_FLAG(gpio, u32PinMask) ((gpio)->INTSRC = u32PinMask)
268
279#define GPIO_DISABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN &= ~u32PinMask)
280
291#define GPIO_ENABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN |= u32PinMask)
292
303#define GPIO_DISABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->DINOFF |= (u32PinMask << 16))
304
315#define GPIO_ENABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->DINOFF &= ~(u32PinMask << 16))
316
327#define GPIO_DISABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DATMSK &= ~u32PinMask)
328
339#define GPIO_ENABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DATMSK |= u32PinMask)
340
352#define GPIO_GET_INT_FLAG(gpio, u32PinMask) ((gpio)->INTSRC & u32PinMask)
353
372#define GPIO_SET_DEBOUNCE_TIME(u32ClkSrc, u32ClkSel) (GPIO->DBCTL = (GPIO_DBCTL_ICLKON_Msk | u32ClkSrc | u32ClkSel))
373
383#define GPIO_GET_IN_DATA(gpio) ((gpio)->PIN)
384
395#define GPIO_SET_OUT_DATA(gpio, u32Data) ((gpio)->DOUT = (u32Data))
396
397
407#define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1)
408
421#define GPIO_EnableEINT0 GPIO_EnableInt
422
423
434#define GPIO_DisableEINT0 GPIO_DisableInt
435
436
449#define GPIO_EnableEINT1 GPIO_EnableInt
450
451
462#define GPIO_DisableEINT1 GPIO_DisableInt
463
476#define GPIO_EnableEINT GPIO_EnableInt
477
478
489#define GPIO_DisableEINT GPIO_DisableInt
490
491
492void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode);
493void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs);
494void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin);
495
496
497 /* end of group NUC472_442_GPIO_EXPORTED_FUNCTIONS */
499 /* end of group NUC472_442_GPIO_Driver */
501 /* end of group NUC472_442_Device_Driver */
503
504#ifdef __cplusplus
505}
506#endif
507
508#endif //__GPIO_H__
509
510/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin)
Disable GPIO interrupt.
Definition: gpio.c:82
void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO operation mode.
Definition: gpio.c:40
void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs)
Enable GPIO interrupt.
Definition: gpio.c:65