mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-980 change how the semaphore is used on PIOS_USB_CheckAvailable to prevent deadlocks
This commit is contained in:
parent
5fe1bfbe36
commit
87db5d30b0
@ -179,20 +179,20 @@ bool PIOS_USB_CheckAvailable(__attribute__((unused)) uint32_t id)
|
|||||||
usb_found = ((usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin) != 0) ^ usb_dev->cfg->vsense_active_low;
|
usb_found = ((usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin) != 0) ^ usb_dev->cfg->vsense_active_low;
|
||||||
|
|
||||||
bool status = usb_found != 0 && transfer_possible ? 1 : 0;
|
bool status = usb_found != 0 && transfer_possible ? 1 : 0;
|
||||||
|
bool reconnect = false;
|
||||||
#ifdef PIOS_INCLUDE_FREERTOS
|
#ifdef PIOS_INCLUDE_FREERTOS
|
||||||
while (xSemaphoreTakeFromISR(usb_dev->statusCheckSemaphore, NULL) != pdTRUE) {
|
if(xSemaphoreTakeFromISR(usb_dev->statusCheckSemaphore, NULL) == pdTRUE) {
|
||||||
;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
bool reconnect = (lastStatus && !status);
|
reconnect = (lastStatus && !status);
|
||||||
lastStatus = status;
|
lastStatus = status;
|
||||||
#ifdef PIOS_INCLUDE_FREERTOS
|
#ifdef PIOS_INCLUDE_FREERTOS
|
||||||
xSemaphoreGiveFromISR(usb_dev->statusCheckSemaphore, NULL);
|
xSemaphoreGiveFromISR(usb_dev->statusCheckSemaphore, NULL);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (reconnect) {
|
if (reconnect) {
|
||||||
raiseDisconnectionCallbacks();
|
raiseDisconnectionCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user