AP_Airspeed: use take_blocking instead of HAL_SEMAPHORE_BLOCK_FOREVER

this makes for cleaner and smaller code as the failure case is not
needed
This commit is contained in:
Andrew Tridgell 2020-01-19 08:42:32 +11:00
parent e1274aea33
commit 2e5fe75aa7
2 changed files with 4 additions and 12 deletions

View File

@ -71,9 +71,7 @@ bool AP_Airspeed_MS5525::init()
if (!dev) {
continue;
}
if (!dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
continue;
}
dev->get_semaphore()->take_blocking();
// lots of retries during probe
dev->set_retries(5);

View File

@ -68,9 +68,7 @@ bool AP_Airspeed_SDP3X::init()
if (!_dev) {
continue;
}
if (!_dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
continue;
}
_dev->get_semaphore()->take_blocking();
// lots of retries during probe
_dev->set_retries(10);
@ -84,9 +82,7 @@ bool AP_Airspeed_SDP3X::init()
// these delays are needed for reliable operation
_dev->get_semaphore()->give();
hal.scheduler->delay_microseconds(20000);
if (!_dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
continue;
}
_dev->get_semaphore()->take_blocking();
// start continuous average mode
if (!_send_command(SDP3X_CONT_MEAS_AVG_MODE)) {
@ -97,9 +93,7 @@ bool AP_Airspeed_SDP3X::init()
// these delays are needed for reliable operation
_dev->get_semaphore()->give();
hal.scheduler->delay_microseconds(20000);
if (!_dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
continue;
}
_dev->get_semaphore()->take_blocking();
// step 3 - get scale
uint8_t val[9];