gpio.h 881 Bytes
Newer Older
Haojian Zhuang's avatar
Haojian Zhuang committed
1
2
3
/*
 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
Haojian Zhuang's avatar
Haojian Zhuang committed
5
6
 */

7
8
#ifndef GPIO_H
#define GPIO_H
Haojian Zhuang's avatar
Haojian Zhuang committed
9
10
11
12
13
14
15

#define GPIO_DIR_OUT		0
#define GPIO_DIR_IN		1

#define GPIO_LEVEL_LOW		0
#define GPIO_LEVEL_HIGH		1

16
17
18
19
#define GPIO_PULL_NONE		0
#define GPIO_PULL_UP		1
#define GPIO_PULL_DOWN		2

Haojian Zhuang's avatar
Haojian Zhuang committed
20
21
22
23
24
typedef struct gpio_ops {
	int (*get_direction)(int gpio);
	void (*set_direction)(int gpio, int direction);
	int (*get_value)(int gpio);
	void (*set_value)(int gpio, int value);
25
26
	void (*set_pull)(int gpio, int pull);
	int (*get_pull)(int gpio);
Haojian Zhuang's avatar
Haojian Zhuang committed
27
28
29
30
31
32
} gpio_ops_t;

int gpio_get_direction(int gpio);
void gpio_set_direction(int gpio, int direction);
int gpio_get_value(int gpio);
void gpio_set_value(int gpio, int value);
33
34
void gpio_set_pull(int gpio, int pull);
int gpio_get_pull(int gpio);
Haojian Zhuang's avatar
Haojian Zhuang committed
35
36
void gpio_init(const gpio_ops_t *ops);

37
#endif /* GPIO_H */