Skip to content

Commit 580d964

Browse files
committed
STM32 I2C manage STOP specific case
In case the user applicaiton makes a mixed usage of unitary function (start, stop, byte write & read) with SYNC operation (write and read of data buffers with start and stop management), we need to reset the STM32 HAL state as it is by-passed by a direct call to STOP
1 parent 8406a99 commit 580d964

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

targets/TARGET_STM/i2c_api.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,18 @@ int i2c_start(i2c_t *obj) {
483483
int i2c_stop(i2c_t *obj) {
484484
struct i2c_s *obj_s = I2C_S(obj);
485485
I2C_TypeDef *i2c = (I2C_TypeDef *)obj_s->i2c;
486+
I2C_HandleTypeDef *handle = &(obj_s->handle);
487+
int timeout;
486488

487489
// Generate the STOP condition
488490
i2c->CR1 |= I2C_CR1_STOP;
489491

492+
/* In case of mixed usage of the APIs (unitary + SYNC)
493+
* re-inti HAL state
494+
*/
495+
if(obj_s->XferOperation != I2C_FIRST_AND_LAST_FRAME)
496+
i2c_init(obj, obj_s->sda, obj_s->scl);
497+
490498
return 0;
491499
}
492500

0 commit comments

Comments
 (0)