From c2d0f2af2f21a3c9539b89749bf6139c9f15b903 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sat, 10 Aug 2019 19:40:34 -0400 Subject: A bunch of cleanup and fixes. Simplify the code a bunch to reduce it to states we actually care about. This will now probe my Logitech G105, NIZ Plum 85EC, and Keyboard.io Model 01. * Don't listen for wakeup interrupts. Only listen for device connection and disconnection, which wakeups sometimes mean. * Remove the SETTLE_DELAY stuff on device connection, as this appears to be handled in hardware, and prevents over-delay which was causing the Model 01 to reset, since it wasn't getting a SOF in time. * Set initial max packet size for address 0 endpoint 0 based on whether the connection is Full Speed or Low Speed. * Remove all intflag checks from USB handler that we don't explicitly set up. * Always listen dor dconn/ddisc in handler. Since we're using a ring buffer for event storage, we shouldn't miss these and always handle them in order. * Don't freeze pipes on errors. Let the hardware do it. * Don't retransmit packets on errors, just keep polling hardware. * Move trfail check to the end, since it's either dependent on previous, more specific checks, or it's just a NAK (but, for some reason, not ERRORFLOW). * Add `modify` method to control pipe register. --- src/pipe/ctrl_pipe.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/pipe/ctrl_pipe.rs') diff --git a/src/pipe/ctrl_pipe.rs b/src/pipe/ctrl_pipe.rs index 9301d51..91235cd 100644 --- a/src/pipe/ctrl_pipe.rs +++ b/src/pipe/ctrl_pipe.rs @@ -28,6 +28,16 @@ impl CtrlPipe { f(&mut w); self.0 = w.bits; } + + pub fn modify(&mut self, f: F) + where + for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W, + { + let r = R { bits: self.0 }; + let mut w = W { bits: self.0 }; + f(&r, &mut w); + self.0 = w.bits; + } } impl From for CtrlPipe { -- cgit v1.2.3