RTOS Template for ELEC35X 2019

Committer:
noutram
Date:
Wed Sep 25 15:02:03 2019 +0000
Revision:
0:2f993270f60e
RTOS Template for 2019

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 0:2f993270f60e 1 #include "mbed.h"
noutram 0:2f993270f60e 2 #include "ThisThread.h"
noutram 0:2f993270f60e 3 #include "stats_report.h"
noutram 0:2f993270f60e 4
noutram 0:2f993270f60e 5 DigitalOut led1(LED1);
noutram 0:2f993270f60e 6
noutram 0:2f993270f60e 7 #define SLEEP_TIME 500 // (msec)
noutram 0:2f993270f60e 8 #define PRINT_AFTER_N_LOOPS 20
noutram 0:2f993270f60e 9
noutram 0:2f993270f60e 10 // main() runs in its own thread in the OS
noutram 0:2f993270f60e 11 // Serial BAUD set to max ( 926100 )
noutram 0:2f993270f60e 12
noutram 0:2f993270f60e 13 int main()
noutram 0:2f993270f60e 14 {
noutram 0:2f993270f60e 15 SystemReport sys_state( SLEEP_TIME * PRINT_AFTER_N_LOOPS /* Loop delay time in ms */);
noutram 0:2f993270f60e 16
noutram 0:2f993270f60e 17 int count = 0;
noutram 0:2f993270f60e 18 while (true) {
noutram 0:2f993270f60e 19 // Blink LED and wait 0.5 seconds
noutram 0:2f993270f60e 20 led1 = !led1;
noutram 0:2f993270f60e 21 ThisThread::sleep_for(SLEEP_TIME);
noutram 0:2f993270f60e 22
noutram 0:2f993270f60e 23
noutram 0:2f993270f60e 24
noutram 0:2f993270f60e 25 //************************************************************************
noutram 0:2f993270f60e 26 // Status Information
noutram 0:2f993270f60e 27 //************************************************************************
noutram 0:2f993270f60e 28 if ((count==0) || (count == PRINT_AFTER_N_LOOPS)) {
noutram 0:2f993270f60e 29 // Following the main thread wait, report on the current system status
noutram 0:2f993270f60e 30 sys_state.report_state();
noutram 0:2f993270f60e 31 count = 0;
noutram 0:2f993270f60e 32 }
noutram 0:2f993270f60e 33 count++;
noutram 0:2f993270f60e 34 //************************************************************************
noutram 0:2f993270f60e 35
noutram 0:2f993270f60e 36 }
noutram 0:2f993270f60e 37 }