00

Committer:
peng103617
Date:
Thu Oct 17 03:27:19 2019 +0000
Revision:
0:69db88456c7f
916

Who changed what in which revision?

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