Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 1_MPU9250 4_sensor-Integration-function2 5_waitmode 5_flightmode ... more
MPU9250.h
00001 #ifndef MBED_MPU9250_H 00002 #define MBED_MPU9250_H 00003 00004 #include "mbed.h" 00005 00006 00007 //MPU9250 Slave address 00008 #define ADDR_MPU 0xD2 00009 00010 //MPU9250 registers 00011 #define MPU_WHO 0x75 00012 #define MPU_PWR 0x6B 00013 #define MPU_ACCELDATA 0x3B 00014 #define MPU_GYRODATA 0x43 00015 00016 //AK9250 Slave address 00017 #define ADDR_AK 0x18 00018 #define MPU_MAG_INT 0x37 00019 00020 //MPU9250 accel setup register 00021 #define ACCEL_CONFIG 0x1c 00022 #define ACCEL_2G 0x00 00023 #define ACCEL_4G 0x08 00024 #define ACCEL_8G 0x10 00025 #define ACCEL_16G 0x18 00026 00027 //MPU9250 gyro setup register 00028 #define gyro_CONFIG 0x1b 00029 #define gyro_250DPS 0x00 00030 #define gyro_500DPS 0x08 00031 #define gyro_1000DPS 0x10 00032 #define gyro_2000DPS 0x18 00033 00034 //MPU9250 mag setup registers 00035 #define AK_WHO 0x00 00036 #define AK_DATA 0x03 00037 #define AK_CNTL1 0x0A 00038 #define AK_8Hz 0x12 00039 #define AK_100Hz 0x16 00040 #define ST1 0x02 00041 00042 00043 class MPU9250 00044 { 00045 public: 00046 MPU9250(PinName sda,PinName scl); 00047 ~MPU9250(); 00048 00049 char read(char addr, char regist); // 基本read関数 00050 void write(char addr, char regist,char data); // 基本write関数 00051 char who(); // WHO_AM_I(MPU) 00052 char AKwho(); // WHO_AM_I(AK) 00053 void start(); // Start,mode0;normal,mode1;high rate 00054 void accelsetup(char mode); // 加速度計の測定範囲選択 00055 void gyrosetup(char mode); // 角速度計の測定範囲選択 00056 void AKsetup(char mode); // 地磁気の測定モード選択 00057 void accel_read(char mode, float *A); // 加速度のデータを読み込む 00058 void gyro_read(char mode, float *G); // 角速度計のデータを読み込む 00059 void mag_read(float *M); // 地磁気のデータを読み込む 00060 00061 private: 00062 I2C i2c; 00063 00064 }; 00065 00066 #endif
Generated on Wed Jul 20 2022 16:25:40 by
1.7.2