aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2019-08-08 09:53:06 -0400
committerBrian Cully <bjc@kublai.com>2019-08-08 09:53:06 -0400
commit385efdf53fa3fe38591f22d01edf75d3087c2326 (patch)
tree343a27618844fff70f06c3d2b5c2267b35140377 /src
parent80372dedcd7e5f319a1fb9ce28c9188803b46370 (diff)
downloadatsamd-usb-host-385efdf53fa3fe38591f22d01edf75d3087c2326.tar.gz
atsamd-usb-host-385efdf53fa3fe38591f22d01edf75d3087c2326.zip
Simplify data toggle handling.
Only use the data toggle from hardware if we get a data toggle error. Otherwise, use computed toggle values based on endpoint.
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(());
}