From 7824874cc8e94d6df1b663b015fc1fe87e478790 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 14 Jun 2024 18:57:48 +0800 Subject: [PATCH] some tweaks to try and make stalls appear at the right time??? --- libs/cramium-hal/src/usb/driver.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libs/cramium-hal/src/usb/driver.rs b/libs/cramium-hal/src/usb/driver.rs index a9313a209..6f8134ebc 100644 --- a/libs/cramium-hal/src/usb/driver.rs +++ b/libs/cramium-hal/src/usb/driver.rs @@ -1744,7 +1744,7 @@ impl CorigineUsb { 0, true, false, - false, + USB_SEND, self.setup_tag, intr_target, ); @@ -2039,7 +2039,20 @@ impl CorigineUsb { // this works with linux, but not with windows. if stalled != self.stall_spec[pei].unwrap_or(false) { self.stall_spec[pei] = Some(stalled); - self.ep0_enqueue_zlp(stalled, CRG_INT_TARGET); + // this code is sus, too + if ep_num == 0 { + if dir == USB_RECV { + self.ep0_enqueue_zlp(stalled, CRG_INT_TARGET); + } else { + self.ep0_status(stalled, CRG_INT_TARGET); + } + } else { + if stalled { + self.ep_halt(ep_num, dir); + } else { + self.ep_unhalt(ep_num, dir); + } + } } } @@ -2292,6 +2305,10 @@ impl UsbBus for CorigineWrapper { ); self.core().ep0_enqueue(ep0_buf.as_ptr() as usize, buf.len(), CRG_INT_TARGET); self.txn_offset.lock().unwrap()[ep_addr.index()] = txn_offset + mps as usize; + } else { + log::info!(" ******* ZLP EP0 ack"); // not sure if this is the right way to do it + let stalled = self.core().stall_spec[0].unwrap_or(false); + self.core().ep0_status(stalled, CRG_INT_TARGET); } Ok(buf.len()) } else {