ST-DEVKIT-LRWAN

Dependents:   DISCO-L072CZ-LRWAN1-base

Fork of SX1276GenericLib by Helmut Tschemernjak

Revision:
90:d98572047c9c
Parent:
88:d120930aeb13
--- 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);
+                }
+            }
         }
     }
 }