|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for the Invensense v3 IMUs ICM40605, ICM40609, ICM42605, IIM42652 and ICM42688. More...
#include "peripherals/invensense3.h"#include "peripherals/invensense3_regs.h"#include "math/pprz_isa.h"#include "math/pprz_algebra_int.h"#include "math/pprz_algebra_float.h"#include "modules/imu/imu.h"#include "modules/core/abi.h"#include "mcu_periph/sys_time.h"#include "mcu_periph/gpio_arch.h"#include "std.h"Go to the source code of this file.
Functions | |
| static void | invensense3_parse_fifo_data (struct invensense3_t *inv, uint8_t *data, uint16_t samples) |
| Parse the FIFO buffer data. | |
| static void | invensense3_parse_reg_data (struct invensense3_t *inv, uint8_t *data) |
| Parse data from registers. | |
| static void | invensense3_fix_config (struct invensense3_t *inv) |
| This fixes the configuration errors and sets the correct scalings. | |
| static bool | invensense3_register_write (struct invensense3_t *inv, uint16_t bank_reg, uint8_t value) |
| Write a register based on a combined bank/regsiter value. | |
| static bool | invensense3_register_read (struct invensense3_t *inv, uint16_t bank_reg, uint16_t size) |
| Read a register based on a combined bank/regsiter value. | |
| static bool | invensense3_select_bank (struct invensense3_t *inv, uint8_t bank) |
| Select the correct register bank. | |
| static bool | invensense3_config (struct invensense3_t *inv) |
| Configure the Invensense 3 device register by register. | |
| static bool | invensense3_reset_fifo (struct invensense3_t *inv) |
| Reset FIFO (can be useful in some situations). | |
| static int | samples_from_odr (int odr) |
| void | invensense3_init (struct invensense3_t *inv) |
| Initialize the invensense v3 sensor instance. | |
| void | invensense3_periodic (struct invensense3_t *inv) |
| Should be called periodically to request sensor readings. | |
| void | invensense3_event (struct invensense3_t *inv) |
| Should be called in the event thread. | |
Variables | |
| static const struct FloatRates | invensense3_gyro_scale_f [8] |
| static const struct FloatVect3 | invensense3_accel_scale_f [5] |
| static const uint16_t | invensense3_aaf [][4] |
| static const uint16_t | invensense3_aaf4x605 [][4] |
| static const uint8_t | invensense3_fifo_sample_size [4] = {8,8,16,20} |
Driver for the Invensense v3 IMUs ICM40605, ICM40609, ICM42605, IIM42652 and ICM42688.
Definition in file invensense3.c.
|
static |
Configure the Invensense 3 device register by register.
| inv | The invensense v3 instance |
Definition at line 820 of file invensense3.c.
References ACCEL_AAF_BITSHIFT_SHIFT, ACCEL_AAF_DELT_SHIFT, invensense3_t::accel_aaf_regs, ACCEL_FS_SEL_SHIFT, ACCEL_MODE_LN, ACCEL_MODE_SHIFT, invensense3_t::accel_odr, ACCEL_ODR_SHIFT, invensense3_t::accel_range, BIT_DEVICE_CONFIG_SOFT_RESET_CONFIG, BIT_FIFO_CONFIG1_ACCEL_EN, BIT_FIFO_CONFIG1_GYRO_EN, BIT_FIFO_CONFIG1_TEMP_EN, BIT_FIFO_FULL_INT_EN, BIT_FIFO_THS_INT_EN, BIT_INT_ASYNC_RESET, BIT_UI_DRDY_INT_EN, invensense3_t::config_idx, invensense3_t::device, FIFO_CONFIG_MODE_SHIFT, FIFO_CONFIG_MODE_STOP_ON_FULL, FIFO_COUNT_REC, get_sys_time_usec(), GYRO_AAF_BITSHIFT_SHIFT, invensense3_t::gyro_aaf_regs, GYRO_FS_SEL_SHIFT, GYRO_MODE_LN, GYRO_MODE_SHIFT, invensense3_t::gyro_odr, GYRO_ODR_SHIFT, invensense3_t::gyro_range, INV3REG_ACCEL_CONFIG0, INV3REG_ACCEL_CONFIG_STATIC2, INV3REG_ACCEL_CONFIG_STATIC3, INV3REG_ACCEL_CONFIG_STATIC4, INV3REG_DEVICE_CONFIG, INV3REG_FIFO_CONFIG, INV3REG_FIFO_CONFIG1, INV3REG_FIFO_CONFIG2, INV3REG_FIFO_CONFIG3, INV3REG_GYRO_CONFIG0, INV3REG_GYRO_CONFIG_STATIC2, INV3REG_GYRO_CONFIG_STATIC3, INV3REG_GYRO_CONFIG_STATIC4, INV3REG_GYRO_CONFIG_STATIC5, INV3REG_INT_CONFIG1, INV3REG_INT_SOURCE0, INV3REG_INTF_CONFIG0, INV3REG_INTF_CONFIG1, INV3REG_PWR_MGMT0, INVENSENSE3_ICM40609, INVENSENSE3_PARSER_FIFO, INVENSENSE3_PARSER_REGISTERS, invensense3_register_write(), invensense3_reset_fifo(), invensense3_t::parser, and invensense3_t::timer.
Referenced by invensense3_event(), and invensense3_periodic().
| void invensense3_event | ( | struct invensense3_t * | inv | ) |
Should be called in the event thread.
| inv | The invensense v3 instance |
Definition at line 318 of file invensense3.c.
References invensense3_t::bus, invensense3_t::config_idx, invensense3_t::device, I2CTransDone, I2CTransFailed, I2CTransSuccess, INV3_WHOAMI_ICM40605, INV3_WHOAMI_ICM40609, INV3_WHOAMI_ICM42605, INV3_WHOAMI_ICM42688, INV3_WHOAMI_IIM42652, INV3REG_BANK_SEL, INV3REG_FIFO_COUNTH, INVENSENSE3_CONFIG, invensense3_config(), invensense3_fifo_sample_size, invensense3_fix_config(), INVENSENSE3_I2C, INVENSENSE3_ICM40605, INVENSENSE3_ICM40609, INVENSENSE3_ICM42605, INVENSENSE3_ICM42688, INVENSENSE3_IDLE, INVENSENSE3_IIM42652, invensense3_parse_fifo_data(), invensense3_parse_reg_data(), INVENSENSE3_PARSER_FIFO, INVENSENSE3_PARSER_REGISTERS, invensense3_register_read(), INVENSENSE3_RUNNING, INVENSENSE3_SPI, Min, n_samples, invensense3_t::parser, invensense3_t::register_bank, invensense3_t::rx_buffer, invensense3_t::rx_length, invensense3_t::sample_size, SPITransDone, SPITransFailed, SPITransSuccess, invensense3_t::status, invensense3_t::timer, and invensense3_t::tx_buffer.
Referenced by imu_cube_event(), imu_icm42688_event(), and imu_pixhawk6x_event().
|
static |
This fixes the configuration errors and sets the correct scalings.
| inv | The invensense v3 instance |
Definition at line 541 of file invensense3.c.
References invensense3_t::abi_id, invensense3_t::accel_aaf, invensense3_t::accel_aaf_regs, invensense3_t::accel_odr, invensense3_t::accel_range, invensense3_t::accel_samplerate, invensense3_t::device, invensense3_t::gyro_aaf, invensense3_t::gyro_aaf_regs, invensense3_t::gyro_odr, invensense3_t::gyro_range, invensense3_t::gyro_samplerate, imu_set_defaults_accel(), imu_set_defaults_gyro(), invensense3_aaf, invensense3_aaf4x605, INVENSENSE3_ACCEL_ODR_100HZ, INVENSENSE3_ACCEL_ODR_12_5HZ, INVENSENSE3_ACCEL_ODR_16KHZ, INVENSENSE3_ACCEL_ODR_1_5625HZ, INVENSENSE3_ACCEL_ODR_1KHZ, INVENSENSE3_ACCEL_ODR_200HZ, INVENSENSE3_ACCEL_ODR_25HZ, INVENSENSE3_ACCEL_ODR_2KHZ, INVENSENSE3_ACCEL_ODR_32KHZ, INVENSENSE3_ACCEL_ODR_3_125HZ, INVENSENSE3_ACCEL_ODR_4KHZ, INVENSENSE3_ACCEL_ODR_500HZ, INVENSENSE3_ACCEL_ODR_50HZ, INVENSENSE3_ACCEL_ODR_6_25HZ, INVENSENSE3_ACCEL_ODR_8KHZ, INVENSENSE3_ACCEL_RANGE_16G, INVENSENSE3_ACCEL_RANGE_4G, invensense3_accel_scale_f, INVENSENSE3_GYRO_ODR_100HZ, INVENSENSE3_GYRO_ODR_12_5HZ, INVENSENSE3_GYRO_ODR_16KHZ, INVENSENSE3_GYRO_ODR_1_5625HZ, INVENSENSE3_GYRO_ODR_1KHZ, INVENSENSE3_GYRO_ODR_200HZ, INVENSENSE3_GYRO_ODR_25HZ, INVENSENSE3_GYRO_ODR_2KHZ, INVENSENSE3_GYRO_ODR_32KHZ, INVENSENSE3_GYRO_ODR_3_125HZ, INVENSENSE3_GYRO_ODR_4KHZ, INVENSENSE3_GYRO_ODR_500HZ, INVENSENSE3_GYRO_ODR_50HZ, INVENSENSE3_GYRO_ODR_6_25HZ, INVENSENSE3_GYRO_ODR_8KHZ, invensense3_gyro_scale_f, INVENSENSE3_ICM40605, INVENSENSE3_ICM40609, INVENSENSE3_ICM42605, and RMAT_COPY.
Referenced by invensense3_event().
| void invensense3_init | ( | struct invensense3_t * | inv | ) |
Initialize the invensense v3 sensor instance.
| inv | The structure containing the configuration of the invensense v3 instance |
Definition at line 212 of file invensense3.c.
References invensense3_t::accel_odr, invensense3_t::bus, invensense3_t::config_idx, invensense3_t::device, invensense3_t::fifo_cnt, invensense3_t::gyro_odr, I2CTransDone, INVENSENSE3_IDLE, INVENSENSE3_SAMPLE_SIZE_PK3, INVENSENSE3_SPI, INVENSENSE3_UNKOWN, Min, invensense3_t::register_bank, invensense3_t::rx_buffer, invensense3_t::rx_length, invensense3_t::sample_numbers, invensense3_t::sample_size, samples_from_odr(), SPICphaEdge2, SPICpolIdleHigh, SPIDiv16, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, SPITransDone, invensense3_t::status, and invensense3_t::tx_buffer.
Referenced by imu_cube_init(), imu_icm42688_init(), and imu_pixhawk6x_init().
|
static |
Parse the FIFO buffer data.
| inv | The invensense v3 instance |
| data | The FIFO buffer data to parse |
| len | The length of the FIFO buffer |
Definition at line 450 of file invensense3.c.
References invensense3_t::abi_id, invensense3_t::accel_samplerate, invensense3_t::fifo_cnt, get_sys_time_usec(), invensense3_t::gyro_samplerate, INVENSENSE3_FIFO_BUFFER_LEN, invensense3_fifo_sample_size, Min, Int32Rates::p, Int32Rates::q, Int32Rates::r, invensense3_t::sample_size, TEMPERATURE_TYPE_IMU, Int32Vect3::x, Int32Vect3::y, and Int32Vect3::z.
Referenced by invensense3_event().
|
static |
Parse data from registers.
| inv | The invensense v3 instance |
| data | The data from all registers (DATA_TEMP, DATA_ACCEL and DATA_GYRO) |
Definition at line 513 of file invensense3.c.
References invensense3_t::abi_id, invensense3_t::accel_samplerate, get_sys_time_usec(), invensense3_t::gyro_samplerate, Int32Rates::p, Int32Rates::q, Int32Rates::r, TEMPERATURE_TYPE_IMU, Int32Vect3::x, Int32Vect3::y, and Int32Vect3::z.
Referenced by invensense3_event().
| void invensense3_periodic | ( | struct invensense3_t * | inv | ) |
Should be called periodically to request sensor readings.
| inv | The invensense v3 instance |
Definition at line 265 of file invensense3.c.
References invensense3_t::bus, I2CTransDone, INV3REG_FIFO_COUNTH, INV3REG_TEMP_DATA1, INV3REG_WHO_AM_I, INVENSENSE3_CONFIG, invensense3_config(), INVENSENSE3_FIFO_BUFFER_LEN, invensense3_fifo_sample_size, INVENSENSE3_I2C, INVENSENSE3_IDLE, INVENSENSE3_PARSER_FIFO, INVENSENSE3_PARSER_REGISTERS, invensense3_register_read(), INVENSENSE3_RUNNING, INVENSENSE3_SPI, Min, invensense3_t::parser, invensense3_t::sample_numbers, invensense3_t::sample_size, SPITransDone, invensense3_t::status, and invensense3_t::timer.
Referenced by imu_cube_periodic(), imu_icm42688_periodic(), and imu_pixhawk6x_periodic().
|
static |
Read a register based on a combined bank/regsiter value.
| inv | The invensense v3 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 746 of file invensense3.c.
References invensense3_t::bus, i2c_transceive(), INV3_READ_FLAG, invensense3_select_bank(), INVENSENSE3_SPI, spi_submit(), and invensense3_t::tx_buffer.
Referenced by invensense3_event(), and invensense3_periodic().
|
static |
Write a register based on a combined bank/regsiter value.
| inv | The invensense v3 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 710 of file invensense3.c.
References invensense3_t::bus, i2c_transmit(), invensense3_select_bank(), INVENSENSE3_SPI, spi_submit(), and invensense3_t::tx_buffer.
Referenced by invensense3_config(), and invensense3_reset_fifo().
|
static |
Reset FIFO (can be useful in some situations).
| inv | The invensense v3 instance |
Definition at line 807 of file invensense3.c.
References BIT_SIGNAL_PATH_RESET_FIFO_FLUSH, INV3REG_SIGNAL_PATH_RESET, and invensense3_register_write().
Referenced by invensense3_config().
|
static |
Select the correct register bank.
| inv | The invensense v3 instance |
| bank | The bank ID to select |
Definition at line 780 of file invensense3.c.
References invensense3_t::bus, i2c_transmit(), INV3REG_BANK_SEL, INVENSENSE3_SPI, invensense3_t::register_bank, spi_submit(), and invensense3_t::tx_buffer.
Referenced by invensense3_register_read(), and invensense3_register_write().
|
static |
Definition at line 964 of file invensense3.c.
References INVENSENSE3_GYRO_ODR_200HZ, INVENSENSE3_GYRO_ODR_32KHZ, and INVENSENSE3_GYRO_ODR_500HZ.
Referenced by invensense3_init().
|
static |
Definition at line 73 of file invensense3.c.
Referenced by invensense3_fix_config().
|
static |
Definition at line 139 of file invensense3.c.
Referenced by invensense3_fix_config().
|
static |
Definition at line 64 of file invensense3.c.
Referenced by invensense3_fix_config().
|
static |
Definition at line 205 of file invensense3.c.
Referenced by invensense3_event(), invensense3_parse_fifo_data(), and invensense3_periodic().
|
static |
Definition at line 52 of file invensense3.c.
Referenced by invensense3_fix_config().