133 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
142 if (bit_is_set(l3g->
rx_buf[1], 3)) {
enum SPIClockPolarity cpol
clock polarity control
#define L3GD20_REG_CTRL_REG1
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint16_t output_length
number of data words to write
void l3gd20_spi_start_configure(struct L3gd20_Spi *l3g)
struct spi_transaction spi_trans
void l3gd20_spi_event(struct L3gd20_Spi *l3g)
struct spi_periph * spi_p
enum L3gd20ConfStatus init_status
init status
enum L3gd20DRBW drbw
Data rate and bandwidth.
union L3gd20_Spi::@36 data_rates
enum SPIBitOrder bitorder
MSB/LSB order.
void l3gd20_spi_init(struct L3gd20_Spi *l3g, struct spi_periph *spi_p, uint8_t slave_idx)
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
enum SPISlaveSelect select
slave selection behavior
volatile bool_t data_available
data ready flag
volatile uint8_t tx_buf[2]
enum SPIClockPhase cpha
clock phase control
static void l3gd20_set_default_config(struct L3gd20Config *c)
enum L3gd20FullScale full_scale
gyro full scale
SPI peripheral structure.
Driver for L3GD20 3-axis gyroscope from ST using SPI.
bool_t spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit a spi transaction.
SPICallback after_cb
NULL or function called after the transaction.
static void l3gd20_spi_send_config(struct L3gd20_Spi *l3g)
volatile uint8_t rx_buf[8]
static void l3gd20_spi_write_to_reg(struct L3gd20_Spi *l3g, uint8_t _reg, uint8_t _val)
bool_t initialized
config done flag
#define L3GD20_WHO_AM_I
L3GD20 device identifier contained in L3GD20_REG_WHO_AM_I.
uint16_t input_length
number of data words to read
#define Int16FromBuf(_buf, _idx)
slave is selected before transaction and unselected after
#define L3GD20_REG_STATUS_REG
enum SPIDataSizeSelect dss
data transfer word size
#define L3GD20_REG_WHO_AM_I
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
bool_t spi_3_wire
Set 3-wire SPI mode, if FALSE: 4-wire SPI mode.
volatile uint8_t * input_buf
pointer to receive buffer for DMA
#define L3GD20_REG_CTRL_REG4
SPICallback before_cb
NULL or function called before the transaction.
void l3gd20_spi_read(struct L3gd20_Spi *l3g)
struct L3gd20Config config
enum SPITransactionStatus status