Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
invensense3.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Freek van Tienen <freek.v.tienen@gmail.com>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
29#ifndef INVENSENSE3_H
30#define INVENSENSE3_H
31
32#include "std.h"
33#include "mcu_periph/spi.h"
34#include "mcu_periph/i2c.h"
35
36/* This sensor has an option to request little-endian data */
37// Hold 22 measurements + 3 for the register address and length
38#define INVENSENSE3_FIFO_BUFFER_LEN 22
39#define INVENSENSE3_BUFFER_SIZE INVENSENSE3_FIFO_BUFFER_LEN * 20 + 3 // 20 bytes is the maximum sample size
40
41/* Invensense v3 SPI peripheral */
50
51/* Invensense v3 I2C peripheral */
57
58/* Possible communication busses for the invense V3 driver */
63
64/* Different states the invensense v3 driver can be in */
70
71/* Different parsers of the invensense v3 driver */
76
83
84/* Different device types compatible with the invensense v3 driver */
93
94/* The gyro output data rate configuration */
112
113/* The gyro range in degrees per second(dps) */
124
125/* The accelerometer output data rate configuration */
143
144/* The accelerometer range in G */
152
153/* Main invensense v3 device structure */
186
187/* External functions */
191
192#endif // INVENSENSE3_H
I2C transaction structure.
Definition i2c.h:93
SPI peripheral structure.
Definition spi.h:174
SPI transaction structure.
Definition spi.h:148
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
enum invensense3_gyro_range_t gyro_range
Gyro range configuration.
invensense3_accel_range_t
@ INVENSENSE3_ACCEL_RANGE_16G
@ INVENSENSE3_ACCEL_RANGE_4G
@ INVENSENSE3_ACCEL_RANGE_32G
Only possible for ICM40609.
@ INVENSENSE3_ACCEL_RANGE_2G
@ INVENSENSE3_ACCEL_RANGE_8G
void invensense3_periodic(struct invensense3_t *inv)
Should be called periodically to request sensor readings.
uint8_t register_bank
The current register bank communicating with.
enum invensense3_status_t status
Status of the invensense v3 device.
uint16_t * rx_length
invensense3_gyro_odr_t
Definition invensense3.h:95
@ INVENSENSE3_GYRO_ODR_4KHZ
Definition invensense3.h:99
@ INVENSENSE3_GYRO_ODR_25HZ
@ INVENSENSE3_GYRO_ODR_500HZ
@ INVENSENSE3_GYRO_ODR_8KHZ
Definition invensense3.h:98
@ INVENSENSE3_GYRO_ODR_1_5625HZ
@ INVENSENSE3_GYRO_ODR_100HZ
@ INVENSENSE3_GYRO_ODR_2KHZ
@ INVENSENSE3_GYRO_ODR_50HZ
@ INVENSENSE3_GYRO_ODR_1KHZ
@ INVENSENSE3_GYRO_ODR_16KHZ
Not possible for ICM40605 and ICM42605.
Definition invensense3.h:97
@ INVENSENSE3_GYRO_ODR_32KHZ
Not possible for ICM40605 and ICM42605.
Definition invensense3.h:96
@ INVENSENSE3_GYRO_ODR_3_125HZ
@ INVENSENSE3_GYRO_ODR_6_25HZ
@ INVENSENSE3_GYRO_ODR_200HZ
@ INVENSENSE3_GYRO_ODR_12_5HZ
struct i2c_periph * p
Peripheral device for communication.
Definition invensense3.h:53
invensense3_device_t
Definition invensense3.h:85
@ INVENSENSE3_UNKOWN
Definition invensense3.h:86
@ INVENSENSE3_ICM42688
Definition invensense3.h:91
@ INVENSENSE3_ICM40605
Definition invensense3.h:87
@ INVENSENSE3_IIM42652
Definition invensense3.h:90
@ INVENSENSE3_ICM40609
Definition invensense3.h:88
@ INVENSENSE3_ICM42605
Definition invensense3.h:89
uint8_t tx_buf[2]
Transmit buffer.
Definition invensense3.h:47
enum invensense3_parser_t parser
Parser of the device.
void invensense3_event(struct invensense3_t *inv)
Should be called in the event thread.
uint16_t accel_aaf
Accelerometer Anti-alias filter 3dB Bandwidth configuration [Hz].
uint8_t slave_idx
Slave index used for Slave Select.
Definition invensense3.h:44
struct spi_transaction trans
Transaction used during configuration and measurements.
Definition invensense3.h:45
invensense3_parser_t
Definition invensense3.h:72
@ INVENSENSE3_PARSER_FIFO
Definition invensense3.h:74
@ INVENSENSE3_PARSER_REGISTERS
Definition invensense3.h:73
uint32_t timer
Used to time operations during configuration (samples left during measuring)
enum invensense3_accel_odr_t accel_odr
Accelerometer Output Data Rate configuration.
struct spi_periph * p
Peripheral device for communication.
Definition invensense3.h:43
invensense3_accel_odr_t
@ INVENSENSE3_ACCEL_ODR_4KHZ
@ INVENSENSE3_ACCEL_ODR_16KHZ
Not possible for ICM40605 and ICM42605.
@ INVENSENSE3_ACCEL_ODR_50HZ
@ INVENSENSE3_ACCEL_ODR_32KHZ
Not possible for ICM40605 and ICM42605.
@ INVENSENSE3_ACCEL_ODR_2KHZ
@ INVENSENSE3_ACCEL_ODR_25HZ
@ INVENSENSE3_ACCEL_ODR_1_5625HZ
@ INVENSENSE3_ACCEL_ODR_8KHZ
@ INVENSENSE3_ACCEL_ODR_6_25HZ
@ INVENSENSE3_ACCEL_ODR_200HZ
@ INVENSENSE3_ACCEL_ODR_100HZ
@ INVENSENSE3_ACCEL_ODR_1KHZ
@ INVENSENSE3_ACCEL_ODR_500HZ
@ INVENSENSE3_ACCEL_ODR_12_5HZ
@ INVENSENSE3_ACCEL_ODR_3_125HZ
enum invensense3_bus_t bus
The communication bus used to connect the device SPI/I2C.
uint8_t config_idx
The current configuration index.
uint8_t * rx_buffer
struct i2c_transaction trans
TRansaction used during configuration and measurements.
Definition invensense3.h:55
#define INVENSENSE3_BUFFER_SIZE
Definition invensense3.h:39
invensense3_gyro_range_t
@ INVENSENSE3_GYRO_RANGE_62_5DPS
@ INVENSENSE3_GYRO_RANGE_31_25DPS
@ INVENSENSE3_GYRO_RANGE_15_625DPS
@ INVENSENSE3_GYRO_RANGE_500DPS
@ INVENSENSE3_GYRO_RANGE_250DPS
@ INVENSENSE3_GYRO_RANGE_1000DPS
@ INVENSENSE3_GYRO_RANGE_125DPS
@ INVENSENSE3_GYRO_RANGE_2000DPS
int sample_numbers
expected FIFO packet number, assuming reading at PERIODIC_FREQUENCY
enum invensense3_device_t device
The device type detected.
float gyro_samplerate
Sample rate in Hz from the gyro_odr.
invensense3_bus_t
Definition invensense3.h:59
@ INVENSENSE3_I2C
Definition invensense3.h:61
@ INVENSENSE3_SPI
Definition invensense3.h:60
uint8_t * tx_buffer
float accel_samplerate
Sample rate in Hz from the accel_odr.
enum invensense3_accel_range_t accel_range
Accelerometer range configuration.
enum invensense3_fifo_packet_t sample_size
FIFO packet size.
invensense3_fifo_packet_t
Definition invensense3.h:77
@ INVENSENSE3_SAMPLE_SIZE_PK3
Definition invensense3.h:80
@ INVENSENSE3_SAMPLE_SIZE_PK1
Definition invensense3.h:78
@ INVENSENSE3_SAMPLE_SIZE_PK4
Definition invensense3.h:81
@ INVENSENSE3_SAMPLE_SIZE_PK2
Definition invensense3.h:79
uint8_t slave_addr
The I2C slave address on the bus.
Definition invensense3.h:54
uint16_t gyro_aaf_regs[4]
Gyro Anti-alias filter register values.
uint8_t abi_id
The ABI id used to broadcast the device measurements.
uint16_t accel_aaf_regs[4]
Accelerometer Anti-alias filter register values.
uint8_t rx_buf[INVENSENSE3_BUFFER_SIZE]
Receive buffer.
Definition invensense3.h:48
uint16_t gyro_aaf
Gyro Anti-alias filter 3dB Bandwidth configuration [Hz].
enum invensense3_gyro_odr_t gyro_odr
Gyro Output Data Rate configuration.
invensense3_status_t
Definition invensense3.h:65
@ INVENSENSE3_CONFIG
Definition invensense3.h:67
@ INVENSENSE3_IDLE
Definition invensense3.h:66
@ INVENSENSE3_RUNNING
Definition invensense3.h:68
void invensense3_init(struct invensense3_t *inv)
Initialize the invensense v3 sensor instance.
uint16_t foo
Definition main_demo5.c:58
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.