1 /*
2  * Copyright (c) 2006-2022, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2022-03-02     FMD-AE       first version
9  */
10 
11 #ifndef __DRV_GPIO_H__
12 #define __DRV_GPIO_H__
13 
14 #include <board.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define GPIO_GET_INDEX(__GPIOx__)    (((__GPIOx__) == (GPIOA))? 0U :\
21                                       ((__GPIOx__) == (GPIOB))? 1U :\
22                                       ((__GPIOx__) == (GPIOC))? 2U :\
23                                       ((__GPIOx__) == (GPIOD))? 3U :\
24                                       ((__GPIOx__) == (GPIOF))? 5U : 4U)
25 
26 #define __GPIO_EXTI_GET_IT(__EXTI_LINE__) (EXTI->PR & (__EXTI_LINE__))
27 
28 #define __GPIO_EXTI_CLEAR_IT(__EXTI_LINE__) (EXTI->PR = (__EXTI_LINE__))
29 
30 #define __FT32_PORT(port)  GPIO##port##_BASE
31 
32 #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__FT32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
33 
34 struct pin_irq_map
35 {
36     rt_uint16_t pinbit;
37     IRQn_Type irqno;
38 };
39 
40 int rt_hw_pin_init(void);
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif /* __DRV_GPIO_H__ */
47 
48