Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
mpu60x0.h File Reference
#include "std.h"
#include "math/pprz_algebra_int.h"
#include "peripherals/mpu60x0_regs.h"
+ Include dependency graph for mpu60x0.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Mpu60x0I2cSlave
 
struct  Mpu60x0Config
 

Macros

#define MPU60X0_DEFAULT_SMPLRT_DIV   0
 Default sample rate divider. More...
 
#define MPU60X0_DEFAULT_FS_SEL   MPU60X0_GYRO_RANGE_2000
 Default gyro full scale range +- 2000°/s. More...
 
#define MPU60X0_DEFAULT_AFS_SEL   MPU60X0_ACCEL_RANGE_16G
 Default accel full scale range +- 16g. More...
 
#define MPU60X0_DEFAULT_DLPF_CFG   MPU60X0_DLPF_98HZ
 Default internal sampling (1kHz, 98Hz LP Bandwidth) More...
 
#define MPU60X0_DEFAULT_DLPF_CFG_ACC   MPU60X0_DLPF_ACC_99HZ
 Default internal sampling for accelerometer ICM devices only (1kHz, 99Hz LP Bandwidth) More...
 
#define MPU60X0_DEFAULT_INT_CFG   1
 Default interrupt config: DATA_RDY_EN. More...
 
#define MPU60X0_DEFAULT_CLK_SEL   1
 Default clock: PLL with X gyro reference. More...
 
#define MPU60X0_I2C_NB_SLAVES   5
 
#define MPU60X0_GYRO_SENS_250   0.544883
 default gyro sensitivy from the datasheet sens = 1/ [LSB/(deg/s)] * pi/180 * 2^INT32_RATE_FRAC ex: MPU with 1000 deg/s has 32.8 LSB/(deg/s) sens = 1/32.8 * pi/180 * 4096 = 2.17953 More...
 
#define MPU60X0_GYRO_SENS_250_NUM   19327
 
#define MPU60X0_GYRO_SENS_250_DEN   35470
 
#define MPU60X0_GYRO_SENS_500   1.08977
 
#define MPU60X0_GYRO_SENS_500_NUM   57663
 
#define MPU60X0_GYRO_SENS_500_DEN   52913
 
#define MPU60X0_GYRO_SENS_1000   2.17953
 
#define MPU60X0_GYRO_SENS_1000_NUM   18271
 
#define MPU60X0_GYRO_SENS_1000_DEN   8383
 
#define MPU60X0_GYRO_SENS_2000   4.35906
 
#define MPU60X0_GYRO_SENS_2000_NUM   36542
 
#define MPU60X0_GYRO_SENS_2000_DEN   8383
 
#define MPU60X0_ACCEL_SENS_2G   0.613125
 default accel sensitivy from the datasheet sens = 9.81 [m/s^2] / [LSB/g] * 2^INT32_ACCEL_FRAC ex: MPU with 8g has 4096 LSB/g sens = 9.81 [m/s^2] / 4096 [LSB/g] * 2^INT32_ACCEL_FRAC = 2.4525 More...
 
#define MPU60X0_ACCEL_SENS_2G_NUM   981
 
#define MPU60X0_ACCEL_SENS_2G_DEN   1600
 
#define MPU60X0_ACCEL_SENS_4G   1.22625
 
#define MPU60X0_ACCEL_SENS_4G_NUM   981
 
#define MPU60X0_ACCEL_SENS_4G_DEN   800
 
#define MPU60X0_ACCEL_SENS_8G   2.4525
 
#define MPU60X0_ACCEL_SENS_8G_NUM   981
 
#define MPU60X0_ACCEL_SENS_8G_DEN   400
 
#define MPU60X0_ACCEL_SENS_16G   4.905
 
#define MPU60X0_ACCEL_SENS_16G_NUM   981
 
#define MPU60X0_ACCEL_SENS_16G_DEN   200
 

Typedefs

typedef void(* Mpu60x0ConfigSet) (void *mpu, uint8_t _reg, uint8_t _val)
 Configuration function prototype. More...
 
typedef bool(* Mpu60x0I2cSlaveConfigure) (Mpu60x0ConfigSet mpu_set, void *mpu)
 function prototype for configuration of a single I2C slave More...
 

Enumerations

enum  Mpu60x0Type {
  MPU60X0, ICM20600, ICM20608, ICM20602,
  ICM20689
}
 MPU60x0 sensor type. More...
 
enum  Mpu60x0ConfStatus {
  MPU60X0_CONF_UNINIT, MPU60X0_CONF_RESET, MPU60X0_CONF_USER_RESET, MPU60X0_CONF_PWR,
  MPU60X0_CONF_SD, MPU60X0_CONF_DLPF, MPU60X0_CONF_GYRO, MPU60X0_CONF_ACCEL,
  MPU60X0_CONF_ACCEL2, MPU60X0_CONF_I2C_SLAVES, MPU60X0_CONF_INT_ENABLE, MPU60X0_CONF_UNDOC1,
  MPU60X0_CONF_DONE
}
 

Functions

void mpu60x0_set_default_config (struct Mpu60x0Config *c)
 
void mpu60x0_send_config (Mpu60x0ConfigSet mpu_set, void *mpu, struct Mpu60x0Config *config)
 Configuration sequence called once before normal use. More...
 
bool mpu60x0_configure_i2c_slaves (Mpu60x0ConfigSet mpu_set, void *mpu)
 Configure I2C slaves of the MPU. More...
 

Variables

const float MPU60X0_GYRO_SENS [4]
 
const struct Int32Rates MPU60X0_GYRO_SENS_FRAC [4][2]
 
const float MPU60X0_ACCEL_SENS [4]
 
const struct Int32Vect3 MPU60X0_ACCEL_SENS_FRAC [4][2]
 

Detailed Description

MPU-60X0 driver common interface (I2C and SPI).

Definition in file mpu60x0.h.


Data Structure Documentation

◆ Mpu60x0I2cSlave

struct Mpu60x0I2cSlave

Definition at line 134 of file mpu60x0.h.

Data Fields
Mpu60x0I2cSlaveConfigure configure

◆ Mpu60x0Config

struct Mpu60x0Config

Definition at line 138 of file mpu60x0.h.

+ Collaboration diagram for Mpu60x0Config:
Data Fields
enum Mpu60x0AccelRanges accel_range g Range
uint8_t clk_sel Clock select.
enum Mpu60x0DLPF dlpf_cfg Digital Low Pass Filter.
enum Mpu60x0ACCDLPF dlpf_cfg_acc Digital Low Pass Filter for acceleremoter (ICM devices only)
bool drdy_int_enable Enable Data Ready Interrupt.
enum Mpu60x0GyroRanges gyro_range deg/s Range
bool i2c_bypass Bypass MPU I2C.

Only effective if using the I2C implementation.

enum Mpu60x0MstClk i2c_mst_clk MPU I2C master clock speed.
uint8_t i2c_mst_delay MPU I2C slaves delayed sample rate.
enum Mpu60x0ConfStatus init_status init status
bool initialized config done flag
uint8_t nb_bytes number of bytes to read starting with MPU60X0_REG_INT_STATUS
uint8_t nb_slave_init number of already configured/initialized slaves
uint8_t nb_slaves number of used I2C slaves
struct Mpu60x0I2cSlave slaves[MPU60X0_I2C_NB_SLAVES] I2C slaves.
uint8_t smplrt_div Sample rate divider.
enum Mpu60x0Type type The type of sensor (MPU60x0, ICM20608, ...)

Macro Definition Documentation

◆ MPU60X0_ACCEL_SENS_16G

#define MPU60X0_ACCEL_SENS_16G   4.905

Definition at line 93 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_16G_DEN

#define MPU60X0_ACCEL_SENS_16G_DEN   200

Definition at line 95 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_16G_NUM

#define MPU60X0_ACCEL_SENS_16G_NUM   981

Definition at line 94 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_2G

#define MPU60X0_ACCEL_SENS_2G   0.613125

default accel sensitivy from the datasheet sens = 9.81 [m/s^2] / [LSB/g] * 2^INT32_ACCEL_FRAC ex: MPU with 8g has 4096 LSB/g sens = 9.81 [m/s^2] / 4096 [LSB/g] * 2^INT32_ACCEL_FRAC = 2.4525

Definition at line 84 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_2G_DEN

#define MPU60X0_ACCEL_SENS_2G_DEN   1600

Definition at line 86 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_2G_NUM

#define MPU60X0_ACCEL_SENS_2G_NUM   981

Definition at line 85 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_4G

#define MPU60X0_ACCEL_SENS_4G   1.22625

Definition at line 87 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_4G_DEN

#define MPU60X0_ACCEL_SENS_4G_DEN   800

Definition at line 89 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_4G_NUM

#define MPU60X0_ACCEL_SENS_4G_NUM   981

Definition at line 88 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_8G

#define MPU60X0_ACCEL_SENS_8G   2.4525

Definition at line 90 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_8G_DEN

#define MPU60X0_ACCEL_SENS_8G_DEN   400

Definition at line 92 of file mpu60x0.h.

◆ MPU60X0_ACCEL_SENS_8G_NUM

#define MPU60X0_ACCEL_SENS_8G_NUM   981

Definition at line 91 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_AFS_SEL

#define MPU60X0_DEFAULT_AFS_SEL   MPU60X0_ACCEL_RANGE_16G

Default accel full scale range +- 16g.

Definition at line 41 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_CLK_SEL

#define MPU60X0_DEFAULT_CLK_SEL   1

Default clock: PLL with X gyro reference.

Definition at line 49 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_DLPF_CFG

#define MPU60X0_DEFAULT_DLPF_CFG   MPU60X0_DLPF_98HZ

Default internal sampling (1kHz, 98Hz LP Bandwidth)

Definition at line 43 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_DLPF_CFG_ACC

#define MPU60X0_DEFAULT_DLPF_CFG_ACC   MPU60X0_DLPF_ACC_99HZ

Default internal sampling for accelerometer ICM devices only (1kHz, 99Hz LP Bandwidth)

Definition at line 45 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_FS_SEL

#define MPU60X0_DEFAULT_FS_SEL   MPU60X0_GYRO_RANGE_2000

Default gyro full scale range +- 2000°/s.

Definition at line 39 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_INT_CFG

#define MPU60X0_DEFAULT_INT_CFG   1

Default interrupt config: DATA_RDY_EN.

Definition at line 47 of file mpu60x0.h.

◆ MPU60X0_DEFAULT_SMPLRT_DIV

#define MPU60X0_DEFAULT_SMPLRT_DIV   0

Default sample rate divider.

Definition at line 37 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_1000

#define MPU60X0_GYRO_SENS_1000   2.17953

Definition at line 67 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_1000_DEN

#define MPU60X0_GYRO_SENS_1000_DEN   8383

Definition at line 69 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_1000_NUM

#define MPU60X0_GYRO_SENS_1000_NUM   18271

Definition at line 68 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_2000

#define MPU60X0_GYRO_SENS_2000   4.35906

Definition at line 70 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_2000_DEN

#define MPU60X0_GYRO_SENS_2000_DEN   8383

Definition at line 72 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_2000_NUM

#define MPU60X0_GYRO_SENS_2000_NUM   36542

Definition at line 71 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_250

#define MPU60X0_GYRO_SENS_250   0.544883

default gyro sensitivy from the datasheet sens = 1/ [LSB/(deg/s)] * pi/180 * 2^INT32_RATE_FRAC ex: MPU with 1000 deg/s has 32.8 LSB/(deg/s) sens = 1/32.8 * pi/180 * 4096 = 2.17953

Definition at line 61 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_250_DEN

#define MPU60X0_GYRO_SENS_250_DEN   35470

Definition at line 63 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_250_NUM

#define MPU60X0_GYRO_SENS_250_NUM   19327

Definition at line 62 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_500

#define MPU60X0_GYRO_SENS_500   1.08977

Definition at line 64 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_500_DEN

#define MPU60X0_GYRO_SENS_500_DEN   52913

Definition at line 66 of file mpu60x0.h.

◆ MPU60X0_GYRO_SENS_500_NUM

#define MPU60X0_GYRO_SENS_500_NUM   57663

Definition at line 65 of file mpu60x0.h.

◆ MPU60X0_I2C_NB_SLAVES

#define MPU60X0_I2C_NB_SLAVES   5

Definition at line 53 of file mpu60x0.h.

Typedef Documentation

◆ Mpu60x0ConfigSet

typedef void(* Mpu60x0ConfigSet) (void *mpu, uint8_t _reg, uint8_t _val)

Configuration function prototype.

Definition at line 129 of file mpu60x0.h.

◆ Mpu60x0I2cSlaveConfigure

typedef bool(* Mpu60x0I2cSlaveConfigure) (Mpu60x0ConfigSet mpu_set, void *mpu)

function prototype for configuration of a single I2C slave

Definition at line 132 of file mpu60x0.h.

Enumeration Type Documentation

◆ Mpu60x0ConfStatus

Enumerator
MPU60X0_CONF_UNINIT 
MPU60X0_CONF_RESET 
MPU60X0_CONF_USER_RESET 
MPU60X0_CONF_PWR 
MPU60X0_CONF_SD 
MPU60X0_CONF_DLPF 
MPU60X0_CONF_GYRO 
MPU60X0_CONF_ACCEL 
MPU60X0_CONF_ACCEL2 
MPU60X0_CONF_I2C_SLAVES 
MPU60X0_CONF_INT_ENABLE 
MPU60X0_CONF_UNDOC1 
MPU60X0_CONF_DONE 

Definition at line 112 of file mpu60x0.h.

◆ Mpu60x0Type

MPU60x0 sensor type.

Enumerator
MPU60X0 
ICM20600 
ICM20608 
ICM20602 
ICM20689 

Definition at line 104 of file mpu60x0.h.

Function Documentation

◆ mpu60x0_configure_i2c_slaves()

◆ mpu60x0_send_config()

◆ mpu60x0_set_default_config()

Variable Documentation

◆ MPU60X0_ACCEL_SENS

const float MPU60X0_ACCEL_SENS[4]

Definition at line 49 of file mpu60x0.c.

◆ MPU60X0_ACCEL_SENS_FRAC

◆ MPU60X0_GYRO_SENS

const float MPU60X0_GYRO_SENS[4]

Definition at line 31 of file mpu60x0.c.

◆ MPU60X0_GYRO_SENS_FRAC