Reads the internal AK8963 mag as I2C slave of the MPU.
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
1 <module name="imu_mpu9250_spi">
2 <define name="IMU_MPU9250_GYRO_LOWPASS_FILTER" value="MPU9250_DLPF_GYRO_250HZ" />
3 <define name="IMU_MPU9250_ACCEL_LOWPASS_FILTER" value="MPU9250_DLPF_ACCEL_184HZ" />
4 <define name="IMU_MPU9250_SMPLRT_DIV" value="3" />
5 <define name="IMU_MPU9250_GYRO_RANGE" value="MPU9250_GYRO_RANGE_1000" />
6 <define name="IMU_MPU9250_ACCEL_RANGE" value="MPU9250_ACCEL_RANGE_8G" />
7 <define name="IMU_MPU9250_READ_MAG" value="TRUE" />
8 <define name="IMU_MPU9250_STARTUP_DELAY" value="1.0" />
9 <define name="IMU_MPU9250_CHAN_X" value="0" />
10 <define name="IMU_MPU9250_CHAN_Y" value="1" />
11 <define name="IMU_MPU9250_CHAN_Z" value="2" />
12 <define name="IMU_MPU9250_X_SIGN" value="1" />
13 <define name="IMU_MPU9250_Y_SIGN" value="1" />
14 <define name="IMU_MPU9250_Z_SIGN" value="1" />
The following modules are automatically loaded (just as if you had added them in the airframe file)
These initialization functions are called once on startup.
These event functions are called in each cycle of the module event loop.
These functions are called periodically at the specified frequency from the module periodic loop.
<!DOCTYPE module SYSTEM "module.dtd">
<module name="imu_mpu9250_spi" dir="imu">
<doc>
<description>
IMU with MPU9250 via SPI.
Reads the internal AK8963 mag as I2C slave of the MPU.
</description>
<define name="IMU_MPU9250_GYRO_LOWPASS_FILTER" value="MPU9250_DLPF_GYRO_250HZ" description="gyro DigitalLowPassFilter setting of the MPU"/>
<define name="IMU_MPU9250_ACCEL_LOWPASS_FILTER" value="MPU9250_DLPF_ACCEL_184HZ" description="accelerometer DigitalLowPassFilter setting of the MPU"/>
<define name="IMU_MPU9250_SMPLRT_DIV" value="3" description="sample rate divider setting of the MPU"/>
<define name="IMU_MPU9250_GYRO_RANGE" value="MPU9250_GYRO_RANGE_1000" description="gyroscope range setting of the MPU"/>
<define name="IMU_MPU9250_ACCEL_RANGE" value="MPU9250_ACCEL_RANGE_8G" description="accelerometer range setting of the MPU"/>
<define name="IMU_MPU9250_READ_MAG" value="TRUE" description="set to FALSE to disable mag"/>
<define name="IMU_MPU9250_STARTUP_DELAY" value="1.0" description="startup delay in seconds until mag slave is configured"/>
<define name="IMU_MPU9250_CHAN_X" value="0" description="channel index"/>
<define name="IMU_MPU9250_CHAN_Y" value="1" description="channel index"/>
<define name="IMU_MPU9250_CHAN_Z" value="2" description="channel index"/>
<define name="IMU_MPU9250_X_SIGN" value="1" description="axis sign"/>
<define name="IMU_MPU9250_Y_SIGN" value="1" description="axis sign"/>
<define name="IMU_MPU9250_Z_SIGN" value="1" description="axis sign"/>
</doc>
<autoload name="imu_common"/>
<autoload name="imu_nps"/>
<header>
<file name="imu_mpu9250_spi.h" dir="subsystems/imu"/>
</header>
<init fun="imu_mpu9250_init()"/>
<periodic fun="imu_mpu9250_periodic()"/>
<event fun="imu_mpu9250_event()"/>
<makefile target="!sim|nps|fbw">
<configure name="IMU_MPU9250_SPI_DEV" default="spi2" case="lower|upper"/>
<configure name="IMU_MPU9250_SPI_SLAVE_IDX" default="SPI_SLAVE2"/>
<define name="IMU_MPU9250_SPI_DEV" value="$(IMU_MPU9250_SPI_DEV_LOWER)"/>
<define name="USE_$(IMU_MPU9250_SPI_DEV_UPPER)"/>
<define name="IMU_MPU9250_SPI_SLAVE_IDX" value="$(IMU_MPU9250_SPI_SLAVE_IDX)"/>
<define name="USE_$(IMU_MPU9250_SPI_SLAVE_IDX)"/>
<define name="IMU_TYPE_H" value="imu/imu_mpu9250_spi.h" type="string"/>
<file name="mpu9250.c" dir="peripherals"/>
<file name="mpu9250_spi.c" dir="peripherals"/>
<file name="imu_mpu9250_spi.c" dir="subsystems/imu"/>
<raw>
include $(CFG_SHARED)/spi_master.makefile
</raw>
</makefile>
</module>