Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN
Tool/software:
In the Halcogen I2C driver code, i2cSend()
void i2cSend(i2cBASE_t *i2c, uint32 length, uint8 * data)
{
uint32 index = i2c == i2cREG1 ? 0U : 1U;
/* USER CODE BEGIN (17) */
/* USER CODE END */
if ((g_i2cTransfer_t[index].mode & (uint32)I2C_TX_INT) != 0U)
{
/* we are in interrupt mode */
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
g_i2cTransfer_t[index].data = data;
/* start transmit by sending first byte */
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
i2c->DXR = (uint32)*g_i2cTransfer_t[index].data;
/*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
g_i2cTransfer_t[index].data++;
/* Length -1 since one data is written already */
g_i2cTransfer_t[index].length = (length - 1U);
/* Enable Transmit Interrupt */
i2c->IMR |= (uint32)I2C_TX_INT;
}
else
{
/* send the data */
/* snipped */
}
/* USER CODE BEGIN (18) */
/* USER CODE END */
}
Note the:
g_i2cTransfer_t[index].length = (length - 1U);
Then in the ISR:
case 5U:
/* USER CODE BEGIN (42) */
/* USER CODE END */
/* transmit */
/*SAFETYMCUSW 30 S MR:12.2,12.3 <APPROVED> "Used for data count in Transmit/Receive polling and Interrupt mode" */
if (g_i2cTransfer_t[0U].length > 0U)
{
i2cREG1->DXR = (uint32) *g_i2cTransfer_t[0U].data;
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
g_i2cTransfer_t[0U].data++;
g_i2cTransfer_t[0U].length--;
if(g_i2cTransfer_t[0U].length == 0U)
{ /* Disable TX interrupt after desired data count transfered*/
i2cREG1->IMR &= (uint32)(~(uint32)I2C_TX_INT);
i2cNotification(i2cREG1, (uint32)I2C_TX_INT);
}
}
break;
Note the:
if (g_i2cTransfer_t[0U].length > 0U)
So, if you're sending 1 byte, when the Tx complete interrupt fires, i2cNotification() will NOT be called.
That's not very helpful.