Tizen RT Public API  v1.1 D4
iotbus_gpio.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 
31 #ifndef IOTBUS_GPIO_H_
32 #define IOTBUS_GPIO_H_
33 
42 typedef enum {
43  IOTBUS_GPIO_DRIVE_PULLUP = 0, /* Resistive High */
44  IOTBUS_GPIO_DRIVE_PULLDOWN = 1, /* Resistive Low */
45  IOTBUS_GPIO_DRIVE_FLOAT = 2,
47 
56 typedef enum {
57  IOTBUS_GPIO_DIRECTION_NONE = 0,
58  IOTBUS_GPIO_DIRECTION_OUT = 1, /* Output. A Mode can also be set */
59  IOTBUS_GPIO_DIRECTION_IN = 2, /* Input */
61 
71 typedef enum {
72  IOTBUS_GPIO_EDGE_NONE = 0, /* No interrupt on Gpio */
73  IOTBUS_GPIO_EDGE_BOTH = 1, /* Interrupt on rising & falling */
74  IOTBUS_GPIO_EDGE_RISING = 2, /* Interrupt on rising only */
75  IOTBUS_GPIO_EDGE_FALLING = 3 /* Interrupt on falling only */
77 
78 struct _iotbus_gpio_s;
79 
83 typedef struct _iotbus_gpio_s *iotbus_gpio_context_h;
84 
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88 
89 typedef void (*gpio_isr_cb)(void *user_data);
90 
100 
110 
121 
132 
143 
159 int iotbus_gpio_register_cb(iotbus_gpio_context_h dev, iotbus_gpio_edge_e edge, gpio_isr_cb isr_cb, void *user_data);
160 
170 
181 
191 int iotbus_gpio_write(iotbus_gpio_context_h dev, int value);
192 
203 
213 
224 
235 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif /* IOTBUS_GPIO_H_ */
241  // end of GPIO group
int iotbus_gpio_get_edge_mode(iotbus_gpio_context_h dev, iotbus_gpio_edge_e *edge)
gets a edge mode of the gpio.
int iotbus_gpio_set_direction(iotbus_gpio_context_h dev, iotbus_gpio_direction_e dir)
sets gpio direction.
int iotbus_gpio_close(iotbus_gpio_context_h dev)
closes the gpio_context.
int iotbus_gpio_get_pin(iotbus_gpio_context_h dev)
gets a pin number of the gpio.
int iotbus_gpio_unregister_cb(iotbus_gpio_context_h dev)
unregisters event handler callback for interrupt.
iotbus_gpio_edge_e
Enumeration of Gpio edge type for interrupt.
Definition: iotbus_gpio.h:71
int iotbus_gpio_get_drive_mode(iotbus_gpio_context_h dev, iotbus_gpio_drive_e *drive)
gets a drive mode of the gpio.
int iotbus_gpio_set_edge_mode(iotbus_gpio_context_h dev, iotbus_gpio_edge_e edge)
sets the edge mode on the gpio.
iotbus_gpio_context_h iotbus_gpio_open(int gpiopin)
initializes gpio_context based on gpio pin.
int iotbus_gpio_write(iotbus_gpio_context_h dev, int value)
writes to the gpio value.
int iotbus_gpio_get_direction(iotbus_gpio_context_h dev, iotbus_gpio_direction_e *dir)
gets a direction of the gpio.
iotbus_gpio_drive_e
Enumeration of Gpio output mode.
Definition: iotbus_gpio.h:42
int iotbus_gpio_register_cb(iotbus_gpio_context_h dev, iotbus_gpio_edge_e edge, gpio_isr_cb isr_cb, void *user_data)
registers event handler callback for interrupt.
struct _iotbus_gpio_s * iotbus_gpio_context_h
Pointer definition to the internal struct iotbus_gpio_s.
Definition: iotbus_gpio.h:83
iotbus_gpio_direction_e
Enumeration of Gpio direction options.
Definition: iotbus_gpio.h:56
int iotbus_gpio_read(iotbus_gpio_context_h dev)
reads the gpio value.
int iotbus_gpio_set_drive_mode(iotbus_gpio_context_h dev, iotbus_gpio_drive_e drive)
sets gpio output mode.