diff options
author | Brian Cully <bjc@kublai.com> | 2019-07-28 12:12:41 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-07-28 12:12:41 -0400 |
commit | d13c53906ffba1495f49fcf90f1f3260bb17703f (patch) | |
tree | 9f19f3487210c05ed8921020fe11a92d1ab9bf09 /usbh | |
parent | d5927616c9fa4feb4cf819c81e26536ca97b1c4e (diff) | |
download | samd21-demo-d13c53906ffba1495f49fcf90f1f3260bb17703f.tar.gz samd21-demo-d13c53906ffba1495f49fcf90f1f3260bb17703f.zip |
Add pipe::NO_DATA_STAGE const for convenience.
For use in `control_req`'s buffer argument if no data stage is
required. It was either this or have a separate function.
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, |