Skip to content

Commit

Permalink
Merge pull request #11 from tlyu/stall-ep0
Browse files Browse the repository at this point in the history
stall ep0 instead of timing out
  • Loading branch information
obra authored Nov 4, 2022
2 parents e6345d7 + 61651e8 commit 27dc0cf
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cores/arduino/USBCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,12 @@ void USBCore_::transcSetup(usb_dev* usbd, uint8_t ep)
return;
} else if ((usbd->control.req.bmRequestType & USB_RECPTYPE_MASK) == USB_RECPTYPE_ITF) {
reqstat = (usb_reqsta)ClassCore::reqProcess(usbd, &usbd->control.req);
if (reqstat == REQ_SUPP
&& (usbd->control.req.bmRequestType & USB_TRX_IN) != USB_TRX_IN) {
this->sendZLP(usbd, 0);
if (reqstat == REQ_SUPP) {
if ((usbd->control.req.bmRequestType & USB_TRX_IN) != USB_TRX_IN) {
this->sendZLP(usbd, 0);
}
} else {
usbd_ep_stall(usbd, 0);
}
return;
} else {
Expand All @@ -778,10 +781,15 @@ void USBCore_::transcSetup(usb_dev* usbd, uint8_t ep)

// Respond with a ZLP if the host has sent data,
// because we’ve already handled in in the class request.
if (reqstat == REQ_SUPP
&& ((usbd->control.req.bmRequestType & USB_TRX_IN) != USB_TRX_IN)) {
this->sendZLP(usbd, 0);
if (reqstat == REQ_SUPP) {
if ((usbd->control.req.bmRequestType & USB_TRX_IN) != USB_TRX_IN) {
this->sendZLP(usbd, 0);
}
} else {
usbd_ep_stall(usbd, 0);
}
// Return early, because the usbd_ep_send() call below is for
// processing transmissions from the original low-level code.
return;

/* vendor defined request */
Expand Down

0 comments on commit 27dc0cf

Please sign in to comment.