Clear I2C data register on transmit failure

This commit is contained in:
mj 2022-01-02 18:19:03 +01:00
parent ef18028fe7
commit 047f1f0025

View File

@ -34,6 +34,7 @@ int8_t i2c_transmit(uint8_t address, uint8_t *buffer, int len)
} }
} }
LL_I2C_ClearFlag_STOP(i2c_context->i2c); LL_I2C_ClearFlag_STOP(i2c_context->i2c);
LL_I2C_ClearFlag_TXE(i2c_context->i2c);
if (len != i) { if (len != i) {
/* If we detect NACK during transaction (before the end of the last byte) */ /* If we detect NACK during transaction (before the end of the last byte) */
return I2C_ERROR_TX_INCOMPLETE; return I2C_ERROR_TX_INCOMPLETE;