Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
imu_cube module

IMU driver for the sensors inside the cube autopilots

  • IMU1: ICM20948 (non-isolated)
  • IMU2: ICM20602 (isolated)
  • IMU3: ICM20649 (isolated)

Example for airframe file

Add to your firmware section:

<module name="imu_cube"/>

Module functions

Init Functions

These initialization functions are called once on startup.

Event Functions

These event functions are called in each cycle of the module event loop.

Periodic Functions

These functions are called periodically at the specified frequency from the module periodic loop.

  • imu_cube_periodic()
    • Running at maximum module frequency.
    • Autorun: LOCK
      Periodic function automatically starts after init and can't be stopped.

Files

Header Files

The following headers are automatically included in modules.h

Source Files

Raw imu_cube.xml file:

<!DOCTYPE module SYSTEM "module.dtd">
<module name="imu_cube" dir="imu" task="sensors">
<doc>
<description>
IMU driver for the sensors inside the cube autopilots
- IMU1: ICM20948 (non-isolated)
- IMU2: ICM20602 (isolated)
- IMU3: ICM20649 (isolated)
</description>
</doc>
<dep>
<depends>spi_master,i2c,imu_common,intermcu_iomcu,imu_heater</depends>
<provides>imu</provides>
</dep>
<header>
<file name="imu_cube.h"/>
</header>
<init fun="imu_cube_init()"/>
<periodic fun="imu_cube_periodic()"/>
<event fun="imu_cube_event()"/>
<makefile target="!sim|nps|fbw">
<!-- ICM20948 (non-isolated) -->
<configure name="CUBE_IMU1_SPI_DEV" default="spi1" case="lower|upper"/>
<configure name="CUBE_IMU1_SPI_SLAVE_IDX" default="SPI_SLAVE2"/>
<define name="CUBE_IMU1_SPI_DEV" value="$(CUBE_IMU1_SPI_DEV_LOWER)"/>
<define name="USE_$(CUBE_IMU1_SPI_DEV_UPPER)"/>
<define name="CUBE_IMU1_SPI_SLAVE_IDX" value="$(CUBE_IMU1_SPI_SLAVE_IDX)"/>
<define name="USE_$(CUBE_IMU1_SPI_SLAVE_IDX)"/>
<!-- ICM20602 or ICM45686 (isolated) -->
<configure name="CUBE_IMU2_SPI_DEV" default="spi4" case="lower|upper"/>
<configure name="CUBE_IMU2_SPI_SLAVE_IDX" default="SPI_SLAVE3"/> <!-- Overwritten to SPI_SLAVE5 for cube+ -->
<define name="CUBE_IMU2_SPI_DEV" value="$(CUBE_IMU2_SPI_DEV_LOWER)"/>
<define name="USE_$(CUBE_IMU2_SPI_DEV_UPPER)"/>
<define name="CUBE_IMU2_SPI_SLAVE_IDX" value="$(CUBE_IMU2_SPI_SLAVE_IDX)"/>
<define name="USE_$(CUBE_IMU2_SPI_SLAVE_IDX)"/>
<!-- ICM20649 (isolated) -->
<configure name="CUBE_IMU3_SPI_DEV" default="spi4" case="lower|upper"/>
<configure name="CUBE_IMU3_SPI_SLAVE_IDX" default="SPI_SLAVE8"/>
<define name="CUBE_IMU3_SPI_DEV" value="$(CUBE_IMU3_SPI_DEV_LOWER)"/>
<define name="USE_$(CUBE_IMU3_SPI_DEV_UPPER)"/>
<define name="CUBE_IMU3_SPI_SLAVE_IDX" value="$(CUBE_IMU3_SPI_SLAVE_IDX)"/>
<define name="USE_$(CUBE_IMU3_SPI_SLAVE_IDX)"/>
<!-- Configure the heater (ICM20602) -->
<define name="IMU_HEATER_GYRO_ID" value="IMU_CUBE2_ID"/>
<define name="IMU_HEATER_TARGET_TEMP" value="45.0"/>
<define name="IMU_HEATER_P_GAIN" value="50.0"/>
<define name="IMU_HEATER_I_GAIN" value="0.07"/>
<!-- Different IMU for the cube+ -->
<define name="IMU_CUBE_ORANGEPLUS" value="TRUE" cond="ifeq ($(BOARD_VERSION), orange_plus)"/>
<file name="invensense2.c" dir="peripherals"/>
<file name="invensense3.c" dir="peripherals" cond="ifeq ($(BOARD_VERSION), orange_plus)"/>
<file name="mpu60x0.c" dir="peripherals" cond="ifeq ($(BOARD_VERSION), orange)"/>
<file name="mpu60x0_spi.c" dir="peripherals" cond="ifeq ($(BOARD_VERSION), orange)"/>
<file name="imu_cube.c"/>
<test>
<define name="SPI_MASTER"/>
<define name="CUBE_IMU1_SPI_DEV" value="spi1"/>
<define name="CUBE_IMU1_SPI_SLAVE_IDX" value="0"/>
<define name="CUBE_IMU2_SPI_DEV" value="spi4"/>
<define name="CUBE_IMU2_SPI_SLAVE_IDX" value="1"/>
<define name="CUBE_IMU3_SPI_DEV" value="spi4"/>
<define name="CUBE_IMU3_SPI_SLAVE_IDX" value="2"/>
<define name="USE_SPI1"/>
<define name="USE_SPI4"/>
<define name="USE_SPI_SLAVE0"/>
<define name="USE_SPI_SLAVE2"/>
<define name="USE_SPI_SLAVE2"/>
<define name="PERIODIC_FREQUENCY" value="512"/>
<define name="IMU_CUBE_PERIODIC_FREQ" value="512"/>
</test>
</makefile>
</module>