summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/debug_menu.c5
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/export/config-clip.h10
-rw-r--r--firmware/target/arm/as3525/sansa-clip/powermgmt-clip.c13
-rw-r--r--firmware/target/arm/as3525/sansa-clip/powermgmt-target.h42
5 files changed, 51 insertions, 20 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index ca1085d67e..57f525df70 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -106,7 +106,8 @@
106#include "debug-target.h" 106#include "debug-target.h"
107#endif 107#endif
108 108
109#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) 109#if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
110 || defined(SANSA_CLIP)
110#include "ascodec.h" 111#include "ascodec.h"
111#include "as3514.h" 112#include "as3514.h"
112#endif 113#endif
@@ -1758,7 +1759,7 @@ static bool view_battery(void)
1758 } 1759 }
1759 1760
1760 lcd_puts(0, line++, buf); 1761 lcd_puts(0, line++, buf);
1761#elif defined(SANSA_E200) || defined(SANSA_C200) 1762#elif defined(SANSA_E200) || defined(SANSA_C200) || defined(SANSA_CLIP)
1762 const int first = CHARGE_STATE_DISABLED; 1763 const int first = CHARGE_STATE_DISABLED;
1763 static const char * const chrgstate_strings[] = 1764 static const char * const chrgstate_strings[] =
1764 { 1765 {
diff --git a/firmware/SOURCES b/firmware/SOURCES
index ae9bbc0733..69ffe29a8f 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1094,6 +1094,7 @@ target/arm/as3525/sansa-clip/lcd-as-clip.S
1094target/arm/as3525/sansa-clip/button-clip.c 1094target/arm/as3525/sansa-clip/button-clip.c
1095target/arm/as3525/sansa-clip/backlight-clip.c 1095target/arm/as3525/sansa-clip/backlight-clip.c
1096#ifndef BOOTLOADER 1096#ifndef BOOTLOADER
1097target/arm/powermgmt-ascodec.c
1097target/arm/as3525/sansa-clip/powermgmt-clip.c 1098target/arm/as3525/sansa-clip/powermgmt-clip.c
1098#endif /* !BOOTLOADER */ 1099#endif /* !BOOTLOADER */
1099#endif /* !SIMULATOR */ 1100#endif /* !SIMULATOR */
diff --git a/firmware/export/config-clip.h b/firmware/export/config-clip.h
index 95ed715276..1068440e63 100644
--- a/firmware/export/config-clip.h
+++ b/firmware/export/config-clip.h
@@ -134,14 +134,14 @@
134/* define this if the flash memory uses the SecureDigital Memory Card protocol */ 134/* define this if the flash memory uses the SecureDigital Memory Card protocol */
135#define CONFIG_STORAGE STORAGE_SD 135#define CONFIG_STORAGE STORAGE_SD
136 136
137#define BATTERY_CAPACITY_DEFAULT 750 /* default battery capacity */ 137#define BATTERY_CAPACITY_DEFAULT 380 /* default battery capacity */
138#define BATTERY_CAPACITY_MIN 750 /* min. capacity selectable */ 138#define BATTERY_CAPACITY_MIN 380 /* min. capacity selectable */
139#define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */ 139#define BATTERY_CAPACITY_MAX 380 /* max. capacity selectable */
140#define BATTERY_CAPACITY_INC 0 /* capacity increment */ 140#define BATTERY_CAPACITY_INC 0 /* capacity increment */
141#define BATTERY_TYPES_COUNT 1 /* only one type */ 141#define BATTERY_TYPES_COUNT 1 /* only one type */
142 142
143/* Hardware controlled charging? FIXME */ 143/* Charging implemented in a target-specific algorithm */
144#define CONFIG_CHARGING CHARGING_SIMPLE 144#define CONFIG_CHARGING CHARGING_TARGET
145 145
146/* define this if the unit can be powered or charged via USB */ 146/* define this if the unit can be powered or charged via USB */
147#define HAVE_USB_POWER 147#define HAVE_USB_POWER
diff --git a/firmware/target/arm/as3525/sansa-clip/powermgmt-clip.c b/firmware/target/arm/as3525/sansa-clip/powermgmt-clip.c
index f04760d9de..d908981523 100644
--- a/firmware/target/arm/as3525/sansa-clip/powermgmt-clip.c
+++ b/firmware/target/arm/as3525/sansa-clip/powermgmt-clip.c
@@ -20,9 +20,6 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "config.h" 22#include "config.h"
23#include "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26 23
27/* The battery manufacturer's website shows discharge curves down to 3.0V, 24/* The battery manufacturer's website shows discharge curves down to 3.0V,
28 so 'dangerous' and 'shutoff' levels of 3.4V and 3.3V should be safe. 25 so 'dangerous' and 'shutoff' levels of 3.4V and 3.3V should be safe.
@@ -52,13 +49,3 @@ const unsigned short percent_to_volt_charge[11] =
52}; 49};
53#endif /* CONFIG_CHARGING */ 50#endif /* CONFIG_CHARGING */
54 51
55/* ADC should read 0x3ff=5.12V */
56#define BATTERY_SCALE_FACTOR 5125
57/* full-scale ADC readout (2^10) in millivolt */
58
59/* Returns battery voltage from ADC [millivolts] */
60unsigned int battery_adc_voltage(void)
61{
62 return (adc_read(ADC_RTCSUP) * BATTERY_SCALE_FACTOR) >> 10;
63}
64
diff --git a/firmware/target/arm/as3525/sansa-clip/powermgmt-target.h b/firmware/target/arm/as3525/sansa-clip/powermgmt-target.h
new file mode 100644
index 0000000000..691d134ffa
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-clip/powermgmt-target.h
@@ -0,0 +1,42 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 by Michael Sevakis
11 * Copyright (C) 2008 by Bertrik Sikken
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22#ifndef POWERMGMT_TARGET_H
23#define POWERMGMT_TARGET_H
24
25/* Check if topped-off and monitor voltage while plugged. */
26#define BATT_FULL_VOLTAGE 4160
27#define BATT_VAUTO_RECHARGE 4100
28#define BATT_CHG_V CHG_V_4_20V
29#define BATT_CHG_I CHG_I_100MA
30#define CHARGER_TOTAL_TIMER (6*3600*2) /* about 1.5 * capacity / current */
31#define ADC_BATTERY ADC_BVDD
32
33void powermgmt_init_target(void);
34void charging_algorithm_step(void);
35void charging_algorithm_close(void);
36
37/* We want to be able to reset the averaging filter */
38#define HAVE_RESET_BATTERY_FILTER
39
40#define BATT_AVE_SAMPLES 32
41
42#endif /* POWERMGMT_TARGET_H */