@@ -38,7 +38,6 @@ static volatile uint8_t rxLEDPulse; /**< Milliseconds remaining for data Rx LED
38
38
#endif
39
39
static char isRemoteWakeUpEnabled = 0 ;
40
40
static char isEndpointHalt = 0 ;
41
- static char lastTransmitTimedOut = 0 ;
42
41
43
42
extern void (*gpf_isr)(void );
44
43
@@ -606,6 +605,16 @@ uint8_t USBDeviceClass::armRecv(uint32_t ep)
606
605
// Timeout for sends
607
606
#define TX_TIMEOUT_MS 70
608
607
608
+ static char LastTransmitTimedOut[7 ] = {
609
+ 0 ,
610
+ 0 ,
611
+ 0 ,
612
+ 0 ,
613
+ 0 ,
614
+ 0 ,
615
+ 0
616
+ };
617
+
609
618
// Blocking Send of data to an endpoint
610
619
uint32_t USBDeviceClass::send (uint32_t ep, const void *data, uint32_t len)
611
620
{
@@ -662,13 +671,13 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
662
671
// previous transfer is still not complete
663
672
664
673
// convert the timeout from microseconds to a number of times through
665
- // the wait loop; it takes (roughly) 18 clock cycles per iteration.
666
- uint32_t timeout = microsecondsToClockCycles (TX_TIMEOUT_MS * 1000 ) / 18 ;
674
+ // the wait loop; it takes (roughly) 23 clock cycles per iteration.
675
+ uint32_t timeout = microsecondsToClockCycles (TX_TIMEOUT_MS * 1000 ) / 23 ;
667
676
668
677
// Wait for (previous) transfer to complete
669
678
while (!usbd.epBank1IsTransferComplete (ep)) {
670
- if (lastTransmitTimedOut || timeout-- == 0 ) {
671
- lastTransmitTimedOut = 1 ;
679
+ if (LastTransmitTimedOut[ep] || timeout-- == 0 ) {
680
+ LastTransmitTimedOut[ep] = 1 ;
672
681
673
682
// set byte count to zero, so that ZLP is sent
674
683
// instead of stale data
@@ -678,7 +687,7 @@ uint32_t USBDeviceClass::send(uint32_t ep, const void *data, uint32_t len)
678
687
}
679
688
}
680
689
681
- lastTransmitTimedOut = 0 ;
690
+ LastTransmitTimedOut[ep] = 0 ;
682
691
683
692
if (len >= 64 ) {
684
693
length = 64 ;
0 commit comments