From f607a99127cc9e8dfc3f716f977e6c1bfb6f7c2d Mon Sep 17 00:00:00 2001 From: Martin Thierer Date: Tue, 20 Jul 2021 18:55:00 +0200 Subject: Send a ZLP if nothing to transfer and last transfer was EPSIZE --- src/class/vendor/vendor_device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/class/vendor/vendor_device.c b/src/class/vendor/vendor_device.c index 6718a97bf..5b58d85e1 100644 --- a/src/class/vendor/vendor_device.c +++ b/src/class/vendor/vendor_device.c @@ -61,6 +61,8 @@ typedef struct CFG_TUSB_MEM_SECTION static vendord_interface_t _vendord_itf[CFG_TUD_VENDOR]; +CFG_TUSB_MEM_SECTION static bool last_in_transfer_was_epsize = false; + #define ITF_MEM_RESET_SIZE offsetof(vendord_interface_t, rx_ff) @@ -112,10 +114,11 @@ static bool maybe_transmit(vendord_interface_t* p_itf) TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, p_itf->ep_in) ); uint16_t count = tu_fifo_read_n(&p_itf->tx_ff, p_itf->epin_buf, CFG_TUD_VENDOR_EPSIZE); - if (count > 0) + if (count > 0 || last_in_transfer_was_epsize) { TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_in, p_itf->epin_buf, count) ); } + last_in_transfer_was_epsize = count && (count == CFG_TUD_VENDOR_EPSIZE); return true; } -- cgit v1.3.1