Sensor data verwerking
Dependencies: SEGGER_RTT mbed
Fork of MPU9250AHRS by
Diff: MPU9250.h
- Revision:
- 3:d53674889db3
- Parent:
- 2:4e59a37182df
diff -r 4e59a37182df -r d53674889db3 MPU9250.h --- a/MPU9250.h Tue Aug 05 01:37:23 2014 +0000 +++ b/MPU9250.h Mon Feb 19 12:43:16 2018 +0000 @@ -156,7 +156,7 @@ // Using the MSENSR-9250 breakout board, ADO is set to 0 // Seven-bit device address is 110100 for ADO = 0 and 110101 for ADO = 1 //mbed uses the eight-bit device address, so shift seven-bit addresses left by one! -#define ADO 0 +#define ADO 1 #if ADO #define MPU9250_ADDRESS 0x69<<1 // Device address when ADO = 1 #else @@ -166,16 +166,16 @@ // Set initial input parameters enum Ascale { AFS_2G = 0, - AFS_4G, - AFS_8G, - AFS_16G + AFS_4G = 1, + AFS_8G = 2, + AFS_16G = 3 }; enum Gscale { GFS_250DPS = 0, - GFS_500DPS, - GFS_1000DPS, - GFS_2000DPS + GFS_500DPS = 1, + GFS_1000DPS = 2, + GFS_2000DPS = 3 }; enum Mscale { @@ -183,19 +183,17 @@ MFS_16BITS // 0.15 mG per LSB }; -uint8_t Ascale = AFS_2G; // AFS_2G, AFS_4G, AFS_8G, AFS_16G -uint8_t Gscale = GFS_250DPS; // GFS_250DPS, GFS_500DPS, GFS_1000DPS, GFS_2000DPS +uint8_t Ascale = AFS_8G; // AFS_2G, AFS_4G, AFS_8G, AFS_16G +uint8_t Gscale = GFS_1000DPS; // GFS_250DPS, GFS_500DPS, GFS_1000DPS, GFS_2000DPS uint8_t Mscale = MFS_16BITS; // MFS_14BITS or MFS_16BITS, 14-bit or 16-bit magnetometer resolution uint8_t Mmode = 0x06; // Either 8 Hz 0x02) or 100 Hz (0x06) magnetometer data ODR float aRes, gRes, mRes; // scale resolutions per LSB for the sensors //Set up I2C, (SDA,SCL) -I2C i2c(I2C_SDA, I2C_SCL); - -DigitalOut myled(LED1); +I2C i2c(P0_8, P0_9); // Pin definitions -int intPin = 12; // These can be changed, 2 and 3 are the Arduinos ext int pins +int intPin = 16; // These can be changed, 2 and 3 are the Arduinos ext int pins int16_t accelCount[3]; // Stores the 16-bit signed accelerometer sensor output int16_t gyroCount[3]; // Stores the 16-bit signed gyro sensor output @@ -625,7 +623,7 @@ // Configure the accelerometer for self-test writeByte(MPU9250_ADDRESS, ACCEL_CONFIG, 0xE0); // Enable self test on all three axes and set accelerometer range to +/- 2 g writeByte(MPU9250_ADDRESS, GYRO_CONFIG, 0xE0); // Enable self test on all three axes and set gyro range to +/- 250 degrees/s - delay(25); // Delay a while to let the device stabilize + wait(0.1); // Delay a while to let the device stabilize for( int ii = 0; ii < 200; ii++) { // get average self-test values of gyro and acclerometer @@ -648,7 +646,7 @@ // Configure the gyro and accelerometer for normal operation writeByte(MPU9250_ADDRESS, ACCEL_CONFIG, 0x00); writeByte(MPU9250_ADDRESS, GYRO_CONFIG, 0x00); - delay(25); // Delay a while to let the device stabilize + wait(0.1); // Delay a while to let the device stabilize // Retrieve accelerometer and gyro factory Self-Test Code from USR_Reg selfTest[0] = readByte(MPU9250_ADDRESS, SELF_TEST_X_ACCEL); // X-axis accel self-test results