Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Loading...
Searching...
No Matches
include
GPIOcontrol.h
1
/*
2
* SimpleGPIO.h
3
*
4
* Copyright Derek Molloy, School of Electronic Engineering, Dublin City University
5
* www.derekmolloy.ie
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
#ifdef __cplusplus
41
extern
"C"
42
{
43
#endif
44
/****************************************************************
45
* Constants
46
****************************************************************/
47
48
#define SYSFS_GPIO_DIR "/sys/class/gpio"
49
#define SYSFS_LED_DIR "/sys/class/leds"
50
#define POLL_TIMEOUT (3 * 1000)
/* 3 seconds */
51
#define MAX_BUF 128
52
53
enum
PIN_DIRECTION{
54
INPUT_PIN=0,
55
OUTPUT_PIN=1
56
};
57
58
enum
PIN_VALUE{
59
LOW=0,
60
HIGH=1
61
};
62
63
/****************************************************************
64
* gpio_functions
65
****************************************************************/
66
int
gpio_setup(
unsigned
int
gpio,
int
out_flag);
67
int
gpio_export(
unsigned
int
gpio);
68
int
gpio_unexport(
unsigned
int
gpio);
69
int
gpio_set_dir(
unsigned
int
gpio,
int
out_flag);
70
int
gpio_set_value(
unsigned
int
gpio,
int
value);
71
int
gpio_get_value(
unsigned
int
gpio,
unsigned
int
*value);
72
int
gpio_set_edge(
unsigned
int
gpio,
char
*edge);
73
int
gpio_fd_open(
unsigned
int
gpio,
int
writeFlag);
74
int
gpio_fd_close(
int
fd);
75
int
gpio_write(
int
fd,
int
value);
76
int
gpio_read(
int
fd,
unsigned
int
*value);
77
int
gpio_dismiss(
int
fd,
unsigned
int
gpio);
78
79
int
led_set_trigger(
unsigned
int
lednum,
const
char
*trigger);
80
81
#ifdef __cplusplus
82
}
83
#endif
84
85
#endif
/* SIMPLEGPIO_H_ */
Generated on
for Bela by
1.16.0