M471M/R1/S BSP V3.01.000
The Board Support Package for M4521
gpio.h
Go to the documentation of this file.
1/**************************************************************************/
8#ifndef __GPIO_H__
9#define __GPIO_H__
10
11
12#ifdef __cplusplus
13extern "C"
14{
15#endif
16
30#define GPIO_PIN_MAX 16
33/*---------------------------------------------------------------------------------------------------------*/
34/* GPIO_MODE Constant Definitions */
35/*---------------------------------------------------------------------------------------------------------*/
36#define GPIO_MODE_INPUT 0x0UL
37#define GPIO_MODE_OUTPUT 0x1UL
38#define GPIO_MODE_OPEN_DRAIN 0x2UL
39#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
52/*---------------------------------------------------------------------------------------------------------*/
53/* GPIO_INTTYPE Constant Definitions */
54/*---------------------------------------------------------------------------------------------------------*/
55#define GPIO_INTTYPE_EDGE 0UL
56#define GPIO_INTTYPE_LEVEL 1UL
59/*---------------------------------------------------------------------------------------------------------*/
60/* GPIO_DBCTL Constant Definitions */
61/*---------------------------------------------------------------------------------------------------------*/
62#define GPIO_DBCTL_ICLK_ON 0x00000020UL
63#define GPIO_DBCTL_ICLK_OFF 0x00000000UL
65#define GPIO_DBCTL_DBCLKSRC_LIRC 0x00000010UL
66#define GPIO_DBCTL_DBCLKSRC_HCLK 0x00000000UL
68#define GPIO_DBCTL_DBCLKSEL_1 0x00000000UL
69#define GPIO_DBCTL_DBCLKSEL_2 0x00000001UL
70#define GPIO_DBCTL_DBCLKSEL_4 0x00000002UL
71#define GPIO_DBCTL_DBCLKSEL_8 0x00000003UL
72#define GPIO_DBCTL_DBCLKSEL_16 0x00000004UL
73#define GPIO_DBCTL_DBCLKSEL_32 0x00000005UL
74#define GPIO_DBCTL_DBCLKSEL_64 0x00000006UL
75#define GPIO_DBCTL_DBCLKSEL_128 0x00000007UL
76#define GPIO_DBCTL_DBCLKSEL_256 0x00000008UL
77#define GPIO_DBCTL_DBCLKSEL_512 0x00000009UL
78#define GPIO_DBCTL_DBCLKSEL_1024 0x0000000AUL
79#define GPIO_DBCTL_DBCLKSEL_2048 0x0000000BUL
80#define GPIO_DBCTL_DBCLKSEL_4096 0x0000000CUL
81#define GPIO_DBCTL_DBCLKSEL_8192 0x0000000DUL
82#define GPIO_DBCTL_DBCLKSEL_16384 0x0000000EUL
83#define GPIO_DBCTL_DBCLKSEL_32768 0x0000000FUL
86/* Define GPIO Pin Data Input/Output. It could be used to control each I/O pin by pin address mapping.
87 Example 1:
88
89 PA0 = 1;
90
91 It is used to set GPIO PA.0 to high;
92
93 Example 2:
94
95 if (PA0)
96 PA0 = 0;
97
98 If GPIO PA.0 pin status is high, then set GPIO PA.0 data output to low.
99 */
100#define GPIO_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2))))
101#define PA0 GPIO_PIN_DATA(0, 0 )
102#define PA1 GPIO_PIN_DATA(0, 1 )
103#define PA2 GPIO_PIN_DATA(0, 2 )
104#define PA3 GPIO_PIN_DATA(0, 3 )
105#define PB0 GPIO_PIN_DATA(1, 0 )
106#define PB1 GPIO_PIN_DATA(1, 1 )
107#define PB2 GPIO_PIN_DATA(1, 2 )
108#define PB3 GPIO_PIN_DATA(1, 3 )
109#define PB4 GPIO_PIN_DATA(1, 4 )
110#define PB5 GPIO_PIN_DATA(1, 5 )
111#define PB6 GPIO_PIN_DATA(1, 6 )
112#define PB7 GPIO_PIN_DATA(1, 7 )
113#define PB8 GPIO_PIN_DATA(1, 8 )
114#define PB11 GPIO_PIN_DATA(1, 11)
115#define PB12 GPIO_PIN_DATA(1, 12)
116#define PB15 GPIO_PIN_DATA(1, 15)
117#define PC0 GPIO_PIN_DATA(2, 0 )
118#define PC1 GPIO_PIN_DATA(2, 1 )
119#define PC2 GPIO_PIN_DATA(2, 2 )
120#define PC3 GPIO_PIN_DATA(2, 3 )
121#define PC4 GPIO_PIN_DATA(2, 4 )
122#define PC5 GPIO_PIN_DATA(2, 5 )
123#define PC6 GPIO_PIN_DATA(2, 6 )
124#define PC7 GPIO_PIN_DATA(2, 7 )
125#define PD0 GPIO_PIN_DATA(3, 0 )
126#define PD1 GPIO_PIN_DATA(3, 1 )
127#define PD2 GPIO_PIN_DATA(3, 2 )
128#define PD3 GPIO_PIN_DATA(3, 3 )
129#define PD7 GPIO_PIN_DATA(3, 7 )
130#define PD8 GPIO_PIN_DATA(3, 8 )
131#define PD9 GPIO_PIN_DATA(3, 9 )
132#define PD12 GPIO_PIN_DATA(3, 12)
133#define PD13 GPIO_PIN_DATA(3, 13)
134#define PD14 GPIO_PIN_DATA(3, 14)
135#define PD15 GPIO_PIN_DATA(3, 15)
136#define PE0 GPIO_PIN_DATA(4, 0 )
137#define PE8 GPIO_PIN_DATA(4, 8 )
138#define PE9 GPIO_PIN_DATA(4, 9 )
139#define PE10 GPIO_PIN_DATA(4, 10)
140#define PE11 GPIO_PIN_DATA(4, 11)
141#define PE12 GPIO_PIN_DATA(4, 12)
142#define PE13 GPIO_PIN_DATA(4, 13)
143#define PF0 GPIO_PIN_DATA(5, 0 )
144#define PF1 GPIO_PIN_DATA(5, 1 )
145#define PF2 GPIO_PIN_DATA(5, 2 )
146#define PF3 GPIO_PIN_DATA(5, 3 )
147#define PF4 GPIO_PIN_DATA(5, 4 )
148#define PF5 GPIO_PIN_DATA(5, 5 )
149#define PF6 GPIO_PIN_DATA(5, 6 )
150#define PF7 GPIO_PIN_DATA(5, 7 ) /* end of group GPIO_EXPORTED_CONSTANTS */
154
155
173#define GPIO_CLR_INT_FLAG(port, u32PinMask) ((port)->INTSRC = (u32PinMask))
174
188#define GPIO_DISABLE_DEBOUNCE(port, u32PinMask) ((port)->DBEN &= ~(u32PinMask))
189
202#define GPIO_ENABLE_DEBOUNCE(port, u32PinMask) ((port)->DBEN |= (u32PinMask))
203
217#define GPIO_DISABLE_DIGITAL_PATH(port, u32PinMask) ((port)->DINOFF |= ((u32PinMask)<<16))
218
232#define GPIO_ENABLE_DIGITAL_PATH(port, u32PinMask) ((port)->DINOFF &= ~((u32PinMask)<<16))
233
247#define GPIO_DISABLE_DOUT_MASK(port, u32PinMask) ((port)->DATMSK &= ~(u32PinMask))
248
262#define GPIO_ENABLE_DOUT_MASK(port, u32PinMask) ((port)->DATMSK |= (u32PinMask))
263
278#define GPIO_GET_INT_FLAG(port, u32PinMask) ((port)->INTSRC & (u32PinMask))
279
310#define GPIO_SET_DEBOUNCE_TIME(u32ClkSrc, u32ClkSel) (GPIO->DBCTL = (GPIO_DBCTL_ICLKON_Msk | (u32ClkSrc) | (u32ClkSel)))
311
321#define GPIO_GET_IN_DATA(port) ((port)->PIN)
322
333#define GPIO_SET_OUT_DATA(port, u32Data) ((port)->DOUT = (u32Data))
334
344#define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1)
345
346
362#define GPIO_EnableEINT GPIO_EnableInt
363
377#define GPIO_DisableEINT GPIO_DisableInt
378
379
380void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode);
381void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs);
382void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin);
383
384 /* end of group GPIO_EXPORTED_FUNCTIONS */
386 /* end of group GPIO_Driver */
388 /* end of group Standard_Driver */
390
391
392#ifdef __cplusplus
393}
394#endif
395
396#endif // __GPIO_H__
397
void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
Enable GPIO interrupt.
Definition: gpio.c:66
void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin)
Disable GPIO interrupt.
Definition: gpio.c:86
void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
Set GPIO operation mode.
Definition: gpio.c:38