aboutsummaryrefslogtreecommitdiffstats
path: root/usbh/src/pipe.rs
diff options
context:
space:
mode:
Diffstat (limited to 'usbh/src/pipe.rs')
-rw-r--r--usbh/src/pipe.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/usbh/src/pipe.rs b/usbh/src/pipe.rs
index 936aa23..0a8503b 100644
--- a/usbh/src/pipe.rs
+++ b/usbh/src/pipe.rs
@@ -41,8 +41,14 @@ pub(crate) enum PipeErr {
HWTimeout,
DataToggle,
SWTimeout,
- Other,
+ Other(&'static str),
}
+impl From<&'static str> for PipeErr {
+ fn from(v: &'static str) -> Self {
+ Self::Other(v)
+ }
+}
+
pub(crate) struct PipeTable {
tbl: [PipeDesc; MAX_PIPES],
}
@@ -135,7 +141,7 @@ impl Pipe<'_, '_> {
if let Some(b) = buf {
// TODO: data stage, has up to 5,000ms (in 500ms
// per-packet chunks) to complete. cf ยง9.2.6.4 of USB 2.0.
- match bm_request_type.direction() {
+ match bm_request_type.direction()? {
USBSetupDirection::DeviceToHost => {
trace!("buf0: {:?}", &b);
self.in_transfer(&b, NAK_LIMIT, millis)?;
@@ -159,7 +165,7 @@ impl Pipe<'_, '_> {
unsafe { w.multi_packet_size().bits(0) }
});
- let token = match bm_request_type.direction() {
+ let token = match bm_request_type.direction()? {
USBSetupDirection::DeviceToHost => USBToken::Out,
USBSetupDirection::HostToDevice => USBToken::In,
};