Tool/software: TI-RTOS
Hi,
In my project, I want to read MAC Adrress from the Eeprom of the device by means of i2 protocol in TI-RTOS.For this purpose, I created a new task that reads the MAC from eeprom registers and write the related registers that are lUser0 and lUser1 like this:
void macInitFxn()
{
I2C_Handle i2c6Handle;
I2C_Params i2c6Params;
uint8_t txBuffer[1];
/* 48 bits of MAC Addr */
uint8_t getMacBuffer[6];
I2C_Transaction i2cTransaction;
I2C_Params_init(&i2c6Params);
i2c6Handle = I2C_open(DK_TM4C129X_I2C6, &i2c6Params);
if(i2c6Handle == NULL)
{
LOG("I2C cannot be opened correctly for MAC Address!\n");
return;
}
/* Take MAC Address Information */
/* MAC Address start register from 0xFA to 0xFF */
txBuffer[0] = 0xFA;
/* Slave Address for Eeprom */
i2cTransaction.slaveAddress = 0x50;
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = getMacBuffer;
i2cTransaction.readCount = 6;
if (I2C_transfer(i2c6Handle, &i2cTransaction))
{
uint32_t hMAC = ( ( getMacBuffer[0] << 16 ) | ( getMacBuffer[1] << 8 ) | ( getMacBuffer[2]) );
uint32_t lMAC = ( ( getMacBuffer[3] << 16 ) | ( getMacBuffer[4] << 8 ) | ( getMacBuffer[5]) );
if(FlashUserSet( hMAC, lMAC ) != SUCCESS)
{
LOGERR("MAC Address could not be programmed successfully");
I2C_close(i2c6Handle);
return;
}
if(FlashUserSave() != SUCCESS)
{
LOGERR("Changing of MAC Address could not be committed");
I2C_close(i2c6Handle);
return;
}
LOG("MAC Address is changed successfully");
I2C_close(i2c6Handle);
return;
}
LOGERR("I2C Bus fault\n");
I2C_close(i2c6Handle);
return;
}
I see that MAC Address from LM Flah programmer is changed succesfully to value which is read from Eeprom even though it could not been as changed when I use "arp -a" command in cmd. I see FF-FF-FF-FF-FF-FF .Is there any problem for changing MAC in my code ? Am I read only register values from LM Flah Porgrammer? Thanks for your answers.
Best Regards,
Cengizhan YAPICIOĞLU