mraa  1.7.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
gpio.h
Go to the documentation of this file.
1 /*
2  * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3  * Copyright (c) 2014 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <stdio.h>
44 #include <pthread.h>
45 #include "common.h"
46 
47 #if defined(SWIGJAVA) || defined(JAVACALLBACK)
48 #include <jni.h>
49 void mraa_java_isr_callback(void *args);
50 #endif
51 
55 typedef struct _gpio* mraa_gpio_context;
56 
60 typedef enum {
66 
70 typedef enum {
76 
80 typedef enum {
86 
93 mraa_gpio_context mraa_gpio_init(int pin);
94 
101 mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
102 
110 mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
111 
122 mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (*fptr)(void*), void* args);
123 
131 mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
132 
140 mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode);
141 
149 mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir);
150 
158 mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir);
159 
167 mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
168 
176 int mraa_gpio_read(mraa_gpio_context dev);
177 
185 mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
186 
194 mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
195 
203 mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
204 
211 int mraa_gpio_get_pin(mraa_gpio_context dev);
212 
219 int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
220 
221 #ifdef __cplusplus
222 }
223 #endif
Definition: gpio.h:84
mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner)
Definition: gpio.h:64
Definition: gpio.h:74
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void(*fptr)(void *), void *args)
unsigned int mraa_boolean_t
Definition: common.h:61
Definition: gpio.h:81
Definition: gpio.h:82
mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev)
Definition: gpio.h:61
mraa_result_t mraa_gpio_close(mraa_gpio_context dev)
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir)
Definition: gpio.h:73
mraa_gpio_dir_t
Definition: gpio.h:70
mraa_gpio_mode_t
Definition: gpio.h:60
mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode)
int mraa_gpio_get_pin(mraa_gpio_context dev)
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode)
mraa_gpio_edge_t
Definition: gpio.h:80
Definition: gpio.h:72
mraa_gpio_context mraa_gpio_init_raw(int gpiopin)
struct _gpio * mraa_gpio_context
Definition: gpio.h:55
mraa_gpio_context mraa_gpio_init(int pin)
int mraa_gpio_get_pin_raw(mraa_gpio_context dev)
Definition: gpio.h:71
mraa_result_t
Definition: types.h:205
Definition: gpio.h:83
mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir)
Definition: gpio.h:62
mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value)
mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap)
int mraa_gpio_read(mraa_gpio_context dev)
Definition: gpio.h:63