Haojian Zhuang | 1ffecc2 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Haojian Zhuang | 1ffecc2 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | c3cf06f | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef GPIO_H |
| 8 | #define GPIO_H |
Haojian Zhuang | 1ffecc2 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 9 | |
| 10 | #define GPIO_DIR_OUT 0 |
| 11 | #define GPIO_DIR_IN 1 |
| 12 | |
| 13 | #define GPIO_LEVEL_LOW 0 |
| 14 | #define GPIO_LEVEL_HIGH 1 |
| 15 | |
Caesar Wang | 1958898 | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 16 | #define GPIO_PULL_NONE 0 |
| 17 | #define GPIO_PULL_UP 1 |
| 18 | #define GPIO_PULL_DOWN 2 |
| 19 | |
Haojian Zhuang | 1ffecc2 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 20 | typedef struct gpio_ops { |
| 21 | int (*get_direction)(int gpio); |
| 22 | void (*set_direction)(int gpio, int direction); |
| 23 | int (*get_value)(int gpio); |
| 24 | void (*set_value)(int gpio, int value); |
Caesar Wang | 1958898 | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 25 | void (*set_pull)(int gpio, int pull); |
| 26 | int (*get_pull)(int gpio); |
Haojian Zhuang | 1ffecc2 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 27 | } gpio_ops_t; |
| 28 | |
| 29 | int gpio_get_direction(int gpio); |
| 30 | void gpio_set_direction(int gpio, int direction); |
| 31 | int gpio_get_value(int gpio); |
| 32 | void gpio_set_value(int gpio, int value); |
Caesar Wang | 1958898 | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 33 | void gpio_set_pull(int gpio, int pull); |
| 34 | int gpio_get_pull(int gpio); |
Haojian Zhuang | 1ffecc2 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 35 | void gpio_init(const gpio_ops_t *ops); |
| 36 | |
Antonio Nino Diaz | c3cf06f | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 37 | #endif /* GPIO_H */ |