From 82df4b990ed046b74e929b16ddefa70ed65b2946 Mon Sep 17 00:00:00 2001 From: Yuuichi Akagawa Date: Fri, 26 Mar 2021 14:43:31 +0900 Subject: [PATCH] Recover from OUT-NAK --- Usb.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Usb.cpp b/Usb.cpp index 7843d49b..5fa75ec8 100644 --- a/Usb.cpp +++ b/Usb.cpp @@ -388,6 +388,11 @@ uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8 data_p += bytes_tosend; }//while( bytes_left... breakout: + /* If rcode(=rHRSL) is non-zero, untransmitted data remains in the SNDFIFO. */ + if(rcode != 0) { + //Switch the FIFO containing the OUT data back under microcontroller control and reset pointer. + regWr(rSNDBC, 0); + } pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle return ( rcode); //should be 0 in all cases