Matheus Castro / Mbed OS mbed-os-example-blinky
Committer:
matheusctro
Date:
Thu Oct 17 13:14:00 2019 +0000
Revision:
0:0d27bd05c2d2
teste

Who changed what in which revision?

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