dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Invensense MPU Functions

Common driver for Invensense MPU-xxx0 6/9-axis IMUs. More...

Data Structures

struct  pios_mpu_cfg
 

Macros

#define PIOS_MPU_PRODUCT_ID   0x0C
 
#define PIOS_MPU_SMPLRT_DIV_REG   0X19
 
#define PIOS_MPU_DLPF_CFG_REG   0X1A
 
#define PIOS_MPU_GYRO_CFG_REG   0X1B
 
#define PIOS_MPU_ACCEL_CFG_REG   0X1C
 
#define PIOS_MPU_ACCEL_CFG2_REG   0X1D
 
#define PIOS_MPU_FIFO_EN_REG   0x23
 
#define PIOS_MPU_SLV0_ADDR_REG   0x25
 
#define PIOS_MPU_SLV0_REG_REG   0x26
 
#define PIOS_MPU_SLV0_CTRL_REG   0x27
 
#define PIOS_MPU_SLV1_ADDR_REG   0x28
 
#define PIOS_MPU_SLV1_REG_REG   0x29
 
#define PIOS_MPU_SLV1_DO_REG   0x64
 
#define PIOS_MPU_SLV1_CTRL_REG   0x2A
 
#define PIOS_MPU_SLV4_ADDR_REG   0x31
 
#define PIOS_MPU_SLV4_REG_REG   0x32
 
#define PIOS_MPU_SLV4_DO_REG   0x33
 
#define PIOS_MPU_SLV4_CTRL_REG   0x34
 
#define PIOS_MPU_SLV4_DI_REG   0x35
 
#define PIOS_MPU_I2C_MST_STATUS_REG   0x36
 
#define PIOS_MPU_INT_CFG_REG   0x37
 
#define PIOS_MPU_INT_EN_REG   0x38
 
#define PIOS_MPU_INT_STATUS_REG   0x3A
 
#define PIOS_MPU_ACCEL_X_OUT_MSB   0x3B
 
#define PIOS_MPU_ACCEL_X_OUT_LSB   0x3C
 
#define PIOS_MPU_ACCEL_Y_OUT_MSB   0x3D
 
#define PIOS_MPU_ACCEL_Y_OUT_LSB   0x3E
 
#define PIOS_MPU_ACCEL_Z_OUT_MSB   0x3F
 
#define PIOS_MPU_ACCEL_Z_OUT_LSB   0x40
 
#define PIOS_MPU_TEMP_OUT_MSB   0x41
 
#define PIOS_MPU_TEMP_OUT_LSB   0x42
 
#define PIOS_MPU_GYRO_X_OUT_MSB   0x43
 
#define PIOS_MPU_GYRO_X_OUT_LSB   0x44
 
#define PIOS_MPU_GYRO_Y_OUT_MSB   0x45
 
#define PIOS_MPU_GYRO_Y_OUT_LSB   0x46
 
#define PIOS_MPU_GYRO_Z_OUT_MSB   0x47
 
#define PIOS_MPU_GYRO_Z_OUT_LSB   0x48
 
#define PIOS_MPU_I2C_MST_DELAY_CTRL   0x67
 
#define PIOS_MPU_SIGNAL_PATH_RESET   0x68
 
#define PIOS_MPU_USER_CTRL_REG   0x6A
 
#define PIOS_MPU_PWR_MGMT_REG   0x6B
 
#define PIOS_MPU_FIFO_CNT_MSB   0x72
 
#define PIOS_MPU_FIFO_CNT_LSB   0x73
 
#define PIOS_MPU_FIFO_REG   0x74
 
#define PIOS_MPU_WHOAMI   0x75
 
#define PIOS_MPU_FIFO_TEMP_OUT   0x80
 
#define PIOS_MPU_FIFO_GYRO_X_OUT   0x40
 
#define PIOS_MPU_FIFO_GYRO_Y_OUT   0x20
 
#define PIOS_MPU_FIFO_GYRO_Z_OUT   0x10
 
#define PIOS_MPU_ACCEL_OUT   0x08
 
#define PIOS_MPU_INT_ACTL   0x80
 
#define PIOS_MPU_INT_OPEN   0x40
 
#define PIOS_MPU_INT_LATCH_EN   0x20
 
#define PIOS_MPU_INT_CLR_ANYRD   0x10
 
#define PIOS_MPU_INT_I2C_BYPASS_EN   0x02
 
#define PIOS_MPU_INTEN_OVERFLOW   0x10
 
#define PIOS_MPU_INTEN_DATA_RDY   0x01
 
#define PIOS_MPU_INT_STATUS_OVERFLOW   0x10
 
#define PIOS_MPU_INT_STATUS_IMU_RDY   0X04
 
#define PIOS_MPU_INT_STATUS_DATA_RDY   0X01
 
#define PIOS_MPU_USERCTL_FIFO_EN   0X40
 
#define PIOS_MPU_USERCTL_I2C_MST_EN   0X20
 
#define PIOS_MPU_USERCTL_DIS_I2C   0X10
 
#define PIOS_MPU_USERCTL_FIFO_RST   0X02
 
#define PIOS_MPU_USERCTL_GYRO_RST   0X01
 
#define PIOS_MPU_PWRMGMT_IMU_RST   0X80
 
#define PIOS_MPU_PWRMGMT_INTERN_CLK   0X00
 
#define PIOS_MPU_PWRMGMT_PLL_X_CLK   0X01
 
#define PIOS_MPU_PWRMGMT_PLL_Y_CLK   0X02
 
#define PIOS_MPU_PWRMGMT_PLL_Z_CLK   0X03
 
#define PIOS_MPU_PWRMGMT_STOP_CLK   0X07
 
#define PIOS_MPU_I2C_MST_SLV4_DONE   0x40
 
#define PIOS_MPU_I2C_MST_LOST_ARB   0x20
 
#define PIOS_MPU_I2C_MST_SLV4_NACK   0x10
 
#define PIOS_MPU_I2C_MST_SLV0_NACK   0x01
 
#define PIOS_MPU_I2CSLV_EN   0x80
 
#define PIOS_MPU_I2CSLV_BYTE_SW   0x40
 
#define PIOS_MPU_I2CSLV_REG_DIS   0x20
 
#define PIOS_MPU_I2CSLV_GRP   0x10
 
#define PIOS_MPU_I2CMSTDELAY_SLV0EN   0x01
 
#define PIOS_MPU_I2CMSTDELAY_SLV1EN   0x02
 
#define PIOS_MPU_I2CMSTDELAY_ESSHADOW   0x80
 
#define PIOS_MPU_AK89XX_ADDR   0x0C
 
#define PIOS_MPU_AK89XX_WHOAMI_REG   0x00
 
#define PIOS_MPU_AK89XX_WHOAMI_ID   0x48
 
#define PIOS_MPU_AK89XX_ST1_REG   0x02
 
#define PIOS_MPU_AK89XX_ST2_REG   0x09
 
#define PIOS_MPU_AK89XX_ST1_DRDY   0x01
 
#define PIOS_MPU_AK8963_ST2_BITM   0x10
 
#define PIOS_MPU_AK89XX_ST2_HOFL   0x08
 
#define PIOS_MPU_AK8975_ST2_DERR   0x04
 
#define PIOS_MPU_AK89XX_CNTL1_REG   0x0A
 
#define PIOS_MPU_AK8963_CNTL2_REG   0x0B
 
#define PIOS_MPU_AK8963_CNTL2_SRST   0x01
 
#define PIOS_MPU_AK8963_MODE_CONTINUOUS_FAST_16B   0x16
 
#define PIOS_MPU_AK8975_MODE_SINGLE_12B   0x01
 

Typedefs

typedef struct pios_mpu_dev * pios_mpu_dev_t
 

Enumerations

enum  pios_mpu_error {
  PIOS_MPU_ERROR_NONE = 0, PIOS_MPU_ERROR_NOCONFIG = 1, PIOS_MPU_ERROR_PROBEFAILED, PIOS_MPU_ERROR_WRITEFAILED,
  PIOS_MPU_ERROR_READFAILED, PIOS_MPU_ERROR_NOIRQ, PIOS_MPU_ERROR_SAMPLERATE, PIOS_MPU_ERROR_WHOAMI,
  PIOS_MPU_ERROR_MAGFAILED
}
 
enum  pios_mpu_type {
  PIOS_MPU60X0, PIOS_MPU6500, PIOS_MPU9150, PIOS_MPU9250,
  PIOS_ICM20608G, PIOS_ICM20602, PIOS_ICM20689, PIOS_MPU_NUM
}
 
enum  pios_mpu60x0_gyro_filter {
  PIOS_MPU60X0_GYRO_LOWPASS_256_HZ = 0x00, PIOS_MPU60X0_GYRO_LOWPASS_188_HZ = 0x01, PIOS_MPU60X0_GYRO_LOWPASS_98_HZ = 0x02, PIOS_MPU60X0_GYRO_LOWPASS_42_HZ = 0x03,
  PIOS_MPU60X0_GYRO_LOWPASS_20_HZ = 0x04, PIOS_MPU60X0_GYRO_LOWPASS_10_HZ = 0x05, PIOS_MPU60X0_GYRO_LOWPASS_5_HZ = 0x06
}
 
enum  pios_mpu6500_gyro_filter {
  PIOS_MPU6500_GYRO_LOWPASS_250_HZ = 0x00, PIOS_MPU6500_GYRO_LOWPASS_184_HZ = 0x01, PIOS_MPU6500_GYRO_LOWPASS_92_HZ = 0x02, PIOS_MPU6500_GYRO_LOWPASS_41_HZ = 0x03,
  PIOS_MPU6500_GYRO_LOWPASS_20_HZ = 0x04, PIOS_MPU6500_GYRO_LOWPASS_10_HZ = 0x05, PIOS_MPU6500_GYRO_LOWPASS_5_HZ = 0x06
}
 
enum  pios_icm206xx_gyro_filter {
  PIOS_ICM206XX_GYRO_LOWPASS_250_HZ = 0x00, PIOS_ICM206XX_GYRO_LOWPASS_176_HZ = 0x01, PIOS_ICM206XX_GYRO_LOWPASS_92_HZ = 0x02, PIOS_ICM206XX_GYRO_LOWPASS_41_HZ = 0x03,
  PIOS_ICM206XX_GYRO_LOWPASS_20_HZ = 0x04, PIOS_ICM206XX_GYRO_LOWPASS_10_HZ = 0x05, PIOS_ICM206XX_GYRO_LOWPASS_5_HZ = 0x06, PIOS_ICM206XX_GYRO_LOWPASS_3281_HZ = 0x07
}
 
enum  pios_mpu6500_accel_filter {
  PIOS_MPU6500_ACCEL_LOWPASS_460_HZ = 0x00, PIOS_MPU6500_ACCEL_LOWPASS_184_HZ = 0x01, PIOS_MPU6500_ACCEL_LOWPASS_92_HZ = 0x02, PIOS_MPU6500_ACCEL_LOWPASS_41_HZ = 0x03,
  PIOS_MPU6500_ACCEL_LOWPASS_20_HZ = 0x04, PIOS_MPU6500_ACCEL_LOWPASS_10_HZ = 0x05, PIOS_MPU6500_ACCEL_LOWPASS_5_HZ = 0x06
}
 
enum  pios_icm206xx_accel_filter {
  PIOS_ICM206XX_ACCEL_LOWPASS_218_HZ = 0x00, PIOS_ICM206XX_ACCEL_LOWPASS_99_HZ = 0x02, PIOS_ICM206XX_ACCEL_LOWPASS_45_HZ = 0x03, PIOS_ICM206XX_ACCEL_LOWPASS_21_HZ = 0x04,
  PIOS_ICM206XX_ACCEL_LOWPASS_10_HZ = 0x05, PIOS_ICM206XX_ACCEL_LOWPASS_5_HZ = 0x06, PIOS_ICM206XX_ACCEL_LOWPASS_420_HZ = 0x07
}
 
enum  pios_mpu_gyro_range { PIOS_MPU_SCALE_250_DEG = 0x00, PIOS_MPU_SCALE_500_DEG = 0x08, PIOS_MPU_SCALE_1000_DEG = 0x10, PIOS_MPU_SCALE_2000_DEG = 0x18 }
 
enum  pios_mpu_accel_range { PIOS_MPU_SCALE_2G = 0x00, PIOS_MPU_SCALE_4G = 0x08, PIOS_MPU_SCALE_8G = 0x10, PIOS_MPU_SCALE_16G = 0x18 }
 
enum  pios_mpu_orientation {
  PIOS_MPU_TOP_0DEG = 0x00, PIOS_MPU_TOP_90DEG = 0x01, PIOS_MPU_TOP_180DEG = 0x02, PIOS_MPU_TOP_270DEG = 0x03,
  PIOS_MPU_BOTTOM_0DEG = 0x04, PIOS_MPU_BOTTOM_90DEG = 0x05, PIOS_MPU_BOTTOM_180DEG = 0x06, PIOS_MPU_BOTTOM_270DEG = 0x07
}
 

Functions

int32_t PIOS_MPU_I2C_Init (pios_mpu_dev_t *dev, pios_i2c_t i2c_id, const struct pios_mpu_cfg *cfg)
 Initialize the MPU-xxxx 6/9-axis sensor on I2C. More...
 
int32_t PIOS_MPU_SPI_Init (pios_mpu_dev_t *dev, pios_spi_t spi_id, uint32_t slave_num, const struct pios_mpu_cfg *cfg)
 Initialize the MPU-xxxx 6/9-axis sensor on SPI. More...
 
int32_t PIOS_MPU_Test ()
 
int32_t PIOS_MPU_SetGyroRange (enum pios_mpu_gyro_range range)
 
int32_t PIOS_MPU_SetAccelRange (enum pios_mpu_accel_range range)
 
int32_t PIOS_MPU_SetSampleRate (uint16_t samplerate_hz)
 
void PIOS_MPU_SetGyroBandwidth (uint16_t bandwidth)
 Sets the bandwidth desired from the gyro. The driver will automatically select the lowest bandwidth low-pass filter capable of providing the desired bandwidth. More...
 
void PIOS_MPU_SetAccelBandwidth (uint16_t bandwidth)
 Sets the bandwidth desired from the accelerometer. The driver will automatically select the lowest bandwidth low-pass filter capable of providing the desired bandwidth. More...
 
bool PIOS_MPU_IRQHandler (void)
 The IMU interrupt handler. Fetches new data from the IMU. More...
 
enum pios_mpu_type PIOS_MPU_GetType (void)
 Which type of MPU was detected? More...
 

Detailed Description

Common driver for Invensense MPU-xxx0 6/9-axis IMUs.

Common driver for Invensense MPU-xxx0 6/9-axis IMUs. Private Declarations.

Common driver for Invensense MPU-xxx0 6/9-axis IMUs. Public Interface.

Macro Definition Documentation

#define PIOS_MPU_ACCEL_CFG2_REG   0X1D

Definition at line 40 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_CFG_REG   0X1C

Definition at line 39 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_OUT   0x08

Definition at line 86 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_X_OUT_LSB   0x3C

Definition at line 59 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_X_OUT_MSB   0x3B

Definition at line 58 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_Y_OUT_LSB   0x3E

Definition at line 61 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_Y_OUT_MSB   0x3D

Definition at line 60 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_Z_OUT_LSB   0x40

Definition at line 63 of file pios_mpu_priv.h.

#define PIOS_MPU_ACCEL_Z_OUT_MSB   0x3F

Definition at line 62 of file pios_mpu_priv.h.

#define PIOS_MPU_AK8963_CNTL2_REG   0x0B

Definition at line 146 of file pios_mpu_priv.h.

#define PIOS_MPU_AK8963_CNTL2_SRST   0x01

Definition at line 147 of file pios_mpu_priv.h.

#define PIOS_MPU_AK8963_MODE_CONTINUOUS_FAST_16B   0x16

Definition at line 148 of file pios_mpu_priv.h.

#define PIOS_MPU_AK8963_ST2_BITM   0x10

Definition at line 142 of file pios_mpu_priv.h.

#define PIOS_MPU_AK8975_MODE_SINGLE_12B   0x01

Definition at line 149 of file pios_mpu_priv.h.

#define PIOS_MPU_AK8975_ST2_DERR   0x04

Definition at line 144 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_ADDR   0x0C

Definition at line 136 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_CNTL1_REG   0x0A

Definition at line 145 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_ST1_DRDY   0x01

Definition at line 141 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_ST1_REG   0x02

Definition at line 139 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_ST2_HOFL   0x08

Definition at line 143 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_ST2_REG   0x09

Definition at line 140 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_WHOAMI_ID   0x48

Definition at line 138 of file pios_mpu_priv.h.

#define PIOS_MPU_AK89XX_WHOAMI_REG   0x00

Definition at line 137 of file pios_mpu_priv.h.

#define PIOS_MPU_DLPF_CFG_REG   0X1A

Definition at line 37 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_CNT_LSB   0x73

Definition at line 77 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_CNT_MSB   0x72

Definition at line 76 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_EN_REG   0x23

Definition at line 41 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_GYRO_X_OUT   0x40

Definition at line 83 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_GYRO_Y_OUT   0x20

Definition at line 84 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_GYRO_Z_OUT   0x10

Definition at line 85 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_REG   0x74

Definition at line 78 of file pios_mpu_priv.h.

#define PIOS_MPU_FIFO_TEMP_OUT   0x80

Definition at line 82 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_CFG_REG   0X1B

Definition at line 38 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_X_OUT_LSB   0x44

Definition at line 67 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_X_OUT_MSB   0x43

Definition at line 66 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_Y_OUT_LSB   0x46

Definition at line 69 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_Y_OUT_MSB   0x45

Definition at line 68 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_Z_OUT_LSB   0x48

Definition at line 71 of file pios_mpu_priv.h.

#define PIOS_MPU_GYRO_Z_OUT_MSB   0x47

Definition at line 70 of file pios_mpu_priv.h.

#define PIOS_MPU_I2C_MST_DELAY_CTRL   0x67

Definition at line 72 of file pios_mpu_priv.h.

#define PIOS_MPU_I2C_MST_LOST_ARB   0x20

Definition at line 120 of file pios_mpu_priv.h.

#define PIOS_MPU_I2C_MST_SLV0_NACK   0x01

Definition at line 122 of file pios_mpu_priv.h.

#define PIOS_MPU_I2C_MST_SLV4_DONE   0x40

Definition at line 119 of file pios_mpu_priv.h.

#define PIOS_MPU_I2C_MST_SLV4_NACK   0x10

Definition at line 121 of file pios_mpu_priv.h.

#define PIOS_MPU_I2C_MST_STATUS_REG   0x36

Definition at line 54 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CMSTDELAY_ESSHADOW   0x80

Definition at line 133 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CMSTDELAY_SLV0EN   0x01

Definition at line 131 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CMSTDELAY_SLV1EN   0x02

Definition at line 132 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CSLV_BYTE_SW   0x40

Definition at line 126 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CSLV_EN   0x80

Definition at line 125 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CSLV_GRP   0x10

Definition at line 128 of file pios_mpu_priv.h.

#define PIOS_MPU_I2CSLV_REG_DIS   0x20

Definition at line 127 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_ACTL   0x80

Definition at line 89 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_CFG_REG   0x37

Definition at line 55 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_CLR_ANYRD   0x10

Definition at line 92 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_EN_REG   0x38

Definition at line 56 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_I2C_BYPASS_EN   0x02

Definition at line 93 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_LATCH_EN   0x20

Definition at line 91 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_OPEN   0x40

Definition at line 90 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_STATUS_DATA_RDY   0X01

Definition at line 101 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_STATUS_IMU_RDY   0X04

Definition at line 100 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_STATUS_OVERFLOW   0x10

Definition at line 99 of file pios_mpu_priv.h.

#define PIOS_MPU_INT_STATUS_REG   0x3A

Definition at line 57 of file pios_mpu_priv.h.

#define PIOS_MPU_INTEN_DATA_RDY   0x01

Definition at line 96 of file pios_mpu_priv.h.

#define PIOS_MPU_INTEN_OVERFLOW   0x10

Definition at line 95 of file pios_mpu_priv.h.

#define PIOS_MPU_PRODUCT_ID   0x0C

Definition at line 35 of file pios_mpu_priv.h.

#define PIOS_MPU_PWR_MGMT_REG   0x6B

Definition at line 75 of file pios_mpu_priv.h.

#define PIOS_MPU_PWRMGMT_IMU_RST   0X80

Definition at line 111 of file pios_mpu_priv.h.

#define PIOS_MPU_PWRMGMT_INTERN_CLK   0X00

Definition at line 112 of file pios_mpu_priv.h.

#define PIOS_MPU_PWRMGMT_PLL_X_CLK   0X01

Definition at line 113 of file pios_mpu_priv.h.

#define PIOS_MPU_PWRMGMT_PLL_Y_CLK   0X02

Definition at line 114 of file pios_mpu_priv.h.

#define PIOS_MPU_PWRMGMT_PLL_Z_CLK   0X03

Definition at line 115 of file pios_mpu_priv.h.

#define PIOS_MPU_PWRMGMT_STOP_CLK   0X07

Definition at line 116 of file pios_mpu_priv.h.

#define PIOS_MPU_SIGNAL_PATH_RESET   0x68

Definition at line 73 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV0_ADDR_REG   0x25

Definition at line 42 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV0_CTRL_REG   0x27

Definition at line 44 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV0_REG_REG   0x26

Definition at line 43 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV1_ADDR_REG   0x28

Definition at line 45 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV1_CTRL_REG   0x2A

Definition at line 48 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV1_DO_REG   0x64

Definition at line 47 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV1_REG_REG   0x29

Definition at line 46 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV4_ADDR_REG   0x31

Definition at line 49 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV4_CTRL_REG   0x34

Definition at line 52 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV4_DI_REG   0x35

Definition at line 53 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV4_DO_REG   0x33

Definition at line 51 of file pios_mpu_priv.h.

#define PIOS_MPU_SLV4_REG_REG   0x32

Definition at line 50 of file pios_mpu_priv.h.

#define PIOS_MPU_SMPLRT_DIV_REG   0X19

Definition at line 36 of file pios_mpu_priv.h.

#define PIOS_MPU_TEMP_OUT_LSB   0x42

Definition at line 65 of file pios_mpu_priv.h.

#define PIOS_MPU_TEMP_OUT_MSB   0x41

Definition at line 64 of file pios_mpu_priv.h.

#define PIOS_MPU_USER_CTRL_REG   0x6A

Definition at line 74 of file pios_mpu_priv.h.

#define PIOS_MPU_USERCTL_DIS_I2C   0X10

Definition at line 106 of file pios_mpu_priv.h.

#define PIOS_MPU_USERCTL_FIFO_EN   0X40

Definition at line 104 of file pios_mpu_priv.h.

#define PIOS_MPU_USERCTL_FIFO_RST   0X02

Definition at line 107 of file pios_mpu_priv.h.

#define PIOS_MPU_USERCTL_GYRO_RST   0X01

Definition at line 108 of file pios_mpu_priv.h.

#define PIOS_MPU_USERCTL_I2C_MST_EN   0X20

Definition at line 105 of file pios_mpu_priv.h.

#define PIOS_MPU_WHOAMI   0x75

Definition at line 79 of file pios_mpu_priv.h.

Typedef Documentation

typedef struct pios_mpu_dev* pios_mpu_dev_t

Definition at line 150 of file pios_mpu.h.

Enumeration Type Documentation

Enumerator
PIOS_ICM206XX_ACCEL_LOWPASS_218_HZ 
PIOS_ICM206XX_ACCEL_LOWPASS_99_HZ 
PIOS_ICM206XX_ACCEL_LOWPASS_45_HZ 
PIOS_ICM206XX_ACCEL_LOWPASS_21_HZ 
PIOS_ICM206XX_ACCEL_LOWPASS_10_HZ 
PIOS_ICM206XX_ACCEL_LOWPASS_5_HZ 
PIOS_ICM206XX_ACCEL_LOWPASS_420_HZ 

Definition at line 104 of file pios_mpu.h.

Enumerator
PIOS_ICM206XX_GYRO_LOWPASS_250_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_176_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_92_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_41_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_20_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_10_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_5_HZ 
PIOS_ICM206XX_GYRO_LOWPASS_3281_HZ 

Definition at line 83 of file pios_mpu.h.

Enumerator
PIOS_MPU60X0_GYRO_LOWPASS_256_HZ 
PIOS_MPU60X0_GYRO_LOWPASS_188_HZ 
PIOS_MPU60X0_GYRO_LOWPASS_98_HZ 
PIOS_MPU60X0_GYRO_LOWPASS_42_HZ 
PIOS_MPU60X0_GYRO_LOWPASS_20_HZ 
PIOS_MPU60X0_GYRO_LOWPASS_10_HZ 
PIOS_MPU60X0_GYRO_LOWPASS_5_HZ 

Definition at line 63 of file pios_mpu.h.

Enumerator
PIOS_MPU6500_ACCEL_LOWPASS_460_HZ 
PIOS_MPU6500_ACCEL_LOWPASS_184_HZ 
PIOS_MPU6500_ACCEL_LOWPASS_92_HZ 
PIOS_MPU6500_ACCEL_LOWPASS_41_HZ 
PIOS_MPU6500_ACCEL_LOWPASS_20_HZ 
PIOS_MPU6500_ACCEL_LOWPASS_10_HZ 
PIOS_MPU6500_ACCEL_LOWPASS_5_HZ 

Definition at line 94 of file pios_mpu.h.

Enumerator
PIOS_MPU6500_GYRO_LOWPASS_250_HZ 
PIOS_MPU6500_GYRO_LOWPASS_184_HZ 
PIOS_MPU6500_GYRO_LOWPASS_92_HZ 
PIOS_MPU6500_GYRO_LOWPASS_41_HZ 
PIOS_MPU6500_GYRO_LOWPASS_20_HZ 
PIOS_MPU6500_GYRO_LOWPASS_10_HZ 
PIOS_MPU6500_GYRO_LOWPASS_5_HZ 

Definition at line 73 of file pios_mpu.h.

Enumerator
PIOS_MPU_SCALE_2G 
PIOS_MPU_SCALE_4G 
PIOS_MPU_SCALE_8G 
PIOS_MPU_SCALE_16G 

Definition at line 121 of file pios_mpu.h.

MPU driver error return types

Enumerator
PIOS_MPU_ERROR_NONE 
PIOS_MPU_ERROR_NOCONFIG 
PIOS_MPU_ERROR_PROBEFAILED 
PIOS_MPU_ERROR_WRITEFAILED 
PIOS_MPU_ERROR_READFAILED 
PIOS_MPU_ERROR_NOIRQ 
PIOS_MPU_ERROR_SAMPLERATE 
PIOS_MPU_ERROR_WHOAMI 
PIOS_MPU_ERROR_MAGFAILED 

Definition at line 37 of file pios_mpu.h.

Enumerator
PIOS_MPU_SCALE_250_DEG 
PIOS_MPU_SCALE_500_DEG 
PIOS_MPU_SCALE_1000_DEG 
PIOS_MPU_SCALE_2000_DEG 

Definition at line 114 of file pios_mpu.h.

Enumerator
PIOS_MPU_TOP_0DEG 
PIOS_MPU_TOP_90DEG 
PIOS_MPU_TOP_180DEG 
PIOS_MPU_TOP_270DEG 
PIOS_MPU_BOTTOM_0DEG 
PIOS_MPU_BOTTOM_90DEG 
PIOS_MPU_BOTTOM_180DEG 
PIOS_MPU_BOTTOM_270DEG 

Definition at line 128 of file pios_mpu.h.

Supported IMU devices

Enumerator
PIOS_MPU60X0 

MPU-6000, SPI/I2C or MPU-6050, I2C

PIOS_MPU6500 

MPU-6500, SPI/I2C

PIOS_MPU9150 

MPU-9150, contains MPU-6050+AK8975C

PIOS_MPU9250 

MPU-9250, contains MPU-6500+AK8963

PIOS_ICM20608G 

ICM-20608-G, SPI/I2C

PIOS_ICM20602 

ICM-20602, SPI/I2C

PIOS_ICM20689 

ICM-20689, SPI/I2C

PIOS_MPU_NUM 

Number of elements

Definition at line 52 of file pios_mpu.h.

Function Documentation

enum pios_mpu_type PIOS_MPU_GetType ( void  )

Which type of MPU was detected?

int32_t PIOS_MPU_I2C_Init ( pios_mpu_dev_t dev,
pios_i2c_t  i2c_id,
const struct pios_mpu_cfg cfg 
)

Initialize the MPU-xxxx 6/9-axis sensor on I2C.

Parameters
[in]i2c_idPiOS I2C driver instance ID/pointer
[in]cfgMPU config
Returns
0 for success, -1 for failure to allocate, -10 for failure to get irq
bool PIOS_MPU_IRQHandler ( void  )

The IMU interrupt handler. Fetches new data from the IMU.

void PIOS_MPU_SetAccelBandwidth ( uint16_t  bandwidth)

Sets the bandwidth desired from the accelerometer. The driver will automatically select the lowest bandwidth low-pass filter capable of providing the desired bandwidth.

Parameters
[in]bandwidthThe desired bandwidth [Hz]
int32_t PIOS_MPU_SetAccelRange ( enum pios_mpu_accel_range  range)
void PIOS_MPU_SetGyroBandwidth ( uint16_t  bandwidth)

Sets the bandwidth desired from the gyro. The driver will automatically select the lowest bandwidth low-pass filter capable of providing the desired bandwidth.

Parameters
[in]bandwidthThe desired bandwidth [Hz]
int32_t PIOS_MPU_SetGyroRange ( enum pios_mpu_gyro_range  range)
int32_t PIOS_MPU_SetSampleRate ( uint16_t  samplerate_hz)

Set the sample rate in Hz by determining the nearest divisor

Parameters
[in]samplerate in Hz
int32_t PIOS_MPU_SPI_Init ( pios_mpu_dev_t dev,
pios_spi_t  spi_id,
uint32_t  slave_num,
const struct pios_mpu_cfg cfg 
)

Initialize the MPU-xxxx 6/9-axis sensor on SPI.

Returns
0 for success, -1 for failure to allocate, -10 for failure to get irq
int32_t PIOS_MPU_Test ( )