Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/soc/gpio.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2019-2023 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _GPIO_H_
19
#define _GPIO_H_
20
21
#include <utils/types.h>
22
23
#define GPIO_MODE_SPIO 0
24
#define GPIO_MODE_GPIO 1
25
26
#define GPIO_OUTPUT_DISABLE 0
27
#define GPIO_OUTPUT_ENABLE 1
28
29
#define GPIO_IRQ_DISABLE 0
30
#define GPIO_IRQ_ENABLE 1
31
32
#define GPIO_LOW 0
33
#define GPIO_HIGH 1
34
#define GPIO_FALLING 0
35
#define GPIO_RISING 1
36
37
#define GPIO_LEVEL 0
38
#define GPIO_EDGE 1
39
40
#define GPIO_CONFIGURED_EDGE 0
41
#define GPIO_ANY_EDGE_CHANGE 1
42
43
/*! GPIO pins (0-7 for each port). */
44
#define GPIO_PIN_0 BIT(0)
45
#define GPIO_PIN_1 BIT(1)
46
#define GPIO_PIN_2 BIT(2)
47
#define GPIO_PIN_3 BIT(3)
48
#define GPIO_PIN_4 BIT(4)
49
#define GPIO_PIN_5 BIT(5)
50
#define GPIO_PIN_6 BIT(6)
51
#define GPIO_PIN_7 BIT(7)
52
53
/*! GPIO ports (A-EE). */
54
#define GPIO_PORT_A 0
55
#define GPIO_PORT_B 1
56
#define GPIO_PORT_C 2
57
#define GPIO_PORT_D 3
58
#define GPIO_PORT_E 4
59
#define GPIO_PORT_F 5
60
#define GPIO_PORT_G 6
61
#define GPIO_PORT_H 7
62
#define GPIO_PORT_I 8
63
#define GPIO_PORT_J 9
64
#define GPIO_PORT_K 10
65
#define GPIO_PORT_L 11
66
#define GPIO_PORT_M 12
67
#define GPIO_PORT_N 13
68
#define GPIO_PORT_O 14
69
#define GPIO_PORT_P 15
70
#define GPIO_PORT_Q 16
71
#define GPIO_PORT_R 17
72
#define GPIO_PORT_S 18
73
#define GPIO_PORT_T 19
74
#define GPIO_PORT_U 20
75
#define GPIO_PORT_V 21
76
#define GPIO_PORT_W 22
77
#define GPIO_PORT_X 23
78
#define GPIO_PORT_Y 24
79
#define GPIO_PORT_Z 25
80
#define GPIO_PORT_AA 26
81
#define GPIO_PORT_BB 27
82
#define GPIO_PORT_CC 28
83
#define GPIO_PORT_DD 29
84
#define GPIO_PORT_EE 30
85
86
void gpio_config(u32 port, u32 pins, int mode);
87
void gpio_output_enable(u32 port, u32 pins, int enable);
88
void gpio_direction_input(u32 port, u32 pins);
89
void gpio_direction_output(u32 port, u32 pins, int high);
90
void gpio_write(u32 port, u32 pins, int high);
91
int gpio_read(u32 port, u32 pins);
92
void gpio_set_debounce(u32 port, u32 pins, u32 ms);
93
int gpio_interrupt_status(u32 port, u32 pins);
94
void gpio_interrupt_enable(u32 port, u32 pins, int enable);
95
void gpio_interrupt_level(u32 port, u32 pins, int high, int edge, int delta);
96
u32 gpio_get_bank_irq_id(u32 port);
97
98
#endif
99
100