aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/usb.c
diff options
context:
space:
mode:
authorajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123>2010-01-07 03:31:35 +0000
committerajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123>2010-01-07 03:31:35 +0000
commit2addfe8c42c6bcdc0a15c751e2436447b73d03fe (patch)
tree07e569cd0fe7fd4a06cb5f71e12ba76dda3d5e2c /src/lib/usb.c
parent5f423270cde82f9dfffb52bdd617e5eb439921c5 (diff)
downloadlibrambutan-2addfe8c42c6bcdc0a15c751e2436447b73d03fe.tar.gz
librambutan-2addfe8c42c6bcdc0a15c751e2436447b73d03fe.zip
Added a print class for USB, works identically to the Serial object. Bugs out if you try and pump more than 64 bytes through it in a single packet (which is really the OS's decision). This can be fixed
git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@93 749a229e-a60e-11de-b98f-4500b42dc123
Diffstat (limited to 'src/lib/usb.c')
-rw-r--r--src/lib/usb.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/lib/usb.c b/src/lib/usb.c
index 17c8c8d..8c312f8 100644
--- a/src/lib/usb.c
+++ b/src/lib/usb.c
@@ -1,8 +1,6 @@
#include <inttypes.h>
#include "usb.h"
-BootVectTable* bootVect = ((BootVectTable*) BOOTLOADER_VECT_TABLE);
-
void usb_lpIRQHandler(void)
{
typedef void (*funcPtr)(void);
@@ -60,8 +58,26 @@ void usb_serialWriteStr(const char* outStr) {
}
+void usb_serialWriteChar(unsigned char ch) {
+ BootVectTable *bootVector = ((BootVectTable*)BOOTLOADER_VECT_TABLE);
+
+ delay(1);
+
+ *(bootVector->serial_count_in) = 1;
+ usb_userToPMABufferCopy((u8*)(&ch),USB_SERIAL_ENDP_TXADDR,1);
+ _SetEPTxCount(USB_SERIAL_ENDP_TX,1);
+ _SetEPTxValid(USB_SERIAL_ENDP_TX);
+
+}
+
uint8_t usb_serialGetRecvLen() {
- uint8_t count_out = _GetEPRxCount(USB_SERIAL_ENDP_RX);
- _SetEPRxValid(USB_SERIAL_ENDP_RX);
+ uint8_t count_out =_GetEPRxCount(USB_SERIAL_ENDP_RX);
return count_out;
}
+
+void usb_copyRecvBuffer(unsigned char* dest, uint8_t len) {
+ ASSERT(len < USB_SERIAL_BUF_SIZE);
+ usb_PMAToUserBufferCopy((u8*)(dest),USB_SERIAL_ENDP_RXADDR,len);
+ _SetEPRxValid(USB_SERIAL_ENDP_RX);
+}
+