107 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
116 if (bit_is_set(mpu->
rx_buf[1], 0)) {
130 #pragma GCC diagnostic push
131 #pragma GCC diagnostic ignored "-Wcast-qual"
133 #pragma GCC diagnostic pop
148 if (mpu->config.initialized) {
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback before_cb
NULL or function called before the transaction.
SPICallback after_cb
NULL or function called after the transaction.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI peripheral structure.
void mpu9250_send_config(Mpu9250ConfigSet mpu_set, void *mpu, struct Mpu9250Config *config)
Configuration sequence called once before normal use.
void mpu9250_set_default_config(struct Mpu9250Config *c)
Mpu9250I2cSlaveConfigure configure
void(* Mpu9250ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
uint8_t nb_slave_init
number of already configured/initialized slaves
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
enum Mpu9250MstClk i2c_mst_clk
MPU I2C master clock speed.
uint8_t nb_slaves
number of used I2C slaves
uint8_t nb_bytes
number of bytes to read starting with MPU9250_REG_INT_STATUS
#define MPU9250_I2C_NB_SLAVES
enum Mpu9250ConfStatus init_status
init status
struct Mpu9250I2cSlave slaves[MPU9250_I2C_NB_SLAVES]
I2C slaves.
bool initialized
config done flag
#define MPU9250_WHOAMI_REPLY
#define MPU9250_REG_WHO_AM_I
#define MPU9250_REG_I2C_MST_DELAY
#define MPU9250_REG_I2C_MST_CTRL
#define MPU9250_I2C_MST_EN
#define MPU9250_REG_USER_CTRL
#define MPU9250_I2C_IF_DIS
#define MPU9250_REG_INT_STATUS
void mpu9250_spi_init(struct Mpu9250_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
void mpu9250_spi_read(struct Mpu9250_Spi *mpu)
static void mpu9250_spi_write_to_reg(void *mpu, uint8_t _reg, uint8_t _val)
void mpu9250_spi_start_configure(struct Mpu9250_Spi *mpu)
bool mpu9250_configure_i2c_slaves(Mpu9250ConfigSet mpu_set, void *mpu)
configure the registered I2C slaves
#define Int16FromBuf(_buf, _idx)
void mpu9250_spi_event(struct Mpu9250_Spi *mpu)
Driver for the MPU-9250 using SPI.
volatile bool data_available
data ready flag
uint8_t data_ext[MPU9250_BUFFER_EXT_LEN]
enum Mpu9250SpiSlaveInitStatus slave_init_status
volatile uint8_t rx_buf[MPU9250_BUFFER_LEN]
struct Mpu9250Config config
volatile uint8_t tx_buf[2]
union Mpu9250_Spi::@345 data_accel
struct spi_periph * spi_p
struct spi_transaction spi_trans
union Mpu9250_Spi::@346 data_rates
#define MPU9250_BUFFER_LEN
@ MPU9250_SPI_CONF_UNINIT
@ MPU9250_SPI_CONF_SLAVES_CONFIGURE
@ MPU9250_SPI_CONF_I2C_MST_EN
@ MPU9250_SPI_CONF_I2C_MST_DELAY
@ MPU9250_SPI_CONF_I2C_MST_CLK
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.