Nicholas Outram / Mbed OS Task611-mbedos54

Fork of Task611-mbedos54 by Stage-1 Students SoCEM

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 
00004 //Function declarations
00005 void Function1();
00006 void Function2();
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, t2;
00019 
00020 void Function1()
00021 {
00022     while (true) {
00023         redLED = !redLED;
00024         Thread::wait(2000);
00025     }
00026 }
00027 
00028 void Function2()
00029 {
00030     while (true) {
00031         yellowLED = !yellowLED;
00032         Thread::wait(1000);
00033     }
00034 }
00035 
00036 //Main thread
00037 int main() {
00038     redLED    = 0;
00039     yellowLED = 0;
00040     
00041     //Create and run threads
00042     t1.start(Function1);           
00043     t2.start(Function2);    
00044     
00045     while(1) {
00046         //Thread::wait(osWaitForever);
00047         Thread::wait(5000);
00048         printf("Awake\n");  //Should not happen
00049     }
00050 }