diff --git a/firmware/target/coldfire/iriver/h300/adc-h300.c b/firmware/target/coldfire/iriver/h300/adc-h300.c index 77d7b4689f..b13d0c73cc 100644 --- a/firmware/target/coldfire/iriver/h300/adc-h300.c +++ b/firmware/target/coldfire/iriver/h300/adc-h300.c @@ -26,20 +26,23 @@ static int adcc2_parms[] = { - [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ - [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* ADCIN3 */ - [ADC_BATTERY] = 0x80 | (0 << 1) | 1, /* BATVOLT, resistive divider */ - [ADC_REMOTEDETECT] = 0x80 | (2 << 1) | 1, /* ADCIN1, resistive divider */ + [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* 8b, ADCIN2 */ + [ADC_REMOTE] = 0x80 | (6 << 1) | 1, /* 8b, ADCIN3 */ + [ADC_BATTERY] = 0x00 | (0 << 1) | 1, /* 10b, BATVOLT, resistive divider */ + [ADC_REMOTEDETECT] = 0x80 | (2 << 1) | 1, /* 8b, ADCIN1, resistive divider */ }; unsigned short adc_scan(int channel) { int level = set_irq_level(HIGHEST_IRQ_LEVEL); - unsigned char data; + unsigned data; pcf50606_write(0x2f, adcc2_parms[channel]); data = pcf50606_read(0x30); + if (channel == ADC_BATTERY) + data = (data << 2) | (pcf50606_read(0x31) & 0x03); + set_irq_level(level); return data; } diff --git a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c index b2d844075e..1bf1de59d9 100644 --- a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c +++ b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c @@ -48,11 +48,11 @@ const unsigned short percent_to_volt_charge[11] = /* FIX: this value is picked at random */ #define BATTERY_SCALE_FACTOR 6000 -/* full-scale ADC readout (2^8) in millivolt */ +/* 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) >> 8; + return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; }