Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for the MPU-9250 using SPI. More...
#include "std.h"
#include "math/pprz_algebra_int.h"
#include "mcu_periph/spi.h"
#include "peripherals/mpu9250.h"
Go to the source code of this file.
Data Structures | |
struct | Mpu9250_Spi |
union | Mpu9250_Spi.data_accel |
union | Mpu9250_Spi.data_rates |
Macros | |
#define | MPU9250_BUFFER_LEN 32 |
#define | MPU9250_BUFFER_EXT_LEN 16 |
Functions | |
void | mpu9250_spi_init (struct Mpu9250_Spi *mpu, struct spi_periph *spi_p, uint8_t addr) |
void | mpu9250_spi_start_configure (struct Mpu9250_Spi *mpu) |
void | mpu9250_spi_read (struct Mpu9250_Spi *mpu) |
void | mpu9250_spi_event (struct Mpu9250_Spi *mpu) |
static void | mpu9250_spi_periodic (struct Mpu9250_Spi *mpu) |
convenience function: read or start configuration if not already initialized More... | |
Driver for the MPU-9250 using SPI.
Definition in file mpu9250_spi.h.
struct Mpu9250_Spi |
Definition at line 51 of file mpu9250_spi.h.
Data Fields | ||
---|---|---|
struct Mpu9250Config | config | |
union Mpu9250_Spi | data_accel | |
volatile bool | data_available | data ready flag |
uint8_t | data_ext[MPU9250_BUFFER_EXT_LEN] | |
union Mpu9250_Spi | data_rates | |
volatile uint8_t | rx_buf[MPU9250_BUFFER_LEN] | |
enum Mpu9250SpiSlaveInitStatus | slave_init_status | |
struct spi_periph * | spi_p | |
struct spi_transaction | spi_trans | |
volatile uint8_t | tx_buf[2] |
union Mpu9250_Spi.data_accel |
Definition at line 57 of file mpu9250_spi.h.
Data Fields | ||
---|---|---|
int16_t | value[3] | accel data values accessible by channel index |
struct Int16Vect3 | vect | accel data vector in accel coordinate system |
union Mpu9250_Spi.data_rates |
Definition at line 61 of file mpu9250_spi.h.
Data Fields | ||
---|---|---|
struct Int16Rates | rates | rates data as angular rates in gyro coordinate system |
int16_t | value[3] | rates data values accessible by channel index |
#define MPU9250_BUFFER_EXT_LEN 16 |
Definition at line 40 of file mpu9250_spi.h.
#define MPU9250_BUFFER_LEN 32 |
Definition at line 39 of file mpu9250_spi.h.
Referenced by mpu9250_spi_init().
Enumerator | |
---|---|
MPU9250_SPI_CONF_UNINIT | |
MPU9250_SPI_CONF_I2C_MST_CLK | |
MPU9250_SPI_CONF_I2C_MST_DELAY | |
MPU9250_SPI_CONF_I2C_MST_EN | |
MPU9250_SPI_CONF_SLAVES_CONFIGURE | |
MPU9250_SPI_CONF_DONE |
Definition at line 42 of file mpu9250_spi.h.
void mpu9250_spi_event | ( | struct Mpu9250_Spi * | mpu | ) |
Definition at line 100 of file mpu9250_spi.c.
References Mpu9250_Spi::config, Mpu9250_Spi::data_accel, Mpu9250_Spi::data_available, Mpu9250_Spi::data_ext, Mpu9250_Spi::data_rates, Mpu9250Config::init_status, Mpu9250Config::initialized, Int16FromBuf, MPU9250_CONF_UNINIT, mpu9250_send_config(), mpu9250_spi_write_to_reg(), Mpu9250Config::nb_bytes, Mpu9250Config::nb_slaves, Mpu9250_Spi::rx_buf, Mpu9250_Spi::spi_trans, SPITransDone, SPITransFailed, SPITransSuccess, and spi_transaction::status.
Referenced by imu_mpu9250_event().
void mpu9250_spi_init | ( | struct Mpu9250_Spi * | mpu, |
struct spi_periph * | spi_p, | ||
uint8_t | addr | ||
) |
Definition at line 31 of file mpu9250_spi.c.
References spi_transaction::after_cb, spi_transaction::before_cb, spi_transaction::bitorder, spi_transaction::cdiv, Mpu9250_Spi::config, spi_transaction::cpha, spi_transaction::cpol, Mpu9250_Spi::data_available, spi_transaction::dss, Mpu9250Config::init_status, Mpu9250Config::initialized, spi_transaction::input_buf, spi_transaction::input_length, MPU9250_BUFFER_LEN, MPU9250_CONF_UNINIT, mpu9250_set_default_config(), MPU9250_SPI_CONF_UNINIT, spi_transaction::output_buf, spi_transaction::output_length, Mpu9250_Spi::rx_buf, spi_transaction::select, spi_transaction::slave_idx, Mpu9250_Spi::slave_init_status, Mpu9250_Spi::spi_p, Mpu9250_Spi::spi_trans, SPICphaEdge2, SPICpolIdleHigh, SPIDiv64, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, SPITransDone, spi_transaction::status, and Mpu9250_Spi::tx_buf.
Referenced by imu_mpu9250_init().
|
inlinestatic |
convenience function: read or start configuration if not already initialized
Definition at line 77 of file mpu9250_spi.h.
References Mpu9250_Spi::config, Mpu9250Config::initialized, mpu9250_spi_read(), and mpu9250_spi_start_configure().
Referenced by imu_mpu9250_periodic().
void mpu9250_spi_read | ( | struct Mpu9250_Spi * | mpu | ) |
Definition at line 87 of file mpu9250_spi.c.
References Mpu9250_Spi::config, Mpu9250Config::initialized, spi_transaction::input_length, MPU9250_REG_INT_STATUS, MPU9250_SPI_READ, Mpu9250Config::nb_bytes, spi_transaction::output_length, Mpu9250_Spi::spi_p, spi_submit(), Mpu9250_Spi::spi_trans, SPITransDone, spi_transaction::status, and Mpu9250_Spi::tx_buf.
Referenced by mpu9250_spi_periodic().
void mpu9250_spi_start_configure | ( | struct Mpu9250_Spi * | mpu | ) |
Definition at line 77 of file mpu9250_spi.c.
References Mpu9250_Spi::config, Mpu9250Config::init_status, MPU9250_CONF_UNINIT, mpu9250_send_config(), mpu9250_spi_write_to_reg(), Mpu9250_Spi::spi_trans, SPITransDone, SPITransSuccess, and spi_transaction::status.
Referenced by mpu9250_spi_periodic().