From 99e98db99c3e4ed5863f2e6006b322b7b050e1f9 Mon Sep 17 00:00:00 2001 From: Ian Rees Date: Thu, 24 Jun 2021 17:11:30 +1200 Subject: [PATCH] Clear USB OUT interrupts when buffer is full Relies on https://github.com/atsamd-rs/atsamd/pull/459 --- src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3046c11..d67c5d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -451,9 +451,13 @@ where }; } Err(_) => { - // Don't read the data out of the USB endpoint, because we don't - // have anywhere to put it. The USB hardware will NAK the - // packet and decide whether to retry or abort the transfer. + // Since we don't have anywhere to put more data, we can't read + // data out of the USB endpoint. The USB hardware will NAK + // transfers, and the host will decide whether to retry, until + // we eventually read. In the meantime, clear interrupt flags + // in the USB endpoint hardware with an empty read: + let _ = self.read_ep.read(&mut[]); + self.flush_uart(); // Ensure we continue draining the buffer } }