![](/media/cache/profiles/d741d4ae35aff8fd3674206068e40684.jpg.50x50_q85.jpg)
MPU-9250 with Kalman Filter
Dependencies: ADXL362-helloworld MPU9250_SPI mbed
Fork of ADXL362-helloworld by
main.cpp@2:9ef7a594159c, 2016-05-23 (annotated)
- Committer:
- mfurukawa
- Date:
- Mon May 23 12:51:26 2016 +0000
- Revision:
- 2:9ef7a594159c
- Parent:
- 1:f1e4ee4fc335
- Child:
- 3:07aa20aa678d
et
Who changed what in which revision?
User | Revision | Line number | New 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() { |
mfurukawa | 2:9ef7a594159c | 16 | pc.baud(115200); |
adisuciu | 0:83fda1bfaffe | 17 | |
mfurukawa | 2:9ef7a594159c | 18 | //DigitalOut Ch1(p8); |
mfurukawa | 2:9ef7a594159c | 19 | //DigitalOut Ch2(p9); |
mfurukawa | 2:9ef7a594159c | 20 | //DigitalOut Ch3(p10); |
mfurukawa | 2:9ef7a594159c | 21 | |
mfurukawa | 2:9ef7a594159c | 22 | //adxl362.set_cs_pin(&Ch1); |
mfurukawa | 1:f1e4ee4fc335 | 23 | |
adisuciu | 0:83fda1bfaffe | 24 | adxl362.reset(); |
adisuciu | 0:83fda1bfaffe | 25 | wait_ms(600); // we need to wait at least 500ms after ADXL362 reset |
adisuciu | 0:83fda1bfaffe | 26 | adxl362.set_mode(ADXL362::MEASUREMENT); |
mfurukawa | 2:9ef7a594159c | 27 | |
adisuciu | 0:83fda1bfaffe | 28 | uint8_t x,y,z; |
mfurukawa | 1:f1e4ee4fc335 | 29 | uint64_t t; |
mfurukawa | 2:9ef7a594159c | 30 | |
adisuciu | 0:83fda1bfaffe | 31 | while(1) { |
adisuciu | 0:83fda1bfaffe | 32 | x=adxl362.scanx_u8(); |
adisuciu | 0:83fda1bfaffe | 33 | y=adxl362.scany_u8(); |
adisuciu | 0:83fda1bfaffe | 34 | z=adxl362.scanz_u8(); |
mfurukawa | 1:f1e4ee4fc335 | 35 | t=adxl362.scan(); |
mfurukawa | 1:f1e4ee4fc335 | 36 | printf("x = %02x y = %02x z = %02x %04x %04x %04x\r\n",x,y,z, |
mfurukawa | 1:f1e4ee4fc335 | 37 | static_cast<uint16_t>(0xFFFF&(t>>48)), |
mfurukawa | 1:f1e4ee4fc335 | 38 | static_cast<uint16_t>(0xFFFF&(t>>32)), |
mfurukawa | 1:f1e4ee4fc335 | 39 | static_cast<uint16_t>(0xFFFF&(t>>16)) ); |
mfurukawa | 1:f1e4ee4fc335 | 40 | wait_ms(1); |
adisuciu | 0:83fda1bfaffe | 41 | } |
adisuciu | 0:83fda1bfaffe | 42 | } |