aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb/usb.c
diff options
context:
space:
mode:
authorAJM <poslathian@poslathian.(none)>2010-12-14 01:39:20 -0500
committerAJM <poslathian@poslathian.(none)>2010-12-14 01:39:20 -0500
commit84fd2532a7f23d20354ff590790b3f892cb7e7d7 (patch)
tree610c5448997cb07bacb53261484d43ce9ef01c3d /libmaple/usb/usb.c
parent40573207a2a5d17110c58a8d4051a4f2804b960a (diff)
downloadlibrambutan-84fd2532a7f23d20354ff590790b3f892cb7e7d7.tar.gz
librambutan-84fd2532a7f23d20354ff590790b3f892cb7e7d7.zip
added a usbBlockingSendByte(char ch)
this new function will only return AFTER the usb interrupt has been serviced and the byte is sent. Bytes should NOT fall on the floor ever with this function. (but they still do? pyserials problem?)
Diffstat (limited to 'libmaple/usb/usb.c')
-rw-r--r--libmaple/usb/usb.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c
index 448c4ff..4e86ed0 100644
--- a/libmaple/usb/usb.c
+++ b/libmaple/usb/usb.c
@@ -336,10 +336,15 @@ void usbWaitReset(void) {
*
*
*/
+void usbBlockingSendByte(char ch) {
+ while (countTx);
+ UserToPMABufferCopy(&ch,VCOM_TX_ADDR,1);
+ _SetEPTxCount(VCOM_TX_ENDP,1);
+ _SetEPTxValid(VCOM_TX_ENDP);
+ countTx = 1;
+ while (countTx);
+}
uint32 usbSendBytes(uint8* sendBuf, uint32 len) {
-
- uint16 loaded = 0;
-
/* any checks on connection (via dtr/rts) done upstream in wirish or by user */
/* last xmit hasnt finished, abort */
@@ -348,8 +353,8 @@ uint32 usbSendBytes(uint8* sendBuf, uint32 len) {
}
// We can only put VCOM_TX_EPSIZE bytes in the buffer
- if(len > VCOM_TX_EPSIZE) {
- len = VCOM_TX_EPSIZE;
+ if(len > VCOM_TX_EPSIZE/2) {
+ len = VCOM_TX_EPSIZE/2;
}
// Try to load some bytes if we can