From 88d713d65fbac81ab74d8299f9df99d9218de38a Mon Sep 17 00:00:00 2001 From: Lotte Steenbrink Date: Fri, 3 Jul 2020 16:27:48 +0200 Subject: [PATCH] usb-4.rs: unify --- advanced/firmware/src/bin/usb-4.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/advanced/firmware/src/bin/usb-4.rs b/advanced/firmware/src/bin/usb-4.rs index 8aa68f9..b99f05f 100644 --- a/advanced/firmware/src/bin/usb-4.rs +++ b/advanced/firmware/src/bin/usb-4.rs @@ -77,10 +77,11 @@ fn ep0setup(usbd: &USBD, ep0in: &mut Ep0In, _state: &mut usb2::State) -> Result< wvalue ); - let req = Request::parse(bmrequesttype, brequest, wvalue, windex, wlength)?; - log::info!("{:?}", req); + let request = Request::parse(bmrequesttype, brequest, wvalue, windex, wlength) + .expect("Error parsing request"); + log::info!("EP0: {:?}", request); - match req { + match request { Request::GetDescriptor { descriptor, length } => match descriptor { Descriptor::Device => { let desc = usb2::device::Descriptor { @@ -100,11 +101,17 @@ fn ep0setup(usbd: &USBD, ep0in: &mut Ep0In, _state: &mut usb2::State) -> Result< let _ = ep0in.start(&bytes[..core::cmp::min(bytes.len(), length.into())], usbd); } - // TODO Configuration descriptor - // Descriptor::Configuration => todo!(), + // TODO implement Configuration descriptor + // Descriptor::Configuration { .. } => todo!(), }, - // TODO - // Request::SetAddress { .. } => todo!(), + Request::SetAddress { .. } => { + // On Mac OS you'll get this request before the GET_DESCRIPTOR request so we + // need to catch it here. + + // TODO: handle this request properly now. + todo!() + } + // TODO handle SET_CONFIGURATION request // Request::SetConfiguration { .. } => todo!(), }