Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.48 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
#define WHEEL_PORT AN6
25
#define BATT_PORT  AN7
26

    
27
/*
28
        Call this function before reading from the analog ports
29
        turns on the ADC
30
*/
31
void analog_init(void);
32

    
33
/*
34
        returns an 8-bit number from the desired analog port
35
        argument should be one of the constants AN0 - AN7
36
        behavior is undefined otherwise
37
        analog_init() must be called before a call to this function
38
*/
39
unsigned int analog8(int which);
40

    
41
/*
42
        returns a 10-bit number from the desired analog port
43
        argument should be one of the constants AN0 - AN7
44
        behavior is undefined otherwise
45
        analog_init() must be called before a call to this function
46
*/
47
unsigned int analog10(int which);
48

    
49
/*
50
        returns the current value (0-255) of the wheel
51
        analog_init() must be called before a call to this function
52
*/
53
int wheel(void);
54

    
55
/*
56
        returns the current voltage of the battery (deciVolts)
57
        analog_init() must be called before a call to this function
58
*/
59
int battery(void);
60

    
61
#endif