Skip to content

Commit d51863d

Browse files
committed
- correctly do_ping if received nyet as transfer complete e.g msc 31 byte command
- correctly carry out OUT transfer when PING is ack
1 parent 8111e53 commit d51863d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/portable/synopsys/dwc2/dwc2_type.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -2088,9 +2088,9 @@ TU_VERIFY_STATIC(offsetof(dwc2_regs_t, fifo ) == 0x1000, "incorrect size");
20882088
#define HCTSIZ_DOPING_Pos (31U)
20892089
#define HCTSIZ_DOPING_Msk (0x1UL << HCTSIZ_DOPING_Pos) // 0x80000000
20902090
#define HCTSIZ_DOPING HCTSIZ_DOPING_Msk // Do PING
2091-
#define HCTSIZ_PID_Pos (29U)
2092-
#define HCTSIZ_PID_Msk (0x3UL << HCTSIZ_PID_Pos) // 0x60000000
2093-
#define HCTSIZ_PID HCTSIZ_PID_Msk // Data PID
2091+
#define HCTSIZ_PID_Pos (29U)
2092+
#define HCTSIZ_PID_Msk (0x3UL << HCTSIZ_PID_Pos) // 0x60000000
2093+
#define HCTSIZ_PID HCTSIZ_PID_Msk // Data PID
20942094

20952095
/******************** Bit definition for DIEPDMA register ********************/
20962096
#define DIEPDMA_DMAADDR_Pos (0U)

src/portable/synopsys/dwc2/hcd_dwc2.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,10 @@ static bool handle_channel_out_slave(dwc2_regs_t* dwc2, uint8_t ch_id, uint32_t
959959
is_done = true;
960960
xfer->result = XFER_RESULT_SUCCESS;
961961
channel->hcintmsk &= ~HCINT_ACK;
962+
if (hcint & HCINT_NYET) {
963+
// complete transfer with NYET, do ping next time
964+
edpt->next_do_ping = 1;
965+
}
962966
} else if (hcint & HCINT_STALL) {
963967
xfer->result = XFER_RESULT_STALLED;
964968
channel_disable(dwc2, channel);
@@ -1002,16 +1006,16 @@ static bool handle_channel_out_slave(dwc2_regs_t* dwc2, uint8_t ch_id, uint32_t
10021006
channel->hcintmsk &= ~HCINT_ACK;
10031007
if (hcsplt.split_en) {
10041008
if (!hcsplt.split_compl) {
1005-
// start split is ACK --> do complete split
1009+
// ACK for start split --> do complete split
10061010
hcsplt.split_compl = 1;
10071011
channel->hcsplt = hcsplt.value;
10081012
channel->hcchar |= HCCHAR_CHENA;
10091013
}
10101014
} else {
1011-
// Device is ready, resume transfer
1012-
edpt->next_do_ping = 0;
1013-
xfer->err_count = 0;
1014-
TU_ASSERT(channel_xfer_start(dwc2, ch_id));
1015+
// ACK interrupt is only enabled for Split and PING
1016+
// ACK for PING, which mean device is ready to receive data
1017+
channel->hctsiz &= ~HCTSIZ_DOPING; // HC already cleared PING bit, but we clear anyway
1018+
channel->hcchar |= HCCHAR_CHENA;
10151019
}
10161020
}
10171021

0 commit comments

Comments
 (0)