Potential bug in I2C HAL layer (STM32Cube_FW_F4_V1.25.0) in I2C_MemoryTransmit_TXE_BTF() ?
Details:
MasterMode: HAL_I2C_MODE_MEM
Clockspeed 400kb/s
Symptoms:
In Master-MODE_MEM after memory address has been sent a repeated start should be sent (in I2C_MemoryTransmit_TXE_BTF()) before the switch to read. However if the ISR is handled quickly the code will be triggered twice (= two START conditions after each other) and the slave device will answer with a NAK.

If I added debug code (I2C event logger) the problem went away which made me feel it was a timing issue. So I analysed the code more and found that a the event handler HAL_I2C_EV_IRQHandler() can be triggered multiple times for the same event.
So I modified the code and incremented eventcount to stop the code from executing twice:
In MemoryTransmit_TXE_BTF()...
..else if (hi2c->EventCount == 2U)
{
if (hi2c->State == HAL_I2C_STATE_BUSY_RX)
{
/* Generate Restart */
hi2c->direction = I2C_Direction_Receiver;
hi2c->Instance->CR1 |= I2C_CR1_START;
// TK 20200818- FIX for dual start instead of single for re-start
// inc eventcount makes so that code only executes once
hi2c->EventCount++;
}
else ....
And it seems to work as intended:

Is there anyone else that has seen the same problem ?
/Tony
