Closed accabog closed 1 year ago
Hello @accabog , First of all, thank you for this contribution. Would you please give us more details about how you got this issue? Did you observe it at runtime? If so, could you please share the code you have used to reproduce the problem.
Best Regards,
Hello @HBOSTM ,
To reproduce, try a HAL_I2C_Mem_Read_DMA and after that do HAL_I2C_Mem_Write. The HAL_I2C_Mem_Write will trigger a TX IRQ, even though it should not.
HAL_I2C_Mem_Read_DMA enables I2C_XFER_TX_IT when called and disables only I2C_XFER_RX_IT in I2C_ITMasterCplt.
I've encountered this situation when I called HAL_I2C_Mem_Read_DMA and after that called HAL_I2C_Mem_Write. Got stuck in ISR because hi2c->XferISR had not been set.
Hello @accabog ,
thank you again for this contribution. This point has been reported to our development teams. I will get back to you as soon as I have any updates.
With Regards,
ST Internal Reference: 145679
Hello @accabog
The fix you requested has been implemented and is now available in the frame of the latest stm32l4_hal_driver package V1.18.0 release. This issue can be closed now. Thank you again for your contribution.
Best Regards,
Because HAL_I2C_Mem_Read_DMA MemAddress transmission is based on TX IRQ https://github.com/STMicroelectronics/STM32CubeL4/blob/26be59071141d07a1d0dddb58b9fb335b027cbaa/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c#L3079
neither I2C_Mem_ISR_DMA nor I2C_ITMasterCplt will not disable the TX IRQ after the data transfer
https://github.com/STMicroelectronics/STM32CubeL4/blob/26be59071141d07a1d0dddb58b9fb335b027cbaa/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c#L5930
Therefore, if a non-IT based transmission such as HAL_I2C_Mem_Write will follow, a TX irq will be triggered without any interrupt callback defined, therefore the IRQ cannot be cleared and results in the program stuck in I2C ISR