Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Peripherals SD_Lib Time_Lib_v2 Year3_Version5 BMP280 LCDFunctions TextLCD BME280 Serial_Lib
Revision 1:948bd552a2a2, committed 2017-03-30
- Comitter:
- noutram
- Date:
- Thu Mar 30 13:58:19 2017 +0000
- Parent:
- 0:90e393878517
- Child:
- 2:3d65cd8d7089
- Commit message:
- updated for mbed OS 5.4
Changed in this revision
--- a/main.cpp Tue Mar 08 11:44:46 2016 +0000
+++ b/main.cpp Thu Mar 30 13:58:19 2017 +0000
@@ -7,10 +7,10 @@
#define ALL_OFF 7
//Function declarations
-void Function1(void const *args);
-void Function2(void const *args);
-void Function3(void const *args);
-void Function4(void const *args);
+void Function1();
+void Function2();
+void Function3();
+void Function4();
//I/O
DigitalOut onBoardLED(LED1);
@@ -22,10 +22,10 @@
DigitalIn SW1(D4);
DigitalIn SW2(D3);
-Thread* t1;
-Thread* t2;
-Thread* t3;
-Thread* t4;
+Thread t1;
+Thread t2;
+Thread t3;
+Thread t4;
//Thread ID
osThreadId idMain;
@@ -34,42 +34,42 @@
osThreadId id3;
osThreadId id4;
-void Function1(void const *args)
+void Function1()
{
while (true) {
redLED = !redLED;
if (redLED == 0) {
- t2->signal_set(RED_OFF);
+ t2.signal_set(RED_OFF);
}
Thread::wait(1000);
}
}
-void Function2(void const *args)
+void Function2()
{
while (true) {
Thread::signal_wait(RED_OFF);
yellowLED = !yellowLED;
if (yellowLED == 0) {
- t3->signal_set(YELLOW_OFF);
+ t3.signal_set(YELLOW_OFF);
}
}
}
//Green Flashing
-void Function3(void const *args)
+void Function3()
{
while (true) {
Thread::signal_wait(YELLOW_OFF);
greenLED = !greenLED;
if (greenLED == 0) {
- t4->signal_set(GREEN_OFF);
+ t4.signal_set(GREEN_OFF);
}
}
}
//This function waits for signals from all other threads
-void Function4(void const *args)
+void Function4()
{
while (true) {
Thread::signal_wait(GREEN_OFF);
@@ -87,18 +87,18 @@
//Main thread ID
idMain = osThreadGetId(); //CMSIS RTOS call
- //Create and run threads
- t4 = new Thread(Function4);
- t1 = new Thread(Function1);
- t2 = new Thread(Function2);
- t3 = new Thread(Function3); //Dynamically allocated
+ // run threads
+ t4.start(Function4);
+ t1.start(Function1);
+ t2.start(Function2);
+ t3.start(Function3);
//Thread ID
- id1 = t1->gettid();
- id2 = t2->gettid();
- id3 = t3->gettid();
- id4 = t4->gettid();
+ id1 = t1.gettid();
+ id2 = t2.gettid();
+ id3 = t3.gettid();
+ id4 = t4.gettid();
while(1) {
//Wait for the ALL_ON signal
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Mar 30 13:58:19 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d
--- a/mbed-rtos.lib Tue Mar 08 11:44:46 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#b4c5542476ba
--- a/mbed.bld Tue Mar 08 11:44:46 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file