-
Notifications
You must be signed in to change notification settings - Fork 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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
dwc2->daintmsk |= TU_BIT(DAINTMSK_OEPM_Pos + epnum); | ||
} else { | ||
dwc2->epin[epnum].diepctl |= dxepctl | (epnum << DIEPCTL_TXFNUM_Pos); | ||
dwc2->epin[epnum].diepctl = dxepctl | (epnum << DIEPCTL_TXFNUM_Pos); | ||
dwc2->daintmsk |= (1 << (DAINTMSK_IEPM_Pos + epnum)); | ||
} | ||
} | ||
|
@@ -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 commentThe 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: |
||
if (dwc2->epin[n].diepctl & DIEPCTL_EPENA) { | ||
dwc2->epin[n].diepctl |= DIEPCTL_SNAK | DIEPCTL_EPDIS; | ||
} | ||
} | ||
|
||
fifo_flush_tx(dwc2, 0x10); // all tx fifo | ||
fifo_flush_rx(dwc2); | ||
|
||
// 2. Set up interrupt mask | ||
// 3. Set up interrupt mask | ||
dwc2->daintmsk = TU_BIT(DAINTMSK_OEPM_Pos) | TU_BIT(DAINTMSK_IEPM_Pos); | ||
dwc2->doepmsk = DOEPMSK_STUPM | DOEPMSK_XFRCM; | ||
dwc2->diepmsk = DIEPMSK_TOM | DIEPMSK_XFRCM; | ||
|
@@ -704,11 +711,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 commentThe reason will be displayed to describe this comment to others. Learn more. Write dxepctl to 0 won't clear EPENA. |
||
dwc2->epout[n].doepctl |= DOEPCTL_SNAK | DOEPCTL_EPDIS; | ||
} | ||
xfer_status[n][TUSB_DIR_OUT].max_size = 0; | ||
|
||
// disable IN endpoint | ||
dwc2->epin[n].diepctl = 0; | ||
if (dwc2->epin[n].diepctl & DIEPCTL_EPENA) { | ||
dwc2->epin[n].diepctl |= DIEPCTL_SNAK | DIEPCTL_EPDIS; | ||
} | ||
xfer_status[n][TUSB_DIR_IN].max_size = 0; | ||
} | ||
|
||
|
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.