root / branches / analog / trunk / code / projects / libdragonfly / analog.h @ 324
History | View | Annotate | Download (3.99 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 analog.h
|
29 |
* @brief Contains functions and definitions for using the ADC
|
30 |
*
|
31 |
* Contains definitions and function prototypes for using the
|
32 |
* ADC to detect analog signals on pins AN0 - AN15.
|
33 |
* See analog.c for implementation details.
|
34 |
*
|
35 |
* @author Colony Project, CMU Robotics Club, based on firefly
|
36 |
* code by Tom Lauwers
|
37 |
**/
|
38 |
|
39 |
#ifndef _ANALOG_H
|
40 |
#define _ANALOG_H
|
41 |
|
42 |
#include <inttypes.h> |
43 |
|
44 |
/**
|
45 |
* @addtogroup analog
|
46 |
* @{
|
47 |
**/
|
48 |
|
49 |
/** @brief Analog port 0 **/
|
50 |
#define AN0 0x00 |
51 |
/** @brief Analog port 1 **/
|
52 |
#define AN1 0x01 |
53 |
/** @brief Analog port 2 **/
|
54 |
#define AN2 0x02 |
55 |
/** @brief Analog port 3 **/
|
56 |
#define AN3 0x03 |
57 |
/** @brief Analog port 4 **/
|
58 |
#define AN4 0x04 |
59 |
/** @brief Analog port 5 **/
|
60 |
#define AN5 0x05 |
61 |
/** @brief Analog port 6 **/
|
62 |
#define AN6 0x06 |
63 |
/** @brief Analog port 7 **/
|
64 |
#define AN7 0x07 |
65 |
/** @brief Analog port 8 **/
|
66 |
#define AN8 0x08 |
67 |
/** @brief Analog port 9 **/
|
68 |
#define AN9 0x09 |
69 |
/** @brief Analog port 10 **/
|
70 |
#define AN10 0x0A |
71 |
/** @brief Analog port 11 **/
|
72 |
#define AN11 0x0B |
73 |
/** @brief Analog port 12 **/
|
74 |
#define AN12 0x0C |
75 |
/** @brief Analog port 13 **/
|
76 |
#define AN13 0x0D |
77 |
/** @brief Analog port 14 **/
|
78 |
#define AN14 0x0E |
79 |
/** @brief Analog port 15 **/
|
80 |
#define AN15 0x0F |
81 |
|
82 |
/** @brief BOM_PORT analog port for BOM **/
|
83 |
#define BOM_PORT AN0
|
84 |
/** @brief EXT_MUX analog port **/
|
85 |
#define EXT_MUX AN7
|
86 |
/** @brief Analog port for the wheel **/
|
87 |
#define WHEEL_PORT AN10
|
88 |
/** @brief Analog port for the battery voltage detector **/
|
89 |
#define BATT_PORT AN11
|
90 |
|
91 |
/** @brief Used in analog_init to start the analog loop from the get-go **/
|
92 |
#define ADC_START 1 |
93 |
/** @brief Used in analog_init to not start the analog loop from the get-go **/
|
94 |
#define ADC_STOP 0 |
95 |
/** @brief Maximum number of analog ports to check. This number is equivalent to
|
96 |
* AN1 -> AN11 as AN0 and AN7 are skipped. **/
|
97 |
#define ANMAX 11 |
98 |
/** @brief For use with ADMUX register. Means that We will use AVCC (REFS0) and
|
99 |
* enable ADLAR. **/
|
100 |
#define ADMUX_OPT 0x60 |
101 |
|
102 |
|
103 |
/** @brief Initialize analog ports. Will start running a loop
|
104 |
if start_conversion is ADC_START.**/
|
105 |
void analog_init(int start_conversion); |
106 |
/** @brief starts the analog loop. Doesn't do anything if the loop is already running. **/
|
107 |
void analog_start_loop(void); |
108 |
/** @brief Stops the analog loop. Doesn't do anything if the loop is already stopped. **/
|
109 |
void analog_stop_loop(void); |
110 |
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog8. **/
|
111 |
unsigned int analog8(int which); |
112 |
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog10. **/
|
113 |
unsigned int analog10(int which); |
114 |
/** @brief Read the position of the wheel. **/
|
115 |
int wheel(void); |
116 |
/** @brief Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/
|
117 |
unsigned int analog_get8(int which); |
118 |
/** @brief Read a 10-bit number from an analog port. Loop must be stopped for this to work. **/
|
119 |
unsigned int analog_get10(int which); |
120 |
|
121 |
|
122 |
/**@}**/ //end group |
123 |
|
124 |
#endif
|
125 |
|