航空研究会 / MPU9255_ver1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MPU9255.h Source File

MPU9255.h

00001 #ifndef _MPU9255_H_
00002 #define _MPU9255_H_
00003 
00004 #include"mbed.h"
00005 #include"MPU9255Regs.h"
00006 
00007 // Set initial input parameters
00008 #define  AFS_2G  0
00009 #define  AFS_4G  1
00010 #define  AFS_8G  2
00011 #define  AFS_16G 3
00012 
00013 #define  GFS_250DPS  0
00014 #define  GFS_500DPS  1
00015 #define  GFS_1000DPS 2
00016 #define  GFS_2000DPS 3
00017 
00018 #define  MFS_14BITS  0 // 0.6 mG per LSB
00019 #define  MFS_16BITS  1    // 0.15 mG per LSB
00020 
00021 #define M_8Hz   0x02
00022 #define M_100Hz 0x06
00023 
00024 
00025 class MPU9255
00026 {
00027     I2C *i2c_p;
00028     I2C &i2c;
00029     RawSerial* pc_p;
00030     
00031     void writeByte(uint8_t address, uint8_t subAddress, uint8_t data);
00032     char readByte(uint8_t address, uint8_t subAddress);
00033     void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest);
00034 
00035 public:
00036     MPU9255(PinName sda, PinName scl, RawSerial* serial_p);
00037     ~MPU9255();
00038     
00039     void init_mpu9255(uint8_t Ascale, uint8_t Cscale, uint8_t asmpleRate);
00040     uint8_t whoami_mpu9255();
00041     void reset_mpu9255();
00042     void selftest_mpu9255(float * destination);
00043     float getAres(uint8_t Ascale);
00044     float getGres(uint8_t Gscale);
00045     float getMres(uint8_t Mscale);
00046     void calibrate_mpu9255(float * dest1, float * dest2);
00047     uint8_t get_AK8963CID();
00048     void init_AK8963Slave(uint8_t Mscale, uint8_t Mmode, float * magCalibration);
00049     void readMagData_mpu9255(int16_t * destination);
00050     void readaccgyrodata_mpu9255(int16_t * destination);
00051 };
00052 
00053 #endif