root / branches / rbom / code / projects / colonet / utilities / robot_wireless_relay / analog.h @ 1390
History | View | Annotate | Download (1.94 KB)
1 |
/*
|
---|---|
2 |
* analog.h - Contains definitions and function prototypes for using the
|
3 |
* ADC to detect analog signals on pins AN0 - AN7
|
4 |
* AN6 and AN7 are used for the wheel and battery
|
5 |
|
6 |
* The pins labeled E6 and E7 are external interrupt pins and are not related
|
7 |
* to analog
|
8 |
|
9 |
* author: CMU Robotics Club, Colony Project
|
10 |
* code taken from the fwr analog file (author: Tom Lauwers)
|
11 |
*/
|
12 |
|
13 |
#ifndef _ANALOG_H
|
14 |
#define _ANALOG_H
|
15 |
|
16 |
#define AN0 0x00 |
17 |
#define AN1 0x01 |
18 |
#define AN2 0x02 |
19 |
#define AN3 0x03 |
20 |
#define AN4 0x04 |
21 |
#define AN5 0x05 |
22 |
#define AN6 0x06 |
23 |
#define AN7 0x07 |
24 |
|
25 |
#ifdef FFPP
|
26 |
#define AN8 0x08 |
27 |
#define AN9 0x09 |
28 |
#define ANA 0x0A |
29 |
#define ANB 0x0B |
30 |
#define ANC 0x0C |
31 |
#define AND 0x0D |
32 |
#define ANE 0x0E |
33 |
#define ANF 0x0F |
34 |
|
35 |
#define EXT_MUX 0x07 |
36 |
#define IR_READ 0x08 |
37 |
#define IR1_READ 0x08 |
38 |
#define IR2_READ 0x09 |
39 |
#define IR3_READ 10 |
40 |
#define IR4_READ 11 |
41 |
#define IR5_READ 12 |
42 |
#define ADC_BATT 13 |
43 |
#define ADC_WHEEL 14 |
44 |
#define ADC_3V3 15 |
45 |
|
46 |
#define WHEEL_PORT ANE
|
47 |
#define BATT_PORT AND
|
48 |
|
49 |
#else
|
50 |
|
51 |
#define WHEEL_PORT AN6
|
52 |
#define BATT_PORT AN7
|
53 |
|
54 |
#endif
|
55 |
|
56 |
/*
|
57 |
Call this function before reading from the analog ports
|
58 |
turns on the ADC
|
59 |
*/
|
60 |
void analog_init(void); |
61 |
|
62 |
/*
|
63 |
returns an 8-bit number from the desired analog port
|
64 |
argument should be one of the constants AN0 - AN7
|
65 |
behavior is undefined otherwise
|
66 |
analog_init() must be called before a call to this function
|
67 |
*/
|
68 |
unsigned int analog8(int which); |
69 |
|
70 |
/*
|
71 |
returns a 10-bit number from the desired analog port
|
72 |
argument should be one of the constants AN0 - AN7
|
73 |
behavior is undefined otherwise
|
74 |
analog_init() must be called before a call to this function
|
75 |
*/
|
76 |
unsigned int analog10(int which); |
77 |
|
78 |
/*
|
79 |
returns the current value (0-255) of the wheel
|
80 |
analog_init() must be called before a call to this function
|
81 |
*/
|
82 |
int wheel(void); |
83 |
|
84 |
/*
|
85 |
returns the current voltage of the battery (deciVolts)
|
86 |
analog_init() must be called before a call to this function
|
87 |
*/
|
88 |
int battery(void); |
89 |
|
90 |
#ifdef FFPP
|
91 |
void enable_analog(int analog_setting); |
92 |
void set_adc_mux(int which); |
93 |
#endif
|
94 |
|
95 |
#endif
|