Class of MPU9250

Dependencies:   AHRS_fillter mbed

Fork of MPU9250AHRS by BE@R lab

Committer:
soulx
Date:
Wed Jan 20 15:14:12 2016 +0000
Revision:
9:a9b0f8540cc6
Parent:
8:928673148b55
edit lib

Who changed what in which revision?

UserRevisionLine numberNew contents of line
onehorse 0:2e5e65a6fb30 1 /* MPU9250 Basic Example Code
onehorse 0:2e5e65a6fb30 2 by: Kris Winer
onehorse 0:2e5e65a6fb30 3 date: April 1, 2014
soulx 3:3e04c1c03cab 4 license: Beerware - Use this code however you'd like. If you
onehorse 0:2e5e65a6fb30 5 find it useful you can buy me a beer some time.
soulx 3:3e04c1c03cab 6
soulx 3:3e04c1c03cab 7 Demonstrate basic MPU-9250 functionality including parameterizing the register addresses, initializing the sensor,
soulx 3:3e04c1c03cab 8 getting properly scaled accelerometer, gyroscope, and magnetometer data out. Added display functions to
soulx 3:3e04c1c03cab 9 allow display to on breadboard monitor. Addition of 9 DoF sensor fusion using open source Madgwick and
onehorse 0:2e5e65a6fb30 10 Mahony filter algorithms. Sketch runs on the 3.3 V 8 MHz Pro Mini and the Teensy 3.1.
soulx 3:3e04c1c03cab 11
onehorse 0:2e5e65a6fb30 12 SDA and SCL should have external pull-up resistors (to 3.3V).
onehorse 0:2e5e65a6fb30 13 10k resistors are on the EMSENSR-9250 breakout board.
soulx 3:3e04c1c03cab 14
onehorse 0:2e5e65a6fb30 15 Hardware setup:
onehorse 0:2e5e65a6fb30 16 MPU9250 Breakout --------- Arduino
onehorse 0:2e5e65a6fb30 17 VDD ---------------------- 3.3V
onehorse 0:2e5e65a6fb30 18 VDDI --------------------- 3.3V
onehorse 0:2e5e65a6fb30 19 SDA ----------------------- A4
onehorse 0:2e5e65a6fb30 20 SCL ----------------------- A5
onehorse 0:2e5e65a6fb30 21 GND ---------------------- GND
soulx 3:3e04c1c03cab 22
soulx 3:3e04c1c03cab 23 Note: The MPU9250 is an I2C sensor and uses the Arduino Wire library.
onehorse 0:2e5e65a6fb30 24 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.
onehorse 0:2e5e65a6fb30 25 We have disabled the internal pull-ups used by the Wire library in the Wire.h/twi.c utility file.
onehorse 0:2e5e65a6fb30 26 We are also using the 400 kHz fast I2C mode by setting the TWI_FREQ to 400000L /twi.h utility file.
onehorse 0:2e5e65a6fb30 27 */
soulx 3:3e04c1c03cab 28
soulx 3:3e04c1c03cab 29 //#include "ST_F401_84MHZ.h"
onehorse 0:2e5e65a6fb30 30 //F401_init84 myinit(0);
onehorse 0:2e5e65a6fb30 31 #include "mbed.h"
icyzkungz 6:5665d427bceb 32 #include "AHRS.h"
soulx 3:3e04c1c03cab 33 //#include "N5110.h"
onehorse 0:2e5e65a6fb30 34
onehorse 0:2e5e65a6fb30 35 // Using NOKIA 5110 monochrome 84 x 48 pixel display
onehorse 0:2e5e65a6fb30 36 // pin 9 - Serial clock out (SCLK)
onehorse 0:2e5e65a6fb30 37 // pin 8 - Serial data out (DIN)
onehorse 0:2e5e65a6fb30 38 // pin 7 - Data/Command select (D/C)
onehorse 0:2e5e65a6fb30 39 // pin 5 - LCD chip select (CS)
onehorse 0:2e5e65a6fb30 40 // pin 6 - LCD reset (RST)
onehorse 0:2e5e65a6fb30 41 //Adafruit_PCD8544 display = Adafruit_PCD8544(9, 8, 7, 5, 6);
onehorse 0:2e5e65a6fb30 42
onehorse 0:2e5e65a6fb30 43
icyzkungz 6:5665d427bceb 44 AHRS mpu9250(D15, D14, SERIAL_TX, SERIAL_RX , 0);
soulx 3:3e04c1c03cab 45
soulx 3:3e04c1c03cab 46 Timer t;
onehorse 0:2e5e65a6fb30 47
soulx 3:3e04c1c03cab 48 Serial pc(USBTX, USBRX); // tx, rx
icyzkungz 6:5665d427bceb 49 DigitalIn button(USER_BUTTON);
soulx 3:3e04c1c03cab 50
soulx 3:3e04c1c03cab 51
onehorse 0:2e5e65a6fb30 52 int main()
onehorse 0:2e5e65a6fb30 53 {
soulx 3:3e04c1c03cab 54
soulx 3:3e04c1c03cab 55 pc.baud(115200);
soulx 3:3e04c1c03cab 56
onehorse 0:2e5e65a6fb30 57
soulx 3:3e04c1c03cab 58 pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);
soulx 3:3e04c1c03cab 59
soulx 3:3e04c1c03cab 60 t.start();
soulx 3:3e04c1c03cab 61
soulx 3:3e04c1c03cab 62
icyzkungz 6:5665d427bceb 63 mpu9250.Start();
soulx 3:3e04c1c03cab 64
soulx 3:3e04c1c03cab 65 while(1) {
icyzkungz 6:5665d427bceb 66 mpu9250.Run();
icyzkungz 8:928673148b55 67
icyzkungz 8:928673148b55 68 mpu9250.PrintRollPitchYaw();
onehorse 0:2e5e65a6fb30 69 }
onehorse 0:2e5e65a6fb30 70 }