Browse Source

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
c415-sdk
Andrew Tridgell 5 years ago
parent
commit
2e5fe75aa7
  1. 4
      libraries/AP_Airspeed/AP_Airspeed_MS5525.cpp
  2. 12
      libraries/AP_Airspeed/AP_Airspeed_SDP3X.cpp

4
libraries/AP_Airspeed/AP_Airspeed_MS5525.cpp

@ -71,9 +71,7 @@ bool AP_Airspeed_MS5525::init() @@ -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);

12
libraries/AP_Airspeed/AP_Airspeed_SDP3X.cpp

@ -68,9 +68,7 @@ bool AP_Airspeed_SDP3X::init() @@ -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() @@ -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() @@ -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];

Loading…
Cancel
Save