NANO100_BSP V3.04.002
The Board Support Package for Nano100BN Series
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/* PMD Constant Definitions */
36/*---------------------------------------------------------------------------------------------------------*/
37#define GPIO_PMD_INPUT 0x0UL
38#define GPIO_PMD_OUTPUT 0x1UL
39#define GPIO_PMD_OPEN_DRAIN 0x2UL
41/*---------------------------------------------------------------------------------------------------------*/
42/* GPIO Interrupt Type Constant Definitions */
43/*---------------------------------------------------------------------------------------------------------*/
44#define GPIO_INT_RISING 0x00010000UL
45#define GPIO_INT_FALLING 0x00000001UL
46#define GPIO_INT_BOTH_EDGE 0x00010001UL
47#define GPIO_INT_HIGH 0x01010000UL
48#define GPIO_INT_LOW 0x01000001UL
50/*---------------------------------------------------------------------------------------------------------*/
51/* IMD Constant Definitions */
52/*---------------------------------------------------------------------------------------------------------*/
53#define GPIO_IMD_EDGE 0UL
54#define GPIO_IMD_LEVEL 1UL
56/*---------------------------------------------------------------------------------------------------------*/
57/* DBNCECON Constant Definitions */
58/*---------------------------------------------------------------------------------------------------------*/
59#define GPIO_ICLK_ON 0x00000020UL
60#define GPIO_ICLK_OFF 0x00000000UL
62#define GPIO_DBCLKSRC_IRC10K 0x00000010UL
63#define GPIO_DBCLKSRC_HCLK 0x00000000UL
65#define GPIO_DBCLKSEL_1 0x00000000UL
66#define GPIO_DBCLKSEL_2 0x00000001UL
67#define GPIO_DBCLKSEL_4 0x00000002UL
68#define GPIO_DBCLKSEL_8 0x00000003UL
69#define GPIO_DBCLKSEL_16 0x00000004UL
70#define GPIO_DBCLKSEL_32 0x00000005UL
71#define GPIO_DBCLKSEL_64 0x00000006UL
72#define GPIO_DBCLKSEL_128 0x00000007UL
73#define GPIO_DBCLKSEL_256 0x00000008UL
74#define GPIO_DBCLKSEL_512 0x00000009UL
75#define GPIO_DBCLKSEL_1024 0x0000000AUL
76#define GPIO_DBCLKSEL_2048 0x0000000BUL
77#define GPIO_DBCLKSEL_4096 0x0000000CUL
78#define GPIO_DBCLKSEL_8192 0x0000000DUL
79#define GPIO_DBCLKSEL_16384 0x0000000EUL
80#define GPIO_DBCLKSEL_32768 0x0000000FUL
96#define GPIO_PIN_ADDR(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2))))
97#define PA0 GPIO_PIN_ADDR(0, 0)
98#define PA1 GPIO_PIN_ADDR(0, 1)
99#define PA2 GPIO_PIN_ADDR(0, 2)
100#define PA3 GPIO_PIN_ADDR(0, 3)
101#define PA4 GPIO_PIN_ADDR(0, 4)
102#define PA5 GPIO_PIN_ADDR(0, 5)
103#define PA6 GPIO_PIN_ADDR(0, 6)
104#define PA7 GPIO_PIN_ADDR(0, 7)
105#define PA8 GPIO_PIN_ADDR(0, 8)
106#define PA9 GPIO_PIN_ADDR(0, 9)
107#define PA10 GPIO_PIN_ADDR(0, 10)
108#define PA11 GPIO_PIN_ADDR(0, 11)
109#define PA12 GPIO_PIN_ADDR(0, 12)
110#define PA13 GPIO_PIN_ADDR(0, 13)
111#define PA14 GPIO_PIN_ADDR(0, 14)
112#define PA15 GPIO_PIN_ADDR(0, 15)
114#define PB0 GPIO_PIN_ADDR(1, 0)
115#define PB1 GPIO_PIN_ADDR(1, 1)
116#define PB2 GPIO_PIN_ADDR(1, 2)
117#define PB3 GPIO_PIN_ADDR(1, 3)
118#define PB4 GPIO_PIN_ADDR(1, 4)
119#define PB5 GPIO_PIN_ADDR(1, 5)
120#define PB6 GPIO_PIN_ADDR(1, 6)
121#define PB7 GPIO_PIN_ADDR(1, 7)
122#define PB8 GPIO_PIN_ADDR(1, 8)
123#define PB9 GPIO_PIN_ADDR(1, 9)
124#define PB10 GPIO_PIN_ADDR(1, 10)
125#define PB11 GPIO_PIN_ADDR(1, 11)
126#define PB12 GPIO_PIN_ADDR(1, 12)
127#define PB13 GPIO_PIN_ADDR(1, 13)
128#define PB14 GPIO_PIN_ADDR(1, 14)
129#define PB15 GPIO_PIN_ADDR(1, 15)
131#define PC0 GPIO_PIN_ADDR(2, 0)
132#define PC1 GPIO_PIN_ADDR(2, 1)
133#define PC2 GPIO_PIN_ADDR(2, 2)
134#define PC3 GPIO_PIN_ADDR(2, 3)
135#define PC4 GPIO_PIN_ADDR(2, 4)
136#define PC5 GPIO_PIN_ADDR(2, 5)
137#define PC6 GPIO_PIN_ADDR(2, 6)
138#define PC7 GPIO_PIN_ADDR(2, 7)
139#define PC8 GPIO_PIN_ADDR(2, 8)
140#define PC9 GPIO_PIN_ADDR(2, 9)
141#define PC10 GPIO_PIN_ADDR(2, 10)
142#define PC11 GPIO_PIN_ADDR(2, 11)
143#define PC12 GPIO_PIN_ADDR(2, 12)
144#define PC13 GPIO_PIN_ADDR(2, 13)
145#define PC14 GPIO_PIN_ADDR(2, 14)
146#define PC15 GPIO_PIN_ADDR(2, 15)
148#define PD0 GPIO_PIN_ADDR(3, 0)
149#define PD1 GPIO_PIN_ADDR(3, 1)
150#define PD2 GPIO_PIN_ADDR(3, 2)
151#define PD3 GPIO_PIN_ADDR(3, 3)
152#define PD4 GPIO_PIN_ADDR(3, 4)
153#define PD5 GPIO_PIN_ADDR(3, 5)
154#define PD6 GPIO_PIN_ADDR(3, 6)
155#define PD7 GPIO_PIN_ADDR(3, 7)
156#define PD8 GPIO_PIN_ADDR(3, 8)
157#define PD9 GPIO_PIN_ADDR(3, 9)
158#define PD10 GPIO_PIN_ADDR(3, 10)
159#define PD11 GPIO_PIN_ADDR(3, 11)
160#define PD12 GPIO_PIN_ADDR(3, 12)
161#define PD13 GPIO_PIN_ADDR(3, 13)
162#define PD14 GPIO_PIN_ADDR(3, 14)
163#define PD15 GPIO_PIN_ADDR(3, 15)
165#define PE0 GPIO_PIN_ADDR(4, 0)
166#define PE1 GPIO_PIN_ADDR(4, 1)
167#define PE2 GPIO_PIN_ADDR(4, 2)
168#define PE3 GPIO_PIN_ADDR(4, 3)
169#define PE4 GPIO_PIN_ADDR(4, 4)
170#define PE5 GPIO_PIN_ADDR(4, 5)
171#define PE6 GPIO_PIN_ADDR(4, 6)
172#define PE7 GPIO_PIN_ADDR(4, 7)
173#define PE8 GPIO_PIN_ADDR(4, 8)
174#define PE9 GPIO_PIN_ADDR(4, 9)
175#define PE10 GPIO_PIN_ADDR(4, 10)
176#define PE11 GPIO_PIN_ADDR(4, 11)
177#define PE12 GPIO_PIN_ADDR(4, 12)
178#define PE13 GPIO_PIN_ADDR(4, 13)
179#define PE14 GPIO_PIN_ADDR(4, 14)
180#define PE15 GPIO_PIN_ADDR(4, 15)
182#define PF0 GPIO_PIN_ADDR(5, 0)
183#define PF1 GPIO_PIN_ADDR(5, 1)
184#define PF2 GPIO_PIN_ADDR(5, 2)
185#define PF3 GPIO_PIN_ADDR(5, 3)
186#define PF4 GPIO_PIN_ADDR(5, 4)
187#define PF5 GPIO_PIN_ADDR(5, 5) /* end of group NANO100_GPIO_EXPORTED_CONSTANTS */
190
205#define GPIO_CLR_INT_FLAG(gpio, u32PinMask) ((gpio)->ISRC = u32PinMask)
206
217#define GPIO_DISABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN &= ~u32PinMask)
218
229#define GPIO_ENABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN |= u32PinMask)
230
241#define GPIO_DISABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->OFFD |= (u32PinMask << 16))
242
253#define GPIO_ENABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->OFFD &= ~(u32PinMask << 16))
254
265#define GPIO_DISABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DMASK &= ~u32PinMask)
266
277#define GPIO_ENABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DMASK |= u32PinMask)
278
290#define GPIO_GET_INT_FLAG(gpio, u32PinMask) ((gpio)->ISRC & u32PinMask)
291
310#define GPIO_SET_DEBOUNCE_TIME(u32ClkSrc, u32ClkSel) (GPIO->DBNCECON = (GP_DBNCECON_DBCLK_ON_Msk | u32ClkSrc | u32ClkSel))
311
321#define GPIO_GET_IN_DATA(gpio) ((gpio)->PIN)
322
333#define GPIO_SET_OUT_DATA(gpio, u32Data) ((gpio)->DOUT = (u32Data))
334
345#define GPIO_DISABLE_PULL_UP(gpio, u32PinMask) ((gpio)->PUEN &= ~u32PinMask)
346
357#define GPIO_ENABLE_PULL_UP(gpio, u32PinMask) ((gpio)->PUEN |= u32PinMask)
358
368#define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1)
369
382#define GPIO_EnableEINT0 GPIO_EnableInt
383
384
395#define GPIO_DisableEINT0 GPIO_DisableInt
396
397
410#define GPIO_EnableEINT1 GPIO_EnableInt
411
412
423#define GPIO_DisableEINT1 GPIO_DisableInt
424
425
426void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode);
427void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs);
428void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin);
429
430
431 /* end of group NANO100_GPIO_EXPORTED_FUNCTIONS */
433 /* end of group NANO100_GPIO_Driver */
435 /* end of group NANO100_Device_Driver */
437
438#ifdef __cplusplus
439}
440#endif
441
442#endif //__GPIO_H__
443
444/*** (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