forked from len0rd/rockbox
iPod Classic/6G: fix battery voltage ADC scale
Scale battery voltage ADC readings by 1023 instead of 1000, using ADC1 (substractor) instead of ADC0 (multiplicator) to get better resolution. Percent charge/discharge tables are also modified to return a similar value than the old ones. Change-Id: I2951c75faa02f4302599ec24f9156cfd209c36eb
This commit is contained in:
parent
d798c721e5
commit
1d901a82fd
2 changed files with 5 additions and 5 deletions
|
|
@ -73,7 +73,7 @@ int pmu_read_adc(unsigned int adc)
|
||||||
/* millivolts */
|
/* millivolts */
|
||||||
int pmu_read_battery_voltage(void)
|
int pmu_read_battery_voltage(void)
|
||||||
{
|
{
|
||||||
return pmu_read_adc(0) * 6;
|
return (pmu_read_adc(1) * 2000 / 1023) + 2250;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* milliamps */
|
/* milliamps */
|
||||||
|
|
|
||||||
|
|
@ -27,25 +27,25 @@
|
||||||
|
|
||||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||||
{
|
{
|
||||||
3600
|
3500
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||||
{
|
{
|
||||||
3350
|
3300
|
||||||
};
|
};
|
||||||
|
|
||||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||||
{
|
{
|
||||||
{ 3600, 3730, 3780, 3810, 3840, 3880, 3930, 3990, 4080, 4170, 4270 }
|
{ 3500, 3670, 3720, 3750, 3770, 3800, 3860, 3920, 3980, 4070, 4170 }
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_CHARGING
|
#if CONFIG_CHARGING
|
||||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||||
const unsigned short percent_to_volt_charge[11] =
|
const unsigned short percent_to_volt_charge[11] =
|
||||||
{
|
{
|
||||||
3800, 3900, 3990, 4070, 4140, 4200, 4250, 4290, 4320, 4340, 4350
|
3700, 3820, 3900, 3950, 3990, 4030, 4070, 4120, 4170, 4190, 4200
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_CHARGING */
|
#endif /* CONFIG_CHARGING */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue