avoid multiple USB serial begin (taken from F1)
This commit is contained in:
parent
f1e2cba93b
commit
d872cb1963
|
@ -36,20 +36,25 @@
|
|||
#ifdef SERIAL_USB
|
||||
|
||||
#define USB_TIMEOUT 50
|
||||
bool USBSerial::_hasBegun = false;
|
||||
|
||||
USBSerial::USBSerial(void) {
|
||||
}
|
||||
|
||||
void USBSerial::begin(void) {
|
||||
if (_hasBegun)
|
||||
return;
|
||||
_hasBegun = true;
|
||||
setupUSB();
|
||||
}
|
||||
|
||||
void USBSerial::begin(int) {
|
||||
setupUSB();
|
||||
this->begin();
|
||||
}
|
||||
|
||||
void USBSerial::end(void) {
|
||||
disableUSB();
|
||||
_hasBegun = false;
|
||||
}
|
||||
|
||||
size_t USBSerial::write(uint8 ch) {
|
||||
|
|
|
@ -65,6 +65,9 @@ public:
|
|||
|
||||
void enableBlockingTx(void);
|
||||
void disableBlockingTx(void);
|
||||
|
||||
protected:
|
||||
static bool _hasBegun;
|
||||
};
|
||||
|
||||
extern USBSerial SerialUSB;
|
||||
|
|
Loading…
Reference in New Issue