Merge pull request #85 from Callum-/dilatometer
[matches/MCTX3420.git] / server / bbb_pin_defines.h
1 /**
2  * @file bbb_pin_defines.h
3  * @brief Defines pins on Beaglebone Black
4  */
5
6 #ifndef _BBB_PIN_DEFINES_H
7 #define _BBB_PIN_DEFINES_H
8
9 /** The number of expansion pins on the BBB **/
10 #define BBB_PIN_COUNT 92
11
12 /** GPIO0 defines **/
13 #define GPIO0_1 1
14 #define GPIO0_2 2 // Used for PWM
15 #define GPIO0_3 3 // Used for PWM
16 #define GPIO0_4 4 
17 #define GPIO0_5 5
18 #define GPIO0_6 6
19 #define GPIO0_7 7
20 #define GPIO0_8 8
21 #define GPIO0_9 9
22 #define GPIO0_10 10
23 #define GPIO0_11 11
24 #define GPIO0_12 12
25 #define GPIO0_13 13
26 #define GPIO0_14 14
27 #define GPIO0_15 15
28 #define GPIO0_16 16
29 #define GPIO0_17 17
30 #define GPIO0_18 18
31 #define GPIO0_19 19
32 #define GPIO0_20 20
33 #define GPIO0_21 21
34 #define GPIO0_22 22
35 #define GPIO0_23 23
36 #define GPIO0_24 24
37 #define GPIO0_25 25
38 #define GPIO0_26 26
39 #define GPIO0_27 27
40 #define GPIO0_28 28
41 #define GPIO0_29 29
42 #define GPIO0_30 30
43 #define GPIO0_31 31
44 #define GPIO0_32 32
45
46 /** GPIO1 defines **/
47
48 #define GPIO1_1 33
49 #define GPIO1_2 34
50 #define GPIO1_3 35
51 #define GPIO1_4 36
52 #define GPIO1_5 37
53 #define GPIO1_6 38
54 #define GPIO1_7 39
55 #define GPIO1_8 40
56 #define GPIO1_9 41
57 #define GPIO1_10 42
58 #define GPIO1_11 43
59 #define GPIO1_12 44
60 #define GPIO1_13 45
61 #define GPIO1_14 46
62 #define GPIO1_15 47
63 #define GPIO1_16 48
64 #define GPIO1_17 49
65 #define GPIO1_18 50
66 #define GPIO1_19 51
67 #define GPIO1_20 52
68 #define GPIO1_21 53
69 #define GPIO1_22 54
70 #define GPIO1_23 55
71 #define GPIO1_24 56
72 #define GPIO1_25 57
73 #define GPIO1_26 58
74 #define GPIO1_27 59
75 #define GPIO1_28 60
76 #define GPIO1_29 61
77 #define GPIO1_30 62
78 #define GPIO1_31 63
79 #define GPIO1_32 64
80
81 /** GPIO2 defines **/
82
83 #define GPIO2_1 65
84 #define GPIO2_2 66
85 #define GPIO2_3 67
86 #define GPIO2_4 68
87 #define GPIO2_5 69
88 #define GPIO2_6 70
89 #define GPIO2_7 71
90 #define GPIO2_8 72
91 #define GPIO2_9 73
92 #define GPIO2_10 74
93 #define GPIO2_11 75
94 #define GPIO2_12 76
95 #define GPIO2_13 77
96 #define GPIO2_14 78
97 #define GPIO2_15 79
98 #define GPIO2_16 80
99 #define GPIO2_17 81
100 #define GPIO2_18 82
101 #define GPIO2_19 83
102 #define GPIO2_20 84
103 #define GPIO2_21 85
104 #define GPIO2_22 86
105 #define GPIO2_23 87
106 #define GPIO2_24 88
107 #define GPIO2_25 89
108 #define GPIO2_26 90
109 #define GPIO2_27 91
110 #define GPIO2_28 92
111 #define GPIO2_29 93
112 #define GPIO2_30 94
113 #define GPIO2_31 95
114 #define GPIO2_32 96
115
116 /** Export path **/
117 #define GPIO_DEVICE_PATH "/sys/class/gpio"
118
119 /** Number of useable GPIO pins **/
120 #define GPIO_NUM_PINS 43
121 /** The max usable GPIO number **/
122 #define GPIO_MAX_NUMBER 115
123
124 /* Luts */
125 extern const unsigned char g_pin_gpio_to_index[GPIO_MAX_NUMBER+1];
126 extern const unsigned char g_pin_index_to_gpio[GPIO_NUM_PINS];
127
128 #define ADC_BITS 12
129 #define ADC_DIGITS 5
130 #define ADC0 0
131 #define ADC1 1
132 #define ADC2 2
133 #define ADC3 3
134 #define ADC4 4
135 #define ADC5 5
136 #define ADC6 6
137 #define ADC7 7
138 /** The maximum voltage input to the ADC **/
139 #define ADC_VOLTAGE_MAX 1800
140 /** The maximum raw value from the ADC **/
141 #define ADC_RAW_MAX (2 << ADC_BITS)
142 /** Converts the raw ADC value to a voltage in millivolts **/
143 #define ADC_TO_MVOLTS(x) ((double)((x)/2 << ADC_BITS) * (double)ADC_VOLTAGE_MAX)
144
145 /** Number of ADC pins **/
146 #define ADC_NUM_PINS 8
147 /** The path to the ADCs on the BBB **/
148 #define ADC_DEVICE_PATH "/sys/bus/iio/devices/iio:device0/"
149
150 /** PWM names to sysfs numbers **/
151 #define EHRPWM0A 0 //P9_22
152 #define EHRPWM0B 1 //P9_21 - period paired with EHRPWM0A
153 #define EHRPWM1A 3 //P9_14
154 #define EHRPWM1B 4 //P9_16 - period paired with EHRPWM1A
155 #define ECAP0    2 //P9_42
156 #define ECAP2    7 //P9_28
157 #define EHRPWM2A 5 //P8_19
158 #define EHRPWM2B 6 //P8_13 - period paired with EHRPWM2A
159
160 /** Number of PWM pins **/
161 #define PWM_NUM_PINS 8
162
163 /** Path to PWM sysfs **/
164 #define PWM_DEVICE_PATH "/sys/class/pwm"
165
166 #endif //_BBB_PIN_DEFINES_H
167
168

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