Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / testing / dongle / robot_receiver / analog.h @ 13

History | View | Annotate | Download (1.93 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 to analog
7
        
8
        author: CMU Robotics Club, Colony Project
9
        code taken from the fwr analog file (author:  Tom Lauwers)
10
*/
11

    
12
#ifndef _ANALOG_H
13
#define _ANALOG_H
14

    
15
#define AN0 0x00
16
#define AN1 0x01
17
#define AN2 0x02
18
#define AN3 0x03
19
#define AN4 0x04
20
#define AN5 0x05
21
#define AN6 0x06
22
#define AN7 0x07
23

    
24
#ifdef FFPP
25
#define AN8 0x08
26
#define AN9 0x09
27
#define ANA 0x0A
28
#define ANB 0x0B
29
#define ANC 0x0C
30
#define AND 0x0D
31
#define ANE 0x0E
32
#define ANF 0x0F
33

    
34
#define EXT_MUX   0x07
35
#define IR_READ   0x08
36
#define IR1_READ  0x08
37
#define IR2_READ  0x09
38
#define IR3_READ  10
39
#define IR4_READ  11
40
#define IR5_READ  12
41
#define ADC_BATT  13
42
#define ADC_WHEEL 14
43
#define ADC_3V3   15
44

    
45
#define WHEEL_PORT ANE
46
#define BATT_PORT AND
47

    
48
#else
49

    
50
#define WHEEL_PORT AN6
51
#define BATT_PORT  AN7
52

    
53
#endif
54

    
55
/*
56
        Call this function before reading from the analog ports
57
        turns on the ADC
58
*/
59
void analog_init(void);
60

    
61
/*
62
        returns an 8-bit number from the desired analog port
63
        argument should be one of the constants AN0 - AN7
64
        behavior is undefined otherwise
65
        analog_init() must be called before a call to this function
66
*/
67
unsigned int analog8(int which);
68

    
69
/*
70
        returns a 10-bit number from the desired analog port
71
        argument should be one of the constants AN0 - AN7
72
        behavior is undefined otherwise
73
        analog_init() must be called before a call to this function
74
*/
75
unsigned int analog10(int which);
76

    
77
/*
78
        returns the current value (0-255) of the wheel
79
        analog_init() must be called before a call to this function
80
*/
81
int wheel(void);
82

    
83
/*
84
        returns the current voltage of the battery (deciVolts)
85
        analog_init() must be called before a call to this function
86
*/
87
int battery(void);
88

    
89
#ifdef FFPP
90
 void enable_analog(int analog_setting);
91
void set_adc_mux(int which);
92
#endif
93

    
94

    
95
#endif