diff options
Diffstat (limited to 'usbh')
-rw-r--r-- | usbh/src/device.rs | 6 | ||||
-rwxr-xr-x | usbh/src/lib.rs | 4 | ||||
-rw-r--r-- | usbh/src/pipe.rs | 7 |
3 files changed, 11 insertions, 6 deletions
diff --git a/usbh/src/device.rs b/usbh/src/device.rs index eeaa33b..bdb993e 100644 --- a/usbh/src/device.rs +++ b/usbh/src/device.rs @@ -1,4 +1,4 @@ -use super::pipe::{Pipe, PipeErr, PipeTable}; +use super::pipe::{Pipe, PipeErr, PipeTable, NO_DATA_STAGE}; use super::usbproto::*; use core::convert::TryInto; @@ -199,7 +199,7 @@ impl Device { RequestCode::SetConfiguration, WValue::from((conf, 0)), 0, - Option::<&mut ()>::None, + NO_DATA_STAGE, self.millis, )?; debug!(" -- configuration set"); @@ -214,7 +214,7 @@ impl Device { RequestCode::GetInterface, // This is also idle, but can't have two enums with the same value. WValue::from((0, 0)), 0, - Option::<&mut ()>::None, + NO_DATA_STAGE, self.millis, )?; debug!(" -- idle set"); diff --git a/usbh/src/lib.rs b/usbh/src/lib.rs index 94230b2..70acc31 100755 --- a/usbh/src/lib.rs +++ b/usbh/src/lib.rs @@ -6,7 +6,7 @@ mod pipe; mod usbproto; use device::DeviceTable; -use pipe::{PipeErr, PipeTable, USBPipeType}; +use pipe::{PipeErr, PipeTable, USBPipeType, NO_DATA_STAGE}; use rb::{Reader, RingBuffer, Writer}; use usbproto::*; @@ -383,7 +383,7 @@ where RequestCode::SetAddress, WValue::from((device.addr, 0)), 0, - Option::<&mut ()>::None, + NO_DATA_STAGE, self.millis, )?; diff --git a/usbh/src/pipe.rs b/usbh/src/pipe.rs index 3dab629..388b518 100644 --- a/usbh/src/pipe.rs +++ b/usbh/src/pipe.rs @@ -21,14 +21,19 @@ use atsamd_hal::target_device::usb::{ use core::convert::TryInto; use log::{debug, trace}; -// TODO: verify this timeout against §9.2.6.1 of USB 2.0 spec. +// Maximum time to wait for a control request with data to finish. cf +// §9.2.6.1 of USB 2.0. const USB_TIMEOUT: usize = 5 * 1024; // 5 Seconds // samd21 only supports 8 pipes. const MAX_PIPES: usize = 8; +// How many times to retry a transaction that has transient errors. const NAK_LIMIT: usize = 15; +// For use in control requests that do not require a data stage. +pub(crate) const NO_DATA_STAGE: Option<&mut ()> = None; + #[derive(Copy, Clone, Debug, PartialEq)] pub(crate) enum PipeErr { ShortPacket, |