stm32: Make sure to limit tx during usbfs startup

Wait for two tx packets before startup, and make sure one of those
packets is acked before sending a third tx packet.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2023-10-05 00:03:07 -04:00
parent 447125faae
commit 83ef0e135e
1 changed files with 2 additions and 1 deletions

View File

@ -255,11 +255,12 @@ usb_send_bulk_in(void *data, uint_fast8_t len)
uint32_t epr = USB_EPR[ep]; uint32_t epr = USB_EPR[ep];
if (epr_is_dbuf_blocking(epr) && readl(&bulk_in_pop_flag)) { if (epr_is_dbuf_blocking(epr) && readl(&bulk_in_pop_flag)) {
writel(&bulk_in_pop_flag, 0); writel(&bulk_in_pop_flag, 0);
if (bipp & BI_START) { if (unlikely(bipp & BI_START)) {
// Two packets are always sent when starting in double // Two packets are always sent when starting in double
// buffering mode, so wait for second packet before starting. // buffering mode, so wait for second packet before starting.
if (bipp == (BI_START | 1)) { if (bipp == (BI_START | 1)) {
bulk_in_push_pos = 0; bulk_in_push_pos = 0;
writel(&bulk_in_pop_flag, USB_EP_KIND); // Dummy flag
USB_EPR[ep] = calc_epr_bits(epr, USB_EPTX_STAT USB_EPR[ep] = calc_epr_bits(epr, USB_EPTX_STAT
, USB_EP_TX_VALID); , USB_EP_TX_VALID);
} }