Revision 891
Moved comments to headers. That was painful.
dio.h | ||
---|---|---|
199 | 199 |
*/ |
200 | 200 |
|
201 | 201 |
/** |
202 |
* @addtogroup dio |
|
203 |
* @{ |
|
202 |
* @defgroup dio Digital Input / Output |
|
203 |
* @brief Controls digital input and output |
|
204 |
* |
|
205 |
* A general note on how port / pin numbers work:<br> |
|
206 |
* The portpin is used to select both the bank and which pin is selected. |
|
207 |
* 6 bits are used (lower 6, ex: 0b00abcdef). |
|
208 |
* The first 3 (abc in this example) are used to select the bank.<br> |
|
209 |
* A = 001<br> |
|
210 |
* B = 010<br> |
|
211 |
* C = 011<br> |
|
212 |
* D = 100<br> |
|
213 |
* E = 101<br> |
|
214 |
* F = 110<br> |
|
215 |
* G = 111<br><br> |
|
216 |
* |
|
217 |
* The bank can be found by doing portpin >> 3. <br> |
|
218 |
* |
|
219 |
* The next three (def in this example) are used to select the pin number. |
|
220 |
* These three bits are just the binary representation of the pin number.<br> |
|
221 |
* <br> |
|
222 |
* The pin number can be found by doing portpin & 0b111.<br><br> |
|
223 |
* |
|
224 |
* Include dio.h to access these functions. |
|
204 | 225 |
**/ |
205 | 226 |
/** @brief Pin A0 **/ |
206 | 227 |
#define PIN_A0 8 |
... | ... | |
321 | 342 |
/** @brief button1 Pin **/ |
322 | 343 |
#define BTN1 PING0 |
323 | 344 |
|
324 |
/** @brief Read a portpin. **/ |
|
345 |
/** |
|
346 |
* @brief Read a portpin. |
|
347 |
* |
|
348 |
* Reads the selected portpin. |
|
349 |
* |
|
350 |
* @param portpin The portpin to be read. See the general description |
|
351 |
* for a description of portpins. |
|
352 |
* |
|
353 |
* @return 1 or 0, depending on the value of the portpin. |
|
354 |
**/ |
|
325 | 355 |
int digital_input(int); |
326 |
/** @brief Output to a portpin. **/ |
|
356 |
|
|
357 |
/** |
|
358 |
* @brief Output to a portpin. |
|
359 |
* |
|
360 |
* Sets portpin to the given value. |
|
361 |
* |
|
362 |
* @param portpin the portpin to output to. See the general |
|
363 |
* description for a discussion of portpins. |
|
364 |
* |
|
365 |
* @param val the value to set the portpin to. 0 for off, |
|
366 |
* nonzero for on. |
|
367 |
**/ |
|
327 | 368 |
void digital_output(int bit, int val); |
328 |
/** @brief Pullup a portpin. **/ |
|
369 |
|
|
370 |
/** |
|
371 |
* @brief Pullup a portpin. |
|
372 |
* |
|
373 |
* Enables pullup on a pin. If it is an output pin, the pin will output |
|
374 |
* 1. |
|
375 |
* |
|
376 |
* @param portpin the pin to enable pullup on. See the general description |
|
377 |
* for a discussion of portpins. |
|
378 |
**/ |
|
329 | 379 |
void digital_pull_up(int); |
330 | 380 |
|
331 |
/** @brief Check if button1 is pressed. **/ |
|
381 |
/** |
|
382 |
* @brief Check if button1 is pressed. |
|
383 |
* |
|
384 |
* Checks if button1 is currently pressed. |
|
385 |
* |
|
386 |
* @return 1 if button1 is pressed, 0 otherwise |
|
387 |
* |
|
388 |
* @see button1_wait, button1_click |
|
389 |
**/ |
|
332 | 390 |
int button1_read( void ); |
333 |
/** @brief Check if button1 is clicked. **/ |
|
391 |
|
|
392 |
/** |
|
393 |
* @brief Check if button1 is clicked. |
|
394 |
* |
|
395 |
* If button1 is pressed, waits until it is released before returning. |
|
396 |
* Otherwise, the function returns immediately. |
|
397 |
* |
|
398 |
* @return 1 if button1 has been pressed, 0 otherwise |
|
399 |
* |
|
400 |
* @see button1_read, button1_wait |
|
401 |
**/ |
|
334 | 402 |
int button1_click( void ); |
335 |
/** @brief Wait until button1 is pressed. **/ |
|
403 |
|
|
404 |
/** |
|
405 |
* @brief Wait until button1 is pressed. |
|
406 |
* |
|
407 |
* Delays execution until button1 is pressed. |
|
408 |
* |
|
409 |
* @see button1_read, button1_click |
|
410 |
**/ |
|
336 | 411 |
void button1_wait( void ); |
337 | 412 |
|
338 |
/** @brief Check if button2 is pressed. **/ |
|
413 |
/** |
|
414 |
* @brief Check if button2 is pressed. |
|
415 |
* |
|
416 |
* Checks if button2 is currently pressed. |
|
417 |
* |
|
418 |
* @return 1 if button2 is pressed, 0 otherwise |
|
419 |
* |
|
420 |
* @see button2_wait, button2_click |
|
421 |
**/ |
|
339 | 422 |
int button2_read( void ); |
340 |
/** @brief Check if button2 is clicked. **/ |
|
423 |
|
|
424 |
/** |
|
425 |
* Delays execution until button2 is pressed. |
|
426 |
* |
|
427 |
* @see button2_read, button2_click |
|
428 |
**/ |
|
341 | 429 |
int button2_click( void ); |
342 |
/** @brief Wait until button2 is pressed. **/ |
|
430 |
|
|
431 |
/** |
|
432 |
* @brief Wait until button2 is pressed. |
|
433 |
* |
|
434 |
* If button2 is pressed, waits until it is released before returning. |
|
435 |
* Otherwise, the function returns immediately. |
|
436 |
* |
|
437 |
* @return 1 if button2 has been pressed, 0 otherwise |
|
438 |
* |
|
439 |
* @see button2_read, button2_wait |
|
440 |
**/ |
|
343 | 441 |
void button2_wait( void ); |
344 | 442 |
|
345 | 443 |
/** @} **/ // end addtogroup |
Also available in: Unified diff