36 PRINT_CONFIG_VAR(IMU_MPU9250_SPI_SLAVE_IDX)
37 PRINT_CONFIG_VAR(IMU_MPU9250_SPI_DEV)
40 #if !defined IMU_MPU9250_GYRO_LOWPASS_FILTER && !defined IMU_MPU9250_ACCEL_LOWPASS_FILTER && !defined IMU_MPU9250_SMPLRT_DIV
41 #if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
46 #define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_41HZ
47 #define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_41HZ
48 #define IMU_MPU9250_SMPLRT_DIV 9
49 PRINT_CONFIG_MSG(
"Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
50 #elif PERIODIC_FREQUENCY == 512
55 #define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_250HZ
56 #define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_184HZ
57 #define IMU_MPU9250_SMPLRT_DIV 3
61 #define IMU_MPU9250_SMPLRT_DIV 9
62 #define IMU_MPU9250_GYRO_LOWPASS_FILTER MPU9250_DLPF_GYRO_41HZ
63 #define IMU_MPU9250_ACCEL_LOWPASS_FILTER MPU9250_DLPF_ACCEL_41HZ
64 PRINT_CONFIG_MSG(
"Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
75 #ifndef IMU_MPU9250_CHAN_X
76 #define IMU_MPU9250_CHAN_X 0
79 #ifndef IMU_MPU9250_CHAN_Y
80 #define IMU_MPU9250_CHAN_Y 1
83 #ifndef IMU_MPU9250_CHAN_Z
84 #define IMU_MPU9250_CHAN_Z 2
88 #ifndef IMU_MPU9250_X_SIGN
89 #define IMU_MPU9250_X_SIGN 1
92 #ifndef IMU_MPU9250_Y_SIGN
93 #define IMU_MPU9250_Y_SIGN 1
96 #ifndef IMU_MPU9250_Z_SIGN
97 #define IMU_MPU9250_Z_SIGN 1
101 #ifndef IMU_MPU9250_READ_MAG
102 #define IMU_MPU9250_READ_MAG TRUE
105 #ifndef IMU_MPU9250_MAG_STARTUP_DELAY
106 #define IMU_MPU9250_MAG_STARTUP_DELAY 1
131 #if IMU_MPU9250_READ_MAG
170 #define Int16FromBuf(_buf,_idx) ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
191 #if IMU_MPU9250_READ_MAG
212 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.
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback before_cb
NULL or function called before the transaction.
SPICallback after_cb
NULL or function called after the transaction.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
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_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct Int32Rates *scale)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
Inertial Measurement Unit interface.
#define IMU_MPU9250_ACCEL_RANGE
#define IMU_MPU9250_GYRO_RANGE
#define IMU_MPU9250_MAG_STARTUP_DELAY
#define IMU_MPU9250_GYRO_LOWPASS_FILTER
#define IMU_MPU9250_X_SIGN
#define IMU_MPU9250_CHAN_X
bool imu_mpu9250_configure_mag_slave(Mpu9250ConfigSet mpu_set, void *mpu)
function to configure akm8963 mag
void imu_mpu9250_periodic(void)
#define IMU_MPU9250_Y_SIGN
#define IMU_MPU9250_ACCEL_LOWPASS_FILTER
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
void imu_mpu9250_init(void)
void mpu_wait_slave4_ready(void)
#define IMU_MPU9250_Z_SIGN
#define IMU_MPU9250_SMPLRT_DIV
#define IMU_MPU9250_CHAN_Z
#define IMU_MPU9250_CHAN_Y
static void mpu_set_and_wait(Mpu9250ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)
struct ImuMpu9250 imu_mpu9250
#define Int16FromBuf(_buf, _idx)
void imu_mpu9250_event(void)
IMU driver for the MPU9250 using SPI.
struct spi_transaction wait_slave4_trans
volatile uint8_t wait_slave4_rx_buf[2]
volatile uint8_t wait_slave4_tx_buf[1]
volatile bool slave4_ready
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
const struct Int32Vect3 MPU9250_ACCEL_SENS_FRAC[4][2]
const struct Int32Rates MPU9250_GYRO_SENS_FRAC[4][2]
enum Mpu9250DLPFGyro dlpf_gyro_cfg
Digital Low Pass Filter for gyroscope.
Mpu9250I2cSlaveConfigure configure
void(* Mpu9250ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
enum Mpu9250MstClk i2c_mst_clk
MPU I2C master clock speed.
uint8_t nb_slaves
number of used I2C slaves
enum Mpu9250GyroRanges gyro_range
deg/s Range
uint8_t nb_bytes
number of bytes to read starting with MPU9250_REG_INT_STATUS
enum Mpu9250DLPFAccel dlpf_accel_cfg
Digital Low Pass Filter for accelerometer.
uint8_t smplrt_div
Sample rate divider.
enum Mpu9250AccelRanges accel_range
g Range
struct Mpu9250I2cSlave slaves[MPU9250_I2C_NB_SLAVES]
I2C slaves.
struct Mpu9250Config config
uint8_t data_ext[MPU9250_BUFFER_EXT_LEN]
union Mpu9250_I2c::@328 data_accel
union Mpu9250_I2c::@329 data_rates
volatile bool data_available
data ready flag
#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
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.