179 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
void lsm303dlhc_spi_event(struct Lsm303dlhc_Spi *lsm)
enum SPIClockPolarity cpol
clock polarity control
#define LSM303DLHC_FS_MASK
#define LSM303DLHC_WHO_I_AM
#define LSM303DLHC_REG_CTRL3
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
#define LSM303DLHC_M_ODR_MASK
uint16_t output_length
number of data words to write
#define LSM303DLHC_AHPM_MASK
#define LSM303DLHC_REG_STATUS_REG_M
struct spi_periph * spi_p
#define LSM303DLHC_I1_DRDY_A
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
enum SPIBitOrder bitorder
MSB/LSB order.
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
static void lsm303dlhc_acc_set_default_config(struct Lsm303dlhcAccConfig *c)
#define LSM303DLHC_REG_WHO_AM_I
enum SPISlaveSelect select
slave selection behavior
volatile uint8_t rx_buf[8]
enum SPIClockPhase cpha
clock phase control
volatile bool data_available_acc
data ready flag accelero
SPI peripheral structure.
void lsm303dlhc_spi_start_configure(struct Lsm303dlhc_Spi *lsm)
#define LSM303DLHC_REG_CTRL7
union Lsm303dlhc_Spi::@310 data_mag
volatile uint8_t tx_buf[2]
union Lsm303dlhc_Spi::@311 config
#define LSM303DLHC_MFS_MASK
SPICallback after_cb
NULL or function called after the transaction.
#define Int16FromBuf(_buf, _idx)
union Lsm303dlhc_Spi::@309 data_accel
#define LSM303DLHC_REG_STATUS_REG_A
#define LSM303DLHC_AODR_MASK
#define LSM303DLHC_REG_CTRL1
#define LSM303DLHC_REG_CTRL4
struct spi_transaction spi_trans
#define LSM303DLHC_REG_CTRL5
enum Lsm303dlhcTarget target
uint16_t input_length
number of data words to read
bool initialized
config done flag
static void lsm303dlhc_mag_set_default_config(struct Lsm303dlhcMagConfig *c)
volatile bool data_available_mag
data ready flag magneto
void lsm303dlhc_spi_read(struct Lsm303dlhc_Spi *lsm)
#define LSM303DLHC_REG_STATUS_ZYXMDA
static void lsm303dlhc_spi_send_config(struct Lsm303dlhc_Spi *lsm)
Configuration function called once before normal use.
#define LSM303DLHC_REG_CTRL6
slave is selected before transaction and unselected after
#define LSM303DLHC_REG_STATUS_ZYXADA
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
void lsm303dlhc_spi_init(struct Lsm303dlhc_Spi *lsm, struct spi_periph *spi_p, uint8_t slave_idx, enum Lsm303dlhcTarget target)
enum Lsm303dlhcConfStatus init_status
SPICallback before_cb
NULL or function called before the transaction.
static void lsm303dlhc_spi_tx_reg(struct Lsm303dlhc_Spi *lsm, uint8_t reg, uint8_t val)
#define LSM303DLHC_REG_CTRL2
enum SPITransactionStatus status
#define LSM303DLHC_I2_DRDY_M