STM32: Correct I2C master error handling

If I2C slave support is included, then the I2C error handler would
always reset the I2C address, resulting in incorrectly changing the
I2C state to listen for a controller configured as I2C master.  This
change conditionalizes the address setting to only occur if the
controller was in slave mode when the error occurred.
pull/4012/head
Bradley Scott 2017-03-23 10:54:59 -04:00
parent 75f6f2db30
commit 2eb4048bbe
1 changed files with 4 additions and 1 deletions

View File

@ -904,7 +904,10 @@ void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c){
#if DEVICE_I2CSLAVE #if DEVICE_I2CSLAVE
/* restore slave address */ /* restore slave address */
if (address != 0) {
obj_s->slave = 1;
i2c_slave_address(obj, 0, address, 0); i2c_slave_address(obj, 0, address, 0);
}
#endif #endif
/* Keep Set event flag */ /* Keep Set event flag */