Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@0:38b6065539a0, 2019-09-28 (annotated)
- Committer:
- GaspardD
- Date:
- Sat Sep 28 16:27:37 2019 +0000
- Revision:
- 0:38b6065539a0
- Child:
- 1:8faddee0e52f
firstCommit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GaspardD | 0:38b6065539a0 | 1 | /* mbed Microcontroller Library |
GaspardD | 0:38b6065539a0 | 2 | * Copyright (c) 2018 ARM Limited |
GaspardD | 0:38b6065539a0 | 3 | * SPDX-License-Identifier: Apache-2.0 |
GaspardD | 0:38b6065539a0 | 4 | */ |
GaspardD | 0:38b6065539a0 | 5 | |
GaspardD | 0:38b6065539a0 | 6 | #include "mbed.h" |
GaspardD | 0:38b6065539a0 | 7 | #include "ThisThread.h" |
GaspardD | 0:38b6065539a0 | 8 | #include "stats_report.h" |
GaspardD | 0:38b6065539a0 | 9 | |
GaspardD | 0:38b6065539a0 | 10 | DigitalOut led1(LED1); |
GaspardD | 0:38b6065539a0 | 11 | |
GaspardD | 0:38b6065539a0 | 12 | #define SLEEP_TIME 500 // (msec) |
GaspardD | 0:38b6065539a0 | 13 | #define PRINT_AFTER_N_LOOPS 20 |
GaspardD | 0:38b6065539a0 | 14 | |
GaspardD | 0:38b6065539a0 | 15 | // main() runs in its own thread in the OS |
GaspardD | 0:38b6065539a0 | 16 | int main() |
GaspardD | 0:38b6065539a0 | 17 | { |
GaspardD | 0:38b6065539a0 | 18 | SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); |
GaspardD | 0:38b6065539a0 | 19 | |
GaspardD | 0:38b6065539a0 | 20 | int count = 0; |
GaspardD | 0:38b6065539a0 | 21 | while (true) { |
GaspardD | 0:38b6065539a0 | 22 | // Blink LED and wait 0.5 seconds |
GaspardD | 0:38b6065539a0 | 23 | led1 = !led1; |
GaspardD | 0:38b6065539a0 | 24 | ThisThread::sleep_for(SLEEP_TIME); |
GaspardD | 0:38b6065539a0 | 25 | |
GaspardD | 0:38b6065539a0 | 26 | if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { |
GaspardD | 0:38b6065539a0 | 27 | // Following the main thread wait, report on the current system status |
GaspardD | 0:38b6065539a0 | 28 | sys_state.report_state(); |
GaspardD | 0:38b6065539a0 | 29 | count = 0; |
GaspardD | 0:38b6065539a0 | 30 | } |
GaspardD | 0:38b6065539a0 | 31 | ++count; |
GaspardD | 0:38b6065539a0 | 32 | } |
GaspardD | 0:38b6065539a0 | 33 | } |