From 7366564129bf4e4030e9083f4521eda49d985fb8 Mon Sep 17 00:00:00 2001
From: Marti Bolivar <mbolivar@leaflabs.com>
Date: Wed, 9 Feb 2011 17:55:45 -0500
Subject: Fixing usb.c countTx race; thanks, geoffreymbrown!

---
 libmaple/usb/usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c
index 923e54b..39bf31a 100644
--- a/libmaple/usb/usb.c
+++ b/libmaple/usb/usb.c
@@ -376,8 +376,8 @@ uint16 usbSendBytes(uint8* sendBuf, uint16 len) {
   if (loaded) {
     UserToPMABufferCopy(sendBuf,VCOM_TX_ADDR + countTx, loaded);
     _SetEPTxCount(VCOM_TX_ENDP, countTx+loaded);
-    _SetEPTxValid(VCOM_TX_ENDP);
     countTx += loaded;
+    _SetEPTxValid(VCOM_TX_ENDP);
   }
 
   return loaded;
-- 
cgit v1.2.3