forked from uli/allwinner-bare-metal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathports.h
63 lines (52 loc) · 1.51 KB
/
ports.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
// Port access struct
struct port_registers {
uint32_t cfg0;
uint32_t cfg1;
uint32_t cfg2;
uint32_t cfg3;
uint32_t data;
uint32_t drv0;
uint32_t drv1;
uint32_t pul0;
uint32_t pul1;
};
struct port_irq_registers {
uint32_t cfg0;
uint32_t cfg1;
uint32_t cfg2;
uint32_t cfg3;
uint32_t ctl;
uint32_t status;
uint32_t deb;
};
// The PORT registers base address.
#define PIO_BASE 0x01C20800
#define PORTA PIO_BASE + 0 * 0x24
#define PORTC PIO_BASE + 2 * 0x24
#define PORTD PIO_BASE + 3 * 0x24
#define PORTE PIO_BASE + 4 * 0x24
#define PORTF PIO_BASE + 5 * 0x24
#define PORTG PIO_BASE + 6 * 0x24
#define PORTL 0x01F02C00
#define PIO_PORT(n) ((n) == 7 ? PORTL : PIO_BASE + (n) * 0x24)
#define PIO_PULL_OFF 0
#define PIO_PULL_UP 1
#define PIO_PULL_DOWN 2
void set_pin_mode(uint32_t port_addr, uint32_t pin, uint32_t mode);
void set_pin_data(uint32_t port_addr, uint32_t pin, uint32_t data);
int get_pin_data(uint32_t port_addr, uint32_t pin);
void set_pin_drive(uint32_t port_addr, uint32_t pin, uint32_t strength);
void set_pin_pull(uint32_t port_addr, uint32_t pin, uint32_t pull);
void gpio_irq_set_trigger(uint32_t port_addr, int pin, uint8_t mode);
void gpio_irq_enable(uint32_t port_addr, int pin, int enable);
void gpio_irq_ack(uint32_t port_addr);
void gpio_init();
#define GPIO_MODE_EINT 6
#define GPIO_EINT_NEGEDGE 1
#ifdef __cplusplus
}
#endif