fix(core): consider device in USB suspend connected if it was configured before

[no changelog]
pull/2485/head
Ondrej Mikle 2 years ago
parent a20783731a
commit 77cdf4b43c

@ -153,11 +153,19 @@ void usb_start(void) { USBD_Start(&usb_dev_handle); }
void usb_stop(void) { USBD_Stop(&usb_dev_handle); } void usb_stop(void) { USBD_Stop(&usb_dev_handle); }
secbool usb_configured(void) { secbool usb_configured(void) {
USBD_HandleTypeDef *pdev = &usb_dev_handle; const USBD_HandleTypeDef *pdev = &usb_dev_handle;
if (pdev->dev_state == USBD_STATE_CONFIGURED) { if (pdev->dev_state == USBD_STATE_CONFIGURED) {
return sectrue; return sectrue;
} }
// Linux has autosuspend device after 2 seconds by default.
// So a suspended device that was seen as configured is reported as
// configured.
if (pdev->dev_state == USBD_STATE_SUSPENDED &&
pdev->dev_old_state == USBD_STATE_CONFIGURED) {
return sectrue;
}
return secfalse; return secfalse;
} }

Loading…
Cancel
Save