Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for the Invensense V2 IMUs ICM20948, ICM20648 and ICM20649. More...
#include "peripherals/invensense2.h"
#include "peripherals/invensense2_regs.h"
#include "math/pprz_isa.h"
#include "math/pprz_algebra_int.h"
#include "modules/imu/imu.h"
#include "modules/core/abi.h"
#include "mcu_periph/gpio_arch.h"
Go to the source code of this file.
Functions | |
static void | invensense2_parse_data (struct invensense2_t *inv, volatile uint8_t *data, uint16_t len) |
Parse the FIFO buffer data. More... | |
static void | invensense2_fix_config (struct invensense2_t *inv) |
This fixes the configuration errors and sets the correct scalings. More... | |
static bool | invensense2_register_write (struct invensense2_t *inv, uint16_t bank_reg, uint8_t value) |
Write a register based on a combined bank/regsiter value. More... | |
static bool | invensense2_register_read (struct invensense2_t *inv, uint16_t bank_reg, uint16_t size) |
Read a register based on a combined bank/regsiter value. More... | |
static bool | invensense2_select_bank (struct invensense2_t *inv, uint8_t bank) |
Select the correct register bank. More... | |
static bool | invensense2_config (struct invensense2_t *inv) |
Configure the Invensense 2 device register by register. More... | |
void | invensense2_init (struct invensense2_t *inv) |
Initialize the invensense v2 sensor instance. More... | |
void | invensense2_periodic (struct invensense2_t *inv) |
Should be called periodically to request sensor readings. More... | |
void | invensense2_event (struct invensense2_t *inv) |
Should be called in the event thread. More... | |
Variables | |
static const struct Int32Rates | invensense2_gyro_scale [5][2] |
static const struct Int32Vect3 | invensense2_accel_scale [5][2] |
Driver for the Invensense V2 IMUs ICM20948, ICM20648 and ICM20649.
Definition in file invensense2.c.
|
static |
Configure the Invensense 2 device register by register.
inv | The invensense v2 instance |
Definition at line 457 of file invensense2.c.
References invensense2_t::accel_dlpf, ACCEL_DLPF_CFG_SHIFT, ACCEL_FS_SEL_SHIFT, invensense2_t::accel_range, BIT_ACCEL_DLPF_ENABLE, BIT_ACCEL_FIFO_EN, BIT_GYRO_DLPF_ENABLE, BIT_PWR_MGMT_1_CLK_AUTO, BIT_PWR_MGMT_1_DEVICE_RESET, BIT_TEMP_FIFO_EN, BIT_USER_CTRL_FIFO_EN, BIT_USER_CTRL_I2C_IF_DIS, BIT_USER_CTRL_I2C_MST_RESET, BIT_USER_CTRL_SRAM_RESET, BIT_XG_FIFO_EN, BIT_YG_FIFO_EN, BIT_ZG_FIFO_EN, invensense2_t::bus, invensense2_t::config_idx, invensense2_t::device, get_sys_time_usec(), invensense2_t::gyro_dlpf, GYRO_DLPF_CFG_SHIFT, GYRO_FS_SEL_SHIFT, invensense2_t::gyro_range, INV2REG_ACCEL_CONFIG, INV2REG_FIFO_EN_2, INV2REG_FIFO_MODE, INV2REG_FIFO_RST, INV2REG_GYRO_CONFIG_1, INV2REG_GYRO_SMPLRT_DIV, INV2REG_INT_ENABLE_1, INV2REG_PWR_MGMT_1, INV2REG_TIMEBASE_CORRECTIO, INV2REG_USER_CTRL, INVENSENSE2_ACCEL_DLPF_OFF, INVENSENSE2_GYRO_DLPF_OFF, INVENSENSE2_ICM20649, invensense2_register_read(), invensense2_register_write(), INVENSENSE2_SPI, invensense2_t::timebase_correction_pll, and invensense2_t::timer.
Referenced by invensense2_event(), and invensense2_periodic().
void invensense2_event | ( | struct invensense2_t * | inv | ) |
Should be called in the event thread.
inv | The invensense v2 instance |
Definition at line 152 of file invensense2.c.
References invensense2_t::bus, invensense2_t::config_idx, invensense2_t::device, I2CTransDone, I2CTransFailed, I2CTransSuccess, INV2_WHOAMI_ICM20648, INV2_WHOAMI_ICM20649, INV2_WHOAMI_ICM20948, INV2REG_BANK_SEL, INV2REG_FIFO_COUNTH, invensense2_config(), INVENSENSE2_CONFIG, invensense2_fix_config(), INVENSENSE2_I2C, INVENSENSE2_ICM20648, INVENSENSE2_ICM20649, INVENSENSE2_ICM20948, INVENSENSE2_IDLE, invensense2_parse_data(), invensense2_register_read(), INVENSENSE2_RUNNING, INVENSENSE2_SAMPLE_SIZE, INVENSENSE2_SPI, invensense2_t::register_bank, SPITransDone, SPITransFailed, SPITransSuccess, invensense2_t::status, and invensense2_t::timer.
Referenced by imu_cube_event(), and imu_pixhawk6x_event().
|
static |
This fixes the configuration errors and sets the correct scalings.
inv | The invensense v2 instance |
Definition at line 326 of file invensense2.c.
References invensense2_t::abi_id, invensense2_t::accel_range, invensense2_t::device, invensense2_t::gyro_range, imu_set_defaults_accel(), imu_set_defaults_gyro(), INVENSENSE2_ACCEL_RANGE_16G, INVENSENSE2_ACCEL_RANGE_2G, INVENSENSE2_ACCEL_RANGE_30G, INVENSENSE2_ACCEL_RANGE_4G, invensense2_accel_scale, INVENSENSE2_GYRO_RANGE_2000DPS, INVENSENSE2_GYRO_RANGE_250DPS, INVENSENSE2_GYRO_RANGE_4000DPS, INVENSENSE2_GYRO_RANGE_500DPS, invensense2_gyro_scale, and INVENSENSE2_ICM20649.
Referenced by invensense2_event().
void invensense2_init | ( | struct invensense2_t * | inv | ) |
Initialize the invensense v2 sensor instance.
inv | The structure containing the configuration of the invensense v2 instance |
Definition at line 79 of file invensense2.c.
References invensense2_t::bus, invensense2_t::config_idx, invensense2_t::device, I2CTransDone, INVENSENSE2_IDLE, INVENSENSE2_SPI, INVENSENSE2_UNKOWN, invensense2_t::register_bank, SPICphaEdge2, SPICpolIdleHigh, SPIDiv16, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, SPITransDone, and invensense2_t::status.
Referenced by imu_cube_init(), and imu_pixhawk6x_init().
|
static |
Parse the FIFO buffer data.
inv | The invensense v2 instance |
data | The FIFO buffer data to parse |
len | The length of the FIFO buffer |
Definition at line 277 of file invensense2.c.
References invensense2_t::abi_id, invensense2_t::accel_dlpf, get_sys_time_usec(), invensense2_t::gyro_dlpf, INVENSENSE2_ACCEL_DLPF_OFF, INVENSENSE2_GYRO_DLPF_OFF, INVENSENSE2_SAMPLE_CNT, INVENSENSE2_SAMPLE_SIZE, Int32Rates::p, Int32Rates::q, Int32Rates::r, invensense2_t::timebase_correction_pll, Int32Vect3::x, Int32Vect3::y, and Int32Vect3::z.
Referenced by invensense2_event().
void invensense2_periodic | ( | struct invensense2_t * | inv | ) |
Should be called periodically to request sensor readings.
inv | The invensense v2 instance |
Definition at line 119 of file invensense2.c.
References invensense2_t::bus, I2CTransDone, INV2REG_FIFO_COUNTH, INV2REG_WHO_AM_I, invensense2_config(), INVENSENSE2_CONFIG, INVENSENSE2_I2C, INVENSENSE2_IDLE, invensense2_register_read(), INVENSENSE2_RUNNING, INVENSENSE2_SPI, SPITransDone, and invensense2_t::status.
Referenced by imu_cube_periodic(), and imu_pixhawk6x_periodic().
|
static |
Read a register based on a combined bank/regsiter value.
inv | The invensense v2 instance |
bank_reg | The bank is shifted 8 bits left, adn register is &0xFF |
size | The size to read (already 1 is added for the transmission of the register to read) |
Definition at line 392 of file invensense2.c.
References invensense2_t::bus, i2c_transceive(), INV2_READ_FLAG, invensense2_select_bank(), INVENSENSE2_SPI, and spi_submit().
Referenced by invensense2_config(), invensense2_event(), and invensense2_periodic().
|
static |
Write a register based on a combined bank/regsiter value.
inv | The invensense v2 instance |
bank_reg | The bank is shifted 8 bits left, adn register is &0xFF |
value | The value to write to the register |
Definition at line 355 of file invensense2.c.
References invensense2_t::bus, i2c_transmit(), invensense2_select_bank(), INVENSENSE2_SPI, and spi_submit().
Referenced by invensense2_config().
|
static |
Select the correct register bank.
inv | The invensense v2 instance |
bank | The bank ID to select |
Definition at line 427 of file invensense2.c.
References invensense2_t::bus, i2c_transmit(), INV2REG_BANK_SEL, INVENSENSE2_SPI, invensense2_t::register_bank, and spi_submit().
Referenced by invensense2_register_read(), and invensense2_register_write().
|
static |
Definition at line 44 of file invensense2.c.
Referenced by invensense2_fix_config().
|
static |
Definition at line 44 of file invensense2.c.
Referenced by invensense2_fix_config().