Project

General

Profile

Revision 328

Added by James Kong over 16 years ago

Kevin you suck. -- Chris Your code does not compile. --Brian and Chris I changed analog8 to be what you had as analog_get8, and I did change the methods used in rangefinders and BOM.

View differences:

analog.h
29 29
 * @brief Contains functions and definitions for using the ADC
30 30
 * 
31 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
 *
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
	
35 38
 * @author Colony Project, CMU Robotics Club, based on firefly
36 39
 * code by Tom Lauwers
37
 **/
40
*/
38 41

  
39 42
#ifndef _ANALOG_H
40 43
#define _ANALOG_H
......
88 91
/** @brief Analog port for the battery voltage detector **/
89 92
#define BATT_PORT  AN11
90 93

  
91
/** @brief Used in analog_init to start the analog loop from the get-go **/
92 94
#define ADC_START 1
93
/** @brief Used in analog_init to not start the analog loop from the get-go **/
94 95
#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. **/
96

  
100 97
#define ADMUX_OPT 0x60
101 98

  
99
/** @brief Struct to hold the value of a particular analog port */
100
typedef struct {
101
	uint8_t adc8;
102
	uint16_t adc10;
103
} adc_t;
102 104

  
105

  
103 106
/** @brief Initialize analog ports. Will start running a loop
104 107
	 if start_conversion is ADC_START.**/
105 108
void analog_init(int start_conversion);
......
107 110
void analog_start_loop(void);
108 111
/** @brief Stops the analog loop. Doesn't do anything if the loop is already stopped. **/
109 112
void analog_stop_loop(void);
110
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog8. **/
113
/** @brief Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/
111 114
unsigned int analog8(int which);
112
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog10. **/
115
/** @brief Read a 10-bit number from an analog port. Loop must be stopped for this to work. **/
113 116
unsigned int analog10(int which);
114 117
/** @brief Read the position of the wheel. **/
115 118
int wheel(void);
116
/** @brief Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/
119
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog8. **/
117 120
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. **/
121
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog10. **/
119 122
unsigned int analog_get10(int which);
120 123

  
121 124

  

Also available in: Unified diff