Small fixes + add ability to un/export pins from pin_test
[matches/MCTX3420.git] / server / bbb_pin.h
1 /**
2  * @file bbb_pin.h
3  * @brief Definition of functions for controlling pins on the Beaglebone Black
4  */
5
6 #ifndef _BBB_PIN_H
7 #define _BBB_PIN_H
8
9 #include "common.h"
10
11 #include "bbb_pin_defines.h"
12
13 #if defined(_BBB) || defined(_BBB_PIN_SRC)
14 // Initialise / Deinitialise functions
15 extern bool GPIO_Export(int pin);
16 extern void GPIO_Unexport(int pin);
17
18 extern bool PWM_Export(int pin);
19 extern void PWM_Unexport(int pin);
20
21 extern bool ADC_Export(int pin);
22 extern void ADC_Unexport(int pin);
23
24 // Pin reading/setting functions
25 extern bool GPIO_Read(int pin, bool *result);
26 extern bool GPIO_Set(int pin, bool value);
27
28 extern bool ADC_Read(int id, int *value);
29
30 extern bool PWM_Set(int pin, bool polarity, long period, long duty); // period and duty are in ns
31 extern bool PWM_Stop(int pin);
32
33 #else
34 //'Empty' defines so it compiles on any platform that's not the BBB
35
36 extern bool GPIO_Export(int pin);
37 extern void GPIO_Unexport(int pin);
38
39 #define GPIO_Export(pin) true
40 #define GPIO_Unexport(pin)
41
42 #define PWM_Export(pin) true
43 #define PWM_Unexport(pin)
44
45 #define ADC_Export(pin) true
46 #define ADC_Unexport(pin)
47
48 //Hack to both zero the result field (so it's never uninitialised) and return true
49 #define GPIO_Read(pin, result) ((*(result) = 0) == 0)
50 #define GPIO_Set(pin, value) true
51
52 #define ADC_Read(id, value) ((*(value) = 0) == 0)
53
54 #define PWM_Set(pin, polarity, period, duty) true
55 #define PWM_Stop(pin) true
56
57 #endif //_BBB
58
59 #endif //_BBB_PIN_H
60
61 //EOF

UCC git Repository :: git.ucc.asn.au