aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x]src/lib.rs2
-rw-r--r--src/pipe.rs13
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 85b3b8f..ce551d4 100755..100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,5 @@
+//! USB Host driver implementation for SAMD* series chips.
+
#![no_std]
mod pipe;
diff --git a/src/pipe.rs b/src/pipe.rs
index 0da0e7f..607e1c9 100644
--- a/src/pipe.rs
+++ b/src/pipe.rs
@@ -27,7 +27,7 @@ use atsamd_hal::target_device::usb::{
host::{BINTERVAL, PCFG, PINTFLAG, PSTATUS, PSTATUSCLR, PSTATUSSET},
};
use core::convert::TryInto;
-use log::trace;
+use log::{trace, warn};
// Maximum time to wait for a control request with data to finish. cf
// ยง9.2.6.1 of USB 2.0.
@@ -309,8 +309,8 @@ impl Pipe<'_, '_> {
// the status bit is set, set it again? if it's clear then
// clear it? This is what I get for having to work from
// Arduino sources.
- trace!(
- "~~~ tok: {:?}, dtgl: {}, i: {}, o: {}",
+ warn!(
+ "tok: {:?}, dtgl: {}, i: {}, o: {}",
token,
self.regs.status.read().dtgl().bit(),
ep.in_toggle(),
@@ -330,6 +330,8 @@ impl Pipe<'_, '_> {
t
}
+ PToken::Setup => false,
+
_ => !self.regs.status.read().dtgl().bit_is_set(),
};
@@ -372,10 +374,11 @@ impl Pipe<'_, '_> {
let res = self.dispatch_result(token);
match res {
Ok(true) => {
+ // Swap sequence bits on successful transfer.
if token == PToken::In {
- ep.set_in_toggle(self.regs.status.read().dtgl().bit_is_set());
+ ep.set_in_toggle(!ep.in_toggle());
} else if token == PToken::Out {
- ep.set_out_toggle(self.regs.status.read().dtgl().bit_is_set());
+ ep.set_out_toggle(!ep.out_toggle());
}
return Ok(());
}