We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 342d087 + 9cade87 commit 8fd9944Copy full SHA for 8fd9944
targets/TARGET_STM/i2c_api.c
@@ -590,6 +590,17 @@ int i2c_stop(i2c_t *obj)
590
#endif
591
// Disable reload mode
592
handle->Instance->CR2 &= (uint32_t)~I2C_CR2_RELOAD;
593
+
594
+ // Ensure the transmission is started before sending a stop
595
+ if ((handle->Instance->CR2 & (uint32_t)I2C_CR2_RD_WRN) == 0) {
596
+ timeout = FLAG_TIMEOUT;
597
+ while (!__HAL_I2C_GET_FLAG(handle, I2C_FLAG_TXIS)) {
598
+ if ((timeout--) == 0) {
599
+ return I2C_ERROR_BUS_BUSY;
600
+ }
601
602
603
604
// Generate the STOP condition
605
handle->Instance->CR2 |= I2C_CR2_STOP;
606
0 commit comments