Hello Saket_Om,
thank you very much for taking the time to review my code and for providing such a detailed explanation.
I now understand that the code in the official GitHub examples handles TransferDirection according to the definition you provided.
The issue on my side was caused by code taken from a tutorial in the ST community:
In that code, the subsequent evaluation of TransferDirection appears to be inverted:
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode)
{
Transfer_Direction = TransferDirection;
if (Transfer_Direction != 0)
{
/*##- Start the transmission process #####################################*/
/* While the I2C in reception process, user can transmit data through
"aTxBuffer" buffer */
if (HAL_I2C_Slave_Seq_Transmit_IT(&hi2c1, (uint8_t *)aTxBuffer, TXBUFFERSIZE, I2C_FIRST_AND_LAST_FRAME) != HAL_OK)
{
/* Transfer error in transmission process */
Error_Handler();
}
...I have also seen that other community members reported problems similar to mine when using the code from that example. The tutorial references a different MCU, but I would not expect that to affect the TransferDirection handling.
I would appreciate it if you could take a look at that tutorial as well and, if my conclusion is correct this time, consider updating or correcting the code provided there.
Best regards,
Christian
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
