Dont freak out if we get two suspend events in a row

USG_1.0
Robert Fisk 7 years ago
parent 3276449378
commit 1f365434f9

@ -475,11 +475,11 @@ USBD_StatusTypeDef USBD_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef sp
USBD_StatusTypeDef USBD_Suspend(USBD_HandleTypeDef *pdev) USBD_StatusTypeDef USBD_Suspend(USBD_HandleTypeDef *pdev)
{ {
pdev->dev_old_state = pdev->dev_state; if ((pdev->dev_state > USBD_STATE_DEFAULT) &&
pdev->dev_state = USBD_STATE_SUSPENDED; (pdev->dev_state < USBD_STATE_SUSPENDED))
if (pdev->dev_old_state > USBD_STATE_DEFAULT)
{ {
pdev->dev_old_state = pdev->dev_state;
pdev->dev_state = USBD_STATE_SUSPENDED;
Upstream_StateMachine_Suspend(); Upstream_StateMachine_Suspend();
} }
return USBD_OK; return USBD_OK;

@ -248,7 +248,7 @@ void Upstream_StateMachine_DeviceDisconnected(void)
//Suspend event activated by our host //Suspend event activated by our host
void Upstream_StateMachine_Suspend(void) void Upstream_StateMachine_Suspend(void)
{ {
if (UpstreamState >= STATE_ERROR) if (UpstreamState >= STATE_SUSPENDED) //Ignore when already suspended, or in error state
{ {
return; return;
} }

Loading…
Cancel
Save