lkml.org 
[lkml]   [2009]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[rfc/patch 09/15] power: bq27200: fix up current reporting
Date
according to bq27200 datasheet, avarage current is calculated
with the following equation:

current = (256 * AI) * 3.57 / Rs

where Rs = 20mOhms

Signed-off-by: Felipe Balbi <me@felipebalbi.com>
---
drivers/power/bq27200_battery.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/power/bq27200_battery.c b/drivers/power/bq27200_battery.c
index f36633c..869761e 100644
--- a/drivers/power/bq27200_battery.c
+++ b/drivers/power/bq27200_battery.c
@@ -52,6 +52,9 @@
#define BQ27200_REG_CYCT 0x2a /* cycle-count total */
#define BQ27200_REG_CSOC 0x2c /* compensated state-of-charge */

+#define BQ27200_SENSING_RESISTOR (20) /* 20 mOhms */
+#define BQ27200_CURRENT_CONSTANT (256 * 3570 / 1000) /* 256 * 3.57 uV */
+
struct bq27200 {
struct power_supply bat;
struct i2c_client *client;
@@ -143,7 +146,7 @@ static int bq27200_current(struct bq27200 *bq)
return 0;
}

- return ret;
+ return (ret * BQ27200_CURRENT_CONSTANT) / BQ27200_SENSING_RESISTOR;
}

/*
--
1.6.1.3


\
 
 \ /
  Last update: 2009-07-12 20:37    [W:0.065 / U:3.008 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site