Nicholas Outram
/
Task611-mbedos54-solution
Updated for mbed OS 5.4
Fork of Task611-mbedos54-solution by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 //Function declarations 00004 void Function1(void const *args); 00005 void Function2(void const *args); 00006 void Function3(void const *args); 00007 00008 //I/O 00009 DigitalOut onBoardLED(LED1); 00010 DigitalOut redLED(D7); 00011 DigitalOut yellowLED(D6); 00012 DigitalOut greenLED(D5); 00013 00014 DigitalIn onBoardSwitch(USER_BUTTON); 00015 DigitalIn SW1(D4); 00016 DigitalIn SW2(D3); 00017 00018 Thread t1; 00019 Thread t2; 00020 Thread t3; 00021 00022 void Function1() 00023 { 00024 while (true) { 00025 redLED = !redLED; 00026 Thread::wait(2000); 00027 } 00028 } 00029 00030 void Function2() 00031 { 00032 while (true) { 00033 yellowLED = !yellowLED; 00034 Thread::wait(1000); 00035 } 00036 } 00037 00038 //Green Flashing 00039 void Function3() 00040 { 00041 while (true) { 00042 greenLED = !greenLED; 00043 Thread::wait(500); 00044 } 00045 } 00046 00047 00048 //Main thread 00049 int main() { 00050 redLED = 0; 00051 yellowLED = 0; 00052 greenLED = 0; 00053 00054 //Create and run threads 00055 t1.start(Function1); 00056 t2.start(Function2); 00057 t3.start(Function3); 00058 00059 while(1) { 00060 //Thread::wait(osWaitForever); 00061 Thread::wait(5000); 00062 printf("Awake\n"); //Should not happen 00063 } 00064 } 00065
Generated on Tue Aug 16 2022 01:18:42 by 1.7.2