MPU-9250 with Kalman Filter

Dependencies:   ADXL362-helloworld MPU9250_SPI mbed

Fork of ADXL362-helloworld by Analog Devices

Revision:
3:07aa20aa678d
Parent:
2:9ef7a594159c
Child:
4:5a9aa5ae928a
--- a/main.cpp	Mon May 23 12:51:26 2016 +0000
+++ b/main.cpp	Mon May 23 13:46:35 2016 +0000
@@ -1,3 +1,12 @@
+/**
+ * Masahiro FURUKAWA - m.furukawa@ist.osaka-u.ac.jp
+ * 
+ * May 23, 2016
+ *
+ * LDXL362 Acceleration Sensor (Extended to Ch1 ~ Ch3)
+ *
+ **/
+
 
 #include "mbed.h"
 #include "ADXL362.h"
@@ -10,33 +19,53 @@
     MISO (Master In Slave Out   p6
     SCK  (Serial Clock)         p7
 */
-ADXL362 adxl362(p8, p5, p6, p7);
 
 int main() {
     pc.baud(115200);
     
-    //DigitalOut Ch1(p8);
-    //DigitalOut Ch2(p9);
-    //DigitalOut Ch3(p10);
-
-    //adxl362.set_cs_pin(&Ch1);
+    DigitalOut *Ch1, *Ch2, *Ch3;
+    Ch1 = new DigitalOut(p8);
+    Ch2 = new DigitalOut(p9);
+    Ch3 = new DigitalOut(p10);
+  
+    *Ch1 = true;
+    *Ch2 = true;
+    *Ch3 = true;
     
-    adxl362.reset();
-    wait_ms(600); // we need to wait at least 500ms after ADXL362 reset
-    adxl362.set_mode(ADXL362::MEASUREMENT);
+    ADXL362 adxl362(Ch2, p5, p6, p7);
+  
+    // we need to wait at least 500ms after ADXL362 reset
+    adxl362.set_cs_pin(Ch1);    adxl362.reset(); wait_ms(600); adxl362.set_mode(ADXL362::MEASUREMENT);
+    adxl362.set_cs_pin(Ch2);    adxl362.reset(); wait_ms(600); adxl362.set_mode(ADXL362::MEASUREMENT);
+    adxl362.set_cs_pin(Ch3);    adxl362.reset(); wait_ms(600); adxl362.set_mode(ADXL362::MEASUREMENT);
+    
+    
     
     uint8_t x,y,z; 
-    uint64_t t;
+    uint64_t t1, t2, t3;
     
     while(1) {
-        x=adxl362.scanx_u8();
-        y=adxl362.scany_u8();
-        z=adxl362.scanz_u8();
-        t=adxl362.scan();
-        printf("x = %02x y = %02x z = %02x %04x %04x %04x\r\n",x,y,z,
-        static_cast<uint16_t>(0xFFFF&(t>>48)), 
-        static_cast<uint16_t>(0xFFFF&(t>>32)),
-        static_cast<uint16_t>(0xFFFF&(t>>16)) );
+        x  = adxl362.scanx_u8();
+        y  = adxl362.scany_u8();
+        z  = adxl362.scanz_u8();
+        
+        adxl362.set_cs_pin(Ch1);   t1 = adxl362.scan();
+        adxl362.set_cs_pin(Ch2);   t2 = adxl362.scan();
+        adxl362.set_cs_pin(Ch3);   t3 = adxl362.scan();
+        
+        printf("x = %02x y = %02x z = %02x %04x %04x %04x  %04x %04x %04x  %04x %04x %04x\r\n",x,y,z,
+        static_cast<uint16_t>(0xFFFF&(t1>>48)), 
+        static_cast<uint16_t>(0xFFFF&(t1>>32)),
+        static_cast<uint16_t>(0xFFFF&(t1>>16)),
+        
+        static_cast<uint16_t>(0xFFFF&(t2>>48)), 
+        static_cast<uint16_t>(0xFFFF&(t2>>32)),
+        static_cast<uint16_t>(0xFFFF&(t2>>16)),
+        
+        static_cast<uint16_t>(0xFFFF&(t3>>48)), 
+        static_cast<uint16_t>(0xFFFF&(t3>>32)),
+        static_cast<uint16_t>(0xFFFF&(t3>>16))
+         );
         wait_ms(1);
     }
 }