diff options
author | Amaury Pouly <pamaury@rockbox.org> | 2011-11-14 21:45:25 +0000 |
---|---|---|
committer | Amaury Pouly <pamaury@rockbox.org> | 2011-11-14 21:45:25 +0000 |
commit | 9e4299f6f09707fcde3aef7dd9ab3c4e6b843ce1 (patch) | |
tree | cd92d82ee8a111e253b1b7b90a32f1392dd13f38 | |
parent | 4359b40cf1aa352abfc724f89161e4cd8ed8888c (diff) | |
download | rockbox-9e4299f6f09707fcde3aef7dd9ab3c4e6b843ce1.tar.gz rockbox-9e4299f6f09707fcde3aef7dd9ab3c4e6b843ce1.zip |
imx233: implement battery reading using power register (automatically updated & scaled by lradc delay)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30988 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/imx233/power-imx233.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/imx233/powermgmt-imx233.c | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/firmware/target/arm/imx233/power-imx233.h b/firmware/target/arm/imx233/power-imx233.h index d0fe686888..4d6edaf0e2 100644 --- a/firmware/target/arm/imx233/power-imx233.h +++ b/firmware/target/arm/imx233/power-imx233.h | |||
@@ -67,6 +67,8 @@ | |||
67 | #define HW_POWER_STS__PSWITCH_BM (3 << 20) | 67 | #define HW_POWER_STS__PSWITCH_BM (3 << 20) |
68 | 68 | ||
69 | #define HW_POWER_BATTMONITOR (*(volatile uint32_t *)(HW_POWER_BASE + 0xe0)) | 69 | #define HW_POWER_BATTMONITOR (*(volatile uint32_t *)(HW_POWER_BASE + 0xe0)) |
70 | #define HW_POWER_BATTMONITOR__BATT_VAL_BP 16 | ||
71 | #define HW_POWER_BATTMONITOR__BATT_VAL_BM (0x3ff << 16) | ||
70 | 72 | ||
71 | #define HW_POWER_RESET (*(volatile uint32_t *)(HW_POWER_BASE + 0x100)) | 73 | #define HW_POWER_RESET (*(volatile uint32_t *)(HW_POWER_BASE + 0x100)) |
72 | #define HW_POWER_RESET__UNLOCK 0x3E770000 | 74 | #define HW_POWER_RESET__UNLOCK 0x3E770000 |
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c index 4c7f46e2fb..0f24fa41ff 100644 --- a/firmware/target/arm/imx233/powermgmt-imx233.c +++ b/firmware/target/arm/imx233/powermgmt-imx233.c | |||
@@ -20,7 +20,7 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #include "powermgmt.h" | 22 | #include "powermgmt.h" |
23 | #include "adc-target.h" | 23 | #include "power-imx233.h" |
24 | 24 | ||
25 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 25 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = |
26 | { | 26 | { |
@@ -49,7 +49,8 @@ const unsigned short percent_to_volt_charge[11] = | |||
49 | /* Returns battery voltage from ADC [millivolts] */ | 49 | /* Returns battery voltage from ADC [millivolts] */ |
50 | unsigned int battery_adc_voltage(void) | 50 | unsigned int battery_adc_voltage(void) |
51 | { | 51 | { |
52 | return 4100; | 52 | /* battery value is in 8mV LSB */ |
53 | return __XTRACT(HW_POWER_BATTMONITOR, BATT_VAL) * 8; | ||
53 | } | 54 | } |
54 | 55 | ||
55 | void powermgmt_init_target(void) | 56 | void powermgmt_init_target(void) |