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.
Diff: Arduino-mbed-APIs/arduino-mbed.cpp
- Revision:
- 90:d98572047c9c
- Parent:
- 88:d120930aeb13
- Child:
- 93:c328629726a6
--- a/Arduino-mbed-APIs/arduino-mbed.cpp Wed Aug 30 12:02:09 2017 +0200
+++ b/Arduino-mbed-APIs/arduino-mbed.cpp Sun Sep 17 12:46:18 2017 +0200
@@ -12,10 +12,13 @@
#include "arduino-util.h"
Stream *ser;
-bool SerialUSB_active = false;
+bool SerialUSB_active;
-void InitSerial(Stream *serial, int timeout_ms) {
+void InitSerial(Stream *serial, int timeout_ms, DigitalOut *led) {
ser = serial;
+ SerialUSB_active = true;
+ if (!timeout_ms)
+ return;
if (serial == (Stream *)&SerialUSB) {
uint32_t start = ms_getTicker();
@@ -29,6 +32,15 @@
if (!SerialUSB_active) {
USB->DEVICE.CTRLA.bit.SWRST = 1; // disconnect the USB Port
while (USB->DEVICE.CTRLA.bit.SWRST == 1);
+ if (led) {
+ for (int i = 0; i < 10; i++) {
+ // lets blink the LED to show that SerialUSB is off.
+ *led = 1;
+ delay(80);
+ *led = 0;
+ delay(80);
+ }
+ }
}
}
}