forked from len0rd/rockbox
Samsung YH-820: enable battery monitoring
The "percent_to_volt_charge" values are quite arbitrary and may need some more tweaking. Change-Id: I9f177d46681030d615fe2c2e78cf9bd2dde026af Reviewed-on: http://gerrit.rockbox.org/824 Reviewed-by: Szymon Dziok <b0hoon@o2.pl> Tested: Szymon Dziok <b0hoon@o2.pl>
This commit is contained in:
parent
6bbfb35560
commit
7e778c5f49
3 changed files with 12 additions and 14 deletions
|
@ -125,9 +125,9 @@
|
|||
|
||||
#define AB_REPEAT_ENABLE
|
||||
|
||||
#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */
|
||||
#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
|
||||
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
|
||||
#define BATTERY_CAPACITY_DEFAULT 650 /* default battery capacity */
|
||||
#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */
|
||||
#define BATTERY_CAPACITY_MAX 800 /* max. capacity selectable */
|
||||
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
|
||||
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ unsigned short adc_scan(int channel)
|
|||
|
||||
adcdata[channel] = (adc_data_1<<2 | adc_data_2);
|
||||
|
||||
#if !(defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330))
|
||||
#if !(defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) || defined(SAMSUNG_YH820))
|
||||
/* ADC values read low if PLL is enabled */
|
||||
if(PLL_CONTROL & 0x80000000){
|
||||
adcdata[channel] += 0x14;
|
||||
|
|
|
@ -24,36 +24,34 @@
|
|||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
|
||||
/* TODO: Not yet calibrated */
|
||||
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3695
|
||||
3400
|
||||
};
|
||||
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
3627
|
||||
3199
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
/* NOTE: readout clips at around 4000mV */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 3695, 3714, 3772, 3791, 3811, 3850, 3908, 3985, 4024, 4111, 4198 }
|
||||
{ 3199, 3492, 3543, 3601, 3626, 3651, 3702, 3769, 3794, 3865, 3995 }
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
/* NOTE: these values may be rather inaccurate. Readout clips at around 4000mV */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
3850, 3888, 3927, 3966, 4024, 4063, 4111, 4150, 4198, 4237, 4286
|
||||
3750, 3860, 3880, 3900, 3930, 3994, 4080, 4135, 4200, 4200, 4200
|
||||
};
|
||||
|
||||
#define BATTERY_SCALE_FACTOR 4650
|
||||
/* full-scale ADC readout (2^10) in millivolt */
|
||||
#define BATTERY_SCALE_FACTOR 5000
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
int _battery_voltage(void)
|
||||
{
|
||||
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
|
||||
return 4100;
|
||||
return ((adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10) - 1000;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue