Skip to content

Commit 3c4307e

Browse files
Fix issue where USB Serial begin(xx) begin(xx,yy) did nothing, when they should ahave called begin()
1 parent 16a7334 commit 3c4307e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

STM32F1/cores/maple/usb_serial.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,23 @@ static void ifaceSetupHook(unsigned, void*);
5454
*/
5555

5656
#define USB_TIMEOUT 50
57-
57+
#if BOARD_HAVE_SERIALUSB
5858
bool USBSerial::_hasBegun = false;
59+
#endif
60+
5961
USBSerial::USBSerial(void) {
6062
#if !BOARD_HAVE_SERIALUSB
6163
ASSERT(0);
6264
#endif
6365
}
6466

6567
void USBSerial::begin(void) {
68+
69+
#if BOARD_HAVE_SERIALUSB
6670
if (_hasBegun)
6771
return;
6872
_hasBegun = true;
69-
#if BOARD_HAVE_SERIALUSB
73+
7074
usb_cdcacm_enable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
7175
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_RX, rxHook);
7276
usb_cdcacm_set_hooks(USB_CDCACM_HOOK_IFACE_SETUP, ifaceSetupHook);
@@ -79,6 +83,7 @@ void USBSerial::begin(unsigned long ignoreBaud)
7983
volatile unsigned long removeCompilerWarningsIgnoreBaud=ignoreBaud;
8084

8185
ignoreBaud=removeCompilerWarningsIgnoreBaud;
86+
begin();
8287
}
8388
void USBSerial::begin(unsigned long ignoreBaud, uint8_t ignore)
8489
{
@@ -87,14 +92,16 @@ volatile uint8_t removeCompilerWarningsIgnore=ignore;
8792

8893
ignoreBaud=removeCompilerWarningsIgnoreBaud;
8994
ignore=removeCompilerWarningsIgnore;
95+
begin();
9096
}
9197

9298
void USBSerial::end(void) {
9399
#if BOARD_HAVE_SERIALUSB
94100
usb_cdcacm_disable(BOARD_USB_DISC_DEV, BOARD_USB_DISC_BIT);
95101
usb_cdcacm_remove_hooks(USB_CDCACM_HOOK_RX | USB_CDCACM_HOOK_IFACE_SETUP);
102+
_hasBegun = false;
96103
#endif
97-
_hasBegun = false;
104+
98105
}
99106

100107
size_t USBSerial::write(uint8 ch) {

0 commit comments

Comments
 (0)