Finished project.

Dependencies:   X_NUCLEO_COMMON

Fork of ReferredCoursework2016 by Stage-1 Students SoCEM

Revision:
91:cd9fcd45ecf6
Parent:
90:38dfa3f350aa
--- a/sensor.cpp	Thu Aug 17 02:42:30 2017 +0000
+++ b/sensor.cpp	Thu Aug 17 06:58:29 2017 +0000
@@ -6,6 +6,8 @@
 #include "buffer.h"
 #include "sensor.h"
 
+Mutex mutex;
+
 /* Instantiate the expansion board */
 static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15);
 
@@ -18,15 +20,17 @@
 
 void sensor_run(){
      while (1) {
-   
-    accelerometer->Get_X_Axes(axes);
+          mutex.lock();
+    
+          accelerometer->Get_X_Axes(axes);
 
-    AccelData d;
-    d.x = axes[0];
-    d.y = axes[1];
-    d.z = axes[2];  
+          AccelData d;
+          d.x = axes[0];
+          d.y = axes[1];
+          d.z = axes[2];  
     
-    log_push(d);
+          log_push(d);
+          mutex.unlock();
     }
 
 }
\ No newline at end of file