Explorar o código

usb: Improve double-buffered Tx pipe initialisation.

By setting the user-buffer toggle, we send only one spurious (empty)
packet, and we can legitimately set tx_ready during setup because there
is one user buffer which the peripheral won't touch.
Keir Fraser %!s(int64=5) %!d(string=hai) anos
pai
achega
a577c7a812
Modificáronse 1 ficheiros con 2 adicións e 4 borrados
  1. 2 4
      src/usb/hw_f1.c

+ 2 - 4
src/usb/hw_f1.c

@@ -17,8 +17,6 @@ static struct {
      * Descriptor's COUNT_RX by the hardware. */
     bool_t rx_ready;
     bool_t tx_ready;
-    /* Is this a double-buffered BULK endpoint? */
-    bool_t dbl_buf;
 } eps[8];
 
 void usb_init(void)
@@ -225,8 +223,8 @@ void usb_configure_ep(uint8_t ep, uint8_t type, uint32_t size)
     if (in || (ep == 0)) {
         if (dbl_buf) {
             bd->count_0 = bd->count_1 = 0;
-            /* TX: Clears SW_BUF. */
-            new_epr |= old_epr & 0x4000;
+            /* TX: Sets SW_BUF. */
+            new_epr |= (old_epr & 0x4000) ^ 0x4000;
             /* TX: Clears data toggle and sets status to VALID. */
             new_epr |= (old_epr & 0x0070) ^ USB_EPR_STAT_TX(USB_STAT_VALID);
         } else {