126 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
135 if (bit_is_set(mpu->
rx_buf[1], 0)) {
146 mpu->
temp = (float)temp_raw / 361.0f + 35.0f;
148 mpu->
temp = (float)temp_raw / 326.8f + 25.0f;
156 #pragma GCC diagnostic push
157 #pragma GCC diagnostic ignored "-Wcast-qual"
159 #pragma GCC diagnostic pop
enum Mpu60x0Type type
The type of sensor (MPU60x0, ICM20608, ...)
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
#define ICM20608_WHOAMI_REPLY
bool initialized
config done flag
#define ICM20600_WHOAMI_REPLY
void mpu60x0_spi_start_configure(struct Mpu60x0_Spi *mpu)
#define MPU60X0_WHOAMI_REPLY
struct Mpu60x0Config config
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
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
union Mpu60x0_Spi::@331 data_accel
#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
bool mpu60x0_configure_i2c_slaves(Mpu60x0ConfigSet mpu_set, void *mpu)
configure the registered I2C slaves
slave is selected before transaction and unselected after
#define ICM20602_WHOAMI_REPLY
#define ICM20689_WHOAMI_REPLY
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
union Mpu60x0_Spi::@332 data_rates