altos: Fix battery voltage computation.
authorKeith Packard <keithp@keithp.com>
Sun, 23 Oct 2011 22:20:50 +0000 (15:20 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 23 Oct 2011 22:20:50 +0000 (15:20 -0700)
Full scale is 4.95V, not 3.333V.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/cc1111/ao_battery.c

index 070f682fa60ded378db1b6f646b0a2caf14baae4..b9845fb38612cde07a071bb6e6e9ac1d8e46734f 100644 (file)
@@ -36,7 +36,7 @@ ao_battery_get(void)
                ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | BATTERY_PIN;
                ao_sleep(DATA_TO_XDATA(&ao_battery_value));
                );
-       return (uint16_t) ((int32_t) ao_battery_value.v * (int32_t) 3333 >> 15);
+       return (uint16_t) ((int32_t) ao_battery_value.v * (int32_t) 4950 >> 15);
 }
 
 static void