@@ -94,19 +94,18 @@ fn ep0setup(usbd: &Usbd, ep0in: &mut Ep0In, state: &mut State) -> Result<(), ()>
9494 wvalue
9595 ) ;
9696
97- let request = Request :: parse ( bmrequesttype, brequest, wvalue, windex, wlength)
98- . expect ( "Error parsing request" ) ;
97+ let request = Request :: parse ( bmrequesttype, brequest, wvalue, windex, wlength) ;
9998 defmt:: info!( "EP0: {}" , defmt:: Debug2Format ( & request) ) ;
10099 // ^^^^^^^^^^^^^^^^^^^ this adapter is currently needed to log
101100 // `Request` with `defmt`
102101
103102 match request {
104103 // section 9.4.3
105104 // this request is valid in any state
106- Request :: GetDescriptor {
105+ Ok ( Request :: GetDescriptor {
107106 descriptor : Descriptor :: Device ,
108107 length,
109- } => {
108+ } ) => {
110109 let desc = usb2:: device:: Descriptor {
111110 bDeviceClass : 0 ,
112111 bDeviceProtocol : 0 ,
@@ -131,10 +130,10 @@ fn ep0setup(usbd: &Usbd, ep0in: &mut Ep0In, state: &mut State) -> Result<(), ()>
131130 } ;
132131 ep0in. start ( subslice, usbd) ;
133132 }
134- Request :: GetDescriptor {
133+ Ok ( Request :: GetDescriptor {
135134 descriptor : Descriptor :: Configuration { index } ,
136135 length,
137- } => {
136+ } ) => {
138137 if index == 0 {
139138 let mut resp = heapless:: Vec :: < u8 , 64 > :: new ( ) ;
140139
@@ -170,7 +169,7 @@ fn ep0setup(usbd: &Usbd, ep0in: &mut Ep0In, state: &mut State) -> Result<(), ()>
170169 return Err ( ( ) ) ;
171170 }
172171 }
173- Request :: SetAddress { address } => {
172+ Ok ( Request :: SetAddress { address } ) => {
174173 match state {
175174 State :: Default => {
176175 if let Some ( address) = address {
@@ -195,7 +194,7 @@ fn ep0setup(usbd: &Usbd, ep0in: &mut Ep0In, state: &mut State) -> Result<(), ()>
195194
196195 // the response to this request is handled in hardware
197196 }
198- Request :: SetConfiguration { value } => {
197+ Ok ( Request :: SetConfiguration { value } ) => {
199198 match * state {
200199 // unspecified behavior
201200 State :: Default => return Err ( ( ) ) ,
@@ -240,9 +239,21 @@ fn ep0setup(usbd: &Usbd, ep0in: &mut Ep0In, state: &mut State) -> Result<(), ()>
240239
241240 usbd. tasks_ep0status ( ) . write_value ( 1 ) ;
242241 }
243-
244- // stall any other request
245- _ => return Err ( ( ) ) ,
242+ Ok ( _) => {
243+ // stall anything else
244+ return Err ( ( ) ) ;
245+ }
246+ Err ( _) => {
247+ defmt:: error!(
248+ "Failed to parse: bmrequesttype: 0b{=u8:08b}, brequest: {=u8}, wlength: {=u16}, windex: 0x{=u16:04x}, wvalue: 0x{=u16:04x}" ,
249+ bmrequesttype,
250+ brequest,
251+ wlength,
252+ windex,
253+ wvalue
254+ ) ;
255+ return Err ( ( ) ) ;
256+ }
246257 }
247258
248259 Ok ( ( ) )
0 commit comments