Skip to content

Commit 8ef8ee1

Browse files
committed
dcd/musb: fix zlp IN
Signed-off-by: HiFiPhile <admin@hifiphile.com>
1 parent b03a877 commit 8ef8ee1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/portable/mentor/musb/dcd_musb.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ static void process_setup_packet(uint8_t rhport) {
189189
}
190190
}
191191

192-
static bool handle_xfer_in(uint8_t rhport, uint_fast8_t ep_addr)
192+
static bool handle_xfer_in(uint8_t rhport, uint_fast8_t ep_addr, bool is_zlp)
193193
{
194194
unsigned epnum = tu_edpt_number(ep_addr);
195195
unsigned epnum_minus1 = epnum - 1;
196196
pipe_state_t *pipe = &_dcd.pipe[tu_edpt_dir(ep_addr)][epnum_minus1];
197197
const unsigned rem = pipe->remaining;
198198

199-
if (!rem) {
199+
if (!rem && !is_zlp) {
200200
pipe->buf = NULL;
201201
return true;
202202
}
@@ -268,7 +268,7 @@ static bool edpt_n_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16
268268
pipe->remaining = total_bytes;
269269

270270
if (dir_in) {
271-
handle_xfer_in(rhport, ep_addr);
271+
handle_xfer_in(rhport, ep_addr, total_bytes == 0);
272272
} else {
273273
musb_regs_t* musb_regs = MUSB_REGS(rhport);
274274
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)
445445
ep_csr->tx_csrl &= ~(MUSB_TXCSRL1_STALLED | MUSB_TXCSRL1_UNDRN);
446446
return;
447447
}
448-
completed = handle_xfer_in(rhport, ep_addr);
448+
completed = handle_xfer_in(rhport, ep_addr, false);
449449
} else {
450450
// TU_LOG1(" RX CSRL%d = %x\r\n", epn, ep_csr->rx_csrl);
451451
if (ep_csr->rx_csrl & MUSB_RXCSRL1_STALLED) {

0 commit comments

Comments
 (0)