root / trunk / code / lib / include / libdragonfly / dio.h @ 88
History | View | Annotate | Download (6.53 KB)
1 |
/**
|
---|---|
2 |
* @file dio.h
|
3 |
* @brief Definitions for digital input / output
|
4 |
*
|
5 |
* This file contains definitions and functions for dealing
|
6 |
* with digital input and output.
|
7 |
*
|
8 |
* @author Colony Project, CMU Robotics Club
|
9 |
* Based on Tom Lauwer's Firefly Library
|
10 |
**/
|
11 |
|
12 |
#ifndef _DIO_H
|
13 |
#define _DIO_H
|
14 |
|
15 |
/*
|
16 |
these are ALL the pins
|
17 |
don't use unless you know what you're doing
|
18 |
*/
|
19 |
|
20 |
/*
|
21 |
DIO pins on new dragonfly boards are shown below:
|
22 |
-----------------------------------------------
|
23 |
| _PIN_E6 | _PIN_E7 | _PIN_D2 | _PIN_D3 | VCC |
|
24 |
-----------------------------------------------
|
25 |
| _PIN_E2 | _PIN_E3 | _PIN_E4 | _PIN_E5 | GND |
|
26 |
-----------------------------------------------
|
27 |
*/
|
28 |
|
29 |
/** @brief Port A **/
|
30 |
#define _PORT_A 1 |
31 |
/** @brief Port B **/
|
32 |
#define _PORT_B 2 |
33 |
/** @brief Port C **/
|
34 |
#define _PORT_C 3 |
35 |
/** @brief Port D **/
|
36 |
#define _PORT_D 4 |
37 |
/** @brief Port E **/
|
38 |
#define _PORT_E 5 |
39 |
/** @brief Port F **/
|
40 |
#define _PORT_F 6 |
41 |
/** @brief Port G **/
|
42 |
#define _PORT_G 7 |
43 |
|
44 |
/** @brief Pin A0 **/
|
45 |
#define _PIN_A0 8 |
46 |
/** @brief Pin A1 **/
|
47 |
#define _PIN_A1 9 |
48 |
/** @brief Pin A2 **/
|
49 |
#define _PIN_A2 10 |
50 |
/** @brief Pin A3 **/
|
51 |
#define _PIN_A3 11 |
52 |
/** @brief Pin A4 **/
|
53 |
#define _PIN_A4 12 |
54 |
/** @brief Pin A5 **/
|
55 |
#define _PIN_A5 13 |
56 |
/** @brief Pin A6 **/
|
57 |
#define _PIN_A6 14 |
58 |
/** @brief Pin A7 **/
|
59 |
#define _PIN_A7 15 |
60 |
|
61 |
/** @brief Pin B0 **/
|
62 |
#define _PIN_B0 16 |
63 |
/** @brief Pin B1 **/
|
64 |
#define _PIN_B1 17 |
65 |
/** @brief Pin B2 **/
|
66 |
#define _PIN_B2 18 |
67 |
/** @brief Pin B3 **/
|
68 |
#define _PIN_B3 19 |
69 |
/** @brief Pin B4 **/
|
70 |
#define _PIN_B4 20 |
71 |
/** @brief Pin B5 **/
|
72 |
#define _PIN_B5 21 |
73 |
/** @brief Pin B6 **/
|
74 |
#define _PIN_B6 22 |
75 |
/** @brief Pin B7 **/
|
76 |
#define _PIN_B7 23 |
77 |
|
78 |
/** @brief Pin C0 **/
|
79 |
#define _PIN_C0 24 |
80 |
/** @brief Pin C1 **/
|
81 |
#define _PIN_C1 25 |
82 |
/** @brief Pin C2 **/
|
83 |
#define _PIN_C2 26 |
84 |
/** @brief Pin C3 **/
|
85 |
#define _PIN_C3 27 |
86 |
/** @brief Pin C4 **/
|
87 |
#define _PIN_C4 28 |
88 |
/** @brief Pin C5 **/
|
89 |
#define _PIN_C5 29 |
90 |
/** @brief Pin C6 **/
|
91 |
#define _PIN_C6 30 |
92 |
/** @brief Pin C7 **/
|
93 |
#define _PIN_C7 31 |
94 |
|
95 |
/** @brief Pin D0 **/
|
96 |
#define _PIN_D0 32 // pin DIO6 on new dragonfly boards |
97 |
/** @brief Pin D1 **/
|
98 |
#define _PIN_D1 33 // pin DIO7 |
99 |
/** @brief Pin D2 **/
|
100 |
#define _PIN_D2 34 |
101 |
/** @brief Pin D3 **/
|
102 |
#define _PIN_D3 35 |
103 |
/** @brief Pin D4 **/
|
104 |
#define _PIN_D4 36 |
105 |
/** @brief Pin D5 **/
|
106 |
#define _PIN_D5 37 |
107 |
/** @brief Pin D6 **/
|
108 |
#define _PIN_D6 38 |
109 |
/** @brief Pin D7 **/
|
110 |
#define _PIN_D7 39 |
111 |
|
112 |
/** @brief Pin E0 **/
|
113 |
#define _PIN_E0 40 |
114 |
/** @brief Pin E1 **/
|
115 |
#define _PIN_E1 41 |
116 |
/** @brief Pin E2 **/
|
117 |
#define _PIN_E2 42 // pin DIO0 |
118 |
/** @brief Pin E3 **/
|
119 |
#define _PIN_E3 43 // pin DIO1 |
120 |
/** @brief Pin E4 **/
|
121 |
#define _PIN_E4 44 // pin DIO2 |
122 |
/** @brief Pin E5 **/
|
123 |
#define _PIN_E5 45 // pin DIO3 |
124 |
/** @brief Pin E6 **/
|
125 |
#define _PIN_E6 46 // pin DIO4 |
126 |
/** @brief Pin E7 **/
|
127 |
#define _PIN_E7 47 // pin DIO5 |
128 |
|
129 |
/** @brief Pin F0 **/
|
130 |
#define _PIN_F0 48 |
131 |
/** @brief Pin F1 **/
|
132 |
#define _PIN_F1 49 |
133 |
/** @brief Pin F2 **/
|
134 |
#define _PIN_F2 50 |
135 |
/** @brief Pin F3 **/
|
136 |
#define _PIN_F3 51 |
137 |
/** @brief Pin F4 **/
|
138 |
#define _PIN_F4 52 |
139 |
/** @brief Pin F5 **/
|
140 |
#define _PIN_F5 53 |
141 |
/** @brief Pin F6 **/
|
142 |
#define _PIN_F6 54 |
143 |
/** @brief Pin F7 **/
|
144 |
#define _PIN_F7 55 |
145 |
|
146 |
/** @brief Pin G0 **/
|
147 |
#define _PIN_G0 56 |
148 |
/** @brief Pin WR **/
|
149 |
#define _PIN_WR 56 |
150 |
/** @brief Pin G1 **/
|
151 |
#define _PIN_G1 57 |
152 |
/** @brief Pin RD **/
|
153 |
#define _PIN_RD 57 |
154 |
/** @brief Pin G2 **/
|
155 |
#define _PIN_G2 58 |
156 |
/** @brief Pin ALE **/
|
157 |
#define _PIN_ALE 58 |
158 |
/** @brief Pin G3 **/
|
159 |
#define _PIN_G3 59 |
160 |
/** @brief Pin TOSC2 **/
|
161 |
#define _PIN_TOSC2 59 |
162 |
/** @brief Pin G4 **/
|
163 |
#define _PIN_G4 60 |
164 |
/** @brief Pin TOSC1 **/
|
165 |
#define _PIN_TOSC1 60 |
166 |
//#define _PIN_G5 61
|
167 |
//#define _PIN_G6 62
|
168 |
//#define _PIN_G7 63
|
169 |
|
170 |
/*
|
171 |
These are the header pins (the ones you can connect things to)
|
172 |
Feel free to use these
|
173 |
*/
|
174 |
|
175 |
/**
|
176 |
* @addtogroup dio
|
177 |
* @{
|
178 |
**/
|
179 |
/** @brief Pin A0 **/
|
180 |
#define PIN_A0 8 |
181 |
/** @brief Pin A1 **/
|
182 |
#define PIN_A1 9 |
183 |
/** @brief Pin A2 **/
|
184 |
#define PIN_A2 10 |
185 |
/** @brief Pin A3 **/
|
186 |
#define PIN_A3 11 |
187 |
/** @brief Pin A4 **/
|
188 |
#define PIN_A4 12 |
189 |
/** @brief Pin A5 **/
|
190 |
#define PIN_A5 13 |
191 |
/** @brief Pin A6 **/
|
192 |
#define PIN_A6 14 |
193 |
/** @brief Pin A7 **/
|
194 |
#define PIN_A7 15 |
195 |
|
196 |
/** @brief Pin SS **/
|
197 |
#define PIN_SS 16 |
198 |
/** @brief Pin SCK **/
|
199 |
#define PIN_SCK 17 |
200 |
/** @brief Pin MOSI **/
|
201 |
#define PIN_MOSI 18 |
202 |
/** @brief Pin MISO **/
|
203 |
#define PIN_MISO 19 |
204 |
/** @brief LCD Command Pin **/
|
205 |
#define PIN_LCD_COMMAND 20 |
206 |
|
207 |
/** @brief Pin C0 **/
|
208 |
#define PIN_C0 24 |
209 |
/** @brief Pin C1 **/
|
210 |
#define PIN_C1 25 |
211 |
/** @brief Pin C2 **/
|
212 |
#define PIN_C2 26 |
213 |
/** @brief Pin C3 **/
|
214 |
#define PIN_C3 27 |
215 |
/** @brief Pin C4 **/
|
216 |
#define PIN_C4 28 |
217 |
/** @brief Pin C5 **/
|
218 |
#define PIN_C5 29 |
219 |
/** @brief Pin C6 **/
|
220 |
#define PIN_C6 30 |
221 |
/** @brief Pin C7 **/
|
222 |
#define PIN_C7 31 |
223 |
|
224 |
/** @brief Pin SCL **/
|
225 |
#define PIN_SCL 32 |
226 |
/** @brief Pin SDA **/
|
227 |
#define PIN_SDA 33 |
228 |
|
229 |
/** @brief Pin RX0 **/
|
230 |
#define PIN_RX0 40 |
231 |
/** @brief Pin TX0 **/
|
232 |
#define PIN_TX0 41 |
233 |
/** @brief LCD Reset Pin **/
|
234 |
#define PIN_LCD_RESET 42 |
235 |
/** @brief Pin E6 **/
|
236 |
#define PIN_E6 46 |
237 |
/** @brief Pin EXT_DIO1 **/
|
238 |
#define PIN_EXT_DIO1 46 |
239 |
/** @brief Pin E7 **/
|
240 |
#define PIN_E7 47 |
241 |
/** @brief Pin EXT_DIO2 **/
|
242 |
#define PIN_EXT_DIO2 48 |
243 |
|
244 |
/** @brief Pin AN0 **/
|
245 |
#define PIN_AN0 48 |
246 |
/** @brief Pin ADC0 **/
|
247 |
#define PIN_ADC0 48 |
248 |
/** @brief Pin AN1 **/
|
249 |
#define PIN_AN1 49 |
250 |
/** @brief Pin ADC1 **/
|
251 |
#define PIN_ADC1 49 |
252 |
/** @brief Pin AN2 **/
|
253 |
#define PIN_AN2 50 |
254 |
/** @brief Pin ADC2 **/
|
255 |
#define PIN_ADC2 50 |
256 |
/** @brief Pin AN3 **/
|
257 |
#define PIN_AN3 51 |
258 |
/** @brief Pin ADC3 **/
|
259 |
#define PIN_ADC3 51 |
260 |
/** @brief Pin AN4 **/
|
261 |
#define PIN_AN4 52 |
262 |
/** @brief Pin ADC4 **/
|
263 |
#define PIN_ADC4 52 |
264 |
/** @brief Pin AN5 **/
|
265 |
#define PIN_AN5 53 |
266 |
/** @brief Pin ADC5 **/
|
267 |
#define PIN_ADC5 53 |
268 |
/** @brief Pin AN6 **/
|
269 |
#define PIN_AN6 54 |
270 |
/** @brief Pin ADC6 **/
|
271 |
#define PIN_ADC6 54 |
272 |
/** @brief Pin AN7 **/
|
273 |
#define PIN_AN7 55 |
274 |
/** @brief Pin ADC7 **/
|
275 |
#define PIN_ADC7 55 |
276 |
|
277 |
/** @brief Wheel Pin **/
|
278 |
#define PIN_WHEEL 54 |
279 |
/** @brief Battery Voltage Monitor Pin **/
|
280 |
#define PIN_BATT 55 |
281 |
|
282 |
/** @brief button1 Pin **/
|
283 |
#define PIN_BTN1 56 |
284 |
/** @brief button2 Pin **/
|
285 |
#define PIN_BTN2 57 |
286 |
|
287 |
/** @brief LED1 Pin **/
|
288 |
#define PIN_LED1 58 |
289 |
|
290 |
/* Buttons */
|
291 |
/** @brief Button Pin **/
|
292 |
#define PIN_BTN PING
|
293 |
/** @brief button2 Pin **/
|
294 |
#define BTN2 PING1
|
295 |
/** @brief button1 Pin **/
|
296 |
#define BTN1 PING0
|
297 |
|
298 |
/** @brief Read a portpin. **/
|
299 |
int digital_input(int); |
300 |
/** @brief Output to a portpin. **/
|
301 |
void digital_output(int bit, int val); |
302 |
/** @brief Pullup a portpin. **/
|
303 |
void digital_pull_up(int); |
304 |
|
305 |
/** @brief Check if button1 is pressed. **/
|
306 |
int button1_read( void ); |
307 |
/** @brief Check if button1 is clicked. **/
|
308 |
int button1_click( void ); |
309 |
/** @brief Wait until button1 is pressed. **/
|
310 |
void button1_wait( void ); |
311 |
|
312 |
/** @brief Check if button2 is pressed. **/
|
313 |
int button2_read( void ); |
314 |
/** @brief Check if button2 is clicked. **/
|
315 |
int button2_click( void ); |
316 |
/** @brief Wait until button2 is pressed. **/
|
317 |
void button2_wait( void ); |
318 |
|
319 |
/** @} **/ // end addtogroup |
320 |
|
321 |
#endif
|
322 |
|