Skip to content

Commit d6fb185

Browse files
authored
Merge pull request hathach#1291 from kasjer/kasjer/da1469x-fix-resume
da1469x: fix resume
2 parents c6cde72 + 7b07836 commit d6fb185

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/portable/dialog/da146xx/dcd_da146xx.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@ static void handle_alt_ev(void)
733733
set_nfsr(NFSR_NODE_OPERATIONAL);
734734
USB->USB_ALTMSK_REG = USB_USB_ALTMSK_REG_USB_M_RESET_Msk |
735735
USB_USB_ALTMSK_REG_USB_M_SD3_Msk;
736+
// Re-enable reception of endpoint with pending transfer
737+
for (int epnum = 1; epnum <= 3; ++epnum)
738+
{
739+
xfer_ctl_t * xfer = XFER_CTL_BASE(epnum, TUSB_DIR_OUT);
740+
if (xfer->total_len > xfer->transferred)
741+
{
742+
start_rx_packet(xfer);
743+
}
744+
}
736745
dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
737746
}
738747
}
@@ -935,13 +944,13 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
935944
if (dir == TUSB_DIR_OUT)
936945
{
937946
regs->epc_out = epnum | USB_USB_EPC1_REG_USB_EP_EN_Msk | iso_mask;
938-
USB->USB_RXMSK_REG |= 0x101 << (epnum - 1);
947+
USB->USB_RXMSK_REG |= 0x11 << (epnum - 1);
939948
REG_SET_BIT(USB_MAMSK_REG, USB_M_RX_EV);
940949
}
941950
else
942951
{
943952
regs->epc_in = epnum | USB_USB_EPC1_REG_USB_EP_EN_Msk | iso_mask;
944-
USB->USB_TXMSK_REG |= 0x101 << (epnum - 1);
953+
USB->USB_TXMSK_REG |= 0x11 << (epnum - 1);
945954
REG_SET_BIT(USB_MAMSK_REG, USB_M_TX_EV);
946955
}
947956
}
@@ -982,7 +991,7 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
982991
{
983992
regs->rxc = USB_USB_RXC1_REG_USB_FLUSH_Msk;
984993
regs->epc_out = 0;
985-
USB->USB_RXMSK_REG &= ~(0x101 << (epnum - 1));
994+
USB->USB_RXMSK_REG &= ~(0x11 << (epnum - 1));
986995
// Release DMA if needed
987996
if (_dcd.dma_ep[TUSB_DIR_OUT] == epnum)
988997
{
@@ -994,7 +1003,7 @@ void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
9941003
{
9951004
regs->txc = USB_USB_TXC1_REG_USB_FLUSH_Msk;
9961005
regs->epc_in = 0;
997-
USB->USB_TXMSK_REG &= ~(0x101 << (epnum - 1));
1006+
USB->USB_TXMSK_REG &= ~(0x11 << (epnum - 1));
9981007
// Release DMA if needed
9991008
if (_dcd.dma_ep[TUSB_DIR_IN] == epnum)
10001009
{

0 commit comments

Comments
 (0)