Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for the MPU-60X0 using SPI. More...
#include "std.h"
#include "math/pprz_algebra_int.h"
#include "mcu_periph/spi.h"
#include "peripherals/mpu60x0.h"
Go to the source code of this file.
Data Structures | |
struct | Mpu60x0_Spi |
union | Mpu60x0_Spi.data_accel |
union | Mpu60x0_Spi.data_rates |
Macros | |
#define | MPU60X0_BUFFER_LEN 32 |
#define | MPU60X0_BUFFER_EXT_LEN 16 |
Functions | |
void | mpu60x0_spi_init (struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t addr) |
void | mpu60x0_spi_start_configure (struct Mpu60x0_Spi *mpu) |
void | mpu60x0_spi_read (struct Mpu60x0_Spi *mpu) |
void | mpu60x0_spi_event (struct Mpu60x0_Spi *mpu) |
static void | mpu60x0_spi_periodic (struct Mpu60x0_Spi *mpu) |
convenience function: read or start configuration if not already initialized More... | |
Driver for the MPU-60X0 using SPI.
Definition in file mpu60x0_spi.h.
struct Mpu60x0_Spi |
Definition at line 51 of file mpu60x0_spi.h.
Data Fields | ||
---|---|---|
struct Mpu60x0Config | config | |
union Mpu60x0_Spi | data_accel | |
volatile bool | data_available | data ready flag |
uint8_t | data_ext[MPU60X0_BUFFER_EXT_LEN] | |
union Mpu60x0_Spi | data_rates | |
volatile uint8_t | rx_buf[MPU60X0_BUFFER_LEN] | |
enum Mpu60x0SpiSlaveInitStatus | slave_init_status | |
struct spi_periph * | spi_p | |
struct spi_transaction | spi_trans | |
float | temp | temperature in degrees Celcius |
volatile uint8_t | tx_buf[2] |
union Mpu60x0_Spi.data_accel |
Definition at line 57 of file mpu60x0_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 Mpu60x0_Spi.data_rates |
Definition at line 61 of file mpu60x0_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 MPU60X0_BUFFER_EXT_LEN 16 |
Definition at line 40 of file mpu60x0_spi.h.
#define MPU60X0_BUFFER_LEN 32 |
Definition at line 39 of file mpu60x0_spi.h.
Enumerator | |
---|---|
MPU60X0_SPI_CONF_UNINIT | |
MPU60X0_SPI_CONF_I2C_MST_CLK | |
MPU60X0_SPI_CONF_I2C_MST_DELAY | |
MPU60X0_SPI_CONF_I2C_MST_EN | |
MPU60X0_SPI_CONF_SLAVES_CONFIGURE | |
MPU60X0_SPI_CONF_DONE |
Definition at line 42 of file mpu60x0_spi.h.
void mpu60x0_spi_event | ( | struct Mpu60x0_Spi * | mpu | ) |
Definition at line 128 of file mpu60x0_spi.c.
References Mpu60x0_Spi::config, Mpu60x0_Spi::data_accel, Mpu60x0_Spi::data_available, Mpu60x0_Spi::data_ext, Mpu60x0_Spi::data_rates, ICM20600, ICM20602, ICM20608, ICM20689, Mpu60x0Config::init_status, Mpu60x0Config::initialized, Int16FromBuf, MPU60X0_CONF_UNINIT, mpu60x0_send_config(), mpu60x0_spi_write_to_reg(), Mpu60x0Config::nb_bytes, Mpu60x0Config::nb_slaves, Mpu60x0_Spi::rx_buf, Mpu60x0_Spi::spi_trans, SPITransDone, SPITransFailed, SPITransSuccess, spi_transaction::status, Mpu60x0_Spi::temp, and Mpu60x0Config::type.
Referenced by imu_aspirin2_event(), imu_cube_event(), imu_mpu_hmc_event(), imu_mpu_spi_event(), and imu_px4fmu_event().
void mpu60x0_spi_init | ( | struct Mpu60x0_Spi * | mpu, |
struct spi_periph * | spi_p, | ||
uint8_t | addr | ||
) |
Definition at line 31 of file mpu60x0_spi.c.
References spi_transaction::after_cb, spi_transaction::before_cb, spi_transaction::bitorder, spi_transaction::cdiv, Mpu60x0_Spi::config, spi_transaction::cpha, spi_transaction::cpol, Mpu60x0_Spi::data_available, spi_transaction::dss, Mpu60x0Config::init_status, Mpu60x0Config::initialized, spi_transaction::input_buf, spi_transaction::input_length, MPU60X0_BUFFER_LEN, MPU60X0_CONF_UNINIT, mpu60x0_set_default_config(), MPU60X0_SPI_CONF_UNINIT, spi_transaction::output_buf, spi_transaction::output_length, Mpu60x0_Spi::rx_buf, spi_transaction::select, spi_transaction::slave_idx, Mpu60x0_Spi::slave_init_status, Mpu60x0_Spi::spi_p, Mpu60x0_Spi::spi_trans, SPICphaEdge2, SPICpolIdleHigh, SPIDiv64, SPIDss8bit, SPIMSBFirst, SPISelectUnselect, SPITransDone, spi_transaction::status, and Mpu60x0_Spi::tx_buf.
Referenced by imu_aspirin2_init(), imu_cube_init(), imu_mpu_hmc_init(), imu_mpu_spi_init(), and imu_px4fmu_init().
|
inlinestatic |
convenience function: read or start configuration if not already initialized
Definition at line 78 of file mpu60x0_spi.h.
References Mpu60x0_Spi::config, Mpu60x0Config::initialized, mpu60x0_spi_read(), and mpu60x0_spi_start_configure().
Referenced by imu_aspirin2_periodic(), imu_cube_periodic(), imu_mpu_hmc_periodic(), imu_mpu_spi_periodic(), and imu_px4fmu_periodic().
void mpu60x0_spi_read | ( | struct Mpu60x0_Spi * | mpu | ) |
Definition at line 115 of file mpu60x0_spi.c.
References Mpu60x0_Spi::config, Mpu60x0Config::initialized, spi_transaction::input_length, MPU60X0_REG_INT_STATUS, MPU60X0_SPI_READ, Mpu60x0Config::nb_bytes, spi_transaction::output_length, Mpu60x0_Spi::spi_p, spi_submit(), Mpu60x0_Spi::spi_trans, SPITransDone, spi_transaction::status, and Mpu60x0_Spi::tx_buf.
Referenced by mpu60x0_spi_periodic().
void mpu60x0_spi_start_configure | ( | struct Mpu60x0_Spi * | mpu | ) |
Definition at line 77 of file mpu60x0_spi.c.
References Mpu60x0_Spi::config, ICM20600, ICM20600_WHOAMI_REPLY, ICM20602, ICM20602_WHOAMI_REPLY, ICM20608, ICM20608_WHOAMI_REPLY, ICM20689, ICM20689_WHOAMI_REPLY, Mpu60x0Config::init_status, spi_transaction::input_length, MPU60X0, MPU60X0_CONF_UNINIT, MPU60X0_REG_WHO_AM_I, mpu60x0_send_config(), MPU60X0_SPI_READ, mpu60x0_spi_write_to_reg(), MPU60X0_WHOAMI_REPLY, spi_transaction::output_length, Mpu60x0_Spi::rx_buf, Mpu60x0_Spi::spi_p, spi_submit(), Mpu60x0_Spi::spi_trans, SPITransDone, SPITransPending, SPITransRunning, SPITransSuccess, spi_transaction::status, Mpu60x0_Spi::tx_buf, and Mpu60x0Config::type.
Referenced by mpu60x0_spi_periodic().