Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
gpio.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2012 Ben Croston / 2012-2013 Eric PTAK
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22 
23 #define SETUP_OK 0
24 #define SETUP_DEVMEM_FAIL 1
25 #define SETUP_MALLOC_FAIL 2
26 #define SETUP_MMAP_FAIL 3
27 
28 #define GPIO_COUNT 54
29 
30 #define IN 0
31 #define OUT 1
32 #define ALT5 2
33 #define ALT4 3
34 #define ALT0 4
35 #define ALT1 5
36 #define ALT2 6
37 #define ALT3 7
38 #define PWM 8
39 
40 #define LOW 0
41 #define HIGH 1
42 
43 #define PUD_OFF 0
44 #define PUD_DOWN 1
45 #define PUD_UP 2
46 
47 #define RATIO 1
48 #define ANGLE 2
49 
50 struct pulse {
51  int type;
52  float value;
53 };
54 
55 int setup(void);
56 int get_function(int gpio);
57 void set_function(int gpio, int function, int pud);
58 int input(int gpio);
59 void output(int gpio, int value);
60 void outputSequence(int gpio, int period, char* sequence);
61 struct pulse* getPulse(int gpio);
62 void pulseMilli(int gpio, int up, int down);
63 void pulseMilliRatio(int gpio, int width, float ratio);
64 void pulseMicro(int gpio, int up, int down);
65 void pulseMicroRatio(int gpio, int width, float ratio);
66 void pulseAngle(int gpio, float angle);
67 void pulseRatio(int gpio, float ratio);
68 void enablePWM(int gpio);
69 void disablePWM(int gpio);
70 int isPWMEnabled(int gpio);
71 
72 void cleanup(void);
73 
void output(int gpio, int value)
Definition: gpio.c:163
int type
Definition: gpio.h:51
void pulseMicroRatio(int gpio, int width, float ratio)
Definition: gpio.c:262
void cleanup(void)
Definition: gpio.c:332
void set_function(int gpio, int function, int pud)
Definition: gpio.c:121
void pulseRatio(int gpio, float ratio)
Definition: gpio.c:278
int get_function(int gpio)
Definition: gpio.c:139
int isPWMEnabled(int gpio)
Definition: gpio.c:327
void pulseAngle(int gpio, float angle)
Definition: gpio.c:269
void pulseMilli(int gpio, int up, int down)
Definition: gpio.c:231
void outputSequence(int gpio, int period, char *sequence)
Definition: gpio.c:178
int input(int gpio)
Definition: gpio.c:153
void disablePWM(int gpio)
Definition: gpio.c:314
float value
Definition: gpio.h:52
struct pulse * getPulse(int gpio)
Definition: gpio.c:286
void pulseMilliRatio(int gpio, int width, float ratio)
Definition: gpio.c:243
void pulseMicro(int gpio, int up, int down)
Definition: gpio.c:250
int setup(void)
Definition: cambot.py:93
void enablePWM(int gpio)
Definition: gpio.c:300
Definition: gpio.h:50