Other Parts Discussed in Thread: TM4C123GH6PM, EK-TM4C123GXL
We have a SE97b chip on our board, and I'm trying to read the eeprom using I2C_MODE_CALLBACK, but the callback is never called.
Code:
uint8_t g_eepromTxBuffer[1]; uint8_t g_eepromRxBuffer[256]; I2C_Handle g_i2c; I2C_Params g_i2cParams; I2C_Transaction g_i2cTransaction;
/*********************************************************************************************************************//** * initialize the eeprom reader variables *************************************************************************************************************************/ void initEL1042EEPROM() { /// Create I2C for usage I2C_Params_init(&g_i2cParams); g_i2cParams.bitRate = I2C_100kHz; g_i2cParams.transferMode = I2C_MODE_CALLBACK; g_i2cParams.transferCallbackFxn = EEPROMCallbackFxn; /// Point to the T ambient register and read its 2 bytes g_eepromTxBuffer[0] = 0x00; g_i2cTransaction.slaveAddress = SE97B_ADDR_EEPROM; g_i2cTransaction.writeBuf = g_eepromTxBuffer; g_i2cTransaction.writeCount = 1; g_i2cTransaction.readBuf = g_eepromRxBuffer; g_i2cTransaction.readCount = 256; /// set the lens to offline lens1.conn = LENS_OFFLINE; }
/*********************************************************************************************************************//**
* read the lens eeprom
*************************************************************************************************************************/
void ReadEL1042EEPROM()
{
g_i2c = I2C_open(Board_I2C_TMP, &g_i2cParams);
if (g_i2c == NULL) {
lens1.conn = LENS_I2C_INIT_ERROR;
#ifdef DEBUG
System_abort("Error Initializing I2C\n");
#else
return;
#endif
}
else {
if (I2C_transfer(g_i2c, &g_i2cTransaction)) {
/// we got the EEPROM, lens is connected
lens1.conn = LENS_ONLINE;
#ifdef DEBUG
System_printf("eeprom read\n");
System_flush();
#endif
}
else {
/// there is no lens connected
lens1.conn = LENS_OFFLINE;
#ifdef DEBUG
System_printf("I2C Bus fault\n");
System_flush();
#endif
}
/// Deinitialized I2C
I2C_close(g_i2c);
}
}
/*********************************************************************************************************************//**
* callback
*************************************************************************************************************************/
void EEPROMCallbackFxn(I2C_Handle handle, I2C_Transaction *transaction, bool result)
{
initStruct();
}
and on my .cfg file I've declared:
hwi0Params.instance.name = "i2cHwi"; Program.global.i2cHwi = Hwi.create(52, "&EEPROMCallbackFxn", hwi0Params);
initEL1042EEPROM() is called at the beginning of the applications,
and ReadEL1042EEPROM() is called from a Task.
if someone could point me to the right direction I would appreciate.
Thanks
