summaryrefslogtreecommitdiff
path: root/src/ao_adc.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-01-10 16:31:50 -0800
committerKeith Packard <keithp@keithp.com>2010-01-10 16:35:58 -0800
commit9856b7c4397afcecc8f541af9a83824e817b3612 (patch)
tree71d2d68717c29cd96addd22d1734bbb5040a4b56 /src/ao_adc.c
parent0c2533be15858774ef9381aa8c8344356fd5b971 (diff)
Switch to using internal cc1111 temperature sensor
v0.2 has no temperature sensor, and several of the v0.1 boards didn't get a temperature sensor loaded. Use the internal temperature sensor on the cc1111 in all cases instead. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/ao_adc.c')
-rw-r--r--src/ao_adc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/ao_adc.c b/src/ao_adc.c
index b0bfceb1..2b972e6c 100644
--- a/src/ao_adc.c
+++ b/src/ao_adc.c
@@ -46,16 +46,18 @@ ao_adc_isr(void) interrupt 1
uint8_t __xdata *a;
sequence = (ADCCON2 & ADCCON2_SCH_MASK) >> ADCCON2_SCH_SHIFT;
+ if (sequence == ADCCON3_ECH_TEMP)
+ sequence = 2;
a = (uint8_t __xdata *) (&ao_adc_ring[ao_adc_head].accel + sequence);
a[0] = ADCL;
a[1] = ADCH;
if (sequence < 5) {
/* start next channel conversion */
- sequence++;
- /* skip channel 2, we don't have a temp sensor on v0.2 */
- if (sequence == 2)
- sequence++;
- ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | sequence;
+ /* v0.2 replaces external temp sensor with internal one */
+ if (sequence == 1)
+ ADCCON3 = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP;
+ else
+ ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | (sequence + 1);
} else {
/* record this conversion series */
ao_adc_ring[ao_adc_head].tick = ao_time();