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.
Diff: main.cpp
- Revision:
- 0:b04aae5b80fd
diff -r 000000000000 -r b04aae5b80fd main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri May 06 05:58:29 2022 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "rtos.h"
+DigitalOut led1(LED6);
+DigitalOut led2(LED1);
+
+Mutex mutex;
+
+uint32_t cont =0;
+bool done[2] = {0,0};
+
+Thread t1;
+Thread t2;
+
+void thread1( const int *i){
+ int conth;
+ int conth2 =0;
+ while(conth2<100){
+ mutex.lock();
+ conth = cont;
+ conth2++;
+ conth++;
+ Thread::wait(10);
+ cont = conth;
+ printf(" %d\n\r ",cont);
+ mutex.unlock();
+ }
+ done[(int)i] =1;
+ }
+
+
+int main(){
+ t1.start(callback(thread1, (int*) 1));
+ t2.start(callback(thread1, (int*) 2));
+ while(1){
+ Thread::wait(1);
+ if(done[0] && done[1]){
+ if(cont == 200){
+ led1=1;
+ }
+ else{
+ led2 = 1;
+ }
+ }
+ }
+ }
+
\ No newline at end of file