|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for the Invensense 456XY IMUs: More...
#include "peripherals/invensense3_456.h"#include "peripherals/invensense3_456_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"#include <string.h>#include "modules/datalink/telemetry.h"Go to the source code of this file.
Functions | |
| static void | invensense3_456_parse_fifo_data (struct invensense3_456_t *inv, uint8_t *data, uint16_t samples) |
| Parse the FIFO buffer data. | |
| static void | invensense3_456_set_scalings (struct invensense3_456_t *inv) |
| This sets the correct scalings. | |
| static bool | invensense3_456_register_write (struct invensense3_456_t *inv, uint8_t reg, uint8_t value) |
| Write a register. | |
| static bool | invensense3_456_register_read (struct invensense3_456_t *inv, uint8_t reg, uint16_t size) |
| Read a register based on a combined bank/regsiter value. | |
| static bool | invensense3_456_config (struct invensense3_456_t *inv) |
| Configure the Invensense 3 device register by register. | |
| static int | samples_from_odr (int odr) |
| void | invensense3_456_init (struct invensense3_456_t *inv) |
| Initialize the invensense v3 sensor instance. | |
| void | invensense3_456_periodic (struct invensense3_456_t *inv) |
| Should be called periodically to request sensor readings. | |
| void | invensense3_456_event (struct invensense3_456_t *inv) |
| Should be called in the event thread. | |
| static int32_t | reassemble_uint20 (uint8_t msb, uint8_t bits, uint8_t lsb) |
| static bool | invensense3_register_write_bank (struct invensense3_456_t *inv, uint16_t bank_addr, uint16_t reg, uint8_t val) |
| Write to a register in a specific bank. | |
|
static |
Configure the Invensense 3 device register by register.
| inv | The invensense v3 instance |
Definition at line 415 of file invensense3_456.c.
References ACCEL_FS_SEL_SHIFT, ACCEL_ODR_SHIFT, invensense3_456_t::config_idx, get_sys_time_usec(), GYRO_FS_SEL_SHIFT, GYRO_ODR_SHIFT, invensense3_456_t::imu_odr, INV3BANK_456_IPREG_SYS1_ADDR, INV3BANK_456_IPREG_SYS2_ADDR, INV3BANK_456_IPREG_TOP1_ADDR, INV3REG_456_ACCEL_CONFIG0, INV3REG_456_FIFO_CONFIG0, INV3REG_456_FIFO_CONFIG3, INV3REG_456_GYRO_CONFIG0, INV3REG_456_PWR_MGMT0, INV3REG_456_REG_MISC2, INV_456_BASE_FIFO3_CONFIG_VALUE, INV_456_FIFO_IF_EN, invensense3_456_register_write(), invensense3_register_write_bank(), and invensense3_456_t::timer.
Referenced by invensense3_456_event(), and invensense3_456_periodic().
| void invensense3_456_event | ( | struct invensense3_456_t * | inv | ) |
Should be called in the event thread.
| inv | The invensense v3 instance |
Definition at line 138 of file invensense3_456.c.
References invensense3_456_t::device, INV3_456_WHOAMI_ICM45686, INV3REG_456_FIFO_COUNTH, INVENSENSE3_456_CONFIG, invensense3_456_config(), INVENSENSE3_456_ICM45686, INVENSENSE3_456_IDLE, invensense3_456_register_read(), INVENSENSE3_456_RUNNING, invensense3_456_set_scalings(), n_samples, invensense3_456_t::rx_buffer, invensense3_456_t::rx_length, invensense3_456_t::spi, SPITransDone, SPITransFailed, SPITransSuccess, invensense3_456_t::status, spi_transaction::status, invensense3_456_t::timer, and invensense3_456_spi_t::trans.
Referenced by imu_cube_event(), and imu_pixhawk6x_event().
| void invensense3_456_init | ( | struct invensense3_456_t * | inv | ) |
Initialize the invensense v3 sensor instance.
| inv | The structure containing the configuration of the invensense v3 instance |
Definition at line 58 of file invensense3_456.c.
References spi_transaction::after_cb, spi_transaction::before_cb, spi_transaction::bitorder, spi_transaction::cdiv, invensense3_456_t::config_idx, spi_transaction::cpha, spi_transaction::cpol, invensense3_456_t::device, spi_transaction::dss, invensense3_456_t::imu_odr, spi_transaction::input_buf, spi_transaction::input_length, INVENSENSE3_456_IDLE, INVENSENSE3_456_UNKOWN, spi_transaction::output_buf, spi_transaction::output_length, invensense3_456_spi_t::rx_buf, invensense3_456_t::rx_buffer, invensense3_456_t::rx_length, invensense3_456_t::sample_numbers, samples_from_odr(), spi_transaction::select, invensense3_456_spi_t::slave_idx, spi_transaction::slave_idx, invensense3_456_t::spi, SPICphaEdge2, SPICpolIdleHigh, SPIDiv16, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, SPITransDone, invensense3_456_t::status, spi_transaction::status, invensense3_456_spi_t::trans, invensense3_456_spi_t::tx_buf, and invensense3_456_t::tx_buffer.
Referenced by imu_cube_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 248 of file invensense3_456.c.
References invensense3_456_t::abi_id, FIFODataHighRes::accel, FIFODataHighRes::ax, FIFODataHighRes::ay, FIFODataHighRes::az, get_sys_time_usec(), FIFODataHighRes::gx, FIFODataHighRes::gy, FIFODataHighRes::gyro, FIFODataHighRes::gz, FIFODataHighRes::header, invensense3_456_t::imu_samplerate, INVENSENSE3_456_FIFO_BUFFER_LEN, Min, reassemble_uint20(), FIFODataHighRes::temperature, and TEMPERATURE_TYPE_IMU.
| void invensense3_456_periodic | ( | struct invensense3_456_t * | inv | ) |
Should be called periodically to request sensor readings.
| inv | The invensense v3 instance |
Definition at line 96 of file invensense3_456.c.
References INV3REG_456_FIFO_COUNTH, INV3REG_456_WHOAMI, INVENSENSE3_456_CONFIG, invensense3_456_config(), INVENSENSE3_456_IDLE, invensense3_456_register_read(), INVENSENSE3_456_RUNNING, Min, invensense3_456_spi_t::rx_buf, invensense3_456_t::sample_numbers, invensense3_456_t::spi, SPITransDone, invensense3_456_t::status, spi_transaction::status, invensense3_456_t::timer, and invensense3_456_spi_t::trans.
Referenced by imu_cube_periodic(), and imu_pixhawk6x_periodic().
|
static |
Read a register based on a combined bank/regsiter value.
| inv | The invensense v3 instance |
| reg | The address of the register to read |
| size | The size to read (already 1 is added for the transmission of the register to read) |
Definition at line 396 of file invensense3_456.c.
References spi_transaction::input_length, INV3_456_READ_FLAG, spi_transaction::output_length, invensense3_456_spi_t::p, invensense3_456_t::spi, spi_submit(), invensense3_456_spi_t::trans, and invensense3_456_t::tx_buffer.
Referenced by invensense3_456_event(), and invensense3_456_periodic().
|
static |
Write a register.
| inv | The invensense v3 instance |
| reg | The address of the register to write to |
| value | The value to write to the register |
Definition at line 349 of file invensense3_456.c.
References spi_transaction::input_length, spi_transaction::output_length, invensense3_456_spi_t::p, invensense3_456_t::spi, spi_submit(), invensense3_456_spi_t::trans, and invensense3_456_t::tx_buffer.
Referenced by invensense3_456_config().
|
static |
This sets the correct scalings.
| inv | The invensense v3 instance |
Definition at line 297 of file invensense3_456.c.
References invensense3_456_t::abi_id, ACCEL_BFP_OF_REAL, invensense3_456_t::imu_odr, invensense3_456_t::imu_samplerate, imu_set_defaults_accel(), imu_set_defaults_gyro(), INVENSENSE3_456_ODR_100HZ, INVENSENSE3_456_ODR_1_6KHZ, INVENSENSE3_456_ODR_200HZ, INVENSENSE3_456_ODR_25HZ, INVENSENSE3_456_ODR_3_2KHZ, INVENSENSE3_456_ODR_400HZ, INVENSENSE3_456_ODR_50HZ, INVENSENSE3_456_ODR_6_4KHZ, INVENSENSE3_456_ODR_800HZ, and RATE_BFP_OF_REAL.
Referenced by invensense3_456_event().
|
static |
Write to a register in a specific bank.
| inv | The invensense v3 instance |
| bank_addr | The address of the bank to write to |
| reg | The address of the register to write to |
| value | The value to write to the register |
Definition at line 371 of file invensense3_456.c.
References spi_transaction::input_length, INV3REG_456_IREG_ADDRH, spi_transaction::output_length, invensense3_456_spi_t::p, invensense3_456_t::spi, spi_submit(), invensense3_456_spi_t::trans, invensense3_456_t::tx_buffer, and val.
Referenced by invensense3_456_config().
Definition at line 226 of file invensense3_456.c.
Referenced by invensense3_456_parse_fifo_data().
|
static |
Definition at line 495 of file invensense3_456.c.
References INVENSENSE3_456_ODR_100HZ, INVENSENSE3_456_ODR_1_6KHZ, INVENSENSE3_456_ODR_200HZ, INVENSENSE3_456_ODR_25HZ, INVENSENSE3_456_ODR_3_2KHZ, INVENSENSE3_456_ODR_400HZ, INVENSENSE3_456_ODR_50HZ, INVENSENSE3_456_ODR_6_4KHZ, and INVENSENSE3_456_ODR_800HZ.
Referenced by invensense3_456_init().