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-10-19     Nations      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 __N32_PORT(port)  GPIO##port##_BASE
21 
22 #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__N32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
23 
24 #define __N32_PIN(index, gpio, gpio_pin)                                \
25     {                                                                   \
26         index, gpio, gpio_pin                                           \
27     }
28 
29 #define __N32_PIN_RESERVE                                               \
30     {                                                                   \
31         -1, 0, 0                                                        \
32     }
33 
34 /* GPIO driver */
35 struct pin_index
36 {
37     int index;
38     GPIO_Module *gpio;
39     uint32_t pin;
40 };
41 
42 struct pin_irq_map
43 {
44     uint16_t pinbit;
45     IRQn_Type irqno;
46 };
47 
48 int rt_hw_pin_init(void);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /* __DRV_GPIO_H__ */
55 
56