b0b7c5b60808f29b1576e0110006563d2363f2fa
[platform/core/api/peripheral-io.git] / src / interface / include / gpio.h
1 /*
2  * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __GPIO_H__
18 #define __GPIO_H__
19
20 #define SYSFS_GPIO_DIR "/sys/class/gpio"
21 #define GPIO_BUFFER_MAX 64
22
23 typedef enum {
24         GPIO_DIRECTION_IN = 0,
25         GPIO_DIRECTION_OUT_HIGH = 1,
26         GPIO_DIRECTION_OUT_LOW = 2,
27 } gpio_direction_e;
28
29 typedef enum {
30         GPIO_EDGE_NONE = 0,
31         GPIO_EDGE_RISING = 1,
32         GPIO_EDGE_FALLING = 2,
33         GPIO_EDGE_BOTH = 3,
34 } gpio_edge_e;
35
36 int gpio_open(int gpiopin);
37 int gpio_close(int gpiopin);
38 int gpio_set_edge_mode(int gpiopin, gpio_edge_e edge);
39 int gpio_get_edge_mode(int gpiopin, gpio_edge_e *edge);
40 int gpio_set_direction(int gpiopin, gpio_direction_e dir);
41 int gpio_get_direction(int gpiopin, gpio_direction_e *dir);
42 int gpio_write(int gpiopin, int value);
43 int gpio_read(int gpiopin, int *value);
44
45 int gpio_open_isr(int gpiopin);
46 int gpio_close_isr(int file_hndl);
47 int gpio_read_isr(void *fdset, char *rev_buf, int length);
48 #endif/*__GPIO_H__*/