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