From 292a53da4b862dcb942b02eb47664efaf294d8c9 Mon Sep 17 00:00:00 2001 From: Rob Purchase Date: Thu, 8 Oct 2009 15:47:43 +0000 Subject: D2: Use a common function for reading ADC values from the PMU git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23007 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c') diff --git a/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c b/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c index 683c1c3be7..b52d5c46ba 100644 --- a/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c @@ -26,7 +26,7 @@ #include "pcf50606.h" unsigned short current_voltage = 3910; - + const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3380 @@ -42,7 +42,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = { /* Standard D2 internal battery */ { 3370, 3690, 3750, 3775, 3790, 3820, 3880, 3940, 3980, 4090, 4170 } - + /* TODO: DIY replacements eg. Nokia BP-4L ? */ }; @@ -65,15 +65,9 @@ unsigned int battery_adc_voltage(void) if (TIME_BEFORE(last_tick+HZ, current_tick)) { - int adc_val, irq_status; - unsigned char buf[2]; - - irq_status = disable_irq_save(); - pcf50606_write(PCF5060X_ADCC2, 0x1); - pcf50606_read_multiple(PCF5060X_ADCS1, buf, 2); - restore_interrupt(irq_status); + short adc_val; + pcf50606_read_adc(PCF5060X_ADC_BATVOLT_RES, &adc_val, NULL); - adc_val = (buf[0]<<2) | (buf[1] & 3); //ADCDAT1H+ADCDAT1L current_voltage = (adc_val * BATTERY_SCALE_FACTOR) >> 10; last_tick = current_tick; -- cgit v1.2.3