mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 05:32:40 -05:00
Enable battery charging detection for iBasso DX50/DX90.
This changes iBasso DX50/DX90 config from CHARGING_SIMPLE (Simple, hardware controlled charging (CPU cannot read charger state but may read when power is plugged-in) to CHARGING_MONITOR (Hardware controlled charging with monitoring (CPU is able to read HW charging state and when power is plugged-in)). Not really usefull at the moment, since USB connection (charging) is not (yet) gracefully handled for iBasso devices. Change-Id: I55da81b10637d4de88d713ea5eba08eb59bc629f Reviewed-on: http://gerrit.rockbox.org/1010 Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
This commit is contained in:
parent
ac928ed7a2
commit
fe519c7e4d
3 changed files with 30 additions and 5 deletions
|
|
@ -99,7 +99,7 @@
|
||||||
|
|
||||||
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
|
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
|
||||||
|
|
||||||
#define CONFIG_CHARGING CHARGING_SIMPLE
|
#define CONFIG_CHARGING CHARGING_MONITOR
|
||||||
|
|
||||||
#define NO_LOW_BATTERY_SHUTDOWN
|
#define NO_LOW_BATTERY_SHUTDOWN
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
|
|
||||||
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
|
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
|
||||||
|
|
||||||
#define CONFIG_CHARGING CHARGING_SIMPLE
|
#define CONFIG_CHARGING CHARGING_MONITOR
|
||||||
|
|
||||||
#define NO_LOW_BATTERY_SHUTDOWN
|
#define NO_LOW_BATTERY_SHUTDOWN
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,12 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "powermgmt.h"
|
#include "powermgmt.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned int power_input_status(void)
|
unsigned int power_input_status(void)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
|
@ -34,8 +36,31 @@ unsigned int power_input_status(void)
|
||||||
return val?POWER_INPUT_MAIN_CHARGER:POWER_INPUT_NONE;
|
return val?POWER_INPUT_MAIN_CHARGER:POWER_INPUT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Values for stock PISEN battery. TODO: Needs optimization */
|
|
||||||
|
|
||||||
|
/* Returns true, if battery is charging, false else. */
|
||||||
|
bool charging_state( void )
|
||||||
|
{
|
||||||
|
/* Full, Charging, Discharging */
|
||||||
|
char state[9];
|
||||||
|
|
||||||
|
/* true if charging. */
|
||||||
|
bool charging = false;
|
||||||
|
|
||||||
|
FILE *f = fopen( "/sys/class/power_supply/battery/status", "r" );
|
||||||
|
if( f != NULL )
|
||||||
|
{
|
||||||
|
if( fgets( state, 9, f ) != NULL )
|
||||||
|
{
|
||||||
|
charging = ( strcmp( state, "Charging" ) == 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose( f );
|
||||||
|
|
||||||
|
return charging;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Values for stock PISEN battery. TODO: Needs optimization */
|
||||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||||
{
|
{
|
||||||
3380
|
3380
|
||||||
|
|
@ -52,10 +77,10 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||||
{ 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4090, 4190 }
|
{ 3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4090, 4190 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
/* Voltages (millivolt) of 0%, 10%, ... 100% when charging is enabled. */
|
||||||
const unsigned short percent_to_volt_charge[11] =
|
const unsigned short percent_to_volt_charge[11] =
|
||||||
{
|
{
|
||||||
3540, 3860, 3930, 3980, 4000, 4020, 4040, 4080, 4130, 4180, 4220 /* LiPo */
|
3370, 3650, 3700, 3740, 3780, 3820, 3870, 3930, 4000, 4090, 4190
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue