mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-10 04:01:36 +08:00
drivers: minimize additional I2C retries
This commit is contained in:
@@ -134,25 +134,13 @@ RGBLED::probe()
|
||||
bool on, powersave;
|
||||
uint8_t r, g, b;
|
||||
|
||||
/**
|
||||
this may look strange, but is needed. There is a serial
|
||||
EEPROM (Microchip-24aa01) that responds to a bunch of I2C
|
||||
addresses, including the 0x55 used by this LED device. So
|
||||
we need to do enough operations to be sure we are talking
|
||||
to the right device. These 3 operations seem to be enough,
|
||||
as the 3rd one consistently fails if no RGBLED is on the bus.
|
||||
*/
|
||||
|
||||
unsigned prevretries = _retries;
|
||||
_retries = 4;
|
||||
|
||||
if ((ret = get(on, powersave, r, g, b)) != OK ||
|
||||
(ret = send_led_enable(false) != OK) ||
|
||||
(ret = send_led_enable(false) != OK)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
_retries = prevretries;
|
||||
_retries = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user