Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / libdragonfly / include / dio.h @ 881

History | View | Annotate | Download (7.66 KB)

1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

    
26

    
27
/**
28
 * @file dio.h
29
 * @brief Definitions for digital input / output
30
 *
31
 * This file contains definitions and functions for dealing
32
 * with digital input and output.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 * Based on Tom Lauwer's Firefly Library
36
 **/
37

    
38
#ifndef _DIO_H
39
#define _DIO_H
40

    
41
/*
42
  these are ALL the pins
43
  don't use unless you know what you're doing
44
*/
45

    
46
/*
47
  DIO pins on new dragonfly boards are shown below:
48
  -----------------------------------------------
49
  | _PIN_E6 | _PIN_E7 | _PIN_D2 | _PIN_D3 | VCC |
50
  -----------------------------------------------
51
  | _PIN_E2 | _PIN_E3 | _PIN_E4 | _PIN_E5 | GND |
52
  -----------------------------------------------
53
*/
54

    
55
/** @brief Port A **/
56
#define _PORT_A 1
57
/** @brief Port B **/
58
#define _PORT_B 2
59
/** @brief Port C **/
60
#define _PORT_C 3
61
/** @brief Port D **/
62
#define _PORT_D 4
63
/** @brief Port E **/
64
#define _PORT_E 5
65
/** @brief Port F **/
66
#define _PORT_F 6
67
/** @brief Port G **/
68
#define _PORT_G 7
69

    
70
/** @brief Pin A0 **/
71
#define _PIN_A0 8
72
/** @brief Pin A1 **/
73
#define _PIN_A1 9
74
/** @brief Pin A2 **/
75
#define _PIN_A2 10
76
/** @brief Pin A3 **/
77
#define _PIN_A3 11
78
/** @brief Pin A4 **/
79
#define _PIN_A4 12
80
/** @brief Pin A5 **/
81
#define _PIN_A5 13
82
/** @brief Pin A6 **/
83
#define _PIN_A6 14 
84
/** @brief Pin A7 **/
85
#define _PIN_A7 15
86

    
87
/** @brief Pin B0 **/
88
#define _PIN_B0 16
89
/** @brief Pin B1 **/
90
#define _PIN_B1 17
91
/** @brief Pin B2 **/
92
#define _PIN_B2 18
93
/** @brief Pin B3 **/
94
#define _PIN_B3 19
95
/** @brief Pin B4 **/
96
#define _PIN_B4 20
97
/** @brief Pin B5 **/
98
#define _PIN_B5 21
99
/** @brief Pin B6 **/
100
#define _PIN_B6 22
101
/** @brief Pin B7 **/
102
#define _PIN_B7 23
103

    
104
/** @brief Pin C0 **/
105
#define _PIN_C0 24
106
/** @brief Pin C1 **/
107
#define _PIN_C1 25
108
/** @brief Pin C2 **/
109
#define _PIN_C2 26
110
/** @brief Pin C3 **/
111
#define _PIN_C3 27
112
/** @brief Pin C4 **/
113
#define _PIN_C4 28
114
/** @brief Pin C5 **/
115
#define _PIN_C5 29
116
/** @brief Pin C6 **/
117
#define _PIN_C6 30
118
/** @brief Pin C7 **/
119
#define _PIN_C7 31
120

    
121
/** @brief Pin D0 **/
122
#define _PIN_D0 32  // pin DIO6 on new dragonfly boards
123
/** @brief Pin D1 **/
124
#define _PIN_D1 33  // pin DIO7
125
/** @brief Pin D2 **/
126
#define _PIN_D2 34
127
/** @brief Pin D3 **/
128
#define _PIN_D3 35
129
/** @brief Pin D4 **/
130
#define _PIN_D4 36
131
/** @brief Pin D5 **/
132
#define _PIN_D5 37
133
/** @brief Pin D6 **/
134
#define _PIN_D6 38
135
/** @brief Pin D7 **/
136
#define _PIN_D7 39
137

    
138
/** @brief Pin E0 **/
139
#define _PIN_E0 40
140
/** @brief Pin E1 **/
141
#define _PIN_E1 41
142
/** @brief Pin E2 **/
143
#define _PIN_E2 42  // pin DIO0
144
/** @brief Pin E3 **/
145
#define _PIN_E3 43  // pin DIO1
146
/** @brief Pin E4 **/
147
#define _PIN_E4 44  // pin DIO2
148
/** @brief Pin E5 **/
149
#define _PIN_E5 45  // pin DIO3
150
/** @brief Pin E6 **/
151
#define _PIN_E6 46  // pin DIO4
152
/** @brief Pin E7 **/
153
#define _PIN_E7 47  // pin DIO5
154

    
155
/** @brief Pin F0 **/
156
#define _PIN_F0 48
157
/** @brief Pin F1 **/
158
#define _PIN_F1 49
159
/** @brief Pin F2 **/
160
#define _PIN_F2 50
161
/** @brief Pin F3 **/
162
#define _PIN_F3 51
163
/** @brief Pin F4 **/
164
#define _PIN_F4 52
165
/** @brief Pin F5 **/
166
#define _PIN_F5 53
167
/** @brief Pin F6 **/
168
#define _PIN_F6 54
169
/** @brief Pin F7 **/
170
#define _PIN_F7 55
171

    
172
/** @brief Pin G0 **/
173
#define _PIN_G0 56
174
/** @brief Pin WR **/
175
#define _PIN_WR 56
176
/** @brief Pin G1 **/
177
#define _PIN_G1 57
178
/** @brief Pin RD **/
179
#define _PIN_RD 57
180
/** @brief Pin G2 **/
181
#define _PIN_G2 58
182
/** @brief Pin ALE **/
183
#define _PIN_ALE 58
184
/** @brief Pin G3 **/
185
#define _PIN_G3 59
186
/** @brief Pin TOSC2 **/
187
#define _PIN_TOSC2 59
188
/** @brief Pin G4 **/
189
#define _PIN_G4 60
190
/** @brief Pin TOSC1 **/
191
#define _PIN_TOSC1 60
192
//#define _PIN_G5 61
193
//#define _PIN_G6 62
194
//#define _PIN_G7 63
195

    
196
/*
197
  These are the header pins (the ones you can connect things to)
198
  Feel free to use these
199
*/
200

    
201
/**
202
 * @addtogroup dio
203
 * @{
204
 **/
205
/** @brief Pin A0 **/
206
#define PIN_A0 8
207
/** @brief Pin A1 **/
208
#define PIN_A1 9
209
/** @brief Pin A2 **/
210
#define PIN_A2 10
211
/** @brief Pin A3 **/
212
#define PIN_A3 11
213
/** @brief Pin A4 **/
214
#define PIN_A4 12
215
/** @brief Pin A5 **/
216
#define PIN_A5 13
217
/** @brief Pin A6 **/
218
#define PIN_A6 14 
219
/** @brief Pin A7 **/
220
#define PIN_A7 15
221

    
222
/** @brief Pin SS **/
223
#define PIN_SS 16
224
/** @brief Pin SCK **/
225
#define PIN_SCK 17
226
/** @brief Pin MOSI **/
227
#define PIN_MOSI 18
228
/** @brief Pin MISO **/
229
#define PIN_MISO 19
230
/** @brief LCD Command Pin **/
231
#define PIN_LCD_COMMAND 20
232

    
233
/** @brief Pin C0 **/
234
#define PIN_C0 24
235
/** @brief Pin C1 **/
236
#define PIN_C1 25
237
/** @brief Pin C2 **/
238
#define PIN_C2 26
239
/** @brief Pin C3 **/
240
#define PIN_C3 27
241
/** @brief Pin C4 **/
242
#define PIN_C4 28
243
/** @brief Pin C5 **/
244
#define PIN_C5 29
245
/** @brief Pin C6 **/
246
#define PIN_C6 30
247
/** @brief Pin C7 **/
248
#define PIN_C7 31
249

    
250
/** @brief Pin SCL **/
251
#define PIN_SCL 32
252
/** @brief Pin SDA **/
253
#define PIN_SDA 33
254

    
255
/** @brief Pin RX0 **/
256
#define PIN_RX0 40
257
/** @brief Pin TX0 **/
258
#define PIN_TX0 41
259
/** @brief LCD Reset Pin **/
260
#define PIN_LCD_RESET 42
261
/** @brief Pin E6 **/
262
#define PIN_E6 46
263
/** @brief Pin EXT_DIO1 **/
264
#define PIN_EXT_DIO1 46
265
/** @brief Pin E7 **/
266
#define PIN_E7 47
267
/** @brief Pin EXT_DIO2 **/
268
#define PIN_EXT_DIO2 48
269

    
270
/** @brief Pin AN0 **/
271
#define PIN_AN0 48
272
/** @brief Pin ADC0 **/
273
#define PIN_ADC0 48
274
/** @brief Pin AN1 **/
275
#define PIN_AN1 49
276
/** @brief Pin ADC1 **/
277
#define PIN_ADC1 49
278
/** @brief Pin AN2 **/
279
#define PIN_AN2 50
280
/** @brief Pin ADC2 **/
281
#define PIN_ADC2 50
282
/** @brief Pin AN3 **/
283
#define PIN_AN3 51
284
/** @brief Pin ADC3 **/
285
#define PIN_ADC3 51
286
/** @brief Pin AN4 **/
287
#define PIN_AN4 52
288
/** @brief Pin ADC4 **/
289
#define PIN_ADC4 52
290
/** @brief Pin AN5 **/
291
#define PIN_AN5 53
292
/** @brief Pin ADC5 **/
293
#define PIN_ADC5 53
294
/** @brief Pin AN6 **/
295
#define PIN_AN6 54
296
/** @brief Pin ADC6 **/
297
#define PIN_ADC6 54
298
/** @brief Pin AN7 **/
299
#define PIN_AN7 55
300
/** @brief Pin ADC7 **/
301
#define PIN_ADC7 55
302

    
303
/** @brief Wheel Pin **/
304
#define PIN_WHEEL 54
305
/** @brief Battery Voltage Monitor Pin **/
306
#define PIN_BATT 55
307

    
308
/** @brief button1 Pin **/
309
#define PIN_BTN1 56
310
/** @brief button2 Pin **/
311
#define PIN_BTN2 57
312

    
313
/** @brief LED1 Pin **/
314
#define PIN_LED1 58
315

    
316
/* Buttons */
317
/** @brief Button Pin **/
318
#define PIN_BTN PING
319
/** @brief button2 Pin **/
320
#define BTN2 PING1
321
/** @brief button1 Pin **/
322
#define BTN1 PING0
323

    
324
/** @brief Read a portpin. **/
325
int digital_input(int);
326
/** @brief Output to a portpin. **/
327
void digital_output(int bit, int val);
328
/** @brief Pullup a portpin. **/
329
void digital_pull_up(int);
330

    
331
/** @brief Check if button1 is pressed. **/
332
int button1_read( void );
333
/** @brief Check if button1 is clicked. **/
334
int button1_click( void );
335
/** @brief Wait until button1 is pressed. **/
336
void button1_wait( void );
337

    
338
/** @brief Check if button2 is pressed. **/
339
int button2_read( void );
340
/** @brief Check if button2 is clicked. **/
341
int button2_click( void );
342
/** @brief Wait until button2 is pressed. **/
343
void button2_wait( void );
344

    
345
/** @} **/ // end addtogroup
346

    
347
#endif
348