Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!fix usbd stop ep - after reset there was leaved enabled ep with broken transfers #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/usbd/backend/usbd_dwc_otg.c
Original file line number Diff line number Diff line change
@@ -173,11 +173,11 @@ static void disable_all_non_ep0(usbd_device *dev)

REBASE(DWC_OTG_DOEPxINT, i) = 0xFFFF;
REBASE(DWC_OTG_DOEPxTSIZ, i) = 0;
REBASE(DWC_OTG_DOEPxCTL, i) = DWC_OTG_DOEPCTL_SNAK;
REBASE(DWC_OTG_DOEPxCTL, i) = DWC_OTG_DOEPCTL_SNAK | DWC_OTG_DOEPCTL_EPDIS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is why a NAK has been placed on the endpoint (to mark as not an active endpoint).
host is not expected to IO from the endpoint.
Also, who is handling the endpoint disable interrupt callback?


REBASE(DWC_OTG_DIEPxINT, i) = 0xFFFF;
REBASE(DWC_OTG_DIEPxTSIZ, i) = 0;
REBASE(DWC_OTG_DIEPxCTL, i) = DWC_OTG_DIEPCTL_SNAK;
REBASE(DWC_OTG_DIEPxCTL, i) = DWC_OTG_DIEPCTL_SNAK | DWC_OTG_DOEPCTL_EPDIS;
}

REBASE(DWC_OTG_DAINTMSK) &= ~(DWC_OTG_DAINTMSK_OEPM(0) | DWC_OTG_DAINTMSK_IEPM(0));
@@ -676,11 +676,11 @@ static void premature_urb_complete(usbd_device *dev, usbd_urb *urb,
uint8_t ep_num = ENDPOINT_NUMBER(transfer->ep_addr);

if (IS_IN_ENDPOINT(transfer->ep_addr)) {
REBASE(DWC_OTG_DIEPxCTL, ep_num) |= DWC_OTG_DIEPCTL_SNAK;
REBASE(DWC_OTG_DIEPxCTL, ep_num) |= DWC_OTG_DIEPCTL_SNAK | DWC_OTG_DOEPCTL_EPDIS;
REBASE(DWC_OTG_DIEPxINT, ep_num) = 0xFFFF;
REBASE(DWC_OTG_DAINTMSK) &= ~DWC_OTG_DAINTMSK_IEPM(ep_num);
} else {
REBASE(DWC_OTG_DOEPxCTL, ep_num) |= DWC_OTG_DOEPCTL_SNAK;
REBASE(DWC_OTG_DOEPxCTL, ep_num) |= DWC_OTG_DOEPCTL_SNAK | DWC_OTG_DOEPCTL_EPDIS;
REBASE(DWC_OTG_DOEPxINT, ep_num) = 0xFFFF ^ DWC_OTG_DOEPINT_STUP;
REBASE(DWC_OTG_DAINTMSK) &= ~DWC_OTG_DAINTMSK_OEPM(ep_num);
}