Voss Connection Detection  1
Detect a connector click using realtime code on Bela hardware
SimpleGPIO.h
Go to the documentation of this file.
1 /*
2  * SimpleGPIO.h
3  *
4  * Copyright Derek Molloy, School of Electronic Engineering, Dublin City University
5  * www.eeng.dcu.ie/~molloyd/
6  *
7  * Based on Software by RidgeRun
8  * Copyright (c) 2011, RidgeRun
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  * must display the following acknowledgement:
20  * This product includes software developed by the RidgeRun.
21  * 4. Neither the name of the RidgeRun nor the
22  * names of its contributors may be used to endorse or promote products
23  * derived from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY RIDGERUN ''AS IS'' AND ANY
26  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28  * DISCLAIMED. IN NO EVENT SHALL RIDGERUN BE LIABLE FOR ANY
29  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #ifndef SIMPLEGPIO_H_
38 #define SIMPLEGPIO_H_
39 
40  /****************************************************************
41  * Constants
42  ****************************************************************/
43 
44 #define SYSFS_GPIO_DIR "/sys/class/gpio"
45 #define POLL_TIMEOUT (3 * 1000) /* 3 seconds */
46 #define MAX_BUF 64
47 #define SYSFS_OMAP_MUX_DIR "/sys/kernel/debug/omap_mux/"
48 
52 };
53 
54 enum PIN_VALUE{
55  LOW=0,
56  HIGH=1
57 };
58 
59 /****************************************************************
60  * gpio_export
61  ****************************************************************/
62 int gpio_export(unsigned int gpio);
63 int gpio_unexport(unsigned int gpio);
64 int gpio_set_dir(unsigned int gpio, PIN_DIRECTION out_flag);
65 int gpio_set_value(unsigned int gpio, PIN_VALUE value);
66 int gpio_get_value(unsigned int gpio, unsigned int *value);
67 int gpio_set_edge(unsigned int gpio, char *edge);
68 int gpio_fd_open(unsigned int gpio);
69 int gpio_fd_close(int fd);
70 int gpio_omap_mux_setup(const char *omap_pin0_name, const char *mode);
71 
72 #endif /* SIMPLEGPIO_H_ */
PIN_DIRECTION
PIN_DIRECTION
Definition: SimpleGPIO.h:49
gpio_set_value
int gpio_set_value(unsigned int gpio, PIN_VALUE value)
Definition: SimpleGPIO.cpp:115
PIN_VALUE
PIN_VALUE
Definition: SimpleGPIO.h:54
gpio_get_value
int gpio_get_value(unsigned int gpio, unsigned int *value)
Definition: SimpleGPIO.cpp:140
gpio_set_edge
int gpio_set_edge(unsigned int gpio, char *edge)
Definition: SimpleGPIO.cpp:171
gpio_set_dir
int gpio_set_dir(unsigned int gpio, PIN_DIRECTION out_flag)
Definition: SimpleGPIO.cpp:90
gpio_omap_mux_setup
int gpio_omap_mux_setup(const char *omap_pin0_name, const char *mode)
Definition: SimpleGPIO.cpp:220
HIGH
@ HIGH
Definition: SimpleGPIO.h:56
LOW
@ LOW
Definition: SimpleGPIO.h:55
gpio_export
int gpio_export(unsigned int gpio)
Definition: SimpleGPIO.cpp:49
gpio_fd_close
int gpio_fd_close(int fd)
Definition: SimpleGPIO.cpp:211
INPUT_PIN
@ INPUT_PIN
Definition: SimpleGPIO.h:50
gpio_fd_open
int gpio_fd_open(unsigned int gpio)
Definition: SimpleGPIO.cpp:193
gpio_unexport
int gpio_unexport(unsigned int gpio)
Definition: SimpleGPIO.cpp:70
OUTPUT_PIN
@ OUTPUT_PIN
Definition: SimpleGPIO.h:51