Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable empty transfers for tud_vendor_n_write() #911

Merged
merged 3 commits into from
May 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/class/vendor/vendor_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

condition seems to be overkill (only right side of && makes a difference) or wrong (&& where || should be)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& ist correct, but you're right, it's redundant.

return true;
}

Expand Down