172 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
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.
uint8_t mag_mode
Measurement mode.
static void lsm303d_set_default_config(struct Lsm303dConfig *c)
uint8_t mag_rate
Data Output Rate Bits (Hz)
uint8_t mag_scale
Full scale gain configuration (Gauss)
uint8_t acc_rate
Data Output Rate (Hz)
uint8_t acc_scale
full scale selection (m/s²)
#define LSM303D_INT2_DRDY_M
#define LSM303D_REG_CTRL7
#define LSM303D_M_ODR_MASK
#define LSM303D_AODR_MASK
#define LSM303D_REG_CTRL4
#define LSM303D_REG_WHO_AM_I
#define LSM303D_INT1_DRDY_A
#define LSM303D_AHPM_MASK
#define LSM303D_REG_CTRL1
#define LSM303D_REG_WHO_I_AM
LSM303D device identifier in LSM303D_REG_WHO_AM_I.
#define LSM303D_REG_STATUS_M
#define LSM303D_REG_CTRL3
#define LSM303D_REG_CTRL2
#define LSM303D_REG_CTRL5
#define LSM303D_REG_CTRL6
#define LSM303D_REG_STATUS_A
void lsm303d_spi_event(struct Lsm303d_Spi *lsm)
void lsm303d_spi_init(struct Lsm303d_Spi *lsm, struct spi_periph *spi_p, uint8_t slave_idx, enum Lsm303dTarget target)
static void lsm303d_spi_send_config(struct Lsm303d_Spi *lsm)
Configuration function called once before normal use.
static void lsm303d_spi_tx_reg(struct Lsm303d_Spi *lsm, uint8_t reg, uint8_t val)
void lsm303d_spi_start_configure(struct Lsm303d_Spi *lsm)
#define Int16FromBuf(_buf, _idx)
void lsm303d_spi_read(struct Lsm303d_Spi *lsm)
Driver for ST LSM303D 3D accelerometer and magnetometer.
struct spi_transaction spi_trans
volatile uint8_t rx_buf[8]
enum Lsm303dConfStatus init_status
union Lsm303d_Spi::@335 data_mag
struct spi_periph * spi_p
bool initialized
config done flag
struct Lsm303dConfig conf
volatile bool data_available_acc
data ready flag accelero
enum Lsm303dTarget target
volatile bool data_available_mag
data ready flag magneto
union Lsm303d_Spi::@334 data_accel
volatile uint8_t tx_buf[2]
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.