MPU-9250 with Kalman Filter

Dependencies:   ADXL362-helloworld MPU9250_SPI mbed

Fork of ADXL362-helloworld by Analog Devices

Committer:
mfurukawa
Date:
Mon May 23 09:24:25 2016 +0000
Revision:
1:f1e4ee4fc335
Parent:
0:83fda1bfaffe
Child:
2:9ef7a594159c
3 axis dump

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfurukawa 1:f1e4ee4fc335 1
adisuciu 0:83fda1bfaffe 2 #include "mbed.h"
adisuciu 0:83fda1bfaffe 3 #include "ADXL362.h"
adisuciu 0:83fda1bfaffe 4
mfurukawa 1:f1e4ee4fc335 5 Serial pc(USBTX, USBRX);
mfurukawa 1:f1e4ee4fc335 6
mfurukawa 1:f1e4ee4fc335 7 /*
mfurukawa 1:f1e4ee4fc335 8 ~CS (Chip Select) p8
mfurukawa 1:f1e4ee4fc335 9 MOSI (Master Out Slave In) p5
mfurukawa 1:f1e4ee4fc335 10 MISO (Master In Slave Out p6
mfurukawa 1:f1e4ee4fc335 11 SCK (Serial Clock) p7
mfurukawa 1:f1e4ee4fc335 12 */
mfurukawa 1:f1e4ee4fc335 13 ADXL362 adxl362(p8, p5, p6, p7);
adisuciu 0:83fda1bfaffe 14
adisuciu 0:83fda1bfaffe 15 int main() {
adisuciu 0:83fda1bfaffe 16
mfurukawa 1:f1e4ee4fc335 17 pc.baud(115200);
mfurukawa 1:f1e4ee4fc335 18
adisuciu 0:83fda1bfaffe 19 adxl362.reset();
adisuciu 0:83fda1bfaffe 20 wait_ms(600); // we need to wait at least 500ms after ADXL362 reset
adisuciu 0:83fda1bfaffe 21 adxl362.set_mode(ADXL362::MEASUREMENT);
adisuciu 0:83fda1bfaffe 22 uint8_t x,y,z;
mfurukawa 1:f1e4ee4fc335 23 uint64_t t;
adisuciu 0:83fda1bfaffe 24 while(1) {
adisuciu 0:83fda1bfaffe 25 x=adxl362.scanx_u8();
adisuciu 0:83fda1bfaffe 26 y=adxl362.scany_u8();
adisuciu 0:83fda1bfaffe 27 z=adxl362.scanz_u8();
mfurukawa 1:f1e4ee4fc335 28 t=adxl362.scan();
mfurukawa 1:f1e4ee4fc335 29 printf("x = %02x y = %02x z = %02x %04x %04x %04x\r\n",x,y,z,
mfurukawa 1:f1e4ee4fc335 30 static_cast<uint16_t>(0xFFFF&(t>>48)),
mfurukawa 1:f1e4ee4fc335 31 static_cast<uint16_t>(0xFFFF&(t>>32)),
mfurukawa 1:f1e4ee4fc335 32 static_cast<uint16_t>(0xFFFF&(t>>16)) );
mfurukawa 1:f1e4ee4fc335 33 wait_ms(1);
adisuciu 0:83fda1bfaffe 34 }
adisuciu 0:83fda1bfaffe 35 }