![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
test
main.cpp@0:50a0fdd7f221, 2019-03-25 (annotated)
- Committer:
- kstokely
- Date:
- Mon Mar 25 19:37:05 2019 +0000
- Revision:
- 0:50a0fdd7f221
test os program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kstokely | 0:50a0fdd7f221 | 1 | /* mbed Microcontroller Library |
kstokely | 0:50a0fdd7f221 | 2 | * Copyright (c) 2018 ARM Limited |
kstokely | 0:50a0fdd7f221 | 3 | * SPDX-License-Identifier: Apache-2.0 |
kstokely | 0:50a0fdd7f221 | 4 | */ |
kstokely | 0:50a0fdd7f221 | 5 | |
kstokely | 0:50a0fdd7f221 | 6 | #include "mbed.h" |
kstokely | 0:50a0fdd7f221 | 7 | #include "stats_report.h" |
kstokely | 0:50a0fdd7f221 | 8 | |
kstokely | 0:50a0fdd7f221 | 9 | DigitalOut led1(LED1); |
kstokely | 0:50a0fdd7f221 | 10 | |
kstokely | 0:50a0fdd7f221 | 11 | #define SLEEP_TIME 500 // (msec) |
kstokely | 0:50a0fdd7f221 | 12 | #define PRINT_AFTER_N_LOOPS 20 |
kstokely | 0:50a0fdd7f221 | 13 | |
kstokely | 0:50a0fdd7f221 | 14 | // main() runs in its own thread in the OS |
kstokely | 0:50a0fdd7f221 | 15 | int main() |
kstokely | 0:50a0fdd7f221 | 16 | { |
kstokely | 0:50a0fdd7f221 | 17 | SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */); |
kstokely | 0:50a0fdd7f221 | 18 | |
kstokely | 0:50a0fdd7f221 | 19 | int count = 0; |
kstokely | 0:50a0fdd7f221 | 20 | while (true) { |
kstokely | 0:50a0fdd7f221 | 21 | // Blink LED and wait 0.5 seconds |
kstokely | 0:50a0fdd7f221 | 22 | led1 = !led1; |
kstokely | 0:50a0fdd7f221 | 23 | wait_ms(SLEEP_TIME); |
kstokely | 0:50a0fdd7f221 | 24 | |
kstokely | 0:50a0fdd7f221 | 25 | if ((0 == count) || (PRINT_AFTER_N_LOOPS == count)) { |
kstokely | 0:50a0fdd7f221 | 26 | // Following the main thread wait, report on the current system status |
kstokely | 0:50a0fdd7f221 | 27 | sys_state.report_state(); |
kstokely | 0:50a0fdd7f221 | 28 | count = 0; |
kstokely | 0:50a0fdd7f221 | 29 | } |
kstokely | 0:50a0fdd7f221 | 30 | ++count; |
kstokely | 0:50a0fdd7f221 | 31 | } |
kstokely | 0:50a0fdd7f221 | 32 | } |