From 1a9b0c0790b18673fa8d94c5d3d1fd1c416ec717 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 7 Jun 2010 14:29:00 -0400 Subject: another fix for USB unheard print issue --- libmaple/usb/usb.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'libmaple') diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c index 0474cad..0549f3c 100644 --- a/libmaple/usb/usb.c +++ b/libmaple/usb/usb.c @@ -380,28 +380,19 @@ void usbWaitReset(void) { */ int16 usbSendBytes(uint8* sendBuf, uint16 len) { - if (reset_state == NDTR_NRTS) { + if (reset_state != START || bDeviceState != CONFIGURED) { return -1; /* indicates to caller to stop trying, were not connected */ } - /* Block for any pending writes */ - while (countTx) - ; -/* while (countTx != 0) { */ -/* if (reset_state == NDTR_NRTS) { */ -/* return 0; */ -/* } */ -/* }/\* wait for pipe to be clear *\/ */ - - - /* ideally we should wait here, but it gets stuck - for some reason. countTx wont decrement when - theres no host side port reading the data, this is - known, but even if we add the check for NDTR_NRTS it - still gets stuck...*/ - if (countTx != 0) { - return 0; /* indicated to caller to keep trying, were just busy */ + /* This may be the correct behavior but it's undocumented + if (countTx >= VCOM_TX_EPSIZE) { + return 0; // indicates to caller that the buffer is full } + */ + + /* Block for any pending writes */ + while (countTx) + ; uint16 sent = len; -- cgit v1.2.3