aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2010-07-19 00:24:31 -0400
committerbnewbold <bnewbold@robocracy.org>2010-07-19 00:38:36 -0400
commit52cbd2f1a1557002f46355e0095400a09c267ff9 (patch)
treeb2d8a95eb2cb2ac0c081fc0459a495baa75319c8 /libmaple
parent7ae1ce63259ef440bc13d7493e9dcee43df83591 (diff)
downloadlibrambutan-52cbd2f1a1557002f46355e0095400a09c267ff9.tar.gz
librambutan-52cbd2f1a1557002f46355e0095400a09c267ff9.zip
working serialUSB with timeout
as a temporary workaround for the fact that SerialUSB is often blocking, this crude implementation makes the low-level C usbSendBytes function non-blocking (with a return code of bytes sent) and implements a 2ms timeout in the wirish write() function. also adds begin(), end(), getDTR(), getRTS(), pending(). device is still initialized the old fashioned way during init() so that, eg, autoreset will work. includes a simple multi-test program.
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/usb/usb.c6
-rw-r--r--libmaple/usb/usb.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/libmaple/usb/usb.c b/libmaple/usb/usb.c
index 6c010d9..881c7f9 100644
--- a/libmaple/usb/usb.c
+++ b/libmaple/usb/usb.c
@@ -120,7 +120,13 @@ void setupUSB (void) {
/* initialize the usb application */
gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,0); /* present ourselves to the host */
USB_Init(); /* low level init routine provided by st lib */
+}
+void disableUSB (void) {
+ // These are just guesses about how to do this
+ // TODO: real disable function
+ usbDsbISR();
+ gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,1);
}
void usbSuspend(void) {
diff --git a/libmaple/usb/usb.h b/libmaple/usb/usb.h
index 66e820c..e0d4231 100644
--- a/libmaple/usb/usb.h
+++ b/libmaple/usb/usb.h
@@ -36,6 +36,7 @@ typedef enum
extern volatile uint32 bDeviceState;
void setupUSB(void);
+ void disableUSB(void);
void usbSuspend(void);
void usbResumeInit(void);
void usbResume(RESUME_STATE);