Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
invensense3_456.h File Reference

Driver for the Invensense 456XY IMUs: More...

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

Go to the source code of this file.

Data Structures

struct  FIFODataHighRes
struct  invensense3_456_spi_t
struct  invensense3_456_t

Macros

#define INVENSENSE3_456_FIFO_BUFFER_LEN   22
#define INVENSENSE3_456_BUFFER_SIZE   INVENSENSE3_456_FIFO_BUFFER_LEN * sizeof(struct FIFODataHighRes) + 3

Enumerations

enum  invensense3_456_status_t { INVENSENSE3_456_IDLE , INVENSENSE3_456_CONFIG , INVENSENSE3_456_RUNNING }
enum  invensense3_456_device_t { INVENSENSE3_456_UNKOWN , INVENSENSE3_456_ICM45686 }
enum  invensense3_456_odr_t {
  INVENSENSE3_456_ODR_6_4KHZ = 0b0011 , INVENSENSE3_456_ODR_3_2KHZ = 0b0100 , INVENSENSE3_456_ODR_1_6KHZ = 0b0101 , INVENSENSE3_456_ODR_800HZ = 0b0110 ,
  INVENSENSE3_456_ODR_400HZ = 0b0111 , INVENSENSE3_456_ODR_200HZ = 0b1000 , INVENSENSE3_456_ODR_100HZ = 0b1001 , INVENSENSE3_456_ODR_50HZ = 0b1010 ,
  INVENSENSE3_456_ODR_25HZ = 0b1011
}

Functions

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.

Detailed Description

Driver for the Invensense 456XY IMUs:

  • ICM45686

This driver is largely based on the original Invense v3 driver by Freek van Tienen, the Arupilot AP_InertialSensor_Invensensev3 with some inspiration from the px4 one as well. Split from the "main" invensensev3 driver as the WHO_AM_I register is different, and we operate this driver in high-resolution (20-bit) mode which is not used by any of the existing drivers. TL;DR: the drivers are quite different (even sensor ODR's), so we would be using if statements everywhere anyway. This seemed like the cleaner solution.

Definition in file invensense3_456.h.


Data Structure Documentation

◆ FIFODataHighRes

struct FIFODataHighRes

Definition at line 48 of file invensense3_456.h.

Data Fields
uint8_t accel[6]
uint8_t ax: 4
uint8_t ay: 4
uint8_t az: 4
uint8_t gx: 4
uint8_t gy: 4
uint8_t gyro[6]
uint8_t gz: 4
uint8_t header
int16_t temperature
uint16_t timestamp

◆ invensense3_456_spi_t

struct invensense3_456_spi_t

Definition at line 59 of file invensense3_456.h.

Collaboration diagram for invensense3_456_spi_t:
Data Fields
struct spi_periph * p Peripheral device for communication.
uint8_t rx_buf[INVENSENSE3_456_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[4] Transmit buffer.

◆ invensense3_456_t

struct invensense3_456_t

Definition at line 99 of file invensense3_456.h.

Collaboration diagram for invensense3_456_t:
Data Fields
uint8_t abi_id The ABI id used to broadcast the device measurements.
uint8_t config_idx The current configuration index (used for setup/initial configuration).
enum invensense3_456_device_t device The device type detected.
enum invensense3_456_odr_t imu_odr Accelerometer / gyro Output Data Rate configuration.
float imu_samplerate Sample rate in Hz from the imu_odr.
uint8_t * rx_buffer
uint16_t * rx_length
int sample_numbers expected FIFO packet number, assuming reading at PERIODIC_FREQUENCY
struct invensense3_456_spi_t spi SPI specific configuration (support SPI only for now).
enum invensense3_456_status_t status Status of the invensense device.
uint32_t timer Used to time operations during configuration (samples left during measuring).
uint8_t * tx_buffer

Macro Definition Documentation

◆ INVENSENSE3_456_BUFFER_SIZE

#define INVENSENSE3_456_BUFFER_SIZE   INVENSENSE3_456_FIFO_BUFFER_LEN * sizeof(struct FIFODataHighRes) + 3

Definition at line 45 of file invensense3_456.h.

◆ INVENSENSE3_456_FIFO_BUFFER_LEN

#define INVENSENSE3_456_FIFO_BUFFER_LEN   22

Definition at line 44 of file invensense3_456.h.

Referenced by invensense3_456_parse_fifo_data().

Enumeration Type Documentation

◆ invensense3_456_device_t

Enumerator
INVENSENSE3_456_UNKOWN 
INVENSENSE3_456_ICM45686 

Definition at line 75 of file invensense3_456.h.

◆ invensense3_456_odr_t

Enumerator
INVENSENSE3_456_ODR_6_4KHZ 
INVENSENSE3_456_ODR_3_2KHZ 
INVENSENSE3_456_ODR_1_6KHZ 
INVENSENSE3_456_ODR_800HZ 
INVENSENSE3_456_ODR_400HZ 
INVENSENSE3_456_ODR_200HZ 
INVENSENSE3_456_ODR_100HZ 
INVENSENSE3_456_ODR_50HZ 
INVENSENSE3_456_ODR_25HZ 

Definition at line 82 of file invensense3_456.h.

◆ invensense3_456_status_t

Enumerator
INVENSENSE3_456_IDLE 
INVENSENSE3_456_CONFIG 
INVENSENSE3_456_RUNNING 

Definition at line 69 of file invensense3_456.h.

Function Documentation

◆ invensense3_456_event()

void invensense3_456_event ( struct invensense3_456_t * inv)

Should be called in the event thread.

  • Checks the response of the WHO_AM_I reading
  • Configures the sensor and reads the responses
  • Parse and request the sensor data from the FIFO buffers
Parameters
invThe 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().

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

◆ invensense3_456_init()

◆ invensense3_456_periodic()

void invensense3_456_periodic ( struct invensense3_456_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 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().

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