aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2023-10-05 00:03:07 -0400
committerKevin O'Connor <kevin@koconnor.net>2023-10-05 00:47:42 -0400
commit83ef0e135ef820f73c8579069c347953b9d6d56e (patch)
tree69cbebcdf618a55b8ea25e101d7f380e1070099b /src/stm32
parent447125faae62bfad4a0e483264453a39c9ba52d8 (diff)
downloadkutter-83ef0e135ef820f73c8579069c347953b9d6d56e.tar.gz
kutter-83ef0e135ef820f73c8579069c347953b9d6d56e.tar.xz
kutter-83ef0e135ef820f73c8579069c347953b9d6d56e.zip
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>
Diffstat (limited to 'src/stm32')
-rw-r--r--src/stm32/usbfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stm32/usbfs.c b/src/stm32/usbfs.c
index 0ed2e0ee..ad2e7b3e 100644
--- a/src/stm32/usbfs.c
+++ b/src/stm32/usbfs.c
@@ -255,11 +255,12 @@ usb_send_bulk_in(void *data, uint_fast8_t len)
uint32_t epr = USB_EPR[ep];
if (epr_is_dbuf_blocking(epr) && readl(&bulk_in_pop_flag)) {
writel(&bulk_in_pop_flag, 0);
- if (bipp & BI_START) {
+ if (unlikely(bipp & BI_START)) {
// Two packets are always sent when starting in double
// buffering mode, so wait for second packet before starting.
if (bipp == (BI_START | 1)) {
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_EP_TX_VALID);
}