mirror of https://github.com/ARMmbed/mbed-os.git
STM32 I2C: restore slave address in case of reset
parent
ce9d2526f8
commit
9895bcf130
|
@ -751,12 +751,24 @@ void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c){
|
|||
/* Get object ptr based on handler ptr */
|
||||
i2c_t *obj = get_i2c_obj(hi2c);
|
||||
struct i2c_s *obj_s = I2C_S(obj);
|
||||
#if DEVICE_I2CSLAVE
|
||||
I2C_HandleTypeDef *handle = &(obj_s->handle);
|
||||
uint32_t address = 0;
|
||||
/* Store address to handle it after reset */
|
||||
if(obj_s->slave)
|
||||
address = handle->Init.OwnAddress1;
|
||||
#endif
|
||||
|
||||
DEBUG_PRINTF("HAL_I2C_ErrorCallback:%d, index=%d\r\n", (int) hi2c->ErrorCode, obj_s->index);
|
||||
|
||||
/* re-init IP to try and get back in a working state */
|
||||
i2c_init(obj, obj_s->sda, obj_s->scl);
|
||||
|
||||
#if DEVICE_I2CSLAVE
|
||||
/* restore slave address */
|
||||
i2c_slave_address(obj, 0, address, 0);
|
||||
#endif
|
||||
|
||||
/* Keep Set event flag */
|
||||
obj_s->event = I2C_EVENT_ERROR;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue