From 52cbd2f1a1557002f46355e0095400a09c267ff9 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 19 Jul 2010 00:24:31 -0400 Subject: 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. --- libmaple/usb/usb.c | 6 ++++++ libmaple/usb/usb.h | 1 + 2 files changed, 7 insertions(+) (limited to 'libmaple/usb') 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); -- cgit v1.2.3