mraa  0.6.0
Low Level Skeleton Library for Communication on GNU/Linux platforms
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator 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 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #ifdef SWIGPYTHON
45 #include <Python.h>
46 #endif
47 
48 #include <stdio.h>
49 #include <pthread.h>
50 
51 #include "common.h"
52 
56 typedef struct _gpio* mraa_gpio_context;
57 
61 typedef enum {
66 } gpio_mode_t;
67 
71 typedef enum {
76 } gpio_dir_t;
77 
81 typedef enum {
86 } gpio_edge_t;
87 
94 mraa_gpio_context mraa_gpio_init(int pin);
95 
102 mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
103 
111 mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode);
112 
123 mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t edge, void (*fptr)(void *), void * args);
124 
132 mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
133 
141 mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode);
142 
150 mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir);
151 
159 mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
160 
168 int mraa_gpio_read(mraa_gpio_context dev);
169 
177 mraa_result_t mraa_gpio_write(mraa_gpio_context dev, int value);
178 
186 mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
187 
195 mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
196 
203 int mraa_gpio_get_pin(mraa_gpio_context dev);
204 
211 int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
212 
213 #ifdef __cplusplus
214 }
215 #endif
mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner)
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode)
Definition: gpio.h:62
unsigned int mraa_boolean_t
Definition: common.h:44
mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev)
Definition: gpio.h:65
Definition: gpio.h:85
gpio_mode_t
Definition: gpio.h:61
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir)
mraa_result_t mraa_gpio_close(mraa_gpio_context dev)
Definition: gpio.h:83
Definition: gpio.h:63
Definition: gpio.h:84
mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode)
gpio_dir_t
Definition: gpio.h:71
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t edge, void(*fptr)(void *), void *args)
int mraa_gpio_get_pin(mraa_gpio_context dev)
Definition: gpio.h:72
mraa_gpio_context mraa_gpio_init_raw(int gpiopin)
Definition: gpio.h:75
struct _gpio * mraa_gpio_context
Definition: gpio.h:56
mraa_gpio_context mraa_gpio_init(int pin)
int mraa_gpio_get_pin_raw(mraa_gpio_context dev)
mraa_result_t
Definition: types.h:145
Definition: gpio.h:73
gpio_edge_t
Definition: gpio.h:81
Definition: gpio.h:82
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)
Definition: gpio.h:74
int mraa_gpio_read(mraa_gpio_context dev)
Definition: gpio.h:64