Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_USB_Rx ... more
Fork of SX1276Lib by
Diff: Arduino-mbed-APIs/arduino-mbed.cpp
- Revision:
- 84:3428e25c7157
- Parent:
- 80:62f0b027efff
- Child:
- 88:d120930aeb13
--- a/Arduino-mbed-APIs/arduino-mbed.cpp Sun Aug 06 14:23:43 2017 +0200
+++ b/Arduino-mbed-APIs/arduino-mbed.cpp Fri Aug 11 15:11:08 2017 +0200
@@ -12,8 +12,25 @@
#include "arduino-util.h"
Stream *ser;
-void InitSerial(Stream *serial) {
+bool SerialUSB_active = false;
+
+void InitSerial(Stream *serial, int timeout_ms) {
ser = serial;
+ if (serial == (Stream *)&SerialUSB) {
+ uint32_t start = ms_getTicker();
+
+ SerialUSB_active = true;
+ while(!SerialUSB) {
+ if (ms_getTicker() > start + timeout_ms) {
+ SerialUSB_active = false;
+ break;
+ }
+ }
+ if (!SerialUSB_active) {
+ USB->DEVICE.CTRLA.bit.SWRST = 1; // disconnect the USB Port
+ while (USB->DEVICE.CTRLA.bit.SWRST == 1);
+ }
+ }
}
static void pinInt00(void);

