Revision 338
Copying Kevin's analog code over from the analog branch.
analog.h | ||
---|---|---|
42 | 42 |
#ifndef _ANALOG_H |
43 | 43 |
#define _ANALOG_H |
44 | 44 |
|
45 |
#include <inttypes.h> |
|
46 |
|
|
45 | 47 |
/** |
46 | 48 |
* @addtogroup analog |
47 | 49 |
* @{ |
... | ... | |
68 | 70 |
/** @brief Analog port 9 **/ |
69 | 71 |
#define AN9 0x09 |
70 | 72 |
/** @brief Analog port 10 **/ |
71 |
#define AN10 0x0a
|
|
73 |
#define AN10 0x0A
|
|
72 | 74 |
/** @brief Analog port 11 **/ |
73 |
#define AN11 0x0b
|
|
75 |
#define AN11 0x0B
|
|
74 | 76 |
/** @brief Analog port 12 **/ |
75 |
#define AN12 0x0c
|
|
77 |
#define AN12 0x0C
|
|
76 | 78 |
/** @brief Analog port 13 **/ |
77 |
#define AN13 0x0d
|
|
79 |
#define AN13 0x0D
|
|
78 | 80 |
/** @brief Analog port 14 **/ |
79 |
#define AN14 0x0e
|
|
81 |
#define AN14 0x0E
|
|
80 | 82 |
/** @brief Analog port 15 **/ |
81 |
#define AN15 0x0f
|
|
83 |
#define AN15 0x0F
|
|
82 | 84 |
|
85 |
/** @brief BOM_PORT analog port for BOM **/ |
|
86 |
#define BOM_PORT AN0 |
|
83 | 87 |
/** @brief EXT_MUX analog port **/ |
84 | 88 |
#define EXT_MUX AN7 |
85 | 89 |
/** @brief Analog port for the wheel **/ |
... | ... | |
87 | 91 |
/** @brief Analog port for the battery voltage detector **/ |
88 | 92 |
#define BATT_PORT AN11 |
89 | 93 |
|
90 |
/** @brief Initialize analog ports. **/ |
|
91 |
void analog_init(void); |
|
92 |
/** @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 Read an 8-bit number from an analog port. Loop must be stopped for this to work. **/ |
|
93 | 114 |
unsigned int analog8(int which); |
94 |
/** @brief Read a 10-bit number from an analog port. **/ |
|
115 |
/** @brief Read a 10-bit number from an analog port. Loop must be stopped for this to work. **/
|
|
95 | 116 |
unsigned int analog10(int which); |
96 | 117 |
/** @brief Read the position of the wheel. **/ |
97 | 118 |
int wheel(void); |
119 |
/** @brief Returns an 8-bit analog value from the look up table. Use this instead of analog8. **/ |
|
120 |
unsigned int analog_get8(int which); |
|
121 |
/** @brief Returns an 10-bit analog value from the look up table. Use this instead of analog10. **/ |
|
122 |
unsigned int analog_get10(int which); |
|
98 | 123 |
|
124 |
|
|
99 | 125 |
/**@}**/ //end group |
100 | 126 |
|
101 | 127 |
#endif |
Also available in: Unified diff