mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[imu] Add Invensense V2 driver
This commit is contained in:
@@ -79,7 +79,7 @@
|
||||
<configure name="UAVCAN_USE_CAN2" value="TRUE"/>
|
||||
</module>
|
||||
<module name="actuators" type="pwm"/>
|
||||
<module name="imu" type="mpu6000"/>
|
||||
<module name="imu" type="cube"/>
|
||||
<module name="gps" type="ublox"/>
|
||||
<module name="gps" type="ubx_ucenter"/>
|
||||
<module name="stabilization" type="indi_simple"/>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE module SYSTEM "module.dtd">
|
||||
|
||||
<module name="imu_cube" dir="imu" task="sensors">
|
||||
<doc>
|
||||
<description>
|
||||
IMU driver for the sensors inside the cube autopilots
|
||||
</description>
|
||||
</doc>
|
||||
<dep>
|
||||
<depends>spi_master,imu_common</depends>
|
||||
<provides>imu</provides>
|
||||
</dep>
|
||||
<autoload name="imu_nps"/>
|
||||
<autoload name="imu_sim"/>
|
||||
<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">
|
||||
<!-- ICM20602 (isolated) -->
|
||||
<!--configure name="CUBE_IMU1_SPI_DEV" default="spi4" case="lower|upper"/>
|
||||
<configure name="CUBE_IMU1_SPI_SLAVE_IDX" default="SPI_SLAVE3"/-->
|
||||
<!-- ICM20649 (isolated) -->
|
||||
<!--configure name="CUBE_IMU1_SPI_DEV" default="spi4" case="lower|upper"/>
|
||||
<configure name="CUBE_IMU1_SPI_SLAVE_IDX" default="SPI_SLAVE8"/-->
|
||||
<!-- 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)"/>
|
||||
|
||||
<define name="IMU_TYPE_H" value="modules/imu/imu_cube.h" type="string"/>
|
||||
|
||||
<file name="invensense2.c" dir="peripherals"/>
|
||||
<file name="imu_cube.c"/>
|
||||
</makefile>
|
||||
</module>
|
||||
@@ -9,7 +9,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml [modules/cv_opticflow.xml] modules/gps.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/optical_flow_hover.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="red"
|
||||
release="ac5eaa8da36b999a135f979e598930a9d40f6401"
|
||||
/>
|
||||
<aircraft
|
||||
name="ARDrone2_default"
|
||||
@@ -19,8 +18,8 @@
|
||||
telemetry="telemetry/default_rotorcraft.xml"
|
||||
flight_plan="flight_plans/rotorcraft_basic.xml"
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
gui_color="#ffffd633d633"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_extended.xml modules/nav_basic_rotorcraft.xml modules/stabilization_int_quat.xml modules/video_rtp_stream.xml"
|
||||
gui_color="#ffffd633d633"
|
||||
/>
|
||||
<aircraft
|
||||
name="ARDrone2_indi"
|
||||
@@ -120,7 +119,6 @@
|
||||
settings="settings/rotorcraft_basic.xml settings/control/rotorcraft_speed.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/gps.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_extended.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi.xml"
|
||||
gui_color="#ffffbc3bce5b"
|
||||
release="934f0e14c09da0a3bfe199b7685abd2f4b6badbe"
|
||||
/>
|
||||
<aircraft
|
||||
name="CX10"
|
||||
@@ -165,7 +163,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_indi.xml modules/guidance_rotorcraft.xml modules/heli_throttle_curve.xml modules/imu_common.xml modules/logger_sd_spi_direct.xml modules/nav_basic_rotorcraft.xml modules/opa_controller.xml modules/stabilization_int_quat.xml modules/stabilization_rate.xml modules/temp_adc.xml"
|
||||
gui_color="#ffffdffac31f"
|
||||
release="7c6064c5c3522e3286af8ecbc7498773b421ba7d"
|
||||
/>
|
||||
<aircraft
|
||||
name="Disco"
|
||||
@@ -177,7 +174,6 @@
|
||||
settings="settings/fixedwing_basic.xml"
|
||||
settings_modules="modules/ahrs_float_dcm.xml modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_full_pid_fw.xml modules/imu_common.xml modules/nav_basic_fw.xml modules/stabilization_adaptive_fw.xml"
|
||||
gui_color="blue"
|
||||
release="dfba3220f5b3500611231d02fca8799f9f045cb8"
|
||||
/>
|
||||
<aircraft
|
||||
name="Disco_FlatSpin"
|
||||
@@ -189,7 +185,6 @@
|
||||
settings="settings/fixedwing_basic.xml"
|
||||
settings_modules="modules/ahrs_float_cmpl_quat.xml modules/air_data.xml modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_full_pid_fw.xml modules/imu_common.xml modules/nav_basic_fw.xml modules/stabilization_adaptive_fw.xml"
|
||||
gui_color="blue"
|
||||
release="57fa5506ad03c85215b0ff7659d9f2a26131db1f"
|
||||
/>
|
||||
<aircraft
|
||||
name="Flappy"
|
||||
@@ -201,7 +196,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/gps.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/stabilization_int_quat.xml"
|
||||
gui_color="white"
|
||||
release="65aa9a711dc4a66ed2d7cf73c0f5872bbeeb821d"
|
||||
/>
|
||||
<aircraft
|
||||
name="Heli450"
|
||||
@@ -224,7 +218,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml [modules/air_data.xml] modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_extended.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="#ffffcccaccca"
|
||||
release="433c2150022275f26fb4619e536903676d7e2c9e"
|
||||
/>
|
||||
<aircraft
|
||||
name="LadyLisaBluegiga"
|
||||
@@ -236,7 +229,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/gps.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/stabilization_int_quat.xml"
|
||||
gui_color="blue"
|
||||
release="4f95168b07005474c8fedf3be5c2f2b4f4c7c393"
|
||||
/>
|
||||
<aircraft
|
||||
name="LadybirdMXS"
|
||||
@@ -259,7 +251,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_indi.xml modules/guidance_rotorcraft.xml modules/heli_throttle_curve.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/stabilization_int_quat.xml"
|
||||
gui_color="#ffffdffac31f"
|
||||
release="0fba1ce80a46d8dce23c570e6547595c89988fad"
|
||||
/>
|
||||
<aircraft
|
||||
name="MAVTec1_Kirk"
|
||||
@@ -271,7 +262,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/geo_mag.xml modules/gps.xml modules/guidance_indi.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="#ffff00000000"
|
||||
release="e688107d8a1f9c933cb0931eebb0e7b009ccc445"
|
||||
/>
|
||||
<aircraft
|
||||
name="Mentor"
|
||||
@@ -283,7 +273,6 @@
|
||||
settings="settings/fixedwing_basic.xml settings/estimation/ac_char.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_energy.xml modules/imu_common.xml modules/nav_basic_fw.xml modules/stabilization_attitude_fw.xml"
|
||||
gui_color="white"
|
||||
release="997fa535902c4d8f73bc34c02c862652cd47cae5"
|
||||
/>
|
||||
<aircraft
|
||||
name="Nederdrone4"
|
||||
@@ -295,7 +284,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/air_data.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_ekf2.xml modules/nav_basic_rotorcraft.xml modules/nav_survey_rectangle_rotorcraft.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="blue"
|
||||
release="c52a0b7e581c74b42ecc9f9d712324e3ab1fcc5e"
|
||||
/>
|
||||
<aircraft
|
||||
name="Nederdrone5"
|
||||
@@ -307,7 +295,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_ekf2.xml modules/nav_basic_rotorcraft.xml modules/nav_survey_rectangle_rotorcraft.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="blue"
|
||||
release="c52a0b7e581c74b42ecc9f9d712324e3ab1fcc5e"
|
||||
/>
|
||||
<aircraft
|
||||
name="Nederquad"
|
||||
@@ -330,7 +317,6 @@
|
||||
settings="settings/rotorcraft_basic.xml settings/nps.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/gps.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_hff_extended.xml modules/nav_basic_rotorcraft.xml modules/range_forcefield.xml modules/stabilization_indi_simple.xml modules/stabilization_int_quat.xml"
|
||||
gui_color="blue"
|
||||
release="c11f888de1eba08d751f1ff0b03bf4a5bec8e8fa"
|
||||
/>
|
||||
<aircraft
|
||||
name="Quadplane"
|
||||
@@ -342,7 +328,6 @@
|
||||
settings="settings/nps.xml settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/stabilization_int_quat.xml modules/sys_id_chirp.xml"
|
||||
gui_color="blue"
|
||||
release="f739a81cfa2c633e33f31ab5f095d8f617276974"
|
||||
/>
|
||||
<aircraft
|
||||
name="Robird"
|
||||
@@ -354,7 +339,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml [modules/air_data.xml] modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_extended.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="#ffffcccaccca"
|
||||
release="677c4c77398cfbabffae3efdcafdacfd04a0b9ab"
|
||||
/>
|
||||
<aircraft
|
||||
name="Splash"
|
||||
@@ -366,7 +350,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml [modules/air_data.xml] modules/geo_mag.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_extended.xml modules/nav_basic_rotorcraft.xml modules/spektrum_soft_bind.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="#fff0cccaccca"
|
||||
release="234e898f7fd1483806808313d3086f12a1b5730a"
|
||||
/>
|
||||
<aircraft
|
||||
name="Splash3"
|
||||
@@ -378,7 +361,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/air_data.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_ekf2.xml modules/lidar_tfmini.xml modules/nav_basic_rotorcraft.xml modules/stabilization_int_quat.xml modules/stabilization_rate.xml"
|
||||
gui_color="blue"
|
||||
release="009b121cfd12be8d3e236e0cbd5b564f2639d54f"
|
||||
/>
|
||||
<aircraft
|
||||
name="Splash4"
|
||||
@@ -401,7 +383,6 @@
|
||||
settings="settings/fixedwing_basic.xml"
|
||||
settings_modules="modules/gps.xml modules/guidance_basic_fw.xml modules/light.xml modules/nav_basic_fw.xml modules/stabilization_attitude_fw.xml"
|
||||
gui_color="blue"
|
||||
release="679fcad03bab95b2982cb6d8e3537486da45d306"
|
||||
/>
|
||||
<aircraft
|
||||
name="Walkera_GeniusV1"
|
||||
@@ -457,7 +438,6 @@
|
||||
settings="settings/rotorcraft_basic.xml [settings/estimation/ahrs_secondary.xml]"
|
||||
settings_modules="modules/air_data.xml modules/gps.xml modules/gps_ubx_ucenter.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_ekf2.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="#baa3d698b729"
|
||||
release="cde043338785efbaa7aac97e90cb272099a0c7ec"
|
||||
/>
|
||||
<aircraft
|
||||
name="bebop2_no_dampers"
|
||||
@@ -524,7 +504,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/bebop_ae_awb.xml modules/bebop_cam.xml modules/cv_opticflow.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_hff_extended.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi.xml modules/video_capture.xml modules/video_rtp_stream.xml"
|
||||
gui_color="blue"
|
||||
release="398071ca8f7c8dc24becbe76bc5628b6ea604248"
|
||||
/>
|
||||
<aircraft
|
||||
name="fan_demo"
|
||||
@@ -536,7 +515,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/air_data.xml [modules/geo_mag.xml] modules/gps.xml modules/guidance_indi.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_extended.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi.xml"
|
||||
gui_color="#ffffcccaccca"
|
||||
release="f580c07814aa1068bf3f6960318b2417fc069cbe"
|
||||
/>
|
||||
<aircraft
|
||||
name="frog1"
|
||||
@@ -559,7 +537,6 @@
|
||||
settings="settings/rotorcraft_basic.xml"
|
||||
settings_modules="modules/ahrs_int_cmpl_quat.xml modules/gps.xml modules/guidance_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/nav_basic_rotorcraft.xml modules/stabilization_indi_simple.xml"
|
||||
gui_color="blue"
|
||||
release="93a9608c3bc34eca6a0dcde4123d55dac7d7b448"
|
||||
/>
|
||||
<aircraft
|
||||
name="quadshot_pylons"
|
||||
|
||||
@@ -363,6 +363,18 @@
|
||||
#define IMU_BMI088_ID 19
|
||||
#endif
|
||||
|
||||
#ifndef IMU_CUBE1_ID
|
||||
#define IMU_CUBE1_ID 20
|
||||
#endif
|
||||
|
||||
#ifndef IMU_CUBE2_ID
|
||||
#define IMU_CUBE2_ID 21
|
||||
#endif
|
||||
|
||||
#ifndef IMU_CUBE3_ID
|
||||
#define IMU_CUBE4_ID 22
|
||||
#endif
|
||||
|
||||
// prefiltering with OneEuro filter
|
||||
#ifndef IMU_F1E_ID
|
||||
#define IMU_F1E_ID 30
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Freek van tieen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file modules/imu/imu_cube.c
|
||||
* Driver for the IMU's in the Cube autopilots.
|
||||
*/
|
||||
|
||||
#include "modules/imu/imu.h"
|
||||
#include "modules/core/abi.h"
|
||||
#include "mcu_periph/spi.h"
|
||||
#include "peripherals/invensense2.h"
|
||||
|
||||
|
||||
struct invensense2_t imu1;
|
||||
|
||||
void imu_cube_init(void)
|
||||
{
|
||||
struct Int32RMat rmat;
|
||||
struct Int32Eulers eulers;
|
||||
|
||||
/* IMU 2 (ICM2094) */
|
||||
imu2.abi_id = IMU_CUBE2_ID;
|
||||
imu2.bus = INVENSENSE2_SPI;
|
||||
imu2.spi.p = &CUBE_IMU2_SPI_DEV;
|
||||
imu2.spi.slave_idx = CUBE_IMU2_SPI_SLAVE_IDX;
|
||||
imu2.gyro_dlpf = INVENSENSE2_GYRO_DLPF_229HZ;
|
||||
imu2.gyro_range = INVENSENSE2_GYRO_RANGE_4000DPS;
|
||||
imu2.accel_dlpf = INVENSENSE2_ACCEL_DLPF_265HZ;
|
||||
imu2.accel_range = INVENSENSE2_ACCEL_RANGE_30G;
|
||||
invensense2_init(&imu2);
|
||||
|
||||
// Rotation
|
||||
eulers.phi = ANGLE_BFP_OF_REAL(0),
|
||||
eulers.theta = ANGLE_BFP_OF_REAL(RadOfDeg(180));
|
||||
eulers.psi = ANGLE_BFP_OF_REAL(0);
|
||||
int32_rmat_of_eulers(&rmat, &eulers);
|
||||
imu_set_defaults_gyro(IMU_CUBE2_ID, &rmat, NULL, NULL);
|
||||
imu_set_defaults_accel(IMU_CUBE2_ID, &rmat, NULL, NULL);
|
||||
|
||||
/* IMU 3 (ICM20649) */
|
||||
imu3.abi_id = IMU_CUBE3_ID;
|
||||
imu3.bus = INVENSENSE2_SPI;
|
||||
imu3.spi.p = &CUBE_IMU3_SPI_DEV;
|
||||
imu3.spi.slave_idx = CUBE_IMU3_SPI_SLAVE_IDX;
|
||||
imu3.gyro_dlpf = INVENSENSE2_GYRO_DLPF_229HZ;
|
||||
imu3.gyro_range = INVENSENSE2_GYRO_RANGE_4000DPS;
|
||||
imu3.accel_dlpf = INVENSENSE2_ACCEL_DLPF_265HZ;
|
||||
imu3.accel_range = INVENSENSE2_ACCEL_RANGE_30G;
|
||||
invensense2_init(&imu3);
|
||||
|
||||
// Rotation
|
||||
eulers.phi = ANGLE_BFP_OF_REAL(0);
|
||||
eulers.theta = ANGLE_BFP_OF_REAL(0);
|
||||
eulers.psi = ANGLE_BFP_OF_REAL(RadOfDeg(270));
|
||||
int32_rmat_of_eulers(&rmat, &eulers);
|
||||
imu_set_defaults_gyro(IMU_CUBE3_ID, &rmat, NULL, NULL);
|
||||
imu_set_defaults_accel(IMU_CUBE3_ID, &rmat, NULL, NULL);
|
||||
}
|
||||
|
||||
void imu_cube_periodic(void)
|
||||
{
|
||||
invensense2_periodic(&imu1);
|
||||
}
|
||||
|
||||
void imu_cube_event(void)
|
||||
{
|
||||
invensense2_event(&imu1);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file modules/imu/imu_cube.h
|
||||
* Driver for the IMU's in the Cube autopilots.
|
||||
*/
|
||||
|
||||
#ifndef IMU_CUBE_H
|
||||
#define IMU_CUBE_H
|
||||
|
||||
#include "std.h"
|
||||
|
||||
// Set default sensitivity based on range if needed
|
||||
#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS
|
||||
#define IMU_GYRO_P_SENS 1
|
||||
#define IMU_GYRO_P_SENS_NUM 1
|
||||
#define IMU_GYRO_P_SENS_DEN 1
|
||||
#define IMU_GYRO_Q_SENS 1
|
||||
#define IMU_GYRO_Q_SENS_NUM 1
|
||||
#define IMU_GYRO_Q_SENS_DEN 1
|
||||
#define IMU_GYRO_R_SENS 1
|
||||
#define IMU_GYRO_R_SENS_NUM 1
|
||||
#define IMU_GYRO_R_SENS_DEN 1
|
||||
#endif
|
||||
|
||||
// Set default sensitivity based on range if needed
|
||||
#if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS
|
||||
#define IMU_ACCEL_X_SENS 1
|
||||
#define IMU_ACCEL_X_SENS_NUM 1
|
||||
#define IMU_ACCEL_X_SENS_DEN 1
|
||||
#define IMU_ACCEL_Y_SENS 1
|
||||
#define IMU_ACCEL_Y_SENS_NUM 1
|
||||
#define IMU_ACCEL_Y_SENS_DEN 1
|
||||
#define IMU_ACCEL_Z_SENS 1
|
||||
#define IMU_ACCEL_Z_SENS_NUM 1
|
||||
#define IMU_ACCEL_Z_SENS_DEN 1
|
||||
#endif
|
||||
|
||||
extern void imu_cube_init(void);
|
||||
extern void imu_cube_periodic(void);
|
||||
extern void imu_cube_event(void);
|
||||
|
||||
#endif /* IMU_CUBE_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file peripherals/invensense2.h
|
||||
*
|
||||
* Driver for the Invensense V2 IMUs
|
||||
* ICM20948, ICM20648 and ICM20649
|
||||
*/
|
||||
|
||||
#ifndef INVENSENSE2_H
|
||||
#define INVENSENSE2_H
|
||||
|
||||
#include "std.h"
|
||||
#include "mcu_periph/spi.h"
|
||||
#include "mcu_periph/i2c.h"
|
||||
|
||||
// Hold 22 measurements and 3 for the register address and length
|
||||
#define INVENSENSE2_BUFFER_SIZE ((14*22) + 3)
|
||||
|
||||
/* Invensense v2 SPI peripheral */
|
||||
struct invensense2_spi_t {
|
||||
struct spi_periph *p; ///< Peripheral device for communication
|
||||
uint8_t slave_idx; ///< Slave index used for Slave Select
|
||||
struct spi_transaction trans; ///< Transaction used during configuration and measurements
|
||||
|
||||
volatile uint8_t tx_buf[2]; ///< Transmit buffer
|
||||
volatile uint8_t rx_buf[INVENSENSE2_BUFFER_SIZE]; ///< Receive buffer
|
||||
};
|
||||
|
||||
/* Invensense v2 I2C peripheral */
|
||||
struct invensense2_i2c_t {
|
||||
struct i2c_periph *p; ///< Peripheral device for communication
|
||||
uint8_t slave_addr; ///< The I2C slave address on the bus
|
||||
struct i2c_transaction trans; ///< TRansaction used during configuration and measurements
|
||||
};
|
||||
|
||||
/* Possible communication busses for the invense V2 driver */
|
||||
enum invensense2_bus_t {
|
||||
INVENSENSE2_SPI,
|
||||
INVENSENSE2_I2C
|
||||
};
|
||||
|
||||
/* Different states the invensense driver can be in */
|
||||
enum invensense2_status_t {
|
||||
INVENSENSE2_IDLE,
|
||||
INVENSENSE2_CONFIG,
|
||||
INVENSENSE2_RUNNING
|
||||
};
|
||||
|
||||
/* Different device types compatible with the invensense V2 driver */
|
||||
enum invensense2_device_t {
|
||||
INVENSENSE2_UNKOWN,
|
||||
INVENSENSE2_ICM20648,
|
||||
INVENSENSE2_ICM20649,
|
||||
INVENSENSE2_ICM20948
|
||||
};
|
||||
|
||||
/* The gyro digital low pass filter bandwidth configuration */
|
||||
enum invensense2_gyro_dlpf_t {
|
||||
INVENSENSE2_GYRO_DLPF_OFF,
|
||||
INVENSENSE2_GYRO_DLPF_229HZ,
|
||||
INVENSENSE2_GYRO_DLPF_188HZ,
|
||||
INVENSENSE2_GYRO_DLPF_154HZ,
|
||||
INVENSENSE2_GYRO_DLPF_73HZ,
|
||||
INVENSENSE2_GYRO_DLPF_36HZ,
|
||||
INVENSENSE2_GYRO_DLPF_18HZ,
|
||||
INVENSENSE2_GYRO_DLPF_9HZ,
|
||||
INVENSENSE2_GYRO_DLPF_377HZ
|
||||
};
|
||||
|
||||
/* The gyro range in degrees per second(dps) */
|
||||
enum invensense2_gyro_range_t {
|
||||
INVENSENSE2_GYRO_RANGE_250DPS, ///< Not possible for ICM20649
|
||||
INVENSENSE2_GYRO_RANGE_500DPS,
|
||||
INVENSENSE2_GYRO_RANGE_1000DPS,
|
||||
INVENSENSE2_GYRO_RANGE_2000DPS,
|
||||
INVENSENSE2_GYRO_RANGE_4000DPS ///< Only possible for ICM20649
|
||||
};
|
||||
|
||||
/* The accelerometer digital low pass filter bandwidth configuration */
|
||||
enum invensense2_accel_dlpf_t {
|
||||
INVENSENSE2_ACCEL_DLPF_OFF,
|
||||
INVENSENSE2_ACCEL_DLPF_265HZ,
|
||||
INVENSENSE2_ACCEL_DLPF_136HZ,
|
||||
INVENSENSE2_ACCEL_DLPF_69HZ,
|
||||
INVENSENSE2_ACCEL_DLPF_34HZ,
|
||||
INVENSENSE2_ACCEL_DLPF_17HZ,
|
||||
INVENSENSE2_ACCEL_DLPF_8HZ,
|
||||
INVENSENSE2_ACCEL_DLPF_499HZ
|
||||
};
|
||||
|
||||
/* The accelerometer range in G */
|
||||
enum invensense2_accel_range_t {
|
||||
INVENSENSE2_ACCEL_RANGE_2G, ///< Not possible for ICM20649
|
||||
INVENSENSE2_ACCEL_RANGE_4G,
|
||||
INVENSENSE2_ACCEL_RANGE_8G,
|
||||
INVENSENSE2_ACCEL_RANGE_16G,
|
||||
INVENSENSE2_ACCEL_RANGE_30G ///< Only possible for ICM20649
|
||||
};
|
||||
|
||||
/* Main invensense V2 device structure */
|
||||
struct invensense2_t {
|
||||
uint8_t abi_id; ///< The ABI id used to broadcast the device measurements
|
||||
enum invensense2_status_t status; ///< Status of the invensense V2 device
|
||||
enum invensense2_device_t device; ///< The device type detected
|
||||
|
||||
enum invensense2_bus_t bus; ///< The communication bus used to connect the device SPI/I2C
|
||||
union {
|
||||
struct invensense2_spi_t spi; ///< SPI specific configuration
|
||||
struct invensense2_i2c_t i2c; ///< I2C specific configuration
|
||||
};
|
||||
|
||||
uint8_t register_bank; ///< The current register bank communicating with
|
||||
uint8_t config_idx; ///< The current configuration index
|
||||
uint32_t timer; ///< Used to time operations during configuration (samples left during measuring)
|
||||
|
||||
enum invensense2_gyro_dlpf_t gyro_dlpf; ///< Gyro DLPF configuration
|
||||
enum invensense2_gyro_range_t gyro_range; ///< Gyro range configuration
|
||||
enum invensense2_accel_dlpf_t accel_dlpf; ///< Accelerometer DLPF configuration
|
||||
enum invensense2_accel_range_t accel_range; ///< Accelerometer range configuration
|
||||
|
||||
// float temp; ///< temperature in degrees Celcius
|
||||
};
|
||||
|
||||
/* External functions */
|
||||
void invensense2_init(struct invensense2_t *inv);
|
||||
void invensense2_periodic(struct invensense2_t *inv);
|
||||
void invensense2_event(struct invensense2_t *inv);
|
||||
|
||||
#endif // INVENSENSE2_H
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Freek van Tienen <freek.v.tienen@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file peripherals/invensense2_regs.h
|
||||
*
|
||||
* Register and address definitions for the Invensense V2 from ardupilot.
|
||||
*/
|
||||
|
||||
#ifndef INVENSENSE2_REGS_H
|
||||
#define INVENSENSE2_REGS_H
|
||||
|
||||
#define INV2_BANK0 0x00U
|
||||
#define INV2_BANK1 0x01U
|
||||
#define INV2_BANK2 0x02U
|
||||
#define INV2_BANK3 0x03U
|
||||
|
||||
|
||||
#define INV2REG(b, r) ((((uint16_t)b) << 8)|(r))
|
||||
#define INV2_READ_FLAG 0x80
|
||||
|
||||
//Register Map
|
||||
#define INV2REG_WHO_AM_I INV2REG(INV2_BANK0,0x00U)
|
||||
#define INV2REG_USER_CTRL INV2REG(INV2_BANK0,0x03U)
|
||||
# define BIT_USER_CTRL_I2C_MST_RESET 0x02 // reset I2C Master (only applicable if I2C_MST_EN bit is set)
|
||||
# define BIT_USER_CTRL_SRAM_RESET 0x04 // Reset (i.e. clear) FIFO buffer
|
||||
# define BIT_USER_CTRL_DMP_RESET 0x08 // Reset DMP
|
||||
# define BIT_USER_CTRL_I2C_IF_DIS 0x10 // Disable primary I2C interface and enable hal.spi->interface
|
||||
# define BIT_USER_CTRL_I2C_MST_EN 0x20 // Enable MPU to act as the I2C Master to external slave sensors
|
||||
# define BIT_USER_CTRL_FIFO_EN 0x40 // Enable FIFO operations
|
||||
# define BIT_USER_CTRL_DMP_EN 0x80 // Enable DMP operations
|
||||
#define INV2REG_LP_CONFIG INV2REG(INV2_BANK0,0x05U)
|
||||
#define INV2REG_PWR_MGMT_1 INV2REG(INV2_BANK0,0x06U)
|
||||
# define BIT_PWR_MGMT_1_CLK_INTERNAL 0x00 // clock set to internal 8Mhz oscillator
|
||||
# define BIT_PWR_MGMT_1_CLK_AUTO 0x01 // PLL with X axis gyroscope reference
|
||||
# define BIT_PWR_MGMT_1_CLK_STOP 0x07 // Stops the clock and keeps the timing generator in reset
|
||||
# define BIT_PWR_MGMT_1_TEMP_DIS 0x08 // disable temperature sensor
|
||||
# define BIT_PWR_MGMT_1_SLEEP 0x40 // put sensor into low power sleep mode
|
||||
# define BIT_PWR_MGMT_1_DEVICE_RESET 0x80 // reset entire device
|
||||
#define INV2REG_PWR_MGMT_2 INV2REG(INV2_BANK0,0x07U)
|
||||
#define INV2REG_INT_PIN_CFG INV2REG(INV2_BANK0,0x0FU)
|
||||
# define BIT_BYPASS_EN 0x02
|
||||
# define BIT_INT_RD_CLEAR 0x10 // clear the interrupt when any read occurs
|
||||
# define BIT_LATCH_INT_EN 0x20 // latch data ready pin
|
||||
#define INV2REG_INT_ENABLE INV2REG(INV2_BANK0,0x10U)
|
||||
# define BIT_PLL_RDY_EN 0x04
|
||||
#define INV2REG_INT_ENABLE_1 INV2REG(INV2_BANK0,0x11U)
|
||||
#define INV2REG_INT_ENABLE_2 INV2REG(INV2_BANK0,0x12U)
|
||||
#define INV2REG_INT_ENABLE_3 INV2REG(INV2_BANK0,0x13U)
|
||||
#define INV2REG_I2C_MST_STATUS INV2REG(INV2_BANK0,0x17U)
|
||||
#define INV2REG_INT_STATUS INV2REG(INV2_BANK0,0x19U)
|
||||
|
||||
#define INV2REG_INT_STATUS_1 INV2REG(INV2_BANK0,0x1AU)
|
||||
#define INV2REG_INT_STATUS_2 INV2REG(INV2_BANK0,0x1BU)
|
||||
#define INV2REG_INT_STATUS_3 INV2REG(INV2_BANK0,0x1CU)
|
||||
#define INV2REG_DELAY_TIMEH INV2REG(INV2_BANK0,0x28U)
|
||||
#define INV2REG_DELAY_TIMEL INV2REG(INV2_BANK0,0x29U)
|
||||
#define INV2REG_ACCEL_XOUT_H INV2REG(INV2_BANK0,0x2DU)
|
||||
#define INV2REG_ACCEL_XOUT_L INV2REG(INV2_BANK0,0x2EU)
|
||||
#define INV2REG_ACCEL_YOUT_H INV2REG(INV2_BANK0,0x2FU)
|
||||
#define INV2REG_ACCEL_YOUT_L INV2REG(INV2_BANK0,0x30U)
|
||||
#define INV2REG_ACCEL_ZOUT_H INV2REG(INV2_BANK0,0x31U)
|
||||
#define INV2REG_ACCEL_ZOUT_L INV2REG(INV2_BANK0,0x32U)
|
||||
#define INV2REG_GYRO_XOUT_H INV2REG(INV2_BANK0,0x33U)
|
||||
#define INV2REG_GYRO_XOUT_L INV2REG(INV2_BANK0,0x34U)
|
||||
#define INV2REG_GYRO_YOUT_H INV2REG(INV2_BANK0,0x35U)
|
||||
#define INV2REG_GYRO_YOUT_L INV2REG(INV2_BANK0,0x36U)
|
||||
#define INV2REG_GYRO_ZOUT_H INV2REG(INV2_BANK0,0x37U)
|
||||
#define INV2REG_GYRO_ZOUT_L INV2REG(INV2_BANK0,0x38U)
|
||||
#define INV2REG_TEMP_OUT_H INV2REG(INV2_BANK0,0x39U)
|
||||
#define INV2REG_TEMP_OUT_L INV2REG(INV2_BANK0,0x3AU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_00 INV2REG(INV2_BANK0,0x3BU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_01 INV2REG(INV2_BANK0,0x3CU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_02 INV2REG(INV2_BANK0,0x3DU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_03 INV2REG(INV2_BANK0,0x3EU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_04 INV2REG(INV2_BANK0,0x3FU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_05 INV2REG(INV2_BANK0,0x40U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_06 INV2REG(INV2_BANK0,0x41U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_07 INV2REG(INV2_BANK0,0x42U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_08 INV2REG(INV2_BANK0,0x43U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_09 INV2REG(INV2_BANK0,0x44U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_10 INV2REG(INV2_BANK0,0x45U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_11 INV2REG(INV2_BANK0,0x46U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_12 INV2REG(INV2_BANK0,0x47U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_13 INV2REG(INV2_BANK0,0x48U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_14 INV2REG(INV2_BANK0,0x49U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_15 INV2REG(INV2_BANK0,0x4AU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_16 INV2REG(INV2_BANK0,0x4BU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_17 INV2REG(INV2_BANK0,0x4CU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_18 INV2REG(INV2_BANK0,0x4DU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_19 INV2REG(INV2_BANK0,0x4EU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_20 INV2REG(INV2_BANK0,0x4FU)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_21 INV2REG(INV2_BANK0,0x50U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_22 INV2REG(INV2_BANK0,0x51U)
|
||||
#define INV2REG_EXT_SLV_SENS_DATA_23 INV2REG(INV2_BANK0,0x52U)
|
||||
#define INV2REG_FIFO_EN_1 INV2REG(INV2_BANK0,0x66U)
|
||||
# define BIT_SLV3_FIFO_EN 0x08
|
||||
# define BIT_SLV2_FIFO_EN 0x04
|
||||
# define BIT_SLV1_FIFO_EN 0x02
|
||||
# define BIT_SLV0_FIFI_EN0 0x01
|
||||
#define INV2REG_FIFO_EN_2 INV2REG(INV2_BANK0,0x67U)
|
||||
# define BIT_ACCEL_FIFO_EN 0x10
|
||||
# define BIT_ZG_FIFO_EN 0x08
|
||||
# define BIT_YG_FIFO_EN 0x04
|
||||
# define BIT_XG_FIFO_EN 0x02
|
||||
# define BIT_TEMP_FIFO_EN 0x01
|
||||
#define INV2REG_FIFO_RST INV2REG(INV2_BANK0,0x68U)
|
||||
#define INV2REG_FIFO_MODE INV2REG(INV2_BANK0,0x69U)
|
||||
#define INV2REG_FIFO_COUNTH INV2REG(INV2_BANK0,0x70U)
|
||||
#define INV2REG_FIFO_COUNTL INV2REG(INV2_BANK0,0x71U)
|
||||
#define INV2REG_FIFO_R_W INV2REG(INV2_BANK0,0x72U)
|
||||
#define INV2REG_DATA_RDY_STATUS INV2REG(INV2_BANK0,0x74U)
|
||||
#define INV2REG_FIFO_CFG INV2REG(INV2_BANK0,0x76U)
|
||||
|
||||
#define INV2REG_SELF_TEST_X_GYRO INV2REG(INV2_BANK1,0x02U)
|
||||
#define INV2REG_SELF_TEST_Y_GYRO INV2REG(INV2_BANK1,0x03U)
|
||||
#define INV2REG_SELF_TEST_Z_GYRO INV2REG(INV2_BANK1,0x04U)
|
||||
#define INV2REG_SELF_TEST_X_ACCEL INV2REG(INV2_BANK1,0x0EU)
|
||||
#define INV2REG_SELF_TEST_Y_ACCEL INV2REG(INV2_BANK1,0x0FU)
|
||||
#define INV2REG_SELF_TEST_Z_ACCEL INV2REG(INV2_BANK1,0x10U)
|
||||
#define INV2REG_XA_OFFS_H INV2REG(INV2_BANK1,0x14U)
|
||||
#define INV2REG_XA_OFFS_L INV2REG(INV2_BANK1,0x15U)
|
||||
#define INV2REG_YA_OFFS_H INV2REG(INV2_BANK1,0x17U)
|
||||
#define INV2REG_YA_OFFS_L INV2REG(INV2_BANK1,0x18U)
|
||||
#define INV2REG_ZA_OFFS_H INV2REG(INV2_BANK1,0x1AU)
|
||||
#define INV2REG_ZA_OFFS_L INV2REG(INV2_BANK1,0x1BU)
|
||||
#define INV2REG_TIMEBASE_CORRECTIO INV2REG(INV2_BANK1,0x28U)
|
||||
|
||||
#define INV2REG_GYRO_SMPLRT_DIV INV2REG(INV2_BANK2,0x00U)
|
||||
#define INV2REG_GYRO_CONFIG_1 INV2REG(INV2_BANK2,0x01U)
|
||||
# define BIT_GYRO_NODLPF_9KHZ 0x00
|
||||
# define BIT_GYRO_DLPF_ENABLE 0x01
|
||||
# define GYRO_DLPF_CFG_229HZ 0x00
|
||||
# define GYRO_DLPF_CFG_188HZ 0x01
|
||||
# define GYRO_DLPF_CFG_154HZ 0x02
|
||||
# define GYRO_DLPF_CFG_73HZ 0x03
|
||||
# define GYRO_DLPF_CFG_35HZ 0x04
|
||||
# define GYRO_DLPF_CFG_17HZ 0x05
|
||||
# define GYRO_DLPF_CFG_9HZ 0x06
|
||||
# define GYRO_DLPF_CFG_377HZ 0x07
|
||||
# define GYRO_DLPF_CFG_SHIFT 0x03
|
||||
# define GYRO_FS_SEL_250DPS 0x00
|
||||
# define GYRO_FS_SEL_500DPS 0x01
|
||||
# define GYRO_FS_SEL_1000DPS 0x02
|
||||
# define GYRO_FS_SEL_2000DPS 0x03
|
||||
# define GYRO_FS_SEL_SHIFT 0x01
|
||||
#define INV2REG_GYRO_CONFIG_2 INV2REG(INV2_BANK2,0x02U)
|
||||
#define INV2REG_XG_OFFS_USRH INV2REG(INV2_BANK2,0x03U)
|
||||
#define INV2REG_XG_OFFS_USRL INV2REG(INV2_BANK2,0x04U)
|
||||
#define INV2REG_YG_OFFS_USRH INV2REG(INV2_BANK2,0x05U)
|
||||
#define INV2REG_YG_OFFS_USRL INV2REG(INV2_BANK2,0x06U)
|
||||
#define INV2REG_ZG_OFFS_USRH INV2REG(INV2_BANK2,0x07U)
|
||||
#define INV2REG_ZG_OFFS_USRL INV2REG(INV2_BANK2,0x08U)
|
||||
#define INV2REG_ODR_ALIGN_EN INV2REG(INV2_BANK2,0x09U)
|
||||
#define INV2REG_ACCEL_SMPLRT_DIV_1 INV2REG(INV2_BANK2,0x10U)
|
||||
#define INV2REG_ACCEL_SMPLRT_DIV_2 INV2REG(INV2_BANK2,0x11U)
|
||||
#define INV2REG_ACCEL_INTEL_CTRL INV2REG(INV2_BANK2,0x12U)
|
||||
#define INV2REG_ACCEL_WOM_THR INV2REG(INV2_BANK2,0x13U)
|
||||
#define INV2REG_ACCEL_CONFIG INV2REG(INV2_BANK2,0x14U)
|
||||
# define BIT_ACCEL_NODLPF_4_5KHZ 0x00
|
||||
# define BIT_ACCEL_DLPF_ENABLE 0x01
|
||||
# define ACCEL_DLPF_CFG_265HZ 0x00
|
||||
# define ACCEL_DLPF_CFG_136HZ 0x02
|
||||
# define ACCEL_DLPF_CFG_69HZ 0x03
|
||||
# define ACCEL_DLPF_CFG_34HZ 0x04
|
||||
# define ACCEL_DLPF_CFG_17HZ 0x05
|
||||
# define ACCEL_DLPF_CFG_8HZ 0x06
|
||||
# define ACCEL_DLPF_CFG_499HZ 0x07
|
||||
# define ACCEL_DLPF_CFG_SHIFT 0x03
|
||||
# define ACCEL_FS_SEL_2G 0x00
|
||||
# define ACCEL_FS_SEL_4G 0x01
|
||||
# define ACCEL_FS_SEL_8G 0x02
|
||||
# define ACCEL_FS_SEL_16G 0x03
|
||||
# define ACCEL_FS_SEL_SHIFT 0x01
|
||||
#define INV2REG_FSYNC_CONFIG INV2REG(INV2_BANK2,0x52U)
|
||||
# define FSYNC_CONFIG_EXT_SYNC_TEMP 0x01
|
||||
# define FSYNC_CONFIG_EXT_SYNC_GX 0x02
|
||||
# define FSYNC_CONFIG_EXT_SYNC_GY 0x03
|
||||
# define FSYNC_CONFIG_EXT_SYNC_GZ 0x04
|
||||
# define FSYNC_CONFIG_EXT_SYNC_AX 0x05
|
||||
# define FSYNC_CONFIG_EXT_SYNC_AY 0x06
|
||||
# define FSYNC_CONFIG_EXT_SYNC_AZ 0x07
|
||||
#define INV2REG_TEMP_CONFIG INV2REG(INV2_BANK2,0x53U)
|
||||
#define INV2REG_MOD_CTRL_USR INV2REG(INV2_BANK2,0x54U)
|
||||
|
||||
#define INV2REG_I2C_MST_ODR_CONFIG INV2REG(INV2_BANK3,0x00U)
|
||||
#define INV2REG_I2C_MST_CTRL INV2REG(INV2_BANK3,0x01U)
|
||||
# define BIT_I2C_MST_P_NSR 0x10
|
||||
# define BIT_I2C_MST_CLK_400KHZ 0x0D
|
||||
#define INV2REG_I2C_MST_DELAY_CTRL INV2REG(INV2_BANK3,0x02U)
|
||||
# define BIT_I2C_SLV0_DLY_EN 0x01
|
||||
# define BIT_I2C_SLV1_DLY_EN 0x02
|
||||
# define BIT_I2C_SLV2_DLY_EN 0x04
|
||||
# define BIT_I2C_SLV3_DLY_EN 0x08
|
||||
#define INV2REG_I2C_SLV0_ADDR INV2REG(INV2_BANK3,0x03U)
|
||||
#define INV2REG_I2C_SLV0_REG INV2REG(INV2_BANK3,0x04U)
|
||||
#define INV2REG_I2C_SLV0_CTRL INV2REG(INV2_BANK3,0x05U)
|
||||
#define INV2REG_I2C_SLV0_DO INV2REG(INV2_BANK3,0x06U)
|
||||
#define INV2REG_I2C_SLV1_ADDR INV2REG(INV2_BANK3,0x07U)
|
||||
#define INV2REG_I2C_SLV1_REG INV2REG(INV2_BANK3,0x08U)
|
||||
#define INV2REG_I2C_SLV1_CTRL INV2REG(INV2_BANK3,0x09U)
|
||||
#define INV2REG_I2C_SLV1_DO INV2REG(INV2_BANK3,0x0AU)
|
||||
#define INV2REG_I2C_SLV2_ADDR INV2REG(INV2_BANK3,0x0BU)
|
||||
#define INV2REG_I2C_SLV2_REG INV2REG(INV2_BANK3,0x0CU)
|
||||
#define INV2REG_I2C_SLV2_CTRL INV2REG(INV2_BANK3,0x0DU)
|
||||
#define INV2REG_I2C_SLV2_DO INV2REG(INV2_BANK3,0x0EU)
|
||||
#define INV2REG_I2C_SLV3_ADDR INV2REG(INV2_BANK3,0x0FU)
|
||||
#define INV2REG_I2C_SLV3_REG INV2REG(INV2_BANK3,0x10U)
|
||||
#define INV2REG_I2C_SLV3_CTRL INV2REG(INV2_BANK3,0x11U)
|
||||
#define INV2REG_I2C_SLV3_DO INV2REG(INV2_BANK3,0x12U)
|
||||
#define INV2REG_I2C_SLV4_ADDR INV2REG(INV2_BANK3,0x13U)
|
||||
#define INV2REG_I2C_SLV4_REG INV2REG(INV2_BANK3,0x14U)
|
||||
#define INV2REG_I2C_SLV4_CTRL INV2REG(INV2_BANK3,0x15U)
|
||||
#define INV2REG_I2C_SLV4_DO INV2REG(INV2_BANK3,0x16U)
|
||||
#define INV2REG_I2C_SLV4_DI INV2REG(INV2_BANK3,0x17U)
|
||||
|
||||
#define INV2REG_BANK_SEL 0x7F
|
||||
|
||||
// WHOAMI values
|
||||
#define INV2_WHOAMI_ICM20648 0xe0
|
||||
#define INV2_WHOAMI_ICM20948 0xea
|
||||
#define INV2_WHOAMI_ICM20649 0xe1
|
||||
|
||||
#endif /* INVENSENSE2_REGS_H */
|
||||
Reference in New Issue
Block a user