mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 02:51:37 +08:00
drivers/device/nuttx/I2C: only issue I2C_RESET() if retrying, and only before the next retry
This commit is contained in:
@@ -225,9 +225,11 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we have already retried once, or we are going to give up, then reset the bus */
|
// if we have already retried once, and we aren't going to give up, then reset the bus
|
||||||
if ((retry_count >= 1) || (retry_count >= _retries)) {
|
if ((_retries > 0) && (retry_count < _retries)) {
|
||||||
#if defined(CONFIG_I2C_RESET)
|
#if defined(CONFIG_I2C_RESET)
|
||||||
|
DEVICE_DEBUG("I2C bus: %d, Addr: %X, I2C_RESET %d/%d",
|
||||||
|
get_device_bus(), get_device_address(), retry_count + 1, _retries);
|
||||||
I2C_RESET(_dev);
|
I2C_RESET(_dev);
|
||||||
#endif // CONFIG_I2C_RESET
|
#endif // CONFIG_I2C_RESET
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user