1 /*
2  * Copyright (c) 2020-2021, Bluetrum Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author            Notes
8  * 2020-11-19     greedyhao         first version
9  */
10 
11 #ifndef DRV_GPIO_H__
12 #define DRV_GPIO_H__
13 
14 #include "drv_common.h"
15 #include "board.h"
16 
17 #define __AB32_PORT(port)   GPIO##port
18 #define __AB32_GET_PIN_A(PIN)  PIN
19 #define __AB32_GET_PIN_B(PIN)  8 + PIN
20 #define __AB32_GET_PIN_E(PIN)  13 + PIN
21 #define __AB32_GET_PIN_F(PIN)  21 + PIN
22 
23 #define WAKEUP_INT_ENABLE   16
24 #define WAKEUP_CRICUIT_0    0  // PA7
25 #define WAKEUP_CRICUIT_1    1  // PB1
26 #define WAKEUP_CRICUIT_2    2  // PB2
27 #define WAKEUP_CRICUIT_3    3  // PB3
28 #define WAKEUP_CRICUIT_4    4  // PB4
29 #define WAKEUP_CRICUIT_5    5  // WKO (RTC)
30 #define WAKEUP_CRICUIT_6    6  // Falling edge for other GPIOs
31 #define WAKEUP_CRICUIT_7    7  // Rising edge for other GPIOs
32 #define WAKEUP_EDGE_SELECT_0 16
33 #define WAKEUP_EDGE_SELECT_1 17
34 #define WAKEUP_EDGE_SELECT_2 18
35 #define WAKEUP_EDGE_SELECT_3 19
36 #define WAKEUP_EDGE_SELECT_4 20
37 #define WAKEUP_EDGE_SELECT_5 21
38 #define WAKEUP_EDGE_SELECT_6 22
39 #define WAKEUP_EDGE_SELECT_7 23
40 
41 /* structure to store IRQ handler and arguments per pin */
42 struct ab32_pin_irq
43 {
44     void (*hdr)(void *args);
45     void *args;
46 };
47 
48 int rt_hw_pin_init(void);
49 
50 #endif // DRV_GPIO_H__
51