EXAMPLE DISCO-F303VC

Dependencies:   mbed mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
davidahuertas
Date:
Fri May 06 05:58:29 2022 +0000
Commit message:
LAB 3 DISCO-F303VC

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Fri May 06 05:58:29 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed-rtos/#5713cbbdb706
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 06 05:58:29 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file