Project

General

Profile

Statistics
| Revision:

root / branches / analog / trunk / code / projects / libdragonfly / analog.h @ 275

History | View | Annotate | Download (3.06 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 - AN7.
33
 * AN6 and AN7 are used for the wheel and battery.
34
        
35
 * The pins labeled E6 and E7 are external interrupt pins and are not related 
36
 * to analog.
37
        
38
 * @author Colony Project, CMU Robotics Club, based on firefly
39
 * code by Tom Lauwers
40
*/
41

    
42
#ifndef _ANALOG_H
43
#define _ANALOG_H
44

    
45
#include <inttypes.h>
46

    
47
/**
48
 * @addtogroup analog
49
 * @{
50
 **/
51

    
52
/** @brief Analog port 0 **/
53
#define AN0 0x00
54
/** @brief Analog port 1 **/
55
#define AN1 0x01
56
/** @brief Analog port 2 **/
57
#define AN2 0x02
58
/** @brief Analog port 3 **/
59
#define AN3 0x03
60
/** @brief Analog port 4 **/
61
#define AN4 0x04
62
/** @brief Analog port 5 **/
63
#define AN5 0x05
64
/** @brief Analog port 6 **/
65
#define AN6 0x06
66
/** @brief Analog port 7 **/
67
#define AN7 0x07
68
/** @brief Analog port 8 **/
69
#define AN8 0x08
70
/** @brief Analog port 9 **/
71
#define AN9 0x09
72
/** @brief Analog port 10 **/
73
#define AN10 0x0a
74
/** @brief Analog port 11 **/
75
#define AN11 0x0b
76
/** @brief Analog port 12 **/
77
#define AN12 0x0c
78
/** @brief Analog port 13 **/
79
#define AN13 0x0d
80
/** @brief Analog port 14 **/
81
#define AN14 0x0e
82
/** @brief Analog port 15 **/
83
#define AN15 0x0f
84

    
85
/** @brief EXT_MUX analog port **/
86
#define EXT_MUX AN7
87
/** @brief Analog port for the wheel **/
88
#define WHEEL_PORT AN10
89
/** @brief Analog port for the battery voltage detector **/
90
#define BATT_PORT  AN11
91

    
92
typedef union adc_t{
93
        uint8_t adc8;
94
        uint16_t adc10;
95
} adc_t;
96

    
97
extern adc_t an_val[9];
98

    
99
/** @brief Initialize analog ports. **/
100
void analog_init(void);
101
/** @brief Read an 8-bit number from an analog port. **/
102
unsigned int analog8(int which);
103
/** @brief Read a 10-bit number from an analog port. **/
104
unsigned int analog10(int which);
105
/** @brief Read the position of the wheel. **/
106
int wheel(void);
107
unsigned int analog_get8(int which);
108
unsigned int analog_get10(int which);
109

    
110

    
111
/**@}**/ //end group
112

    
113
#endif
114