Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
invensense3_456.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
37#ifndef INVENSENSE3_456_H
38#define INVENSENSE3_456_H
39
40#include "std.h"
41#include "mcu_periph/spi.h"
42
43// Hold 22 measurements + 3 for the register address and length
44#define INVENSENSE3_456_FIFO_BUFFER_LEN 22
45#define INVENSENSE3_456_BUFFER_SIZE INVENSENSE3_456_FIFO_BUFFER_LEN * sizeof(struct FIFODataHighRes) + 3
46
47// REF: https://github.com/ArduPilot/ardupilot/blob/85a8a55611a95d4c59052f79f56744a93a9c5a63/libraries/AP_InertialSensor/AP_InertialSensor_Invensensev3.cpp#L160C1-L167C3
50 uint8_t accel[6];
51 uint8_t gyro[6];
54 uint8_t gx : 4, ax : 4, gy : 4, ay : 4, gz : 4, az : 4;
55};
56
57/* Invensense v3 SPI peripheral */
58/* Modified to have a 4-bit tx buffer to deal with the different way of accessing register banks */
67
68/* Different states the invensense v3 driver can be in */
74/* Different device types compatible with the invensense v3 - 456xy driver */
79
80/* Output data rate configuration - for this initial driver version,
81 we operate the accelerometer/gyro at the same ODR */
83 INVENSENSE3_456_ODR_6_4KHZ = 0b0011, // LN only
84 INVENSENSE3_456_ODR_3_2KHZ = 0b0100, // LN only
85 INVENSENSE3_456_ODR_1_6KHZ = 0b0101, // LN only
86 INVENSENSE3_456_ODR_800HZ = 0b0110, // LN only
87 INVENSENSE3_456_ODR_400HZ = 0b0111, // LP / LN
88 INVENSENSE3_456_ODR_200HZ = 0b1000, // LP / LN
89 INVENSENSE3_456_ODR_100HZ = 0b1001, // LP / LN
90 INVENSENSE3_456_ODR_50HZ = 0b1010, // LP / LN
91 INVENSENSE3_456_ODR_25HZ = 0b1011, // LP / LN
92 // INVENSENSE3_456_ODR_12_5HZ = 0b1100, // LP / LN - NOT USED
93 // INVENSENSE3_456_ODR_6_25HZ = 0b1101, // LP only - NOT USED
94 // INVENSENSE3_456_ODR_3_125HZ = 0b1110, // LP only - NOT USED
95 // INVENSENSE3_456_ODR_1_5625HZ = 0b1111, // LP only - NOT USED
96};
97
98/* Main invensense 456 device structure */
117
118/* External functions */
122
123#endif // INVENSENSE3_456_H
SPI peripheral structure.
Definition spi.h:171
SPI transaction structure.
Definition spi.h:144
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.
void invensense3_456_init(struct invensense3_456_t *inv)
Initialize the invensense v3 sensor instance.
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_status_t
@ INVENSENSE3_456_CONFIG
@ INVENSENSE3_456_IDLE
@ 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_device_t
@ INVENSENSE3_456_ICM45686
@ INVENSENSE3_456_UNKOWN
float imu_samplerate
Sample rate in Hz from the imu_odr.
#define INVENSENSE3_456_BUFFER_SIZE
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)
void invensense3_456_event(struct invensense3_456_t *inv)
Should be called in the event thread.
struct spi_periph * p
Peripheral device for communication.
void invensense3_456_periodic(struct invensense3_456_t *inv)
Should be called periodically to request sensor readings.
invensense3_456_odr_t
@ 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
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.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.