aboutsummaryrefslogtreecommitdiffstats
path: root/usbh/src
diff options
context:
space:
mode:
Diffstat (limited to 'usbh/src')
-rwxr-xr-xusbh/src/lib.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/usbh/src/lib.rs b/usbh/src/lib.rs
index e15f279..b0a103a 100755
--- a/usbh/src/lib.rs
+++ b/usbh/src/lib.rs
@@ -38,9 +38,9 @@ enum DetachedState {
#[derive(Clone, Copy, Debug, PartialEq)]
enum AttachedState {
- WaitForSettle,
+ WaitForSettle(usize),
WaitResetComplete,
- WaitSOF,
+ WaitSOF(usize),
}
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -73,7 +73,6 @@ where
events: EventReader,
task_state: TaskState,
- delay: usize,
// Need chunk of RAM for USB pipes, which gets used with DESCADD
// register.
@@ -113,7 +112,6 @@ where
events: eventr,
task_state: TaskState::Detached(DetachedState::Initialize),
- delay: 0,
pipe_table: PipeTable::new(),
@@ -216,8 +214,9 @@ where
}
Event::Attached => {
if let TaskState::Detached(_) = self.task_state {
- self.delay = (self.millis)() + SETTLE_DELAY;
- TaskState::Attached(AttachedState::WaitForSettle)
+ TaskState::Attached(AttachedState::WaitForSettle(
+ (self.millis)() + SETTLE_DELAY,
+ ))
} else {
self.task_state
}
@@ -303,8 +302,8 @@ where
fn attached_fsm(&mut self, s: AttachedState) {
match s {
- AttachedState::WaitForSettle => {
- if (self.millis)() >= self.delay {
+ AttachedState::WaitForSettle(until) => {
+ if (self.millis)() >= until {
self.usb.host().ctrlb.modify(|_, w| w.busreset().set_bit());
self.task_state = TaskState::Attached(AttachedState::WaitResetComplete);
}
@@ -322,15 +321,15 @@ where
// immediately after reset according to ยง32.6.3.3.
self.usb.host().ctrlb.modify(|_, w| w.sofe().set_bit());
// USB spec requires 20ms of SOF after bus reset.
- self.delay = (self.millis)() + 20;
- self.task_state = TaskState::Attached(AttachedState::WaitSOF);
+ self.task_state =
+ TaskState::Attached(AttachedState::WaitSOF((self.millis)() + 20));
}
}
- AttachedState::WaitSOF => {
+ AttachedState::WaitSOF(until) => {
if self.usb.host().intflag.read().hsof().bit_is_set() {
self.usb.host().intflag.write(|w| w.hsof().set_bit());
- if (self.millis)() >= self.delay {
+ if (self.millis)() >= until {
self.task_state = TaskState::Steady(SteadyState::Configuring);
}
}