1 /*
2  * Copyright (c) 2006-2023, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2022-08-25     liYony       first version
9  */
10 
11 #ifndef __DRV_GPIO_H__
12 #define __DRV_GPIO_H__
13 
14 #include <board.h>
15 #include <rtthread.h>
16 #include "rtdevice.h"
17 #include <rthw.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define __CH32_PORT(port)  GPIO##port##_BASE
24 #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__CH32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
25 
26 struct pin_irq_map
27 {
28     rt_uint16_t pinbit;
29     IRQn_Type irqno;
30 };
31 
32 int rt_hw_pin_init(void);
33 
34 #ifdef __cplusplus
35 }
36 #endif
37 
38 #endif /* __DRV_GPIO_H__ */
39