updated for mbed os 5.4

Fork of Task611-mbedos54 by Stage-1 Students SoCEM

Committer:
noutram
Date:
Thu Mar 30 12:39:47 2017 +0000
Revision:
0:e48f4ddb9393
updated for mbed os 5.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 0:e48f4ddb9393 1 #include "mbed.h"
noutram 0:e48f4ddb9393 2
noutram 0:e48f4ddb9393 3
noutram 0:e48f4ddb9393 4 //Function declarations
noutram 0:e48f4ddb9393 5 void Function1();
noutram 0:e48f4ddb9393 6 void Function2();
noutram 0:e48f4ddb9393 7
noutram 0:e48f4ddb9393 8 //I/O
noutram 0:e48f4ddb9393 9 DigitalOut onBoardLED(LED1);
noutram 0:e48f4ddb9393 10 DigitalOut redLED(D7);
noutram 0:e48f4ddb9393 11 DigitalOut yellowLED(D6);
noutram 0:e48f4ddb9393 12 DigitalOut greenLED(D5);
noutram 0:e48f4ddb9393 13
noutram 0:e48f4ddb9393 14 DigitalIn onBoardSwitch(USER_BUTTON);
noutram 0:e48f4ddb9393 15 DigitalIn SW1(D4);
noutram 0:e48f4ddb9393 16 DigitalIn SW2(D3);
noutram 0:e48f4ddb9393 17
noutram 0:e48f4ddb9393 18 Thread t1, t2;
noutram 0:e48f4ddb9393 19
noutram 0:e48f4ddb9393 20 void Function1()
noutram 0:e48f4ddb9393 21 {
noutram 0:e48f4ddb9393 22 while (true) {
noutram 0:e48f4ddb9393 23 redLED = !redLED;
noutram 0:e48f4ddb9393 24 Thread::wait(2000);
noutram 0:e48f4ddb9393 25 }
noutram 0:e48f4ddb9393 26 }
noutram 0:e48f4ddb9393 27
noutram 0:e48f4ddb9393 28 void Function2()
noutram 0:e48f4ddb9393 29 {
noutram 0:e48f4ddb9393 30 while (true) {
noutram 0:e48f4ddb9393 31 yellowLED = !yellowLED;
noutram 0:e48f4ddb9393 32 Thread::wait(1000);
noutram 0:e48f4ddb9393 33 }
noutram 0:e48f4ddb9393 34 }
noutram 0:e48f4ddb9393 35
noutram 0:e48f4ddb9393 36 //Main thread
noutram 0:e48f4ddb9393 37 int main() {
noutram 0:e48f4ddb9393 38 redLED = 0;
noutram 0:e48f4ddb9393 39 yellowLED = 0;
noutram 0:e48f4ddb9393 40
noutram 0:e48f4ddb9393 41 //Create and run threads
noutram 0:e48f4ddb9393 42 t1.start(Function1);
noutram 0:e48f4ddb9393 43 t2.start(Function2);
noutram 0:e48f4ddb9393 44
noutram 0:e48f4ddb9393 45 while(1) {
noutram 0:e48f4ddb9393 46 //Thread::wait(osWaitForever);
noutram 0:e48f4ddb9393 47 Thread::wait(5000);
noutram 0:e48f4ddb9393 48 printf("Awake\n"); //Should not happen
noutram 0:e48f4ddb9393 49 }
noutram 0:e48f4ddb9393 50 }