By not waiting until the transmitter is idle, we can reduce the
time between the end of the SE0 indicating EOP of SETUP or OUT
and the first transition of the following DATAx to a mere two
bit times (as oppose to ~6 bit times before).

While I haven't been able to find anything in the USB standard
that would require such tight timing, AVR USB chips (i.e., the
ATmega32U2 of atusb and the AT90USB162 of the Faderfox LV3)
flat out ignore any transfers with longer delays.
---
 softusb-input/main.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/softusb-input/main.c b/softusb-input/main.c
index 038dc8b..883e8c9 100644
--- a/softusb-input/main.c
+++ b/softusb-input/main.c
@@ -119,7 +119,7 @@ static void make_usb_token(unsigned char pid, unsigned int 
elevenbits, unsigned
        out[2] |= usb_crc5(out[1], out[2]) << 3;
 }
 
-static void usb_tx(const unsigned char *buf, unsigned char len)
+static void usb_tx_nowait(const unsigned char *buf, unsigned char len)
 {
        unsigned char i;
 
@@ -130,9 +130,15 @@ static void usb_tx(const unsigned char *buf, unsigned char 
len)
        }
        while(rio8(SIE_TX_PENDING));
        wio8(SIE_TX_VALID, 0);
+}
+
+static void usb_tx(const unsigned char *buf, unsigned char len)
+{
+       usb_tx_nowait(buf, len);
        while(rio8(SIE_TX_BUSY));
 }
 
+
 static inline void usb_ack(void)
 {
        wio8(SIE_TX_DATA, 0x80); /* send SYNC */
@@ -302,7 +308,7 @@ static char usb_out(unsigned addr, const unsigned char 
*buf, unsigned char len)
 
        /* send OUT */
        make_usb_token(USB_PID_OUT, addr, out);
-       usb_tx(out, 3);
+       usb_tx_nowait(out, 3);
 
        /* send DATAx */
        usb_tx(buf, len);
@@ -346,7 +352,7 @@ static int control_transfer(unsigned char addr, struct 
setup_packet *p,
        TRIGGER_ON();
 
        /* send them back-to-back */
-       usb_tx(setup, 3);
+       usb_tx_nowait(setup, 3);
        usb_tx(usb_buffer, 11);
 
        TRIGGER_OFF();
-- 
1.7.1

_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode

Reply via email to