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")
70 #ifndef IMU_MPU9250_GYRO_RANGE
71 #define IMU_MPU9250_GYRO_RANGE MPU9250_GYRO_RANGE_1000
75 #ifndef IMU_MPU9250_ACCEL_RANGE
76 #define IMU_MPU9250_ACCEL_RANGE MPU9250_ACCEL_RANGE_8G
81 #ifndef IMU_MPU9250_CHAN_X
82 #define IMU_MPU9250_CHAN_X 0
85 #ifndef IMU_MPU9250_CHAN_Y
86 #define IMU_MPU9250_CHAN_Y 1
89 #ifndef IMU_MPU9250_CHAN_Z
90 #define IMU_MPU9250_CHAN_Z 2
94 #ifndef IMU_MPU9250_X_SIGN
95 #define IMU_MPU9250_X_SIGN 1
98 #ifndef IMU_MPU9250_Y_SIGN
99 #define IMU_MPU9250_Y_SIGN 1
102 #ifndef IMU_MPU9250_Z_SIGN
103 #define IMU_MPU9250_Z_SIGN 1
107 #ifndef IMU_MPU9250_READ_MAG
108 #define IMU_MPU9250_READ_MAG TRUE
111 #ifndef IMU_MPU9250_MAG_STARTUP_DELAY
112 #define IMU_MPU9250_MAG_STARTUP_DELAY 1
134 #if IMU_MPU9250_READ_MAG
173 #define Int16FromBuf(_buf,_idx) ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
197 #if IMU_MPU9250_READ_MAG
223 mpu_set(mpu, _reg, _val);
enum Mpu9250MstClk i2c_mst_clk
MPU I2C master clock speed.
enum SPIClockPolarity cpol
clock polarity control
Mpu9250I2cSlaveConfigure configure
union Mpu9250_I2c::@46 data_rates
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
void imu_scale_gyro(struct Imu *_imu)
#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
void imu_scale_accel(struct Imu *_imu)
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
uint8_t data_ext[MPU9250_BUFFER_EXT_LEN]
enum SPIBitOrder bitorder
MSB/LSB order.
#define Int16FromBuf(_buf, _idx)
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
volatile bool_t slave4_ready
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
void imu_impl_init(void)
must be defined by underlying hardware
enum Mpu9250DLPFAccel dlpf_accel_cfg
Digital Low Pass Filter for accelerometer.
static uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
void mpu9250_spi_event(struct Mpu9250_Spi *mpu)
union Mpu9250_I2c::@45 data_accel
Architecture independent SPI (Serial Peripheral Interface) API.
struct Mpu9250I2cSlave slaves[5]
I2C slaves.
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
#define IMU_MPU9250_ACCEL_RANGE
bool_t spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit a spi transaction.
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
struct Imu imu
global IMU state
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.
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.
#define IMU_MPU9250_CHAN_Z
#define IMU_MPU9250_SMPLRT_DIV
uint16_t input_length
number of data words to read
void imu_mpu9250_event(void)
volatile bool_t data_available
data ready flag
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
slave is selected before transaction and unselected after
#define MPU9250_REG_I2C_SLV0_REG
enum SPIDataSizeSelect dss
data transfer word size
void imu_periodic(void)
optional.
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.
#define IMU_MPU9250_GYRO_RANGE
#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
bool_t imu_mpu9250_configure_mag_slave(Mpu9250ConfigSet mpu_set, void *mpu)
function to configure akm8963 mag
#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