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

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/gpio_arch.h"
#include "std.h"
#include <string.h>
#include "modules/datalink/telemetry.h"
+ Include dependency graph for invensense3_456.c:

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.
 

Detailed Description

Driver for the Invensense 456XY IMUs:

  • ICM45686

Definition in file invensense3_456.c.

Function Documentation

◆ invensense3_456_config()

◆ 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 137 of file invensense3_456.c.

References foo, INV3_456_WHOAMI_ICM45686, INV3REG_456_FIFO_COUNTH, invensense3_456_config(), INVENSENSE3_456_CONFIG, INVENSENSE3_456_ICM45686, INVENSENSE3_456_IDLE, invensense3_456_parse_fifo_data(), invensense3_456_register_read(), INVENSENSE3_456_RUNNING, invensense3_456_set_scalings(), Min, n_samples, SPITransDone, SPITransFailed, and SPITransSuccess.

Referenced by imu_cube_event().

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

◆ invensense3_456_init()

void invensense3_456_init ( struct invensense3_456_t inv)

Initialize the invensense v3 sensor instance.

Parameters
invThe structure containing the configuration of the invensense v3 instance

Definition at line 57 of file invensense3_456.c.

References foo, INVENSENSE3_456_IDLE, INVENSENSE3_456_UNKOWN, samples_from_odr(), SPICphaEdge2, SPICpolIdleHigh, SPIDiv16, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, and SPITransDone.

Referenced by imu_cube_init().

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

◆ invensense3_456_parse_fifo_data()

static void invensense3_456_parse_fifo_data ( struct invensense3_456_t inv,
uint8_t data,
uint16_t  samples 
)
static

Parse the FIFO buffer data.

Parameters
invThe invensense v3 instance
dataThe FIFO buffer data to parse
lenThe length of the FIFO buffer

Definition at line 247 of file invensense3_456.c.

References FIFODataHighRes::accel, FIFODataHighRes::ax, FIFODataHighRes::ay, FIFODataHighRes::az, foo, get_sys_time_usec(), FIFODataHighRes::gx, FIFODataHighRes::gy, FIFODataHighRes::gyro, FIFODataHighRes::gz, FIFODataHighRes::header, INVENSENSE3_456_FIFO_BUFFER_LEN, Min, reassemble_uint20(), and FIFODataHighRes::temperature.

Referenced by invensense3_456_event().

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

◆ 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 95 of file invensense3_456.c.

References foo, INV3REG_456_FIFO_COUNTH, INV3REG_456_WHOAMI, invensense3_456_config(), INVENSENSE3_456_CONFIG, INVENSENSE3_456_IDLE, invensense3_456_register_read(), INVENSENSE3_456_RUNNING, Min, and SPITransDone.

Referenced by imu_cube_periodic().

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

◆ invensense3_456_register_read()

static bool invensense3_456_register_read ( struct invensense3_456_t inv,
uint8_t  reg,
uint16_t  size 
)
static

Read a register based on a combined bank/regsiter value.

Parameters
invThe invensense v3 instance
regThe address of the register to read
sizeThe size to read (already 1 is added for the transmission of the register to read)
Returns
true If we initiated the register read succesfully
false First we are busy switching the register bank

Definition at line 396 of file invensense3_456.c.

References foo, INV3_456_READ_FLAG, and spi_submit().

Referenced by invensense3_456_event(), and invensense3_456_periodic().

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

◆ invensense3_456_register_write()

static bool invensense3_456_register_write ( struct invensense3_456_t inv,
uint8_t  reg,
uint8_t  value 
)
static

Write a register.

Parameters
invThe invensense v3 instance
regThe address of the register to write to
valueThe value to write to the register
Returns
true Whenever the register write was started

Definition at line 349 of file invensense3_456.c.

References foo, and spi_submit().

Referenced by invensense3_456_config().

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

◆ invensense3_456_set_scalings()

static void invensense3_456_set_scalings ( struct invensense3_456_t inv)
static

This sets the correct scalings.

Parameters
invThe invensense v3 instance

Definition at line 297 of file invensense3_456.c.

References ACCEL_BFP_OF_REAL, foo, 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().

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

◆ invensense3_register_write_bank()

static bool invensense3_register_write_bank ( struct invensense3_456_t inv,
uint16_t  bank_addr,
uint16_t  reg,
uint8_t  val 
)
static

Write to a register in a specific bank.

Parameters
invThe invensense v3 instance
bank_addrThe address of the bank to write to
regThe address of the register to write to
valueThe value to write to the register
Returns
true Whenever the register write was started

Definition at line 371 of file invensense3_456.c.

References foo, INV3REG_456_IREG_ADDRH, spi_submit(), and val.

Referenced by invensense3_456_config().

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

◆ reassemble_uint20()

static int32_t reassemble_uint20 ( uint8_t  msb,
uint8_t  bits,
uint8_t  lsb 
)
inlinestatic

Definition at line 225 of file invensense3_456.c.

References foo.

Referenced by invensense3_456_parse_fifo_data().

+ Here is the caller graph for this function:

◆ samples_from_odr()