aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/usb.c
diff options
context:
space:
mode:
authorajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123>2009-12-19 15:14:29 +0000
committerajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123>2009-12-19 15:14:29 +0000
commit6a0091418a8cdad33f7cb9b2a576e91c6960e07a (patch)
tree8d85cf4b3b008686b26b062025c366876c84ee9f /src/lib/usb.c
parentacf59b1abb346998c492b93fee4a680a32f538d5 (diff)
downloadlibrambutan-6a0091418a8cdad33f7cb9b2a576e91c6960e07a.tar.gz
librambutan-6a0091418a8cdad33f7cb9b2a576e91c6960e07a.zip
added a usb.h and usb.c to cover some of the low level access functions that we can use to build the usb serial port. my sandbox widgets are in main.cpp, look at it then throw it out. I adjusted the stm32f10x_conf.h file to properly NOT include certain st lib files that werent being used, and modified the NVIC init to cope with the bootloader
git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@76 749a229e-a60e-11de-b98f-4500b42dc123
Diffstat (limited to 'src/lib/usb.c')
-rw-r--r--src/lib/usb.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/usb.c b/src/lib/usb.c
index e83bf98..17c8c8d 100644
--- a/src/lib/usb.c
+++ b/src/lib/usb.c
@@ -1,6 +1,8 @@
#include <inttypes.h>
#include "usb.h"
+BootVectTable* bootVect = ((BootVectTable*) BOOTLOADER_VECT_TABLE);
+
void usb_lpIRQHandler(void)
{
typedef void (*funcPtr)(void);
@@ -42,15 +44,24 @@ void usb_PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes)
void usb_serialWriteStr(const char* outStr) {
u8 offset=0;
- while ((outStr[offset] != 0)
+ BootVectTable *bootVector = ((BootVectTable*)BOOTLOADER_VECT_TABLE);
+
+ while ((outStr[offset] != '\0')
&& (offset < USB_SERIAL_BUF_SIZE)) {
offset++;
}
- while (_GetEPTxCount(USB_SERIAL_ENDP_TX) > 0) {}
+ delay(offset*1);
- usb_userToPMABufferCopy(outStr,USB_SERIAL_ENDP_TXADDR,offset);
+ bootVector->serial_count_in = (u32*) &offset;
+ usb_userToPMABufferCopy((u8*)outStr,USB_SERIAL_ENDP_TXADDR,offset);
_SetEPTxCount(USB_SERIAL_ENDP_TX,offset);
_SetEPTxValid(USB_SERIAL_ENDP_TX);
+
}
+uint8_t usb_serialGetRecvLen() {
+ uint8_t count_out = _GetEPRxCount(USB_SERIAL_ENDP_RX);
+ _SetEPRxValid(USB_SERIAL_ENDP_RX);
+ return count_out;
+}