35#include "mcu_periph/gpio_arch.h"
48 {0.545415, 0.545415, 0.545415},
49 {1.09083, 1.09083, 1.09083},
50 {2.18166, 2.18166, 2.18166},
51 {4.36332, 4.36332, 4.36332},
52 {8.72664, 8.72664, 8.72664},
57 {0.61312, 0.61312, 0.61312},
58 {1.22583, 1.22583, 1.22583},
59 {2.4525, 2.4525, 2.4525},
60 {4.905, 4.905, 4.905},
61 {9.196875, 9.196875, 9.196875},
73 inv->register_bank = 0xFF;
85 inv->spi.trans.slave_idx =
inv->spi.slave_idx;
86 inv->spi.trans.output_length = 0;
87 inv->spi.trans.input_length = 0;
88 inv->spi.trans.before_cb =
NULL;
90 inv->spi.trans.input_buf =
inv->spi.rx_buf;
91 inv->spi.trans.output_buf =
inv->spi.tx_buf;
96 inv->i2c.trans.slave_addr =
inv->i2c.slave_addr;
115 switch(
inv->status) {
143 volatile uint8_t *rx_buffer, *tx_buffer;
148 rx_buffer =
inv->spi.rx_buf;
149 tx_buffer =
inv->spi.tx_buf;
150 rx_length =
inv->spi.trans.input_length;
153 rx_buffer =
inv->i2c.trans.buf;
154 tx_buffer =
inv->i2c.trans.buf;
155 rx_length =
inv->i2c.trans.len_r;
164 inv->register_bank =
inv->spi.tx_buf[1] >> 4;
173 switch(
inv->status) {
209 if((rx_length - 3) > 0) {
240 switch(
inv->status) {
277 gyro_samplerate = 1125;
281 accel_samplerate = 1125;
357 inv->spi.trans.output_length = 2;
358 inv->spi.trans.input_length = 0;
359 inv->spi.tx_buf[0] = reg;
360 inv->spi.tx_buf[1] = value;
365 inv->i2c.trans.buf[0] = reg;
366 inv->i2c.trans.buf[1] = value;
394 inv->spi.trans.output_length = 2;
395 inv->spi.trans.input_length = 1 + size;
397 inv->spi.tx_buf[1] = 0;
424 inv->spi.trans.output_length = 2;
425 inv->spi.trans.input_length = 0;
427 inv->spi.tx_buf[1] =
bank << 4;
433 inv->i2c.trans.buf[1] =
bank << 4;
448 switch(
inv->config_idx) {
514 inv->timebase_correction_pll = ((
int8_t)
inv->spi.rx_buf[1]) * 0.079f;
517 inv->timebase_correction_pll = ((
int8_t)
inv->i2c.trans.buf[1]) * 0.079f;
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
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_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct FloatRates *scale_f)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
Inertial Measurement Unit interface.
static const struct FloatVect3 invensense2_accel_scale_f[5]
static bool invensense2_select_bank(struct invensense2_t *inv, uint8_t bank)
Select the correct register bank.
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.
void invensense2_event(struct invensense2_t *inv)
Should be called in the event thread.
static void invensense2_parse_data(struct invensense2_t *inv, volatile uint8_t *data, uint16_t len)
Parse the FIFO buffer data.
void invensense2_periodic(struct invensense2_t *inv)
Should be called periodically to request sensor readings.
static const struct FloatRates invensense2_gyro_scale_f[5]
static bool invensense2_config(struct invensense2_t *inv)
Configure the Invensense 2 device register by register.
static void invensense2_fix_config(struct invensense2_t *inv)
This fixes the configuration errors and sets the correct scalings.
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.
void invensense2_init(struct invensense2_t *inv)
Initialize the invensense v2 sensor instance.
Driver for the Invensense V2 IMUs ICM20948, ICM20648 and ICM20649.
@ INVENSENSE2_GYRO_DLPF_OFF
@ INVENSENSE2_GYRO_RANGE_4000DPS
Only possible for ICM20649.
@ INVENSENSE2_GYRO_RANGE_500DPS
@ INVENSENSE2_GYRO_RANGE_2000DPS
@ INVENSENSE2_GYRO_RANGE_250DPS
Not possible for ICM20649.
@ INVENSENSE2_ACCEL_RANGE_2G
Not possible for ICM20649.
@ INVENSENSE2_ACCEL_RANGE_16G
@ INVENSENSE2_ACCEL_RANGE_4G
@ INVENSENSE2_ACCEL_RANGE_30G
Only possible for ICM20649.
@ INVENSENSE2_ACCEL_DLPF_OFF
#define INVENSENSE2_SAMPLE_CNT
#define INVENSENSE2_SAMPLE_SIZE
Register and address definitions for the Invensense V2 from ardupilot.
#define GYRO_FS_SEL_SHIFT
#define BIT_USER_CTRL_FIFO_EN
#define INV2REG_INT_ENABLE_1
#define INV2REG_FIFO_COUNTH
#define BIT_PWR_MGMT_1_CLK_AUTO
#define INV2_WHOAMI_ICM20948
#define BIT_ACCEL_DLPF_ENABLE
#define INV2_WHOAMI_ICM20648
#define ACCEL_DLPF_CFG_SHIFT
#define INV2REG_ACCEL_CONFIG
#define BIT_USER_CTRL_I2C_IF_DIS
#define INV2REG_PWR_MGMT_1
#define BIT_USER_CTRL_I2C_MST_RESET
#define INV2REG_GYRO_CONFIG_1
#define INV2REG_TIMEBASE_CORRECTIO
#define INV2REG_FIFO_MODE
#define INV2REG_FIFO_EN_2
#define INV2REG_USER_CTRL
#define ACCEL_FS_SEL_SHIFT
#define GYRO_DLPF_CFG_SHIFT
#define BIT_USER_CTRL_SRAM_RESET
#define BIT_ACCEL_FIFO_EN
#define INV2REG_GYRO_SMPLRT_DIV
#define BIT_GYRO_DLPF_ENABLE
#define BIT_PWR_MGMT_1_DEVICE_RESET
#define INV2_WHOAMI_ICM20649
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.