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
invensense2.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 INVENSENSE2_H
30#define INVENSENSE2_H
31
32#include "std.h"
33#include "mcu_periph/spi.h"
34#include "mcu_periph/i2c.h"
35
36// Hold 22 measurements and 3 for the register address and length
37#define INVENSENSE2_SAMPLE_CNT 22
38#define INVENSENSE2_SAMPLE_SIZE 14
39#define INVENSENSE2_BUFFER_SIZE ((INVENSENSE2_SAMPLE_SIZE*INVENSENSE2_SAMPLE_CNT) + 3)
40
41/* Invensense v2 SPI peripheral */
50
51/* Invensense v2 I2C peripheral */
57
58/* Possible communication busses for the invense V2 driver */
63
64/* Different states the invensense driver can be in */
70
71/* Different device types compatible with the invensense V2 driver */
78
79/* The gyro digital low pass filter bandwidth configuration */
91
92/* The gyro range in degrees per second(dps) */
100
101/* The accelerometer digital low pass filter bandwidth configuration */
112
113/* The accelerometer range in G */
121
122/* Main invensense V2 device structure */
144
145/* External functions */
149
150#endif // INVENSENSE2_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 invensense2_accel_range_t accel_range
Accelerometer range configuration.
uint8_t slave_addr
The I2C slave address on the bus.
Definition invensense2.h:54
invensense2_gyro_dlpf_t
Definition invensense2.h:80
@ INVENSENSE2_GYRO_DLPF_73HZ
Definition invensense2.h:85
@ INVENSENSE2_GYRO_DLPF_229HZ
Definition invensense2.h:82
@ INVENSENSE2_GYRO_DLPF_188HZ
Definition invensense2.h:83
@ INVENSENSE2_GYRO_DLPF_377HZ
Definition invensense2.h:89
@ INVENSENSE2_GYRO_DLPF_36HZ
Definition invensense2.h:86
@ INVENSENSE2_GYRO_DLPF_18HZ
Definition invensense2.h:87
@ INVENSENSE2_GYRO_DLPF_154HZ
Definition invensense2.h:84
@ INVENSENSE2_GYRO_DLPF_OFF
Definition invensense2.h:81
@ INVENSENSE2_GYRO_DLPF_9HZ
Definition invensense2.h:88
invensense2_status_t
Definition invensense2.h:65
@ INVENSENSE2_RUNNING
Definition invensense2.h:68
@ INVENSENSE2_IDLE
Definition invensense2.h:66
@ INVENSENSE2_CONFIG
Definition invensense2.h:67
enum invensense2_device_t device
The device type detected.
struct spi_periph * p
Peripheral device for communication.
Definition invensense2.h:43
invensense2_gyro_range_t
Definition invensense2.h:93
@ INVENSENSE2_GYRO_RANGE_4000DPS
Only possible for ICM20649.
Definition invensense2.h:98
@ INVENSENSE2_GYRO_RANGE_500DPS
Definition invensense2.h:95
@ INVENSENSE2_GYRO_RANGE_2000DPS
Definition invensense2.h:97
@ INVENSENSE2_GYRO_RANGE_1000DPS
Definition invensense2.h:96
@ INVENSENSE2_GYRO_RANGE_250DPS
Not possible for ICM20649.
Definition invensense2.h:94
void invensense2_event(struct invensense2_t *inv)
Should be called in the event thread.
struct i2c_periph * p
Peripheral device for communication.
Definition invensense2.h:53
uint8_t config_idx
The current configuration index.
struct spi_transaction trans
Transaction used during configuration and measurements.
Definition invensense2.h:45
enum invensense2_gyro_dlpf_t gyro_dlpf
Gyro DLPF configuration.
uint8_t register_bank
The current register bank communicating with.
invensense2_accel_range_t
@ INVENSENSE2_ACCEL_RANGE_2G
Not possible for ICM20649.
@ INVENSENSE2_ACCEL_RANGE_8G
@ INVENSENSE2_ACCEL_RANGE_16G
@ INVENSENSE2_ACCEL_RANGE_4G
@ INVENSENSE2_ACCEL_RANGE_30G
Only possible for ICM20649.
enum invensense2_status_t status
Status of the invensense V2 device.
invensense2_accel_dlpf_t
@ INVENSENSE2_ACCEL_DLPF_499HZ
@ INVENSENSE2_ACCEL_DLPF_17HZ
@ INVENSENSE2_ACCEL_DLPF_136HZ
@ INVENSENSE2_ACCEL_DLPF_8HZ
@ INVENSENSE2_ACCEL_DLPF_34HZ
@ INVENSENSE2_ACCEL_DLPF_265HZ
@ INVENSENSE2_ACCEL_DLPF_69HZ
@ INVENSENSE2_ACCEL_DLPF_OFF
struct i2c_transaction trans
TRansaction used during configuration and measurements.
Definition invensense2.h:55
volatile uint8_t tx_buf[2]
Transmit buffer.
Definition invensense2.h:47
float timebase_correction_pll
Timebase correction factor for the PLL clock.
uint8_t slave_idx
Slave index used for Slave Select.
Definition invensense2.h:44
void invensense2_periodic(struct invensense2_t *inv)
Should be called periodically to request sensor readings.
invensense2_device_t
Definition invensense2.h:72
@ INVENSENSE2_ICM20648
Definition invensense2.h:74
@ INVENSENSE2_ICM20649
Definition invensense2.h:75
@ INVENSENSE2_UNKOWN
Definition invensense2.h:73
@ INVENSENSE2_ICM20948
Definition invensense2.h:76
enum invensense2_bus_t bus
The communication bus used to connect the device SPI/I2C.
volatile uint8_t rx_buf[INVENSENSE2_BUFFER_SIZE]
Receive buffer.
Definition invensense2.h:48
uint32_t timer
Used to time operations during configuration (samples left during measuring)
#define INVENSENSE2_BUFFER_SIZE
Definition invensense2.h:39
enum invensense2_accel_dlpf_t accel_dlpf
Accelerometer DLPF configuration.
uint8_t abi_id
The ABI id used to broadcast the device measurements.
void invensense2_init(struct invensense2_t *inv)
Initialize the invensense v2 sensor instance.
Definition invensense2.c:79
invensense2_bus_t
Definition invensense2.h:59
@ INVENSENSE2_I2C
Definition invensense2.h:61
@ INVENSENSE2_SPI
Definition invensense2.h:60
enum invensense2_gyro_range_t gyro_range
Gyro range configuration.
uint16_t foo
Definition main_demo5.c:58
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.