From 6aaad0a5cd237f56d7dd37af9af05e2fa799358d Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Sat, 2 Mar 2024 10:37:51 +0100 Subject: [PATCH] drivers: udc_stm32: handle ZLP flag A function, such as CDC ECM, can set the ZLP flag to handle a class-specific protocol. This is not to be confused with the ZLP role in control transfers. Signed-off-by: Johann Fischer --- drivers/usb/udc/udc_stm32.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/udc/udc_stm32.c b/drivers/usb/udc/udc_stm32.c index 220ea17925f..39a795c9840 100644 --- a/drivers/usb/udc/udc_stm32.c +++ b/drivers/usb/udc/udc_stm32.c @@ -322,6 +322,13 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) return; } + if (udc_ep_buf_has_zlp(buf) && ep != USB_CONTROL_EP_IN) { + udc_ep_buf_clear_zlp(buf); + HAL_PCD_EP_Transmit(&priv->pcd, ep, buf->data, 0); + + return; + } + udc_buf_get(dev, ep); if (ep == USB_CONTROL_EP_IN) {