- correctly do_ping if received nyet as transfer complete e.g msc 31 byte command

- correctly carry out OUT transfer when PING is ack
This commit is contained in:
hathach
2025-04-18 22:39:59 +07:00
parent 8111e53ff0
commit d51863d1a0
2 changed files with 12 additions and 8 deletions

View File

@@ -2088,9 +2088,9 @@ TU_VERIFY_STATIC(offsetof(dwc2_regs_t, fifo ) == 0x1000, "incorrect size");
#define HCTSIZ_DOPING_Pos (31U) #define HCTSIZ_DOPING_Pos (31U)
#define HCTSIZ_DOPING_Msk (0x1UL << HCTSIZ_DOPING_Pos) // 0x80000000 #define HCTSIZ_DOPING_Msk (0x1UL << HCTSIZ_DOPING_Pos) // 0x80000000
#define HCTSIZ_DOPING HCTSIZ_DOPING_Msk // Do PING #define HCTSIZ_DOPING HCTSIZ_DOPING_Msk // Do PING
#define HCTSIZ_PID_Pos (29U) #define HCTSIZ_PID_Pos (29U)
#define HCTSIZ_PID_Msk (0x3UL << HCTSIZ_PID_Pos) // 0x60000000 #define HCTSIZ_PID_Msk (0x3UL << HCTSIZ_PID_Pos) // 0x60000000
#define HCTSIZ_PID HCTSIZ_PID_Msk // Data PID #define HCTSIZ_PID HCTSIZ_PID_Msk // Data PID
/******************** Bit definition for DIEPDMA register ********************/ /******************** Bit definition for DIEPDMA register ********************/
#define DIEPDMA_DMAADDR_Pos (0U) #define DIEPDMA_DMAADDR_Pos (0U)

View File

@@ -959,6 +959,10 @@ static bool handle_channel_out_slave(dwc2_regs_t* dwc2, uint8_t ch_id, uint32_t
is_done = true; is_done = true;
xfer->result = XFER_RESULT_SUCCESS; xfer->result = XFER_RESULT_SUCCESS;
channel->hcintmsk &= ~HCINT_ACK; channel->hcintmsk &= ~HCINT_ACK;
if (hcint & HCINT_NYET) {
// complete transfer with NYET, do ping next time
edpt->next_do_ping = 1;
}
} else if (hcint & HCINT_STALL) { } else if (hcint & HCINT_STALL) {
xfer->result = XFER_RESULT_STALLED; xfer->result = XFER_RESULT_STALLED;
channel_disable(dwc2, channel); channel_disable(dwc2, channel);
@@ -1002,16 +1006,16 @@ static bool handle_channel_out_slave(dwc2_regs_t* dwc2, uint8_t ch_id, uint32_t
channel->hcintmsk &= ~HCINT_ACK; channel->hcintmsk &= ~HCINT_ACK;
if (hcsplt.split_en) { if (hcsplt.split_en) {
if (!hcsplt.split_compl) { if (!hcsplt.split_compl) {
// start split is ACK --> do complete split // ACK for start split --> do complete split
hcsplt.split_compl = 1; hcsplt.split_compl = 1;
channel->hcsplt = hcsplt.value; channel->hcsplt = hcsplt.value;
channel->hcchar |= HCCHAR_CHENA; channel->hcchar |= HCCHAR_CHENA;
} }
} else { } else {
// Device is ready, resume transfer // ACK interrupt is only enabled for Split and PING
edpt->next_do_ping = 0; // ACK for PING, which mean device is ready to receive data
xfer->err_count = 0; channel->hctsiz &= ~HCTSIZ_DOPING; // HC already cleared PING bit, but we clear anyway
TU_ASSERT(channel_xfer_start(dwc2, ch_id)); channel->hcchar |= HCCHAR_CHENA;
} }
} }