108 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
117 if (bit_is_set(mpu->
rx_buf[1], 0)) {
127 mpu->
temp = (float)temp_raw / 340.0f + 36.53f;
134 #pragma GCC diagnostic push
135 #pragma GCC diagnostic ignored "-Wcast-qual"
137 #pragma GCC diagnostic pop
enum SPIClockPolarity cpol
clock polarity control
void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
#define MPU60X0_REG_USER_CTRL
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
uint16_t output_length
number of data words to write
#define MPU60X0_I2C_MST_EN
bool initialized
config done flag
void mpu60x0_spi_start_configure(struct Mpu60x0_Spi *mpu)
#define MPU60X0_WHOAMI_REPLY
struct Mpu60x0Config config
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
union Mpu60x0_Spi::@314 data_accel
uint8_t nb_slave_init
number of already configured/initialized slaves
#define MPU60X0_REG_I2C_MST_CTRL
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
enum SPIBitOrder bitorder
MSB/LSB order.
#define MPU60X0_BUFFER_LEN
#define MPU60X0_REG_WHO_AM_I
volatile uint8_t rx_buf[MPU60X0_BUFFER_LEN]
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
enum SPISlaveSelect select
slave selection behavior
Mpu60x0I2cSlaveConfigure configure
enum Mpu60x0ConfStatus init_status
init status
enum SPIClockPhase cpha
clock phase control
enum Mpu60x0MstClk i2c_mst_clk
MPU I2C master clock speed.
#define Int16FromBuf(_buf, _idx)
SPI peripheral structure.
#define MPU60X0_I2C_IF_DIS
enum Mpu60x0SpiSlaveInitStatus slave_init_status
#define MPU60X0_REG_I2C_MST_DELAY
struct spi_transaction spi_trans
SPICallback after_cb
NULL or function called after the transaction.
#define MPU60X0_I2C_NB_SLAVES
uint8_t nb_slaves
number of used I2C slaves
static void mpu60x0_spi_write_to_reg(void *mpu, uint8_t _reg, uint8_t _val)
float temp
temperature in degrees Celcius
struct spi_periph * spi_p
void mpu60x0_spi_read(struct Mpu60x0_Spi *mpu)
volatile uint8_t tx_buf[2]
uint16_t input_length
number of data words to read
volatile bool data_available
data ready flag
void mpu60x0_send_config(Mpu60x0ConfigSet mpu_set, void *mpu, struct Mpu60x0Config *config)
Configuration sequence called once before normal use.
#define MPU60X0_REG_INT_STATUS
union Mpu60x0_Spi::@315 data_rates
bool mpu60x0_configure_i2c_slaves(Mpu60x0ConfigSet mpu_set, void *mpu)
configure the registered I2C slaves
slave is selected before transaction and unselected after
enum SPIDataSizeSelect dss
data transfer word size
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
SPICallback before_cb
NULL or function called before the transaction.
void mpu60x0_set_default_config(struct Mpu60x0Config *c)
uint8_t nb_bytes
number of bytes to read starting with MPU60X0_REG_INT_STATUS
Driver for the MPU-60X0 using SPI.
struct Mpu60x0I2cSlave slaves[MPU60X0_I2C_NB_SLAVES]
I2C slaves.
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
enum SPITransactionStatus status