Los Putacos / Mbed OS WearableDevice_Nucleo_New

Dependencies:   MPU9250_SPI

Fork of WearableDevice_Nucleo by Los Putacos

Revision:
10:577e1fc4453e
Parent:
8:ba93a973f967
Child:
11:f19020fa18f1
Child:
12:c88478dfc622
--- a/main.cpp	Sat Oct 14 10:34:39 2017 +0000
+++ b/main.cpp	Sat Oct 14 23:37:02 2017 +0000
@@ -20,42 +20,39 @@
 #include "mbed_events.h"
 
 #include "configuration.h"
-//#include "event.h"
+#include "event.h"
 #include "pin.h"
 #include "MPU9250.h"
 //-----------------------------------------------------------------
 
 //-----------------------------------------------------------------
 // Declarations
-Timer t; //Timer µS time-stamp
+Timer time_stamp; //Timer µS time-stamp
 
 EventQueue queue(32 * EVENTS_EVENT_SIZE); //Event
 
 Serial pc(USBTX, USBRX); // PC Serial (Debug)
+Serial xbee(PA_2, PA_3); // Xbee
 
-MPU9250 mpu9250; // IMU MPU-9255 by Kris Winer 
+MPU9250 imu; // IMU MPU-9255 by Kris Winer 
 //-----------------------------------------------------------------
 
 //-----------------------------------------------------------------
 // Global Variables
 // Your code here!
 //-----------------------------------------------------------------
-
+/*
 //-----------------------------------------------------------------
 void print_event(void const *argv, int i) {
-    pc.printf("%d",i);
+    pc.printf("%d ",i);
     pc.printf((const char*)argv);
+    pc.printf("\r\n");
 }
 //-----------------------------------------------------------------
-
+*/
 //-----------------------------------------------------------------
 void blink_event(DigitalOut pin){
-    if(pin.read()==0){
-        pin = 1;
-    }
-    else{
-        pin = 0;
-    }
+    pin = !pin;
 }
 //-----------------------------------------------------------------
 
@@ -75,9 +72,10 @@
     // Task queue
     int task1_id = queue.call_every(1000, printf, "called every 1 seconds\n");
     int task2_id = queue.call_every(2500, printf, "called every 2.5 seconds\n");
-    int task3_id = queue.call_every(3000, print_event, (void *)"called every 3 seconds\n", t.read());
-    int task4_id = queue.call_every(50, blink_event, led1);
+    //int task3_id = queue.call_every(3000, &print_event, (void *)"called every 3 seconds\n", (int) time_stamp.read());
+    //int task4_id = queue.call_every(50, blink_event, led1);
     int task5_id = queue.call_every(500, println_event);
+    int task6_id = queue.call_every(500, readIMU);
 }
 //-----------------------------------------------------------------
 
@@ -86,7 +84,7 @@
 {  
  // Initialize MPU9250 device
  // wake up device
-  //writeByte(MPU9250_ADDRESS, PWR_MGMT_1, 0x00); // Clear sleep mode bit (6), enable all sensors 
+  imu.writeByte(MPU9250_ADDRESS, PWR_MGMT_1, 0x00); // Clear sleep mode bit (6), enable all sensors 
 }
   
 //-----------------------------------------------------------------
@@ -99,7 +97,7 @@
     
     //Reading the analog input (Microphone)  array = micro.read_u16();
     
-    t.start(); // Start timer
+    time_stamp.start(); // Start timer
     
     while (true) {
         queue.dispatch();