From 3e201196439a3da9f97a4ad4d77586b38e1a1e5d Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Fri, 2 Jun 2023 23:39:21 +0300 Subject: [PATCH] sn32: Fixed USB sending errors under certain conditions --- os/hal/ports/SN32/LLD/SN32F2xx/USB/hal_usb_lld.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/os/hal/ports/SN32/LLD/SN32F2xx/USB/hal_usb_lld.c b/os/hal/ports/SN32/LLD/SN32F2xx/USB/hal_usb_lld.c index ea73be460c..d9e2a7d386 100644 --- a/os/hal/ports/SN32/LLD/SN32F2xx/USB/hal_usb_lld.c +++ b/os/hal/ports/SN32/LLD/SN32F2xx/USB/hal_usb_lld.c @@ -331,6 +331,12 @@ void usb_serve_endpoints(USBDriver* usbp, usbep_t ep, bool in) { /* IN endpoint, transmission.*/ USBInEndpointState *isp = epcp->in_state; + if (isp->txcnt >= isp->txsize) { + /* Transfer completed, invokes the callback.*/ + _usb_isr_invoke_in_cb(usbp, ep); + return; + } + isp->txcnt += isp->txlast; n = isp->txsize - isp->txcnt;