Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
invensense3.h File Reference

Driver for the Invensense V3 IMUs ICM40605, ICM40609, ICM42605, IIM42652 and ICM42688. More...

#include "std.h"
#include "mcu_periph/spi.h"
#include "mcu_periph/i2c.h"
+ Include dependency graph for invensense3.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  invensense3_spi_t
 
struct  invensense3_i2c_t
 
struct  invensense3_t
 
union  invensense3_t.__unnamed327__
 

Macros

#define INVENSENSE3_FIFO_BUFFER_LEN   22
 
#define INVENSENSE3_BUFFER_SIZE   INVENSENSE3_FIFO_BUFFER_LEN * 20 + 3
 

Enumerations

enum  invensense3_bus_t { INVENSENSE3_SPI , INVENSENSE3_I2C }
 
enum  invensense3_status_t { INVENSENSE3_IDLE , INVENSENSE3_CONFIG , INVENSENSE3_RUNNING }
 
enum  invensense3_parser_t { INVENSENSE3_PARSER_REGISTERS , INVENSENSE3_PARSER_FIFO }
 
enum  invensense3_fifo_packet_t { INVENSENSE3_SAMPLE_SIZE_PK1 , INVENSENSE3_SAMPLE_SIZE_PK2 , INVENSENSE3_SAMPLE_SIZE_PK3 , INVENSENSE3_SAMPLE_SIZE_PK4 }
 
enum  invensense3_device_t {
  INVENSENSE3_UNKOWN , INVENSENSE3_ICM40605 , INVENSENSE3_ICM40609 , INVENSENSE3_ICM42605 ,
  INVENSENSE3_IIM42652 , INVENSENSE3_ICM42688
}
 
enum  invensense3_gyro_odr_t {
  INVENSENSE3_GYRO_ODR_32KHZ = 1 , INVENSENSE3_GYRO_ODR_16KHZ , INVENSENSE3_GYRO_ODR_8KHZ , INVENSENSE3_GYRO_ODR_4KHZ ,
  INVENSENSE3_GYRO_ODR_2KHZ , INVENSENSE3_GYRO_ODR_1KHZ , INVENSENSE3_GYRO_ODR_200HZ , INVENSENSE3_GYRO_ODR_100HZ ,
  INVENSENSE3_GYRO_ODR_50HZ , INVENSENSE3_GYRO_ODR_25HZ , INVENSENSE3_GYRO_ODR_12_5HZ , INVENSENSE3_GYRO_ODR_6_25HZ ,
  INVENSENSE3_GYRO_ODR_3_125HZ , INVENSENSE3_GYRO_ODR_1_5625HZ , INVENSENSE3_GYRO_ODR_500HZ
}
 
enum  invensense3_gyro_range_t {
  INVENSENSE3_GYRO_RANGE_2000DPS , INVENSENSE3_GYRO_RANGE_1000DPS , INVENSENSE3_GYRO_RANGE_500DPS , INVENSENSE3_GYRO_RANGE_250DPS ,
  INVENSENSE3_GYRO_RANGE_125DPS , INVENSENSE3_GYRO_RANGE_62_5DPS , INVENSENSE3_GYRO_RANGE_31_25DPS , INVENSENSE3_GYRO_RANGE_15_625DPS
}
 
enum  invensense3_accel_odr_t {
  INVENSENSE3_ACCEL_ODR_32KHZ = 1 , INVENSENSE3_ACCEL_ODR_16KHZ , INVENSENSE3_ACCEL_ODR_8KHZ , INVENSENSE3_ACCEL_ODR_4KHZ ,
  INVENSENSE3_ACCEL_ODR_2KHZ , INVENSENSE3_ACCEL_ODR_1KHZ , INVENSENSE3_ACCEL_ODR_200HZ , INVENSENSE3_ACCEL_ODR_100HZ ,
  INVENSENSE3_ACCEL_ODR_50HZ , INVENSENSE3_ACCEL_ODR_25HZ , INVENSENSE3_ACCEL_ODR_12_5HZ , INVENSENSE3_ACCEL_ODR_6_25HZ ,
  INVENSENSE3_ACCEL_ODR_3_125HZ , INVENSENSE3_ACCEL_ODR_1_5625HZ , INVENSENSE3_ACCEL_ODR_500HZ
}
 
enum  invensense3_accel_range_t {
  INVENSENSE3_ACCEL_RANGE_32G , INVENSENSE3_ACCEL_RANGE_16G , INVENSENSE3_ACCEL_RANGE_8G , INVENSENSE3_ACCEL_RANGE_4G ,
  INVENSENSE3_ACCEL_RANGE_2G
}
 

Functions

void invensense3_init (struct invensense3_t *inv)
 Initialize the invensense v3 sensor instance. More...
 
void invensense3_periodic (struct invensense3_t *inv)
 Should be called periodically to request sensor readings. More...
 
void invensense3_event (struct invensense3_t *inv)
 Should be called in the event thread. More...
 

Detailed Description

Driver for the Invensense V3 IMUs ICM40605, ICM40609, ICM42605, IIM42652 and ICM42688.

Definition in file invensense3.h.


Data Structure Documentation

◆ invensense3_spi_t

struct invensense3_spi_t

Definition at line 42 of file invensense3.h.

+ Collaboration diagram for invensense3_spi_t:
Data Fields
struct spi_periph * p Peripheral device for communication.
uint8_t rx_buf[INVENSENSE3_BUFFER_SIZE] Receive buffer.
uint8_t slave_idx Slave index used for Slave Select.
struct spi_transaction trans Transaction used during configuration and measurements.
uint8_t tx_buf[2] Transmit buffer.

◆ invensense3_i2c_t

struct invensense3_i2c_t

Definition at line 52 of file invensense3.h.

+ Collaboration diagram for invensense3_i2c_t:
Data Fields
struct i2c_periph * p Peripheral device for communication.
uint8_t slave_addr The I2C slave address on the bus.
struct i2c_transaction trans TRansaction used during configuration and measurements.

◆ invensense3_t

struct invensense3_t

Definition at line 154 of file invensense3.h.

Data Fields
union invensense3_t __unnamed__
uint8_t abi_id The ABI id used to broadcast the device measurements.
uint16_t accel_aaf Accelerometer Anti-alias filter 3dB Bandwidth configuration [Hz].
uint16_t accel_aaf_regs[4] Accelerometer Anti-alias filter register values.
enum invensense3_accel_odr_t accel_odr Accelerometer Output Data Rate configuration.
enum invensense3_accel_range_t accel_range Accelerometer range configuration.
float accel_samplerate Sample rate in Hz from the accel_odr.
enum invensense3_bus_t bus The communication bus used to connect the device SPI/I2C.
uint8_t config_idx The current configuration index.
enum invensense3_device_t device The device type detected.
uint16_t gyro_aaf Gyro Anti-alias filter 3dB Bandwidth configuration [Hz].
uint16_t gyro_aaf_regs[4] Gyro Anti-alias filter register values.
enum invensense3_gyro_odr_t gyro_odr Gyro Output Data Rate configuration.
enum invensense3_gyro_range_t gyro_range Gyro range configuration.
float gyro_samplerate Sample rate in Hz from the gyro_odr.
enum invensense3_parser_t parser Parser of the device.
uint8_t register_bank The current register bank communicating with.
uint8_t * rx_buffer
uint16_t * rx_length
int sample_numbers expected FIFO packet number, assuming reading at PERIODIC_FREQUENCY
enum invensense3_fifo_packet_t sample_size FIFO packet size.
enum invensense3_status_t status Status of the invensense v3 device.
uint32_t timer Used to time operations during configuration (samples left during measuring)
uint8_t * tx_buffer

◆ invensense3_t.__unnamed327__

union invensense3_t.__unnamed327__

Definition at line 161 of file invensense3.h.

Data Fields
struct invensense3_i2c_t i2c I2C specific configuration.
struct invensense3_spi_t spi SPI specific configuration.

Macro Definition Documentation

◆ INVENSENSE3_BUFFER_SIZE

#define INVENSENSE3_BUFFER_SIZE   INVENSENSE3_FIFO_BUFFER_LEN * 20 + 3

Definition at line 39 of file invensense3.h.

◆ INVENSENSE3_FIFO_BUFFER_LEN

#define INVENSENSE3_FIFO_BUFFER_LEN   22

Definition at line 38 of file invensense3.h.

Enumeration Type Documentation

◆ invensense3_accel_odr_t

Enumerator
INVENSENSE3_ACCEL_ODR_32KHZ 

Not possible for ICM40605 and ICM42605.

INVENSENSE3_ACCEL_ODR_16KHZ 

Not possible for ICM40605 and ICM42605.

INVENSENSE3_ACCEL_ODR_8KHZ 
INVENSENSE3_ACCEL_ODR_4KHZ 
INVENSENSE3_ACCEL_ODR_2KHZ 
INVENSENSE3_ACCEL_ODR_1KHZ 
INVENSENSE3_ACCEL_ODR_200HZ 
INVENSENSE3_ACCEL_ODR_100HZ 
INVENSENSE3_ACCEL_ODR_50HZ 
INVENSENSE3_ACCEL_ODR_25HZ 
INVENSENSE3_ACCEL_ODR_12_5HZ 
INVENSENSE3_ACCEL_ODR_6_25HZ 
INVENSENSE3_ACCEL_ODR_3_125HZ 
INVENSENSE3_ACCEL_ODR_1_5625HZ 
INVENSENSE3_ACCEL_ODR_500HZ 

Definition at line 126 of file invensense3.h.

◆ invensense3_accel_range_t

Enumerator
INVENSENSE3_ACCEL_RANGE_32G 

Only possible for ICM40609.

INVENSENSE3_ACCEL_RANGE_16G 
INVENSENSE3_ACCEL_RANGE_8G 
INVENSENSE3_ACCEL_RANGE_4G 
INVENSENSE3_ACCEL_RANGE_2G 

Definition at line 145 of file invensense3.h.

◆ invensense3_bus_t

Enumerator
INVENSENSE3_SPI 
INVENSENSE3_I2C 

Definition at line 59 of file invensense3.h.

◆ invensense3_device_t

Enumerator
INVENSENSE3_UNKOWN 
INVENSENSE3_ICM40605 
INVENSENSE3_ICM40609 
INVENSENSE3_ICM42605 
INVENSENSE3_IIM42652 
INVENSENSE3_ICM42688 

Definition at line 85 of file invensense3.h.

◆ invensense3_fifo_packet_t

Enumerator
INVENSENSE3_SAMPLE_SIZE_PK1 
INVENSENSE3_SAMPLE_SIZE_PK2 
INVENSENSE3_SAMPLE_SIZE_PK3 
INVENSENSE3_SAMPLE_SIZE_PK4 

Definition at line 77 of file invensense3.h.

◆ invensense3_gyro_odr_t

Enumerator
INVENSENSE3_GYRO_ODR_32KHZ 

Not possible for ICM40605 and ICM42605.

INVENSENSE3_GYRO_ODR_16KHZ 

Not possible for ICM40605 and ICM42605.

INVENSENSE3_GYRO_ODR_8KHZ 
INVENSENSE3_GYRO_ODR_4KHZ 
INVENSENSE3_GYRO_ODR_2KHZ 
INVENSENSE3_GYRO_ODR_1KHZ 
INVENSENSE3_GYRO_ODR_200HZ 
INVENSENSE3_GYRO_ODR_100HZ 
INVENSENSE3_GYRO_ODR_50HZ 
INVENSENSE3_GYRO_ODR_25HZ 
INVENSENSE3_GYRO_ODR_12_5HZ 
INVENSENSE3_GYRO_ODR_6_25HZ 
INVENSENSE3_GYRO_ODR_3_125HZ 
INVENSENSE3_GYRO_ODR_1_5625HZ 
INVENSENSE3_GYRO_ODR_500HZ 

Definition at line 95 of file invensense3.h.

◆ invensense3_gyro_range_t

Enumerator
INVENSENSE3_GYRO_RANGE_2000DPS 
INVENSENSE3_GYRO_RANGE_1000DPS 
INVENSENSE3_GYRO_RANGE_500DPS 
INVENSENSE3_GYRO_RANGE_250DPS 
INVENSENSE3_GYRO_RANGE_125DPS 
INVENSENSE3_GYRO_RANGE_62_5DPS 
INVENSENSE3_GYRO_RANGE_31_25DPS 
INVENSENSE3_GYRO_RANGE_15_625DPS 

Definition at line 114 of file invensense3.h.

◆ invensense3_parser_t

Enumerator
INVENSENSE3_PARSER_REGISTERS 
INVENSENSE3_PARSER_FIFO 

Definition at line 72 of file invensense3.h.

◆ invensense3_status_t

Enumerator
INVENSENSE3_IDLE 
INVENSENSE3_CONFIG 
INVENSENSE3_RUNNING 

Definition at line 65 of file invensense3.h.

Function Documentation

◆ invensense3_event()

◆ invensense3_init()

void invensense3_init ( struct invensense3_t inv)

◆ invensense3_periodic()

void invensense3_periodic ( struct invensense3_t inv)

Should be called periodically to request sensor readings.

  • First detects the sensor using WHO_AM_I reading
  • Configures the sensor according the users requested configuration
  • Requests a sensor reading by reading the FIFO_COUNT register
Parameters
invThe invensense v3 instance

Definition at line 275 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_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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: