172 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
enum SPIClockPolarity cpol
clock polarity control
#define LSM303D_REG_WHO_I_AM
LSM303D device identifier in LSM303D_REG_WHO_AM_I.
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint16_t output_length
number of data words to write
#define LSM303D_AODR_MASK
#define LSM303D_REG_WHO_AM_I
#define LSM303D_INT2_DRDY_M
bool initialized
config done flag
union Lsm303d_Spi::@323 data_mag
#define LSM303D_REG_STATUS_M
#define LSM303D_REG_CTRL2
#define LSM303D_REG_CTRL6
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
static void lsm303d_spi_send_config(struct Lsm303d_Spi *lsm)
Configuration function called once before normal use.
enum SPIBitOrder bitorder
MSB/LSB order.
void lsm303d_spi_read(struct Lsm303d_Spi *lsm)
#define LSM303D_REG_CTRL7
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
Driver for ST LSM303D 3D accelerometer and magnetometer.
#define LSM303D_REG_CTRL5
enum SPISlaveSelect select
slave selection behavior
union Lsm303d_Spi::@322 data_accel
struct spi_periph * spi_p
uint8_t acc_scale
full scale selection (m/s²)
#define LSM303D_M_ODR_MASK
volatile uint8_t rx_buf[8]
enum SPIClockPhase cpha
clock phase control
uint8_t mag_scale
Full scale gain configuration (Gauss)
SPI peripheral structure.
uint8_t mag_mode
Measurement mode.
static void lsm303d_set_default_config(struct Lsm303dConfig *c)
volatile bool data_available_mag
data ready flag magneto
struct spi_transaction spi_trans
uint8_t mag_rate
Data Output Rate Bits (Hz)
volatile bool data_available_acc
data ready flag accelero
SPICallback after_cb
NULL or function called after the transaction.
enum Lsm303dTarget target
#define LSM303D_AHPM_MASK
volatile uint8_t tx_buf[2]
void lsm303d_spi_init(struct Lsm303d_Spi *lsm, struct spi_periph *spi_p, uint8_t slave_idx, enum Lsm303dTarget target)
#define LSM303D_REG_CTRL4
uint16_t input_length
number of data words to read
void lsm303d_spi_event(struct Lsm303d_Spi *lsm)
struct Lsm303dConfig conf
static void lsm303d_spi_tx_reg(struct Lsm303d_Spi *lsm, uint8_t reg, uint8_t val)
uint8_t acc_rate
Data Output Rate (Hz)
slave is selected before transaction and unselected after
#define LSM303D_INT1_DRDY_A
#define LSM303D_REG_CTRL3
enum SPIDataSizeSelect dss
data transfer word size
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
#define LSM303D_REG_CTRL1
SPICallback before_cb
NULL or function called before the transaction.
#define Int16FromBuf(_buf, _idx)
void lsm303d_spi_start_configure(struct Lsm303d_Spi *lsm)
#define LSM303D_REG_STATUS_A
enum SPITransactionStatus status
enum Lsm303dConfStatus init_status