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
pull/3430/head
Laurent MEUNIER 2016-12-12 11:44:12 +01:00
parent 8406a99dc8
commit 580d96431e
1 changed files with 8 additions and 0 deletions

View File

@ -483,10 +483,18 @@ int i2c_start(i2c_t *obj) {
int i2c_stop(i2c_t *obj) {
struct i2c_s *obj_s = I2C_S(obj);
I2C_TypeDef *i2c = (I2C_TypeDef *)obj_s->i2c;
I2C_HandleTypeDef *handle = &(obj_s->handle);
int timeout;
// Generate the STOP condition
i2c->CR1 |= I2C_CR1_STOP;
/* In case of mixed usage of the APIs (unitary + SYNC)
* re-inti HAL state
*/
if(obj_s->XferOperation != I2C_FIRST_AND_LAST_FRAME)
i2c_init(obj, obj_s->sda, obj_s->scl);
return 0;
}