Project

General

Profile

Revision 1345

Added by Rich Hong over 11 years ago

Final spline code for master/slave

updated outdated libdragonfly and libwireless

View differences:

analog.h
1 1
/**
2
 * Copyright (c) 2007 Colony Project
2 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
 * 
3 28
 * @file analog.h
4 29
 * @brief Contains functions and definitions for using the ADC
5 30
 * 
......
12 37
	
13 38
 * @author Colony Project, CMU Robotics Club, based on firefly
14 39
 * code by Tom Lauwers
15
*/
40
 */
16 41

  
17 42
#ifndef _ANALOG_H
18 43
#define _ANALOG_H
19 44

  
45
#include <inttypes.h>
46

  
20 47
/**
21 48
 * @addtogroup analog
22 49
 * @{
......
43 70
/** @brief Analog port 9 **/
44 71
#define AN9 0x09
45 72
/** @brief Analog port 10 **/
46
#define AN10 0x0a
73
#define AN10 0x0A
47 74
/** @brief Analog port 11 **/
48
#define AN11 0x0b
75
#define AN11 0x0B
49 76
/** @brief Analog port 12 **/
50
#define AN12 0x0c
77
#define AN12 0x0C
51 78
/** @brief Analog port 13 **/
52
#define AN13 0x0d
79
#define AN13 0x0D
53 80
/** @brief Analog port 14 **/
54
#define AN14 0x0e
81
#define AN14 0x0E
55 82
/** @brief Analog port 15 **/
56
#define AN15 0x0f
83
#define AN15 0x0F
57 84

  
85
/** @brief BOM_PORT analog port for BOM **/
86
#define BOM_PORT AN0
58 87
/** @brief EXT_MUX analog port **/
59 88
#define EXT_MUX AN7
60 89
/** @brief Analog port for the wheel **/
......
62 91
/** @brief Analog port for the battery voltage detector **/
63 92
#define BATT_PORT  AN11
64 93

  
65
/** @brief Initialize analog ports. **/
66
void analog_init(void);
67
/** @brief Read an 8-bit number from an analog port. **/
94
#define ADC_START 1
95
#define ADC_STOP 0
96

  
97
#define ADMUX_OPT 0x60
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;
104

  
105

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

  
124

  
74 125
/**@}**/ //end group
75 126

  
76 127
#endif
128

  

Also available in: Unified diff