File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1067,6 +1067,8 @@ void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c)
10671067 /* Get object ptr based on handler ptr */
10681068 i2c_t * obj = get_i2c_obj (hi2c );
10691069 struct i2c_s * obj_s = I2C_S (obj );
1070+ uint32_t event_code = 0 ;
1071+
10701072#if DEVICE_I2CSLAVE
10711073 I2C_HandleTypeDef * handle = & (obj_s -> handle );
10721074 uint32_t address = 0 ;
@@ -1076,6 +1078,11 @@ void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c)
10761078 }
10771079#endif
10781080
1081+
1082+ if ((handle -> ErrorCode & HAL_I2C_ERROR_AF ) == HAL_I2C_ERROR_AF ) {
1083+ /* Keep Set event flag */
1084+ event_code = (I2C_EVENT_TRANSFER_EARLY_NACK ) | (I2C_EVENT_ERROR_NO_SLAVE );
1085+ }
10791086 DEBUG_PRINTF ("HAL_I2C_ErrorCallback:%d, index=%d\r\n" , (int ) hi2c -> ErrorCode , obj_s -> index );
10801087
10811088 /* re-init IP to try and get back in a working state */
@@ -1090,7 +1097,7 @@ void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c)
10901097#endif
10911098
10921099 /* Keep Set event flag */
1093- obj_s -> event = I2C_EVENT_ERROR ;
1100+ obj_s -> event = event_code | I2C_EVENT_ERROR ;
10941101}
10951102
10961103const PinMap * i2c_master_sda_pinmap ()
You can’t perform that action at this time.
0 commit comments