航空研究会 / MPU9255
Committer:
imanomadao
Date:
Sun Jun 28 11:10:43 2020 +0000
Revision:
0:5a3104f02775
a;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
imanomadao 0:5a3104f02775 1 #ifndef _MPU9255_H_
imanomadao 0:5a3104f02775 2 #define _MPU9255_H_
imanomadao 0:5a3104f02775 3
imanomadao 0:5a3104f02775 4 #include"mbed.h"
imanomadao 0:5a3104f02775 5 #include"MPU9255Regs.h"
imanomadao 0:5a3104f02775 6
imanomadao 0:5a3104f02775 7 // Set initial input parameters
imanomadao 0:5a3104f02775 8 #define AFS_2G 0
imanomadao 0:5a3104f02775 9 #define AFS_4G 1
imanomadao 0:5a3104f02775 10 #define AFS_8G 2
imanomadao 0:5a3104f02775 11 #define AFS_16G 3
imanomadao 0:5a3104f02775 12
imanomadao 0:5a3104f02775 13 #define GFS_250DPS 0
imanomadao 0:5a3104f02775 14 #define GFS_500DPS 1
imanomadao 0:5a3104f02775 15 #define GFS_1000DPS 2
imanomadao 0:5a3104f02775 16 #define GFS_2000DPS 3
imanomadao 0:5a3104f02775 17
imanomadao 0:5a3104f02775 18 #define MFS_14BITS 0 // 0.6 mG per LSB
imanomadao 0:5a3104f02775 19 #define MFS_16BITS 1 // 0.15 mG per LSB
imanomadao 0:5a3104f02775 20
imanomadao 0:5a3104f02775 21 #define M_8Hz 0x02
imanomadao 0:5a3104f02775 22 #define M_100Hz 0x06
imanomadao 0:5a3104f02775 23
imanomadao 0:5a3104f02775 24
imanomadao 0:5a3104f02775 25 class MPU9255
imanomadao 0:5a3104f02775 26 {
imanomadao 0:5a3104f02775 27 I2C *i2c_p;
imanomadao 0:5a3104f02775 28 I2C &i2c;
imanomadao 0:5a3104f02775 29 RawSerial* pc_p;
imanomadao 0:5a3104f02775 30
imanomadao 0:5a3104f02775 31 void writeByte(uint8_t address, uint8_t subAddress, uint8_t data);
imanomadao 0:5a3104f02775 32 char readByte(uint8_t address, uint8_t subAddress);
imanomadao 0:5a3104f02775 33 void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest);
imanomadao 0:5a3104f02775 34
imanomadao 0:5a3104f02775 35 public:
imanomadao 0:5a3104f02775 36 MPU9255(PinName sda, PinName scl, RawSerial* serial_p);
imanomadao 0:5a3104f02775 37 ~MPU9255();
imanomadao 0:5a3104f02775 38
imanomadao 0:5a3104f02775 39 void init_mpu9255(uint8_t Ascale, uint8_t Cscale, uint8_t asmpleRate);
imanomadao 0:5a3104f02775 40 uint8_t whoami_mpu9255();
imanomadao 0:5a3104f02775 41 void reset_mpu9255();
imanomadao 0:5a3104f02775 42 void selftest_mpu9255(float * destination);
imanomadao 0:5a3104f02775 43 float getAres(uint8_t Ascale);
imanomadao 0:5a3104f02775 44 float getGres(uint8_t Gscale);
imanomadao 0:5a3104f02775 45 float getMres(uint8_t Mscale);
imanomadao 0:5a3104f02775 46 void calibrate_mpu9255(float * dest1, float * dest2);
imanomadao 0:5a3104f02775 47 uint8_t get_AK8963CID();
imanomadao 0:5a3104f02775 48 void init_AK8963Slave(uint8_t Mscale, uint8_t Mmode, float * magCalibration);
imanomadao 0:5a3104f02775 49 void readMagData_mpu9255(int16_t * destination);
imanomadao 0:5a3104f02775 50 void readaccgyrodata_mpu9255(int16_t * destination);
imanomadao 0:5a3104f02775 51 };
imanomadao 0:5a3104f02775 52
imanomadao 0:5a3104f02775 53 #endif