From 041f7ee668249e4e2336bf9219bbc52cad9211c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu>
Date: Wed, 18 Jul 2012 13:21:00 +0000
Subject: [PATCH] Removed the hardcoded I2C address. Now it is using the value
 read from the EEPROM at startup.

---
 fuel_gauge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fuel_gauge.c b/fuel_gauge.c
index 0e32e11..5a4dd64 100755
--- a/fuel_gauge.c
+++ b/fuel_gauge.c
@@ -11,7 +11,7 @@ float output_current;
 
 // battery I2C slave address
 unsigned char battery_id;             
-unsigned char EEMEM ee_battery_id=0x31;  
+unsigned char EEMEM ee_battery_id=0x60;  
 
 // remaining_capacity
 volatile unsigned short int remaining_capacity;
@@ -102,9 +102,9 @@ void get_voltage(unsigned char *voltage)
   // read the voltage registers of the battery
   // send the read request
   read_cmd=0x30;
-  if(i2cMasterSendNI(0x62,1,&read_cmd)==I2C_OK)
+  if(i2cMasterSendNI(battery_id,1,&read_cmd)==I2C_OK)
   {
-    if(i2cMasterReceiveNI(0x62,18,voltage_data)==I2C_OK)
+    if(i2cMasterReceiveNI(battery_id,18,voltage_data)==I2C_OK)
     {
       for(i=0;i<16;i++)
         voltage[i]=voltage_data[i+2];
@@ -118,9 +118,9 @@ void get_temperature(unsigned char *temp1, unsigned char *temp2)
   unsigned char read_cmd;
 
   read_cmd=0x4A;// device start read address
-  if(i2cMasterSendNI(0x62,1,&read_cmd)==I2C_OK)
+  if(i2cMasterSendNI(battery_id,1,&read_cmd)==I2C_OK)
   {
-   	if(i2cMasterReceiveNI(0x62,6,temp_data)==I2C_OK)
+   	if(i2cMasterReceiveNI(battery_id,6,temp_data)==I2C_OK)
 	{
 	  temp1[0]=temp_data[2];
 	  temp1[1]=temp_data[3];
-- 
GitLab