MINI51DE_BSP V3.02.004
The Board Support Package for Mini51DE Series MCU
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 8
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
40#define GPIO_PMD_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/* DBNCECON Constant Definitions */
59/*---------------------------------------------------------------------------------------------------------*/
60#define GPIO_DBNCECON_ICLK_ON 0x00000020UL
61#define GPIO_DBNCECON_ICLK_OFF 0x00000000UL
63#define GPIO_DBNCECON_DBCLKSRC_IRC10K 0x00000010UL
64#define GPIO_DBNCECON_DBCLKSRC_HCLK 0x00000000UL
66#define GPIO_DBNCECON_DBCLKSEL_1 0x00000000UL
67#define GPIO_DBNCECON_DBCLKSEL_2 0x00000001UL
68#define GPIO_DBNCECON_DBCLKSEL_4 0x00000002UL
69#define GPIO_DBNCECON_DBCLKSEL_8 0x00000003UL
70#define GPIO_DBNCECON_DBCLKSEL_16 0x00000004UL
71#define GPIO_DBNCECON_DBCLKSEL_32 0x00000005UL
72#define GPIO_DBNCECON_DBCLKSEL_64 0x00000006UL
73#define GPIO_DBNCECON_DBCLKSEL_128 0x00000007UL
74#define GPIO_DBNCECON_DBCLKSEL_256 0x00000008UL
75#define GPIO_DBNCECON_DBCLKSEL_512 0x00000009UL
76#define GPIO_DBNCECON_DBCLKSEL_1024 0x0000000AUL
77#define GPIO_DBNCECON_DBCLKSEL_2048 0x0000000BUL
78#define GPIO_DBNCECON_DBCLKSEL_4096 0x0000000CUL
79#define GPIO_DBNCECON_DBCLKSEL_8192 0x0000000DUL
80#define GPIO_DBNCECON_DBCLKSEL_16384 0x0000000EUL
81#define GPIO_DBNCECON_DBCLKSEL_32768 0x0000000FUL
97#define GPIO_PIN_ADDR(port, pin) (*((volatile uint32_t *)((GPIOBIT0_BASE+(0x20*(port))) + ((pin)<<2))))
98#define P00 GPIO_PIN_ADDR(0, 0)
99#define P01 GPIO_PIN_ADDR(0, 1)
100#define P02 GPIO_PIN_ADDR(0, 2)
101#define P03 GPIO_PIN_ADDR(0, 3)
102#define P04 GPIO_PIN_ADDR(0, 4)
103#define P05 GPIO_PIN_ADDR(0, 5)
104#define P06 GPIO_PIN_ADDR(0, 6)
105#define P07 GPIO_PIN_ADDR(0, 7)
106#define P10 GPIO_PIN_ADDR(1, 0)
107#define P11 GPIO_PIN_ADDR(1, 1)
108#define P12 GPIO_PIN_ADDR(1, 2)
109#define P13 GPIO_PIN_ADDR(1, 3)
110#define P14 GPIO_PIN_ADDR(1, 4)
111#define P15 GPIO_PIN_ADDR(1, 5)
112#define P16 GPIO_PIN_ADDR(1, 6)
113#define P17 GPIO_PIN_ADDR(1, 7)
114#define P20 GPIO_PIN_ADDR(2, 0)
115#define P21 GPIO_PIN_ADDR(2, 1)
116#define P22 GPIO_PIN_ADDR(2, 2)
117#define P23 GPIO_PIN_ADDR(2, 3)
118#define P24 GPIO_PIN_ADDR(2, 4)
119#define P25 GPIO_PIN_ADDR(2, 5)
120#define P26 GPIO_PIN_ADDR(2, 6)
121#define P27 GPIO_PIN_ADDR(2, 7)
122#define P30 GPIO_PIN_ADDR(3, 0)
123#define P31 GPIO_PIN_ADDR(3, 1)
124#define P32 GPIO_PIN_ADDR(3, 2)
125#define P33 GPIO_PIN_ADDR(3, 3)
126#define P34 GPIO_PIN_ADDR(3, 4)
127#define P35 GPIO_PIN_ADDR(3, 5)
128#define P36 GPIO_PIN_ADDR(3, 6)
129#define P37 GPIO_PIN_ADDR(3, 7)
130#define P40 GPIO_PIN_ADDR(4, 0)
131#define P41 GPIO_PIN_ADDR(4, 1)
132#define P42 GPIO_PIN_ADDR(4, 2)
133#define P43 GPIO_PIN_ADDR(4, 3)
134#define P44 GPIO_PIN_ADDR(4, 4)
135#define P45 GPIO_PIN_ADDR(4, 5)
136#define P46 GPIO_PIN_ADDR(4, 6)
137#define P47 GPIO_PIN_ADDR(4, 7)
138#define P50 GPIO_PIN_ADDR(5, 0)
139#define P51 GPIO_PIN_ADDR(5, 1)
140#define P52 GPIO_PIN_ADDR(5, 2)
141#define P53 GPIO_PIN_ADDR(5, 3)
142#define P54 GPIO_PIN_ADDR(5, 4)
143#define P55 GPIO_PIN_ADDR(5, 5) /* end of group MINI51_GPIO_EXPORTED_CONSTANTS */
146
161#define GPIO_CLR_INT_FLAG(gpio, u32PinMask) ((gpio)->ISRC = u32PinMask)
162
173#define GPIO_DISABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN &= ~u32PinMask)
174
185#define GPIO_ENABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN |= u32PinMask)
186
197#define GPIO_DISABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->OFFD |= (u32PinMask << 16))
198
209#define GPIO_ENABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->OFFD &= ~(u32PinMask << 16))
210
221#define GPIO_DISABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DMASK |= u32PinMask)
222
233#define GPIO_ENABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DMASK &= ~u32PinMask)
234
246#define GPIO_GET_INT_FLAG(gpio, u32PinMask) ((gpio)->ISRC & u32PinMask)
247
268#define GPIO_SET_DEBOUNCE_TIME(clksrc, clksel) (GPIO->DBNCECON = (GPIO_DBNCECON_ICLK_ON_Msk | clksrc | clksel))
269
279#define GPIO_GET_IN_DATA(gpio) ((gpio)->PIN)
280
291#define GPIO_SET_OUT_DATA(gpio, data) ((gpio)->DOUT = (data))
292
302#define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1)
303
316#define GPIO_EnableEINT0 GPIO_EnableInt
317
318
329#define GPIO_DisableEINT0 GPIO_DisableInt
330
331
344#define GPIO_EnableEINT1 GPIO_EnableInt
345
346
357#define GPIO_DisableEINT1 GPIO_DisableInt
358
359
360void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode);
361void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs);
362void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin);
363
364
365 /* end of group MINI51_GPIO_EXPORTED_FUNCTIONS */
367 /* end of group MINI51_GPIO_Driver */
369 /* end of group MINI51_Device_Driver */
371
372#ifdef __cplusplus
373}
374#endif
375
376#endif //__GPIO_H__
377
378/*** (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