-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Some misc fixes #2607
Some misc fixes #2607
Conversation
@@ -202,10 +202,10 @@ static void edpt_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoin | |||
(xfer->max_size << DOEPCTL_MPSIZ_Pos); | |||
|
|||
if (dir == TUSB_DIR_OUT) { | |||
dwc2->epout[epnum].doepctl |= dxepctl; | |||
dwc2->epout[epnum].doepctl = dxepctl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dxepctl is not cleared on bus reset, besides no need to do masked write.
@@ -280,10 +280,17 @@ static void bus_reset(uint8_t rhport) { | |||
dwc2->epout[n].doepctl |= DOEPCTL_SNAK; | |||
} | |||
|
|||
// 2. Disable all IN endpoints | |||
for (uint8_t n = 0; n < ep_count; n++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there are pending IN transfer on bus reset, eg. in cdc echo test do only write without read:
Since EPENA is not cleared on reset, once the EP is opened it will enter DIEPINT_TXFE
interrupt and try to write packet and cause access violation.
@@ -700,11 +707,15 @@ void dcd_edpt_close_all(uint8_t rhport) { | |||
|
|||
for (uint8_t n = 1; n < ep_count; n++) { | |||
// disable OUT endpoint | |||
dwc2->epout[n].doepctl = 0; | |||
if (dwc2->epout[n].doepctl & DOEPCTL_EPENA) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write dxepctl to 0 won't clear EPENA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect, thank you for the fix
Describe the PR
Some fixes I did when implementing dwc2 DMA support, better to do a separate PR.