AP_Radio: 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:
parent
0d44d666d0
commit
1cee9bea28
@ -320,9 +320,7 @@ const uint16_t CRCTable[] = {
|
||||
bool AP_Radio_cc2500::probe(void)
|
||||
{
|
||||
auto dev = hal.spi->get_device("cc2500");
|
||||
if (!dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
|
||||
return false;
|
||||
}
|
||||
dev->get_semaphore()->take_blocking();
|
||||
uint8_t r1=0, r2=0;
|
||||
if (!dev->read_registers(CC2500_30_PARTNUM | CC2500_READ_BURST | CC2500_READ_SINGLE, &r1, 1) || r1 != 0x80 ||
|
||||
!dev->read_registers(CC2500_31_VERSION | CC2500_READ_BURST | CC2500_READ_SINGLE, &r2, 1) || r2 != 0x03) {
|
||||
|
@ -282,9 +282,7 @@ bool AP_Radio_cypress::init(void)
|
||||
*/
|
||||
bool AP_Radio_cypress::reset(void)
|
||||
{
|
||||
if (!dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
|
||||
return false;
|
||||
}
|
||||
dev->get_semaphore()->take_blocking();
|
||||
|
||||
/*
|
||||
to reset radio hold reset high for 0.5s, then low for 0.5s
|
||||
@ -1439,10 +1437,7 @@ void AP_Radio_cypress::dsm_choose_channel(void)
|
||||
*/
|
||||
void AP_Radio_cypress::start_recv_bind(void)
|
||||
{
|
||||
if (!dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {
|
||||
// shouldn't be possible
|
||||
return;
|
||||
}
|
||||
dev->get_semaphore()->take_blocking();
|
||||
|
||||
Debug(1, "Cypress: start_recv_bind\n");
|
||||
|
||||
|
@ -373,7 +373,7 @@ public:
|
||||
Radio_Beken(AP_HAL::OwnPtr<AP_HAL::SPIDevice> _dev);
|
||||
bool lock_bus(void)
|
||||
{
|
||||
return dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER);
|
||||
return dev->get_semaphore()->take_blocking();
|
||||
}
|
||||
void unlock_bus(void)
|
||||
{
|
||||
|
@ -157,7 +157,11 @@ public:
|
||||
|
||||
bool lock_bus(void)
|
||||
{
|
||||
return dev && dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER);
|
||||
if (!dev) {
|
||||
return false;
|
||||
}
|
||||
dev->get_semaphore()->take_blocking();
|
||||
return true;
|
||||
}
|
||||
void unlock_bus(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user