updated to mbed os 5.4

Files at this revision

API Documentation at this revision

Comitter:
noutram
Date:
Mon Apr 03 14:24:10 2017 +0000
Parent:
10:3a3d2a571c8f
Commit message:
updated to mbed os 5.4

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
diff -r 3a3d2a571c8f -r ae623ddb2eff main.cpp
--- a/main.cpp	Tue Mar 22 13:40:05 2016 +0000
+++ b/main.cpp	Mon Apr 03 14:24:10 2017 +0000
@@ -1,13 +1,12 @@
 #include "mbed.h"
-#include "rtos.h"
 #include "string.h"
 #include <stdio.h>
 #include <ctype.h>
 
 #define SWITCH1_RELEASE 1
 
-void thread1( const void*  );
-void thread2( const void*  );
+void thread1();
+void thread2();
 void switchISR();
 
 //Analogue inputs
@@ -43,13 +42,18 @@
 };
  
 //Memory Pool - with capacity for 16 message_t types
-MemoryPool<message_t, 16> mpool;
+//MemoryPool<message_t, 16> mpool;
 
 //Message queue - matched to the memory pool
-Queue<message_t, 16> queue;
+//Queue<message_t, 16> queue;
+
+//Mail queue
+Mail<message_t, 16> mail_box;
+
 
 // Call this on precise intervals
 void adcISR() {
+
     
     //Read sample - make a copy
     float sample = adcIn;
@@ -58,9 +62,10 @@
     uint32_t switch2State = sw2;
     
     //Allocate a block from the memory pool
-    message_t *message = mpool.alloc();
+    message_t *message = mail_box.alloc();
     if (message == NULL) {
         //Out of memory
+        printf("Out of memory\n\r");
         redLED = 1;
         return;   
     }
@@ -71,39 +76,42 @@
     message->sw2State = switch2State;
     
     //Write to queue
-    osStatus stat = queue.put(message);    //Note we are sending the "pointer"
+    osStatus stat = mail_box.put(message);    //Note we are sending the "pointer"
     
     //Check if succesful
     if (stat == osErrorResource) {
         redLED = 1; 
         printf("queue->put() Error code: %4Xh, Resource not available\r\n", stat);   
-        mpool.free(message);
+        mail_box.free(message);
         return;
     }
+    
+    
 }
 
 //Normal priority thread (consumer)
-void thread1( const void* arg ) 
+void thread1() 
 {      
     while (true) {
         //Block on the queue
-        osEvent evt = queue.get();
+        osEvent evt = mail_box.get();
         
         //Check status
-        if (evt.status == osEventMessage) {
+        if (evt.status == osEventMail) {
             message_t *pMessage = (message_t*)evt.value.p;  //This is the pointer (address)
             //Make a copy
             message_t msg(pMessage->adcValue, pMessage->sw1State, pMessage->sw2State);
             //We are done with this, so give back the memory to the pool
-            mpool.free(pMessage);
+            mail_box.free(pMessage);
             
             //Echo to the terminal
             printf("ADC Value: %.2f\t",    msg.adcValue);
             printf("SW1: %u\t",             msg.sw1State);
             printf("SW2: %u\n\r",             msg.sw2State);
-        }
-
-             
+        } else {
+            printf("ERROR: %x\n\r", evt.status);   
+        }  
+        
     } //end while
 }
 
@@ -122,7 +130,8 @@
     timer.attach(&adcISR, 0.1);
                
     //Threads
-    t1 = new Thread(&thread1); 
+    t1 = new Thread();
+    t1->start(thread1); 
     
     printf("Main Thread\n");
     while (true) {
diff -r 3a3d2a571c8f -r ae623ddb2eff mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Apr 03 14:24:10 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d
diff -r 3a3d2a571c8f -r ae623ddb2eff mbed-rtos.lib
--- a/mbed-rtos.lib	Tue Mar 22 13:40:05 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
diff -r 3a3d2a571c8f -r ae623ddb2eff mbed.bld
--- a/mbed.bld	Tue Mar 22 13:40:05 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