diff options
author | AJM <poslathian@poslathian.(none)> | 2010-12-14 01:39:20 -0500 |
---|---|---|
committer | AJM <poslathian@poslathian.(none)> | 2010-12-14 01:39:20 -0500 |
commit | 84fd2532a7f23d20354ff590790b3f892cb7e7d7 (patch) | |
tree | 610c5448997cb07bacb53261484d43ce9ef01c3d /libmaple | |
parent | 40573207a2a5d17110c58a8d4051a4f2804b960a (diff) | |
download | librambutan-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')
-rw-r--r-- | libmaple/usb/usb.c | 15 | ||||
-rw-r--r-- | libmaple/usb/usb.h | 1 |
2 files changed, 11 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 diff --git a/libmaple/usb/usb.h b/libmaple/usb/usb.h index 5bc31e1..0ed02e5 100644 --- a/libmaple/usb/usb.h +++ b/libmaple/usb/usb.h @@ -73,6 +73,7 @@ void usb_lpIRQHandler(void); void usbWaitReset(void); /* blocking functions for send/receive */ +void usbBlockingSendByte(char ch); uint32 usbSendBytes(uint8* sendBuf,uint32 len); uint32 usbBytesAvailable(void); uint32 usbReceiveBytes(uint8* recvBuf, uint32 len); |