Commit 496490fe authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Added a device ID to the memory structure to separate different slave devices...

Added a device ID to the memory structure to separate different slave devices EEPROM registers on the same microcontroller.
parent d7d397f5
......@@ -21,6 +21,7 @@ typedef struct
TMemModule *mem_modules[MAX_NUM_MEM_MODULES];
unsigned short int (*eeprom_write_data)(unsigned short int address,unsigned short int data);
unsigned short int (*eeprom_read_data)(unsigned short int address,unsigned short int *data);
unsigned char device_id;
unsigned char data[RAM_SIZE];
unsigned short int total_eeprom;
unsigned short int total_ram;
......
......@@ -30,6 +30,7 @@ void mem_init(TMemory *memory)
/* initialize internal variables */
memory->total_eeprom=0;
memory->total_ram=0;
memory->device_id=0x00;
}
void mem_initialize_data(TMemory *memory)
......@@ -44,7 +45,7 @@ void mem_initialize_data(TMemory *memory)
{
for(i=0;i<EEPROM_SIZE;i++)
{
if(memory->eeprom_read_data(i,&data))
if(memory->eeprom_read_data((memory->device_id<<8)+i,&data))
eeprom_data[i]=0x00;
else
eeprom_data[i]=data&0x00FF;
......
Supports Markdown
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