1
0
Fork 0
forked from len0rd/rockbox

Gigabeat S: Make ADC battery voltage reading correct. Tiny tweak to ADC driver traffic limiting.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17105 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2008-04-14 06:52:38 +00:00
parent 25ebc85842
commit 0257547d58
2 changed files with 3 additions and 6 deletions

View file

@ -50,7 +50,7 @@ unsigned short adc_read(int channel)
mutex_lock(&adc_mtx);
/* Limit the traffic through here */
if (TIME_AFTER(current_tick, last_adc_read[input_select]))
if (current_tick != last_adc_read[input_select])
{
/* Keep enable, start conversion, increment from channel 0,
* increment from channel 4 */

View file

@ -48,13 +48,10 @@ const unsigned short percent_to_volt_charge[11] =
3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990
};
/* ADC[0] is (530) at discharge and 625 at full charge */
#define BATTERY_SCALE_FACTOR 6605
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
unsigned int battery_adc_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
/* ADC reading 0-1023 = 2400mV-4700mV */
return ((adc_read(ADC_BATTERY) * 2303) >> 10) + 2400;
}