Sansa Connect: Remove fake battery voltage scale
Use battery percentage as reported by AVR. Change-Id: Id697d460b240798eb0b103f9e1f419906b87e9ca
This commit is contained in:
parent
f26499bd67
commit
551c74da55
|
@ -1263,7 +1263,6 @@ target/arm/tms320dm320/sansa-connect/crt0-board.S
|
|||
target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c
|
||||
target/arm/tms320dm320/sansa-connect/adc-sansaconnect.c
|
||||
target/arm/tms320dm320/sansa-connect/power-sansaconnect.c
|
||||
target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
|
||||
target/arm/tms320dm320/sansa-connect/tnetv105_cppi.c
|
||||
target/arm/tms320dm320/sansa-connect/tnetv105_usb_drv.c
|
||||
target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
#define BATTERY_CAPACITY_INC 100 /* capacity increment */
|
||||
#define BATTERY_TYPES_COUNT 1 /* only one type */
|
||||
|
||||
#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
|
||||
#define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE
|
||||
|
||||
/* define current usage levels */
|
||||
#if 0
|
||||
|
@ -156,9 +156,6 @@
|
|||
#define CURRENT_BACKLIGHT 200
|
||||
#endif
|
||||
|
||||
/* Hardware controlled charging with monitoring */
|
||||
//#define CONFIG_CHARGING CHARGING_MONITOR
|
||||
|
||||
#define CONFIG_CPU DM320
|
||||
|
||||
#define CONFIG_I2C I2C_DM320
|
||||
|
|
|
@ -79,6 +79,8 @@ static const char btn_thread_name[] = "buttons";
|
|||
static struct event_queue btn_queue;
|
||||
#endif
|
||||
|
||||
static int current_battery_level = 100;
|
||||
|
||||
static inline unsigned short be2short(unsigned char* buf)
|
||||
{
|
||||
return (unsigned short)((buf[0] << 8) | buf[1]);
|
||||
|
@ -284,8 +286,11 @@ void avr_hid_init(void)
|
|||
mutex_init(&avr_mtx);
|
||||
}
|
||||
|
||||
/* defined in powermgmt-sansaconnect.c */
|
||||
void set_battery_level(unsigned int level);
|
||||
int _battery_level(void)
|
||||
{
|
||||
/* Force shutoff when level read by AVR is 4 or lower */
|
||||
return (current_battery_level > 4) ? current_battery_level : 0;
|
||||
}
|
||||
|
||||
static void avr_hid_get_state(void)
|
||||
{
|
||||
|
@ -302,7 +307,7 @@ static void avr_hid_get_state(void)
|
|||
* buf[8] contains some battery/charger related information (unknown)
|
||||
* buf[9] contains battery level in percents (0-100)
|
||||
*/
|
||||
set_battery_level((unsigned int)buf[9]);
|
||||
current_battery_level = (int)buf[9];
|
||||
|
||||
spi_txrx(cmd_empty, NULL, 1); /* request interrupt on button press */
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: $
|
||||
*
|
||||
* Copyright (C) 2011 by Tomasz Moń
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "adc.h"
|
||||
#include "powermgmt.h"
|
||||
#include "kernel.h"
|
||||
|
||||
/* Use fake linear scale as AVR does the voltage to percentage conversion */
|
||||
|
||||
static unsigned int current_battery_level = 100;
|
||||
|
||||
/* This specifies the battery level that writes are still safe */
|
||||
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
5
|
||||
};
|
||||
|
||||
/* Below this the player cannot be considered to operate reliably */
|
||||
const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
|
||||
{
|
||||
4
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
|
||||
const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
|
||||
{
|
||||
{ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 },
|
||||
};
|
||||
|
||||
/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
|
||||
const unsigned short percent_to_volt_charge[11] =
|
||||
{
|
||||
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
|
||||
};
|
||||
|
||||
/* Returns battery voltage from ADC [millivolts] */
|
||||
int _battery_voltage(void)
|
||||
{
|
||||
return current_battery_level;
|
||||
}
|
||||
|
||||
void set_battery_level(unsigned int level)
|
||||
{
|
||||
current_battery_level = level;
|
||||
}
|
||||
|
Loading…
Reference in New Issue