Commit 041f7ee6 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Removed the hardcoded I2C address. Now it is using the value read from the EEPROM at startup.

parent a637366b
......@@ -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];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment