Class of MPU9250
Dependencies: AHRS_fillter mbed
Fork of MPU9250AHRS by
main.cpp
- Committer:
- icyzkungz
- Date:
- 2016-01-20
- Revision:
- 8:928673148b55
- Parent:
- 6:5665d427bceb
File content as of revision 8:928673148b55:
/* MPU9250 Basic Example Code by: Kris Winer date: April 1, 2014 license: Beerware - Use this code however you'd like. If you find it useful you can buy me a beer some time. Demonstrate basic MPU-9250 functionality including parameterizing the register addresses, initializing the sensor, getting properly scaled accelerometer, gyroscope, and magnetometer data out. Added display functions to allow display to on breadboard monitor. Addition of 9 DoF sensor fusion using open source Madgwick and Mahony filter algorithms. Sketch runs on the 3.3 V 8 MHz Pro Mini and the Teensy 3.1. SDA and SCL should have external pull-up resistors (to 3.3V). 10k resistors are on the EMSENSR-9250 breakout board. Hardware setup: MPU9250 Breakout --------- Arduino VDD ---------------------- 3.3V VDDI --------------------- 3.3V SDA ----------------------- A4 SCL ----------------------- A5 GND ---------------------- GND Note: The MPU9250 is an I2C sensor and uses the Arduino Wire library. Because the sensor is not 5V tolerant, we are using a 3.3 V 8 MHz Pro Mini or a 3.3 V Teensy 3.1. We have disabled the internal pull-ups used by the Wire library in the Wire.h/twi.c utility file. We are also using the 400 kHz fast I2C mode by setting the TWI_FREQ to 400000L /twi.h utility file. */ //#include "ST_F401_84MHZ.h" //F401_init84 myinit(0); #include "mbed.h" #include "AHRS.h" //#include "N5110.h" // Using NOKIA 5110 monochrome 84 x 48 pixel display // pin 9 - Serial clock out (SCLK) // pin 8 - Serial data out (DIN) // pin 7 - Data/Command select (D/C) // pin 5 - LCD chip select (CS) // pin 6 - LCD reset (RST) //Adafruit_PCD8544 display = Adafruit_PCD8544(9, 8, 7, 5, 6); AHRS mpu9250(D15, D14, SERIAL_TX, SERIAL_RX , 0); Timer t; Serial pc(USBTX, USBRX); // tx, rx DigitalIn button(USER_BUTTON); int main() { pc.baud(115200); pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock); t.start(); mpu9250.Start(); while(1) { mpu9250.Run(); mpu9250.PrintRollPitchYaw(); } }