From 3c4307ebac3102bf95bc6fd7b637449860bef053 Mon Sep 17 00:00:00 2001 From: Roger Clark Date: Wed, 7 Jun 2017 14:00:24 +1000 Subject: [PATCH] Fix issue where USB Serial begin(xx) begin(xx,yy) did nothing, when they should ahave called begin() --- STM32F1/cores/maple/usb_serial.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/STM32F1/cores/maple/usb_serial.cpp b/STM32F1/cores/maple/usb_serial.cpp index 32fe471..1fe2bf4 100644 --- a/STM32F1/cores/maple/usb_serial.cpp +++ b/STM32F1/cores/maple/usb_serial.cpp @@ -54,8 +54,10 @@ static void ifaceSetupHook(unsigned, void*); */ #define USB_TIMEOUT 50 - +#if BOARD_HAVE_SERIALUSB bool USBSerial::_hasBegun = false; +#endif + USBSerial::USBSerial(void) { #if !BOARD_HAVE_SERIALUSB ASSERT(0); @@ -63,10 +65,12 @@ USBSerial::USBSerial(void) { } void USBSerial::begin(void) { + +#if BOARD_HAVE_SERIALUSB if (_hasBegun) return; _hasBegun = true; -#if BOARD_HAVE_SERIALUSB + usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, rxHook); usb_cdcacm_set_hooks(USB_CDCACM_HOOK_IFACE_SETUP, ifaceSetupHook); @@ -79,6 +83,7 @@ void USBSerial::begin(unsigned long ignoreBaud) volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud; ignoreBaud=removeCompilerWarningsIgnoreBaud; + begin(); } void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore) { @@ -87,14 +92,16 @@ volatile uint8_t removeCompilerWarningsIgnore=ignore; ignoreBaud=removeCompilerWarningsIgnoreBaud; ignore=removeCompilerWarningsIgnore; + begin(); } void USBSerial::end(void) { #if BOARD_HAVE_SERIALUSB usb_cdcacm_disable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT); usb_cdcacm_remove_hooks(USB_CDCACM_HOOK_RX | USB_CDCACM_HOOK_IFACE_SETUP); + _hasBegun = false; #endif - _hasBegun = false; + } size_t USBSerial::write(uint8 ch) {