35 PRINT_CONFIG_VAR(IMU_MPU9250_SPI_SLAVE_IDX)
36 PRINT_CONFIG_VAR(IMU_MPU9250_SPI_DEV)
39 #if !defined IMU_MPU9250_GYRO_LOWPASS_FILTER && !defined IMU_MPU9250_ACCEL_LOWPASS_FILTER && !defined IMU_MPU9250_SMPLRT_DIV
40 #if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
45 #define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_41HZ
46 #define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_41HZ
47 #define IMU_MPU9250_SMPLRT_DIV 9
48 PRINT_CONFIG_MSG(
"Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
49 #elif PERIODIC_FREQUENCY == 512
54 #define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_250HZ
55 #define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_184HZ
56 #define IMU_MPU9250_SMPLRT_DIV 3
60 #define IMU_MPU9250_SMPLRT_DIV 9
61 #define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_41HZ
62 #define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_41HZ
63 PRINT_CONFIG_MSG(
"Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
74 #ifndef IMU_MPU9250_CHAN_X
75 #define IMU_MPU9250_CHAN_X 0
78 #ifndef IMU_MPU9250_CHAN_Y
79 #define IMU_MPU9250_CHAN_Y 1
82 #ifndef IMU_MPU9250_CHAN_Z
83 #define IMU_MPU9250_CHAN_Z 2
87 #ifndef IMU_MPU9250_X_SIGN
88 #define IMU_MPU9250_X_SIGN 1
91 #ifndef IMU_MPU9250_Y_SIGN
92 #define IMU_MPU9250_Y_SIGN 1
95 #ifndef IMU_MPU9250_Z_SIGN
96 #define IMU_MPU9250_Z_SIGN 1
100 #ifndef IMU_MPU9250_READ_MAG
101 #define IMU_MPU9250_READ_MAG TRUE
104 #ifndef IMU_MPU9250_MAG_STARTUP_DELAY
105 #define IMU_MPU9250_MAG_STARTUP_DELAY 1
127 #if IMU_MPU9250_READ_MAG
166 #define Int16FromBuf(_buf,_idx) ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
190 #if IMU_MPU9250_READ_MAG
216 mpu_set(mpu, _reg, _val);
enum Mpu9250MstClk i2c_mst_clk
MPU I2C master clock speed.
enum SPIClockPolarity cpol
clock polarity control
Mpu9250I2cSlaveConfigure configure
enum Mpu9250DLPFGyro dlpf_gyro_cfg
Digital Low Pass Filter for gyroscope.
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint16_t output_length
number of data words to write
#define MPU9250_REG_I2C_SLV0_CTRL
static void mpu9250_spi_periodic(struct Mpu9250_Spi *mpu)
convenience function: read or start configuration if not already initialized
struct Mpu9250Config config
#define MPU9250_REG_I2C_SLV0_ADDR
volatile bool data_available
data ready flag
enum Mpu9250GyroRanges gyro_range
deg/s Range
#define IMU_MPU9250_ACCEL_LOWPASS_FILTER
uint8_t nb_bytes
number of bytes to read starting with MPU9250_REG_INT_STATUS
#define VECT3_COPY(_a, _b)
#define IMU_MPU9250_Z_SIGN
Main include for ABI (AirBorneInterface).
volatile uint8_t wait_slave4_rx_buf[2]
SPI transaction structure.
#define MPU9250_REG_I2C_MST_STATUS
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
uint8_t data_ext[MPU9250_BUFFER_EXT_LEN]
void imu_mpu9250_init(void)
enum SPIBitOrder bitorder
MSB/LSB order.
struct Imu imu
global IMU state
#define Int16FromBuf(_buf, _idx)
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
static float get_sys_time_float(void)
Get the time in seconds since startup.
#define IMU_MPU9250_CHAN_X
enum SPISlaveSelect select
slave selection behavior
union Mpu9250_I2c::@334 data_rates
volatile bool slave4_ready
enum Mpu9250DLPFAccel dlpf_accel_cfg
Digital Low Pass Filter for accelerometer.
void mpu9250_spi_event(struct Mpu9250_Spi *mpu)
Architecture independent SPI (Serial Peripheral Interface) API.
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
enum SPIClockPhase cpha
clock phase control
static void mpu_set_and_wait(Mpu9250ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
struct ImuMpu9250 imu_mpu9250
Architecture independent timing functions.
volatile uint8_t wait_slave4_tx_buf[1]
void mpu9250_spi_init(struct Mpu9250_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
SPICallback after_cb
NULL or function called after the transaction.
#define MPU9250_REG_I2C_SLV4_ADDR
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void(* Mpu9250ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
bool imu_mpu9250_configure_mag_slave(Mpu9250ConfigSet mpu_set, void *mpu)
function to configure akm8963 mag
void imu_mpu9250_periodic(void)
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
#define MPU9250_REG_I2C_SLV4_CTRL
uint8_t nb_slaves
number of used I2C slaves
Inertial Measurement Unit interface.
void imu_scale_gyro(struct Imu *_imu)
#define IMU_MPU9250_CHAN_Z
#define IMU_MPU9250_SMPLRT_DIV
uint16_t input_length
number of data words to read
#define IMU_MPU9250_ACCEL_RANGE
void imu_mpu9250_event(void)
void mpu_wait_slave4_ready(void)
#define IMU_MPU9250_GYRO_LOWPASS_FILTER
#define MPU9250_REG_I2C_SLV4_REG
enum Mpu9250AccelRanges accel_range
g Range
#define IMU_MPU9250_MAG_STARTUP_DELAY
void imu_scale_mag(struct Imu *_imu)
#define MPU9250_I2C_SLV4_DONE
struct Mpu9250I2cSlave slaves[MPU9250_I2C_NB_SLAVES]
I2C slaves.
slave is selected before transaction and unselected after
#define IMU_MPU9250_GYRO_RANGE
#define MPU9250_REG_I2C_SLV0_REG
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
#define IMU_MPU9250_Y_SIGN
volatile uint8_t * input_buf
pointer to receive buffer for DMA
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
SPICallback before_cb
NULL or function called before the transaction.
void imu_scale_accel(struct Imu *_imu)
#define RATES_COPY(_a, _b)
uint8_t smplrt_div
Sample rate divider.
#define IMU_MPU9250_X_SIGN
#define IMU_MPU9250_CHAN_Y
struct spi_transaction wait_slave4_trans
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define MPU9250_REG_I2C_SLV4_DO
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
#define AK8963_CNTL1_CM_2
enum SPITransactionStatus status
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
union Mpu9250_I2c::@333 data_accel