From 19bb191029ab7e618b0eace5a86abfa272c8a791 Mon Sep 17 00:00:00 2001 From: Robert Fisk Date: Mon, 5 Sep 2016 12:23:01 +1200 Subject: [PATCH] Don't fail if device stalls on SetIdle command (*cough* Logitech mice) --- .../Core/Src/usbh_ctlreq.c | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Downstream/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c b/Downstream/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c index a41148d..42d271d 100644 --- a/Downstream/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c +++ b/Downstream/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c @@ -577,19 +577,11 @@ USBH_StatusTypeDef USBH_CtlReq (USBH_HandleTypeDef *phost, case CMD_WAIT: status = USBH_HandleControl(phost); - if (status == USBH_OK) + if (status != USBH_BUSY) { - /* Commands successfully sent and Response Received */ phost->RequestState = CMD_SEND; - phost->Control.state =CTRL_IDLE; - status = USBH_OK; + phost->Control.state = CTRL_IDLE; } - else if (status == USBH_FAIL) - { - /* Failure Mode */ - phost->RequestState = CMD_SEND; - status = USBH_FAIL; - } break; default: @@ -701,8 +693,8 @@ static USBH_StatusTypeDef USBH_HandleControl (USBH_HandleTypeDef *phost) /* manage error cases*/ if (URB_Status == USBH_URB_STALL) { - //Retry transaction - phost->Control.state = CTRL_ERROR; + //Command not supported, report to callee + status = USBH_NOT_SUPPORTED; } else if (URB_Status == USBH_URB_ERROR) { @@ -737,8 +729,8 @@ static USBH_StatusTypeDef USBH_HandleControl (USBH_HandleTypeDef *phost) /* handle error cases */ else if (URB_Status == USBH_URB_STALL) { - //Retry transaction - phost->Control.state = CTRL_ERROR; + //Command not supported, report to callee + status = USBH_NOT_SUPPORTED; } else if (URB_Status == USBH_URB_NOTREADY) { @@ -784,8 +776,8 @@ static USBH_StatusTypeDef USBH_HandleControl (USBH_HandleTypeDef *phost) } else if(URB_Status == USBH_URB_STALL) { - //Retry transaction - phost->Control.state = CTRL_ERROR; + //Command not supported, report to callee + status = USBH_NOT_SUPPORTED; } if ((int32_t)(phost->Timer - phost->Control.timer) >= USBH_CTRL_TRANSACTION_TIMEOUT_MS)