37#include "mcu_periph/gpio_arch.h"
117 read_bytes =
Min(max_bytes, read_bytes);
182 if(fifo_bytes > 4096) {
189 uint16_t nb_packets_read = (*inv->rx_length - 3) / sizeof(struct FIFODataHighRes);
190 invensense3_456_parse_fifo_data(inv, &inv->rx_buffer[3], Min(n_samples, nb_packets_read));
191 inv->timer -= nb_packets_read;
230 if (value20bit & 0x80000) {
232 value32bit = (
int32_t)(value20bit | 0xFFF00000);
235 value32bit = value20bit;
257 for(
uint8_t sample = 0; sample < samples; sample++) {
260 if ((d->
header & 0xFC) != 0x78) {
283 float temp_f = (sample_idx > 0) ? ((
float)temp / sample_idx) / 128.f + 25.f : NAN;
498 return ceilf(6400 / PERIODIC_FREQUENCY);
500 return ceilf(3200 / PERIODIC_FREQUENCY);
502 return ceilf(1600 / PERIODIC_FREQUENCY);
504 return ceilf(800 / PERIODIC_FREQUENCY);
506 return ceilf(400 / PERIODIC_FREQUENCY);
508 return ceilf(200 / PERIODIC_FREQUENCY);
510 return ceilf(100 / PERIODIC_FREQUENCY);
512 return ceilf(50 / PERIODIC_FREQUENCY);
514 return ceilf(25 / PERIODIC_FREQUENCY);
Main include for ABI (AirBorneInterface).
#define TEMPERATURE_TYPE_IMU
IMU die.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define ACCEL_BFP_OF_REAL(_af)
#define RATE_BFP_OF_REAL(_af)
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback before_cb
NULL or function called before the transaction.
SPICallback after_cb
NULL or function called after the transaction.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
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.
#define GYRO_FS_SEL_SHIFT
#define ACCEL_FS_SEL_SHIFT
void invensense3_456_init(struct invensense3_456_t *inv)
Initialize the invensense v3 sensor instance.
static int samples_from_odr(int odr)
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_register_write(struct invensense3_456_t *inv, uint8_t reg, uint8_t value)
Write a register.
static void invensense3_456_parse_fifo_data(struct invensense3_456_t *inv, uint8_t *data, uint16_t samples)
Parse the FIFO buffer data.
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.
static bool invensense3_456_config(struct invensense3_456_t *inv)
Configure the Invensense 3 device register by register.
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 void invensense3_456_set_scalings(struct invensense3_456_t *inv)
This sets the correct scalings.
void invensense3_456_periodic(struct invensense3_456_t *inv)
Should be called periodically to request sensor readings.
Driver for the Invensense 456XY IMUs:
struct invensense3_456_spi_t spi
SPI specific configuration (support SPI only for now).
uint8_t config_idx
The current configuration index (used for setup/initial configuration).
int sample_numbers
expected FIFO packet number, assuming reading at PERIODIC_FREQUENCY
enum invensense3_456_device_t device
The device type detected.
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.
@ INVENSENSE3_456_RUNNING
enum invensense3_456_odr_t imu_odr
Accelerometer / gyro Output Data Rate configuration.
enum invensense3_456_status_t status
Status of the invensense device.
@ INVENSENSE3_456_ICM45686
float imu_samplerate
Sample rate in Hz from the imu_odr.
uint8_t abi_id
The ABI id used to broadcast the device measurements.
uint8_t tx_buf[4]
Transmit buffer.
uint32_t timer
Used to time operations during configuration (samples left during measuring).
struct spi_periph * p
Peripheral device for communication.
#define INVENSENSE3_456_FIFO_BUFFER_LEN
@ INVENSENSE3_456_ODR_100HZ
@ INVENSENSE3_456_ODR_6_4KHZ
@ INVENSENSE3_456_ODR_50HZ
@ INVENSENSE3_456_ODR_800HZ
@ INVENSENSE3_456_ODR_25HZ
@ INVENSENSE3_456_ODR_3_2KHZ
@ INVENSENSE3_456_ODR_1_6KHZ
@ INVENSENSE3_456_ODR_400HZ
@ INVENSENSE3_456_ODR_200HZ
Register and address definitions for the Invensense V3 ICM456xy sensors from ardupilot.
#define INV3REG_456_REG_MISC2
#define INV3REG_456_WHOAMI
#define INV3REG_456_IREG_ADDRH
#define INV3BANK_456_IPREG_TOP1_ADDR
#define INV_456_BASE_FIFO3_CONFIG_VALUE
#define INV3REG_456_GYRO_CONFIG0
#define INV3REG_456_FIFO_CONFIG0
#define INV3BANK_456_IPREG_SYS2_ADDR
#define INV3REG_456_PWR_MGMT0
#define INV_456_FIFO_IF_EN
#define INV3_456_WHOAMI_ICM45686
#define INV3REG_456_FIFO_COUNTH
#define INV3BANK_456_IPREG_SYS1_ADDR
#define INV3_456_READ_FLAG
#define INV3REG_456_FIFO_CONFIG3
#define INV3REG_456_ACCEL_CONFIG0
Paparazzi floating point algebra.
Paparazzi fixed point algebra.
Paparazzi atmospheric pressure conversion utilities.
Architecture independent timing functions.
Periodic telemetry system header (includes downlink utility and generated code).
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.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.