File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -751,12 +751,24 @@ void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c){
751
751
/* Get object ptr based on handler ptr */
752
752
i2c_t * obj = get_i2c_obj (hi2c );
753
753
struct i2c_s * obj_s = I2C_S (obj );
754
+ #if DEVICE_I2CSLAVE
755
+ I2C_HandleTypeDef * handle = & (obj_s -> handle );
756
+ uint32_t address = 0 ;
757
+ /* Store address to handle it after reset */
758
+ if (obj_s -> slave )
759
+ address = handle -> Init .OwnAddress1 ;
760
+ #endif
754
761
755
762
DEBUG_PRINTF ("HAL_I2C_ErrorCallback:%d, index=%d\r\n" , (int ) hi2c -> ErrorCode , obj_s -> index );
756
763
757
764
/* re-init IP to try and get back in a working state */
758
765
i2c_init (obj , obj_s -> sda , obj_s -> scl );
759
766
767
+ #if DEVICE_I2CSLAVE
768
+ /* restore slave address */
769
+ i2c_slave_address (obj , 0 , address , 0 );
770
+ #endif
771
+
760
772
/* Keep Set event flag */
761
773
obj_s -> event = I2C_EVENT_ERROR ;
762
774
}
You can’t perform that action at this time.
0 commit comments