35#include "mcu_periph/gpio_arch.h"
51 { {40147, 40147, 40147},
53 { {40147, 40147, 40147},
54 {18420, 18420, 18420} },
55 { {60534, 60534, 60534},
56 {55463, 55463, 55463} },
57 { {30267, 30267, 30267},
58 {55463, 55463, 55463} },
59 { {30267, 30267, 30267},
60 {110926, 110926, 110926} },
61 { {3292054, 3292054, 3292054},
62 {24144015, 24144015, 24144015} },
63 { {1646027, 1646027, 1646027},
64 {24144015, 24144015, 24144015} },
65 { {1646027, 1646027, 1646027},
66 {48288030, 48288030, 48288030} },
71 { {51024, 51024, 51024},
73 { {25512, 25512, 25512},
75 { {12756, 12756, 12756},
227 inv->register_bank = 0xFF;
239 inv->spi.trans.slave_idx =
inv->spi.slave_idx;
240 inv->spi.trans.output_length = 0;
241 inv->spi.trans.input_length = 0;
242 inv->spi.trans.before_cb =
NULL;
243 inv->spi.trans.after_cb =
NULL;
244 inv->spi.trans.input_buf =
inv->spi.rx_buf;
245 inv->spi.trans.output_buf =
inv->spi.tx_buf;
248 inv->rx_buffer =
inv->spi.rx_buf;
249 inv->tx_buffer =
inv->spi.tx_buf;
250 inv->rx_length = &
inv->spi.trans.input_length;
254 inv->i2c.trans.slave_addr =
inv->i2c.slave_addr;
259 inv->rx_length = &
inv->i2c.trans.len_r;
281 switch(
inv->status) {
296 switch (
inv->parser) {
335 inv->register_bank =
inv->tx_buffer[1];
344 switch(
inv->status) {
376 switch (
inv->parser) {
400 if(*
inv->rx_length > 3) {
431 switch(
inv->status) {
465 uint8_t accel_samplerate = 17 -
inv->accel_odr;
468 if (accel_samplerate > gyro_samplerate)
479 if ((data[0] & 0xFC) != 0x68) {
618 switch(
inv->gyro_odr) {
620 inv->gyro_samplerate = 32000;
623 inv->gyro_samplerate = 16000;
626 inv->gyro_samplerate = 8000;
629 inv->gyro_samplerate = 4000;
632 inv->gyro_samplerate = 2000;
635 inv->gyro_samplerate = 1000;
638 inv->gyro_samplerate = 200;
641 inv->gyro_samplerate = 100;
644 inv->gyro_samplerate = 50;
647 inv->gyro_samplerate = 25;
650 inv->gyro_samplerate = 12.5;
653 inv->gyro_samplerate = 6.25;
656 inv->gyro_samplerate = 3.125;
659 inv->gyro_samplerate = 1.5625;
662 inv->gyro_samplerate = 500;
665 switch(
inv->accel_odr) {
667 inv->accel_samplerate = 32000;
670 inv->accel_samplerate = 16000;
673 inv->accel_samplerate = 8000;
676 inv->accel_samplerate = 4000;
679 inv->accel_samplerate = 2000;
682 inv->accel_samplerate = 1000;
685 inv->accel_samplerate = 200;
688 inv->accel_samplerate = 100;
691 inv->accel_samplerate = 50;
694 inv->accel_samplerate = 25;
697 inv->accel_samplerate = 12.5;
700 inv->accel_samplerate = 6.25;
703 inv->accel_samplerate = 3.125;
706 inv->accel_samplerate = 1.5625;
709 inv->accel_samplerate = 500;
737 inv->tx_buffer[0] = reg;
738 inv->tx_buffer[1] = value;
742 inv->spi.trans.output_length = 2;
743 inv->spi.trans.input_length = 0;
776 inv->spi.trans.output_length = 2;
777 inv->spi.trans.input_length = 1 + size;
778 inv->tx_buffer[1] = 0;
806 inv->spi.trans.output_length = 2;
807 inv->spi.trans.input_length = 0;
838 switch(
inv->config_idx) {
949 switch(
inv->parser) {
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
#define RMAT_COPY(_o, _i)
int32_t p
in rad/s with INT32_RATE_FRAC
int32_t r
in rad/s with INT32_RATE_FRAC
int32_t q
in rad/s with INT32_RATE_FRAC
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelectUnselect
slave is selected before transaction and unselected after
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct Int32Rates *scale)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
Inertial Measurement Unit interface.
#define GYRO_FS_SEL_SHIFT
#define ACCEL_FS_SEL_SHIFT
static const uint16_t invensense3_aaf4x605[][4]
static const struct Int32Vect3 invensense3_accel_scale[5][2]
void invensense3_periodic(struct invensense3_t *inv)
Should be called periodically to request sensor readings.
static void invensense3_parse_fifo_data(struct invensense3_t *inv, uint8_t *data, uint16_t samples)
Parse the FIFO buffer data.
static int samples_from_odr(int odr)
static const uint8_t invensense3_fifo_sample_size[4]
static const uint16_t invensense3_aaf[][4]
static void invensense3_parse_reg_data(struct invensense3_t *inv, uint8_t *data)
Parse data from registers.
static bool invensense3_reset_fifo(struct invensense3_t *inv)
Reset FIFO (can be useful in some situations)
static bool invensense3_select_bank(struct invensense3_t *inv, uint8_t bank)
Select the correct register bank.
void invensense3_event(struct invensense3_t *inv)
Should be called in the event thread.
static bool invensense3_config(struct invensense3_t *inv)
Configure the Invensense 3 device register by register.
static void invensense3_fix_config(struct invensense3_t *inv)
This fixes the configuration errors and sets the correct scalings.
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 const struct Int32Rates invensense3_gyro_scale[8][2]
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.
void invensense3_init(struct invensense3_t *inv)
Initialize the invensense v3 sensor instance.
Driver for the Invensense V3 IMUs ICM40605, ICM40609, ICM42605, IIM42652 and ICM42688.
@ INVENSENSE3_ACCEL_RANGE_16G
@ INVENSENSE3_ACCEL_RANGE_4G
@ INVENSENSE3_GYRO_ODR_4KHZ
@ INVENSENSE3_GYRO_ODR_25HZ
@ INVENSENSE3_GYRO_ODR_500HZ
@ INVENSENSE3_GYRO_ODR_8KHZ
@ INVENSENSE3_GYRO_ODR_1_5625HZ
@ INVENSENSE3_GYRO_ODR_100HZ
@ INVENSENSE3_GYRO_ODR_2KHZ
@ INVENSENSE3_GYRO_ODR_50HZ
@ INVENSENSE3_GYRO_ODR_1KHZ
@ INVENSENSE3_GYRO_ODR_16KHZ
Not possible for ICM40605 and ICM42605.
@ INVENSENSE3_GYRO_ODR_32KHZ
Not possible for ICM40605 and ICM42605.
@ INVENSENSE3_GYRO_ODR_3_125HZ
@ INVENSENSE3_GYRO_ODR_6_25HZ
@ INVENSENSE3_GYRO_ODR_200HZ
@ INVENSENSE3_GYRO_ODR_12_5HZ
@ INVENSENSE3_PARSER_FIFO
@ INVENSENSE3_PARSER_REGISTERS
@ INVENSENSE3_ACCEL_ODR_4KHZ
@ INVENSENSE3_ACCEL_ODR_16KHZ
Not possible for ICM40605 and ICM42605.
@ INVENSENSE3_ACCEL_ODR_50HZ
@ INVENSENSE3_ACCEL_ODR_32KHZ
Not possible for ICM40605 and ICM42605.
@ INVENSENSE3_ACCEL_ODR_2KHZ
@ INVENSENSE3_ACCEL_ODR_25HZ
@ INVENSENSE3_ACCEL_ODR_1_5625HZ
@ INVENSENSE3_ACCEL_ODR_8KHZ
@ INVENSENSE3_ACCEL_ODR_6_25HZ
@ INVENSENSE3_ACCEL_ODR_200HZ
@ INVENSENSE3_ACCEL_ODR_100HZ
@ INVENSENSE3_ACCEL_ODR_1KHZ
@ INVENSENSE3_ACCEL_ODR_500HZ
@ INVENSENSE3_ACCEL_ODR_12_5HZ
@ INVENSENSE3_ACCEL_ODR_3_125HZ
@ INVENSENSE3_SAMPLE_SIZE_PK3
#define INVENSENSE3_FIFO_BUFFER_LEN
Register and address definitions for the Invensense V3 from ardupilot.
#define INV3REG_INTF_CONFIG1
#define FIFO_CONFIG_MODE_SHIFT
#define INV3REG_FIFO_CONFIG
#define FIFO_CONFIG_MODE_STOP_ON_FULL
#define INV3REG_GYRO_CONFIG_STATIC2
#define INV3REG_ACCEL_CONFIG_STATIC2
#define BIT_FIFO_CONFIG1_ACCEL_EN
#define INV3_WHOAMI_ICM42605
#define BIT_FIFO_CONFIG1_GYRO_EN
#define INV3REG_FIFO_CONFIG3
#define ACCEL_AAF_BITSHIFT_SHIFT
#define INV3REG_PWR_MGMT0
#define INV3REG_INT_CONFIG1
#define BIT_SIGNAL_PATH_RESET_FIFO_FLUSH
#define INV3REG_FIFO_CONFIG1
#define BIT_FIFO_FULL_INT_EN
#define ACCEL_AAF_DELT_SHIFT
#define BIT_FIFO_CONFIG1_TEMP_EN
#define INV3REG_INTF_CONFIG0
#define INV3REG_INT_SOURCE0
#define INV3_WHOAMI_ICM42688
#define GYRO_AAF_BITSHIFT_SHIFT
#define INV3REG_TEMP_DATA1
#define INV3_WHOAMI_ICM40605
#define BIT_INT_ASYNC_RESET
#define INV3REG_DEVICE_CONFIG
#define INV3REG_GYRO_CONFIG_STATIC3
#define BIT_FIFO_THS_INT_EN
#define INV3REG_ACCEL_CONFIG_STATIC4
#define INV3REG_GYRO_CONFIG_STATIC5
#define INV3REG_GYRO_CONFIG_STATIC4
#define BIT_UI_DRDY_INT_EN
#define INV3_WHOAMI_IIM42652
#define INV3REG_ACCEL_CONFIG_STATIC3
#define INV3REG_ACCEL_CONFIG0
#define BIT_DEVICE_CONFIG_SOFT_RESET_CONFIG
#define INV3REG_FIFO_CONFIG2
#define INV3REG_FIFO_COUNTH
#define INV3_WHOAMI_ICM40609
#define INV3REG_SIGNAL_PATH_RESET
#define INV3REG_GYRO_CONFIG0
Paparazzi fixed point algebra.
Paparazzi atmospheric pressure conversion utilities.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.