dcd/musb: fix zlp IN

Signed-off-by: HiFiPhile <admin@hifiphile.com>
This commit is contained in:
HiFiPhile
2026-01-15 19:13:18 +01:00
parent b03a87731c
commit 8ef8ee1946

View File

@ -189,14 +189,14 @@ static void process_setup_packet(uint8_t rhport) {
}
}
static bool handle_xfer_in(uint8_t rhport, uint_fast8_t ep_addr)
static bool handle_xfer_in(uint8_t rhport, uint_fast8_t ep_addr, bool is_zlp)
{
unsigned epnum = tu_edpt_number(ep_addr);
unsigned epnum_minus1 = epnum - 1;
pipe_state_t *pipe = &_dcd.pipe[tu_edpt_dir(ep_addr)][epnum_minus1];
const unsigned rem = pipe->remaining;
if (!rem) {
if (!rem && !is_zlp) {
pipe->buf = NULL;
return true;
}
@ -268,7 +268,7 @@ static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16
pipe->remaining = total_bytes;
if (dir_in) {
handle_xfer_in(rhport, ep_addr);
handle_xfer_in(rhport, ep_addr, total_bytes == 0);
} else {
musb_regs_t* musb_regs = MUSB_REGS(rhport);
musb_ep_csr_t* ep_csr = get_ep_csr(musb_regs, epnum);
@ -445,7 +445,7 @@ static void process_edpt_n(uint8_t rhport, uint_fast8_t ep_addr)
ep_csr->tx_csrl &= ~(MUSB_TXCSRL1_STALLED | MUSB_TXCSRL1_UNDRN);
return;
}
completed = handle_xfer_in(rhport, ep_addr);
completed = handle_xfer_in(rhport, ep_addr, false);
} else {
// TU_LOG1(" RX CSRL%d = %x\r\n", epn, ep_csr->rx_csrl);
if (ep_csr->rx_csrl & MUSB_RXCSRL1_STALLED) {