34#include "generated/modules.h"
41#if !defined IMU_MPU9250_GYRO_LOWPASS_FILTER && !defined IMU_MPU9250_ACCEL_LOWPASS_FILTER && !defined IMU_MPU9250_SMPLRT_DIV
42#if PERIODIC_FREQUENCY <= 120
47#define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_41HZ
48#define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_41HZ
49#define IMU_MPU9250_SMPLRT_DIV 9
52#elif PERIODIC_FREQUENCY < 500
57#define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_92HZ
58#define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_92HZ
59#define IMU_MPU9250_SMPLRT_DIV 1
67#define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_250HZ
68#define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_184HZ
69#define IMU_MPU9250_SMPLRT_DIV 3
82#ifndef IMU_MPU9250_CHAN_X
83#define IMU_MPU9250_CHAN_X 0
86#ifndef IMU_MPU9250_CHAN_Y
87#define IMU_MPU9250_CHAN_Y 1
90#ifndef IMU_MPU9250_CHAN_Z
91#define IMU_MPU9250_CHAN_Z 2
95#ifndef IMU_MPU9250_X_SIGN
96#define IMU_MPU9250_X_SIGN 1
99#ifndef IMU_MPU9250_Y_SIGN
100#define IMU_MPU9250_Y_SIGN 1
103#ifndef IMU_MPU9250_Z_SIGN
104#define IMU_MPU9250_Z_SIGN 1
108#ifndef IMU_MPU9250_READ_MAG
109#define IMU_MPU9250_READ_MAG TRUE
112#ifndef IMU_MPU9250_MAG_STARTUP_DELAY
113#define IMU_MPU9250_MAG_STARTUP_DELAY 1
138#if IMU_MPU9250_READ_MAG
160 imu_mpu9250.wait_slave4_trans.slave_idx = IMU_MPU9250_SPI_SLAVE_IDX;
177#define Int16FromBuf(_buf,_idx) ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
198#if IMU_MPU9250_READ_MAG
210 AbiSendMsgIMU_GYRO_RAW(
IMU_MPU9250_ID, now_ts, &rates, 1, IMU_MPU9250_PERIODIC_FREQ, NAN);
211 AbiSendMsgIMU_ACCEL_RAW(
IMU_MPU9250_ID, now_ts, &accel, 1, IMU_MPU9250_PERIODIC_FREQ, NAN);
219 mpu_set(mpu, _reg, _val);
Main include for ABI (AirBorneInterface).
#define AK8963_CNTL1_CM_2
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
volatile uint8_t * input_buf
pointer to receive buffer for DMA
enum SPITransactionStatus status
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI transaction structure.
void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct FloatRates *scale_f)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
Inertial Measurement Unit interface.
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
#define IMU_MPU9250_GYRO_LOWPASS_FILTER
#define IMU_MPU9250_X_SIGN
#define IMU_MPU9250_CHAN_X
#define IMU_MPU9250_Y_SIGN
#define IMU_MPU9250_ACCEL_LOWPASS_FILTER
#define IMU_MPU9250_Z_SIGN
#define IMU_MPU9250_SMPLRT_DIV
#define IMU_MPU9250_CHAN_Z
#define IMU_MPU9250_CHAN_Y
struct ImuMpu9250 imu_mpu9250
#define IMU_MPU9250_ACCEL_RANGE
#define IMU_MPU9250_GYRO_RANGE
#define IMU_MPU9250_MAG_STARTUP_DELAY
bool imu_mpu9250_configure_mag_slave(Mpu9250ConfigSet mpu_set, void *mpu)
function to configure akm8963 mag
void imu_mpu9250_periodic(void)
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
void imu_mpu9250_init(void)
void mpu_wait_slave4_ready(void)
static void mpu_set_and_wait(Mpu9250ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)
#define Int16FromBuf(_buf, _idx)
void imu_mpu9250_event(void)
IMU driver for the MPU9250 using SPI.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
const struct FloatRates MPU9250_GYRO_SENS_F[4]
const struct FloatVect3 MPU9250_ACCEL_SENS_F[4]
void(* Mpu9250ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
#define MPU9250_REG_I2C_SLV4_ADDR
#define MPU9250_I2C_SLV4_DONE
#define MPU9250_REG_I2C_MST_STATUS
#define MPU9250_REG_I2C_SLV0_ADDR
#define MPU9250_REG_I2C_SLV4_REG
#define MPU9250_REG_I2C_SLV4_DO
#define MPU9250_REG_I2C_SLV4_CTRL
#define MPU9250_REG_I2C_SLV0_CTRL
#define MPU9250_REG_I2C_SLV0_REG
void mpu9250_spi_init(struct Mpu9250_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
void mpu9250_spi_event(struct Mpu9250_Spi *mpu)
static void mpu9250_spi_periodic(struct Mpu9250_Spi *mpu)
convenience function: read or start configuration if not already initialized
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Architecture independent SPI (Serial Peripheral Interface) API.
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.