1 /*
2  * Copyright (c) 2006-2025, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author            Notes
8  * 2020-06-16     guohp1128         first version
9  */
10 
11 #ifndef __DRV_GPIO_H__
12 #define __DRV_GPIO_H__
13 
14 #include <board.h>
15 #include <rtdevice.h>
16 #include <hal/nrf_gpio.h>
17 #include <drivers/include/nrfx_gpiote.h>
18 
19 #define __NRF5X_PORT(port)  NRF_P##port##_BASE
20 
21 #define GET_PIN(PORTx,PIN) (rt_base_t)((32 * ( ((rt_base_t)__NRF5X_PORT(PORTx) - (rt_base_t)NRF_P0_BASE)/(0x0300UL) )) + PIN)
22 
23 #define __NRF5X_PIN(index, gpio, gpio_index)                                \
24     {                                                                       \
25         index, NRF_P##gpio, gpio_index                                      \
26     }
27 
28 #define __NRF5X_PIN_RESERVE                                                 \
29     {                                                                       \
30         -1, 0, 0                                                            \
31     }
32 
33 /* nrf5x GPIO driver */
34 struct pin_index
35 {
36     int index;
37     NRF_GPIO_Type *gpio;/* NRF_P0 or NRF_P1 */
38     rt_base_t pin;
39 };
40 
41 int rt_hw_pin_init(void);
42 
43 #endif /* __DRV_GPIO_H__ */
44 
45