mbed OS Blinky LED HelloWorld

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Files at this revision

API Documentation at this revision

Comitter:
cyliang
Date:
Tue Sep 01 06:24:37 2020 +0000
Parent:
66:8321d4bf0808
Commit message:
Support OS v5.14, v5.15 and v6.2. Set default OS v5.15

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 8321d4bf0808 -r 1885193045fb main.cpp
--- a/main.cpp	Fri Oct 04 03:03:14 2019 +0000
+++ b/main.cpp	Tue Sep 01 06:24:37 2020 +0000
@@ -1,12 +1,25 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
 #include "mbed.h"
 
-DigitalOut led1(LED1);
+
+// Blinking rate in milliseconds
+#define BLINKING_RATE     500
+
 
-// main() runs in its own thread in the OS
-int main() {
+int main()
+{
+#ifdef MBED_MAJOR_VERSION
+    printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+#endif
+    // Initialise the digital pin LED1 as an output
+    DigitalOut led(LED1);
+
     while (true) {
-        led1 = !led1;
-        wait(0.5);
+        led = !led;
+        ThisThread::sleep_for(BLINKING_RATE);
     }
-}
-
+}
\ No newline at end of file
diff -r 8321d4bf0808 -r 1885193045fb mbed-os.lib
--- a/mbed-os.lib	Fri Oct 04 03:03:14 2019 +0000
+++ b/mbed-os.lib	Tue Sep 01 06:24:37 2020 +0000
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#b6e5a0a8afa34dec9dae8963778aebce0c82a54b
+https://github.com/ARMmbed/mbed-os/#6a244d7adffc0e93872cfc880e539ee11bbc6002