mraa  2.0.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
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 {
65  MRAA_GPIOD_ACTIVE_LOW = 4,
66  MRAA_GPIOD_OPEN_DRAIN = 5,
67  MRAA_GPIOD_OPEN_SOURCE = 6,
69 
73 typedef enum {
79 
83 typedef enum {
89 
93 typedef enum {
97 
98 
102 typedef enum {
106 
107 typedef long long unsigned int mraa_timestamp_t;
108 
112 typedef struct {
113  int id;
114  mraa_timestamp_t timestamp;
116 
118 
125 mraa_gpio_context mraa_gpio_init(int pin);
126 
135 mraa_gpio_context mraa_gpio_init_multi(int pins[], int num_pins);
136 
143 mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
144 
152 mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
153 
164 mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (*fptr)(void*), void* args);
165 
174 mraa_gpio_events_t mraa_gpio_get_events(mraa_gpio_context dev);
175 
183 mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
184 
192 mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode);
193 
201 mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir);
202 
210 mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir);
211 
220 mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
221 
229 int mraa_gpio_read(mraa_gpio_context dev);
230 
239 mraa_result_t mraa_gpio_read_multi(mraa_gpio_context dev, int output_values[]);
240 
248 mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
249 
259 mraa_result_t mraa_gpio_write_multi(mraa_gpio_context dev, int input_values[]);
260 
268 mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
269 
279 DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
280 
287 int mraa_gpio_get_pin(mraa_gpio_context dev);
288 
295 int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
296 
304 mraa_result_t mraa_gpio_input_mode(mraa_gpio_context dev, mraa_gpio_input_mode_t mode);
305 
314 
315 #ifdef __cplusplus
316 }
317 #endif
Definition: gpio.h:87
mraa_result_t mraa_gpio_read_multi(mraa_gpio_context dev, int output_values[])
mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner)
mraa_gpio_events_t mraa_gpio_get_events(mraa_gpio_context dev)
Definition: gpio.h:64
#define DEPRECATED
Definition: common.h:62
Definition: gpio.h:77
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:78
Definition: gpio.h:84
Definition: gpio.h:85
mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev)
mraa_gpio_context mraa_gpio_init_multi(int pins[], int num_pins)
mraa_result_t mraa_gpio_write_multi(mraa_gpio_context dev, int input_values[])
Definition: gpio.h:61
mraa_result_t mraa_gpio_input_mode(mraa_gpio_context dev, mraa_gpio_input_mode_t mode)
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:76
mraa_gpio_dir_t
Definition: gpio.h:73
int id
Definition: gpio.h:113
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)
Definition: gpio.h:94
mraa_gpio_edge_t
Definition: gpio.h:83
Definition: gpio.h:75
mraa_gpio_context mraa_gpio_init_raw(int gpiopin)
Definition: gpio.h:95
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:74
mraa_result_t
Definition: types.h:209
Definition: gpio.h:112
Definition: gpio.h:86
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_gpio_input_mode_t
Definition: gpio.h:93
Definition: gpio.h:104
DEPRECATED mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap)
mraa_gpio_out_driver_mode_t
Definition: gpio.h:102
int mraa_gpio_read(mraa_gpio_context dev)
Definition: gpio.h:63
mraa_timestamp_t timestamp
Definition: gpio.h:114
mraa_result_t mraa_gpio_out_driver_mode(mraa_gpio_context dev, mraa_gpio_out_driver_mode_t mode)
Definition: gpio.h:103