127 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
136 if (bit_is_set(mpu->
rx_buf[1], 0)) {
150 mpu->
temp = (float)temp_raw / 326.8f + 25.0f;
153 mpu->
temp = (float)temp_raw * 0.003f + 25.0f;
156 mpu->
temp = (float)temp_raw / 340.0f + 36.53f;
165 #pragma GCC diagnostic push
166 #pragma GCC diagnostic ignored "-Wcast-qual"
168 #pragma GCC diagnostic pop
183 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 mpu60x0_set_default_config(struct Mpu60x0Config *c)
void mpu60x0_send_config(Mpu60x0ConfigSet mpu_set, void *mpu, struct Mpu60x0Config *config)
Configuration sequence called once before normal use.
Mpu60x0I2cSlaveConfigure configure
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
#define MPU60X0_I2C_NB_SLAVES
enum Mpu60x0MstClk i2c_mst_clk
MPU I2C master clock speed.
bool initialized
config done flag
uint8_t nb_bytes
number of bytes to read starting with MPU60X0_REG_INT_STATUS
uint8_t nb_slaves
number of used I2C slaves
uint8_t nb_slave_init
number of already configured/initialized slaves
struct Mpu60x0I2cSlave slaves[MPU60X0_I2C_NB_SLAVES]
I2C slaves.
enum Mpu60x0Type type
The type of sensor (MPU60x0, ICM20608, ...)
enum Mpu60x0ConfStatus init_status
init status
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
#define MPU60X0_REG_USER_CTRL
#define MPU6500_WHOAMI_REPLY
#define MPU60X0_WHOAMI_REPLY
#define ICM20600_WHOAMI_REPLY
#define MPU60X0_REG_WHO_AM_I
#define MPU60X0_REG_INT_STATUS
#define ICM20689_WHOAMI_REPLY
#define MPU60X0_I2C_IF_DIS
#define ICM20602_WHOAMI_REPLY
#define MPU60X0_REG_I2C_MST_CTRL
#define ICM20608_WHOAMI_REPLY
#define MPU60X0_I2C_MST_EN
#define MPU60X0_REG_I2C_MST_DELAY
void mpu60x0_spi_read(struct Mpu60x0_Spi *mpu)
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
void mpu60x0_spi_start_configure(struct Mpu60x0_Spi *mpu)
#define Int16FromBuf(_buf, _idx)
bool mpu60x0_configure_i2c_slaves(Mpu60x0ConfigSet mpu_set, void *mpu)
configure the registered I2C slaves
static void mpu60x0_spi_write_to_reg(void *mpu, uint8_t _reg, uint8_t _val)
Driver for the MPU-60X0 using SPI.
volatile bool data_available
data ready flag
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
struct Mpu60x0Config config
struct spi_transaction spi_trans
float temp
temperature in degrees Celcius
volatile uint8_t tx_buf[2]
union Mpu60x0_Spi::@344 data_rates
enum Mpu60x0SpiSlaveInitStatus slave_init_status
struct spi_periph * spi_p
@ MPU60X0_SPI_CONF_SLAVES_CONFIGURE
@ MPU60X0_SPI_CONF_UNINIT
@ MPU60X0_SPI_CONF_I2C_MST_CLK
@ MPU60X0_SPI_CONF_I2C_MST_DELAY
@ MPU60X0_SPI_CONF_I2C_MST_EN
volatile uint8_t rx_buf[MPU60X0_BUFFER_LEN]
#define MPU60X0_BUFFER_LEN
union Mpu60x0_Spi::@343 data_accel
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.