From 16de43cd0240d02a35dad104bc71a454fc8dd63a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 13 May 2013 14:51:25 +0000 Subject: Tentative fix for OUT transactions, not complete. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5733 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/USBv1/usb_lld.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'os') diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.c b/os/hal/platforms/STM32/USBv1/usb_lld.c index f3ee4d1fd..eac014de0 100644 --- a/os/hal/platforms/STM32/USBv1/usb_lld.c +++ b/os/hal/platforms/STM32/USBv1/usb_lld.c @@ -398,19 +398,22 @@ CH_IRQ_HANDLER(STM32_USB1_LP_HANDLER) { usb_packet_read_to_buffer(udp, epcp->out_state->mode.linear.rxbuf, n); - epcp->out_state->mode.linear.rxbuf += n; + epcp->out_state->mode.linear.rxbuf += n; } /* Transaction data updated.*/ epcp->out_state->rxcnt += n; epcp->out_state->rxsize -= n; epcp->out_state->rxpkts -= 1; - if (epcp->out_state->rxpkts > 0) { - /* Transfer not completed, there are more packets to receive.*/ - EPR_SET_STAT_RX(ep, EPR_STAT_RX_VALID); + + /* The transaction is completed if the specified number of packets + has been received or the current packet is a short packet.*/ + if ((n < epcp->out_maxsize) || (epcp->out_state->rxpkts == 0)) { + /* Transfer complete, invokes the callback.*/ + _usb_isr_invoke_out_cb(usbp, ep); } else { - /* Transfer completed, invokes the callback.*/ - _usb_isr_invoke_out_cb(usbp, ep); + /* Transfer not complete, there are more packets to receive.*/ + EPR_SET_STAT_RX(ep, EPR_STAT_RX_VALID); } } } -- cgit v1.2.3