Toggles LED and prints debug information

Committer:
Dheeraj22
Date:
Sun May 26 17:17:27 2019 +0000
Revision:
1:e4d41670a405
Parent:
0:19ea743b1bfa
Child:
2:e83554ed7b87
Blinky example created

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Dheeraj22 0:19ea743b1bfa 1 /* mbed Microcontroller Library
Dheeraj22 0:19ea743b1bfa 2 * Copyright (c) 2018 ARM Limited
Dheeraj22 0:19ea743b1bfa 3 * SPDX-License-Identifier: Apache-2.0
Dheeraj22 0:19ea743b1bfa 4 */
Dheeraj22 0:19ea743b1bfa 5
Dheeraj22 0:19ea743b1bfa 6 #include "mbed.h"
Dheeraj22 1:e4d41670a405 7 #include "stats_report.h"
Dheeraj22 0:19ea743b1bfa 8
Dheeraj22 0:19ea743b1bfa 9 DigitalOut led1(LED1);
Dheeraj22 0:19ea743b1bfa 10
Dheeraj22 0:19ea743b1bfa 11 #define SLEEP_TIME 500 // (msec)
Dheeraj22 1:e4d41670a405 12 #define PRINT_AFTER_N_LOOPS 20
Dheeraj22 0:19ea743b1bfa 13
Dheeraj22 0:19ea743b1bfa 14 // main() runs in its own thread in the OS
Dheeraj22 0:19ea743b1bfa 15 int main()
Dheeraj22 1:e4d41670a405 16 {
Dheeraj22 1:e4d41670a405 17 SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);
Dheeraj22 1:e4d41670a405 18
Dheeraj22 1:e4d41670a405 19 int count = 0;
Dheeraj22 0:19ea743b1bfa 20 while (true) {
Dheeraj22 0:19ea743b1bfa 21 // Blink LED and wait 0.5 seconds
Dheeraj22 0:19ea743b1bfa 22 led1 = !led1;
Dheeraj22 0:19ea743b1bfa 23 wait_ms(SLEEP_TIME);
Dheeraj22 1:e4d41670a405 24
Dheeraj22 1:e4d41670a405 25 if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) {
Dheeraj22 1:e4d41670a405 26 // Following the main thread wait, report on the current system status
Dheeraj22 1:e4d41670a405 27 sys_state.report_state();
Dheeraj22 1:e4d41670a405 28 count = 0;
Dheeraj22 1:e4d41670a405 29 }
Dheeraj22 1:e4d41670a405 30 ++count;
Dheeraj22 0:19ea743b1bfa 31 }
Dheeraj22 0:19ea743b1bfa 32 }