Thread example
Revision 1:20f8dc1354d0, committed 2017-10-31
- Comitter:
- noutram
- Date:
- Tue Oct 31 13:45:19 2017 +0000
- Parent:
- 0:e48f4ddb9393
- Child:
- 2:47c9c24b49fc
- Commit message:
- Updated for 2017 FX429
Changed in this revision
--- a/main.cpp Thu Mar 30 12:39:47 2017 +0000
+++ b/main.cpp Tue Oct 31 13:45:19 2017 +0000
@@ -7,16 +7,18 @@
//I/O
DigitalOut onBoardLED(LED1);
-DigitalOut redLED(D7);
-DigitalOut yellowLED(D6);
-DigitalOut greenLED(D5);
+DigitalOut redLED(PE_15);
+DigitalOut yellowLED(PB_10);
+DigitalOut greenLED(PB_11);
DigitalIn onBoardSwitch(USER_BUTTON);
-DigitalIn SW1(D4);
-DigitalIn SW2(D3);
+DigitalIn SW1(PE_12);
+DigitalIn SW2(PE_14);
+//Create thread objects
Thread t1, t2;
+//Thread
void Function1()
{
while (true) {
@@ -25,6 +27,7 @@
}
}
+//Thread
void Function2()
{
while (true) {
@@ -35,16 +38,20 @@
//Main thread
int main() {
+ //Initial state
redLED = 0;
yellowLED = 0;
+ greenLED = 0;
- //Create and run threads
+ //Create and run threads (C function pointers)
t1.start(Function1);
t2.start(Function2);
+ //Main thread loop
while(1) {
//Thread::wait(osWaitForever);
Thread::wait(5000);
- printf("Awake\n"); //Should not happen
+ greenLED = !greenLED;
+ printf("Main is Awake\n"); //Should not happen when osWaitForever is used
}
}
--- a/mbed-os.lib Thu Mar 30 12:39:47 2017 +0000 +++ b/mbed-os.lib Tue Oct 31 13:45:19 2017 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d +https://github.com/ARMmbed/mbed-os/#e62a1b9236b44e70ae3b0902dc538481c04d455b