From ab9c61e35c825acdd45603bd1f2470f0de82c6c8 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Thu, 10 Jan 2019 14:20:10 +0100 Subject: [PATCH] [USB] Fix EPO STALL issue in STM32 USB Device library USB Specification EP0 should never STALL during setup stage. Device is not properly setup if STALL present. Fixes #664 Signed-off-by: Frederic.Pillon --- .../ST/STM32_USB_Device_Library/Core/Src/usbd_core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c b/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c index b1a60ae2be..d04117f8d1 100644 --- a/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c +++ b/system/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c @@ -393,12 +393,14 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, } else { - if ((pdev->pClass->EP0_TxSent != NULL) && - (pdev->dev_state == USBD_STATE_CONFIGURED)) + if (pdev->dev_state == USBD_STATE_CONFIGURED) { - pdev->pClass->EP0_TxSent(pdev); + if (pdev->pClass->EP0_TxSent != NULL) + { + pdev->pClass->EP0_TxSent(pdev); + } + USBD_LL_StallEP(pdev, 0x80U); } - USBD_LL_StallEP(pdev, 0x80U); USBD_CtlReceiveStatus(pdev); } }