From 011a14e39d2d54ab906270b8cf8291cce59e1736 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 29 May 2013 10:26:00 -0600 Subject: [PATCH] Fix STM32F1 and F3 USB device driver. It was not handling NULL packets correctly and it prevent use of the driver with the CDC/ACM class --- arch/arm/src/stm32/stm32_usbdev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32/stm32_usbdev.c b/arch/arm/src/stm32/stm32_usbdev.c index ab39677837..d35e707c3a 100644 --- a/arch/arm/src/stm32/stm32_usbdev.c +++ b/arch/arm/src/stm32/stm32_usbdev.c @@ -1253,7 +1253,16 @@ static int stm32_wrrequest(struct stm32_usbdev_s *priv, struct stm32_ep_s *prive #warning "REVISIT: If the EP supports double buffering, then we can do better" - /* Send the next packet */ + /* Either (1) we are committed to sending the null packet (because txnullpkt == 1 + * && nbytes == 0), or (2) we have not yet send the last packet (nbytes > 0). + * In either case, it is appropriate to clearn txnullpkt now. + */ + + privep->txnullpkt = 0; + + /* If we are not sending a NULL packet, then clip the size to maxpacket + * and check if we need to send a following NULL packet. + */ if (nbytes > 0) { @@ -1261,7 +1270,6 @@ static int stm32_wrrequest(struct stm32_usbdev_s *priv, struct stm32_ep_s *prive * the request. */ - privep->txnullpkt = 0; if (nbytes >= privep->ep.maxpacket) { nbytes = privep->ep.maxpacket;