Skip to content

Commit de68692

Browse files
committed
[I2C] Fix HAL F4
In function: static HAL_StatusTypeDef I2C_Master_SB(I2C_HandleTypeDef *hi2c) This check has been added: if ((hi2c->hdmatx->XferCpltCallback != NULL) || (hi2c->hdmarx->XferCpltCallback != NULL)) { /* Enable DMA Request */ SET_BIT(hi2c->Instance->CR2, I2C_CR2_DMAEN); } But, in case of the DMA is not used, hi2c->hdmatx and hi2c->hdmarx are NULL. In this case, hi2c->hdma(rx|tx)->XferCpltCallback can be not NULL then I2C_CR2_DMAEN is set while it should not. As this bit is checked several time to know if DMA is used or not this raised an exception handler. Fix #463 Signed-off-by: Frederic.Pillon <[email protected]>
1 parent c64cfb5 commit de68692

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

system/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -5449,7 +5449,8 @@ static void I2C_Master_SB(I2C_HandleTypeDef *hi2c)
54495449
hi2c->Instance->DR = I2C_7BIT_ADD_READ(hi2c->Devaddress);
54505450
}
54515451

5452-
if ((hi2c->hdmatx->XferCpltCallback != NULL) || (hi2c->hdmarx->XferCpltCallback != NULL))
5452+
if (((hi2c->hdmatx) && (hi2c->hdmatx->XferCpltCallback != NULL)) ||
5453+
((hi2c->hdmarx) && (hi2c->hdmarx->XferCpltCallback != NULL)))
54535454
{
54545455
/* Enable DMA Request */
54555456
SET_BIT(hi2c->Instance->CR2, I2C_CR2_DMAEN);

0 commit comments

Comments
 (0)