jk

Dependencies:   mbed-rtos mbed

Fork of rtos_basic by mbed official

Files at this revision

API Documentation at this revision

Comitter:
polrodoreda
Date:
Thu Nov 03 15:40:17 2016 +0000
Parent:
6:209f4db62daf
Commit message:
ppp

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
diff -r 209f4db62daf -r 4fa2695e0d63 main.cpp
--- a/main.cpp	Tue Jun 04 16:01:32 2013 +0100
+++ b/main.cpp	Thu Nov 03 15:40:17 2016 +0000
@@ -1,21 +1,42 @@
 #include "mbed.h"
 #include "rtos.h"
+
+typedef struct {
+    char *mensaje;
+    int  msg_number;
+} msg_type;
  
-DigitalOut led1(LED1);
-DigitalOut led2(LED2);
+MemoryPool<msg_type, 16> mpool;
+Queue<msg_type, 16> queue;
  
-void led2_thread(void const *args) {
+/* Send Thread */
+void producer_thread (void const *args) {
+    uint32_t i = 0;
+    int status;
     while (true) {
-        led2 = !led2;
-        Thread::wait(1000);
+        i++; // fake data update
+        msg_type *message = mpool.alloc();
+        message->mensaje="Hola";
+        message->msg_number=i;
+        status = queue.put(message,1);
+        printf("%d",status);
+        printf("Message into queue: %d,%s\n\r", message->msg_number, message->mensaje);
+        Thread::wait(500);
     }
 }
  
-int main() {
-    Thread thread(led2_thread);
-    
+int main (void) {
+    Thread thread(producer_thread);
+    int msg_count=0;
     while (true) {
-        led1 = !led1;
-        Thread::wait(500);
+        osEvent evt = queue.get();
+        if (evt.status == osEventMessage) {
+            msg_count++;
+            msg_type *message = (msg_type*)evt.value.p;
+            printf("Message out of queue : %d,%s\n\r", message->msg_number, message->mensaje);
+            mpool.free(message);
+            Thread::wait(1100);
+        }
     }
 }
+ 
diff -r 209f4db62daf -r 4fa2695e0d63 mbed-rtos.lib
--- a/mbed-rtos.lib	Tue Jun 04 16:01:32 2013 +0100
+++ b/mbed-rtos.lib	Thu Nov 03 15:40:17 2016 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/mbed_official/code/mbed-rtos/
\ No newline at end of file
+https://mbed.org/users/mbed_official/code/mbed-rtos/#3da5f554d8bf
diff -r 209f4db62daf -r 4fa2695e0d63 mbed.bld
--- a/mbed.bld	Tue Jun 04 16:01:32 2013 +0100
+++ b/mbed.bld	Thu Nov 03 15:40:17 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file