Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
imu_mpu9250_spi.c File Reference

IMU driver for the MPU9250 using SPI. More...

#include "modules/imu/imu_mpu9250_spi.h"
#include "modules/imu/imu.h"
#include "modules/core/abi.h"
#include "mcu_periph/sys_time.h"
#include "mcu_periph/spi.h"
#include "peripherals/ak8963_regs.h"
#include "generated/modules.h"
Include dependency graph for imu_mpu9250_spi.c:

Go to the source code of this file.

Macros

#define IMU_MPU9250_GYRO_LOWPASS_FILTER   MPU9250_DLPF_GYRO_41HZ
#define IMU_MPU9250_ACCEL_LOWPASS_FILTER   MPU9250_DLPF_ACCEL_41HZ
#define IMU_MPU9250_SMPLRT_DIV   9
#define IMU_MPU9250_CHAN_X   0
#define IMU_MPU9250_CHAN_Y   1
#define IMU_MPU9250_CHAN_Z   2
#define IMU_MPU9250_X_SIGN   1
#define IMU_MPU9250_Y_SIGN   1
#define IMU_MPU9250_Z_SIGN   1
#define IMU_MPU9250_READ_MAG   TRUE
#define IMU_MPU9250_MAG_STARTUP_DELAY   1
#define Int16FromBuf(_buf, _idx)

Functions

void mpu_wait_slave4_ready (void)
void mpu_wait_slave4_ready_cb (struct spi_transaction *t)
bool imu_mpu9250_configure_mag_slave (Mpu9250ConfigSet mpu_set, void *mpu)
 function to configure akm8963 mag
void imu_mpu9250_init (void)
void imu_mpu9250_periodic (void)
void imu_mpu9250_event (void)
static void mpu_set_and_wait (Mpu9250ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)

Variables

struct ImuMpu9250 imu_mpu9250

Detailed Description

IMU driver for the MPU9250 using SPI.

Definition in file imu_mpu9250_spi.c.

Macro Definition Documentation

◆ IMU_MPU9250_ACCEL_LOWPASS_FILTER

#define IMU_MPU9250_ACCEL_LOWPASS_FILTER   MPU9250_DLPF_ACCEL_41HZ

Definition at line 48 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_CHAN_X

#define IMU_MPU9250_CHAN_X   0

Definition at line 83 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_CHAN_Y

#define IMU_MPU9250_CHAN_Y   1

Definition at line 87 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_CHAN_Z

#define IMU_MPU9250_CHAN_Z   2

Definition at line 91 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_GYRO_LOWPASS_FILTER

#define IMU_MPU9250_GYRO_LOWPASS_FILTER   MPU9250_DLPF_GYRO_41HZ

Definition at line 47 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_MAG_STARTUP_DELAY

#define IMU_MPU9250_MAG_STARTUP_DELAY   1

Definition at line 113 of file imu_mpu9250_spi.c.

Referenced by imu_mpu9250_configure_mag_slave().

◆ IMU_MPU9250_READ_MAG

#define IMU_MPU9250_READ_MAG   TRUE

Definition at line 109 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_SMPLRT_DIV

#define IMU_MPU9250_SMPLRT_DIV   9

Definition at line 49 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_X_SIGN

#define IMU_MPU9250_X_SIGN   1

Definition at line 96 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_Y_SIGN

#define IMU_MPU9250_Y_SIGN   1

Definition at line 100 of file imu_mpu9250_spi.c.

◆ IMU_MPU9250_Z_SIGN

#define IMU_MPU9250_Z_SIGN   1

Definition at line 104 of file imu_mpu9250_spi.c.

◆ Int16FromBuf

#define Int16FromBuf ( _buf,
_idx )
Value:
((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
short int16_t
Typedef defining 16 bit short type.

Definition at line 177 of file imu_mpu9250_spi.c.

Referenced by imu_mpu9250_event().

Function Documentation

◆ imu_mpu9250_configure_mag_slave()

bool imu_mpu9250_configure_mag_slave ( Mpu9250ConfigSet mpu_set,
void * mpu )

function to configure akm8963 mag

callback function to configure ak8963 mag

Returns
TRUE if mag configuration finished

Definition at line 226 of file imu_mpu9250_spi.c.

References AK8963_CNTL1_CM_2, AK8963_REG_CNTL1, AK8963_REG_CNTL2, AK8963_REG_HXL, get_sys_time_float(), IMU_MPU9250_MAG_STARTUP_DELAY, MPU9250_MAG_ADDR, MPU9250_REG_I2C_SLV0_ADDR, MPU9250_REG_I2C_SLV0_CTRL, MPU9250_REG_I2C_SLV0_REG, MPU9250_REG_I2C_SLV4_ADDR, MPU9250_REG_I2C_SLV4_CTRL, MPU9250_REG_I2C_SLV4_DO, MPU9250_REG_I2C_SLV4_REG, MPU9250_SPI_READ, mpu_set_and_wait(), and mpu_wait_slave4_ready().

Referenced by imu_mpu9250_init(), and mpu9250_i2c_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ imu_mpu9250_event()

◆ imu_mpu9250_init()

◆ imu_mpu9250_periodic()

void imu_mpu9250_periodic ( void )

Definition at line 172 of file imu_mpu9250_spi.c.

References imu_mpu9250, and mpu9250_spi_periodic().

Here is the call graph for this function:

◆ mpu_set_and_wait()

void mpu_set_and_wait ( Mpu9250ConfigSet mpu_set,
void * mpu,
uint8_t _reg,
uint8_t _val )
inlinestatic

Definition at line 217 of file imu_mpu9250_spi.c.

References imu_mpu9250, and SPITransSuccess.

Referenced by imu_mpu9250_configure_mag_slave().

Here is the caller graph for this function:

◆ mpu_wait_slave4_ready()

void mpu_wait_slave4_ready ( void )

Definition at line 261 of file imu_mpu9250_spi.c.

References imu_mpu9250, MPU9250_REG_I2C_MST_STATUS, MPU9250_SPI_READ, spi_submit(), and SPITransDone.

Referenced by imu_mpu9250_configure_mag_slave().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpu_wait_slave4_ready_cb()

void mpu_wait_slave4_ready_cb ( struct spi_transaction * t)

Variable Documentation

◆ imu_mpu9250

struct ImuMpu9250 imu_mpu9250

Definition at line 116 of file imu_mpu9250_spi.c.