Browse Source

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

USG_1.0
Robert Fisk 5 years ago
parent
commit
1f365434f9
  1. 8
      Upstream/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
  2. 2
      Upstream/Src/upstream_statemachine.c

8
Upstream/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c

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

2
Upstream/Src/upstream_statemachine.c

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

Loading…
Cancel
Save