978#if !IS_USED(MODULE_L3GD20H) && !IS_USED(MODULE_L3GD20) \
979 && !IS_USED(MODULE_L3G4200D_NG) \
980 && !IS_USED(MODULE_A3G4250D) \
981 && !IS_USED(MODULE_I3G4250D)
982#error Please select your sensor variant by using the respective pseudomodule.
989#if IS_USED(MODULE_L3GD20H) || IS_USED(MODULE_L3GD20)
990#define L3GXXXX_I2C_ADDR_1 (0x6a)
991#define L3GXXXX_I2C_ADDR_2 (0x6b)
993#define L3GXXXX_I2C_ADDR_1 (0x68)
994#define L3GXXXX_I2C_ADDR_2 (0x69)
1002#define L3GXXXX_CHIP_ID_L3GD20H (0xd7)
1003#define L3GXXXX_CHIP_ID_L3GD20 (0xd4)
1004#define L3GXXXX_CHIP_ID_X3G42XXD (0xd3)
1083#if IS_USED(MODULE_L3GD20H) || IS_USED(MODULE_L3GXXXX_LOW_ODR) || DOXYGEN
1119#if IS_USED(MODULE_L3GD20H) || IS_USED(MODULE_L3GD20) || DOXYGEN
1127#if IS_USED(MODULE_L3GD20H) || DOXYGEN
1253#define L3GXXXX_INT_DATA (L3GXXXX_INT_DATA_READY | \
1254 L3GXXXX_INT_FIFO_WATERMARK | \
1255 L3GXXXX_INT_FIFO_OVERRUN | \
1256 L3GXXXX_INT_FIFO_EMPTY)
1386#if IS_USED(MODULE_L3GXXXX_I2C) || DOXYGEN
1389#if IS_USED(MODULE_L3GXXXX_SPI) || DOXYGEN
1394#if IS_USED(MODULE_L3GXXXX_I2C) || DOXYGEN
1404#if IS_USED(MODULE_L3GXXXX_SPI) || DOXYGEN
1421#if IS_USED(MODULE_L3GXXXX_I2C) || DOXYGEN
1424#if IS_USED(MODULE_L3GXXXX_SPI) || DOXYGEN
1443#if IS_USED(MODULE_L3GXXXX_FIFO) || DOXYGEN
1448#if IS_USED(MODULE_L3GXXXX_IRQ_DATA) || DOXYGEN
1453#if IS_USED(MODULE_L3GXXXX_IRQ_EVENT) || DOXYGEN
1496#if IS_USED(MODULE_L3GXXXX_CONFIG) || DOXYGEN
1561#if IS_USED(MODULE_L3GXXXX_SLEEP) || DOXYGEN
1665#if IS_USED(MODULE_L3GXXXX_FIFO) || DOXYGEN
1672#if IS_USED(MODULE_L3GXXXX_CONFIG) || DOXYGEN
1745#if IS_USED(MODULE_L3GXXXX_CONFIG) || DOXYGEN
1846#if IS_USED(MODULE_L3GXXXX_IRQ) || DOXYGEN
1900#if IS_USED(MODULE_L3GXXXX_IRQ_EVENT) || DOXYGEN
1925#if IS_USED(MODULE_L3GXXXX_CONFIG) || DOXYGEN
1973 uint8_t reg,
const uint8_t *data, uint8_t len);
1991 uint8_t reg, uint8_t *data, uint8_t len);
Low-level GPIO peripheral driver interface definitions.
int l3gxxxx_set_mode(l3gxxxx_t *dev, l3gxxxx_odr_t odr, bool x, bool y, bool z)
Set sensor mode.
int l3gxxxx_reg_write(const l3gxxxx_t *dev, uint8_t reg, const uint8_t *data, uint8_t len)
Direct write to register.
int l3gxxxx_read(const l3gxxxx_t *dev, l3gxxxx_data_t *data)
Read last sample of angular rates in millidegree per second (mpds)
l3gxxxx_int_types_t
Interrupt types.
int l3gxxxx_data_ready(const l3gxxxx_t *dev)
Data ready status function.
l3gxxxx_int_pin_level_t
INT1, INT2/DRDY sensor signal activity level
int l3gxxxx_read_raw_fifo(const l3gxxxx_t *dev, l3gxxxx_raw_data_fifo_t raw)
Get all samples of raw output data stored in the FIFO.
int l3gxxxx_power_up(l3gxxxx_t *dev)
Power up the sensor.
int l3gxxxx_select_output_filter(l3gxxxx_t *dev, l3gxxxx_filter_sel_t filter)
Filter selection for raw output data.
l3gxxxx_hpf_mode_t
HPF (high pass filter) modes.
int l3gxxxx_enable_int(const l3gxxxx_t *dev, l3gxxxx_int_types_t mask, bool enable)
Enable or disable event and/or data interrupts on signal INT1 and INT2/DRDY
l3gxxxx_filter_sel_t
High pass filter (HPF) and low pass filter 2 (LPF2) selection.
l3gxxxx_scale_t
Full scale in degrees per second (dps)
int l3gxxxx_init(l3gxxxx_t *dev, const l3gxxxx_params_t *params)
Initialize the L3Gxxxx sensor device.
int l3gxxxx_reg_read(const l3gxxxx_t *dev, uint8_t reg, uint8_t *data, uint8_t len)
Direct read from register.
l3gxxxx_data_t l3gxxxx_data_fifo_t[32]
Angular rates FIFO type.
int l3gxxxx_sleep(l3gxxxx_t *dev)
Sleep mode.
int l3gxxxx_set_int_event_cfg(const l3gxxxx_t *dev, const l3gxxxx_int_event_cfg_t *cfg)
Set new configuration for event interrupt generation.
l3gxxxx_fifo_mode_t
FIFO mode.
int l3gxxxx_set_hpf_ref(const l3gxxxx_t *dev, int8_t ref)
Set HPF (high pass filter) reference.
l3gxxxx_int_src_t l3gxxxx_wait_int(l3gxxxx_t *dev)
Wait for event and/or data interrupts on signals INT1 and INT2/DRDY
int l3gxxxx_read_fifo(const l3gxxxx_t *dev, l3gxxxx_data_fifo_t data)
Get all samples of angular rates stored in the FIFO (unit mdps)
int l3gxxxx_config_hpf(const l3gxxxx_t *dev, l3gxxxx_hpf_mode_t mode, uint8_t cutoff)
Config HPF (high pass filter) for output data.
l3gxxxx_if_t
L3Gxxxx interface types.
l3gxxxx_int_pin_type_t
INT1, INT2/DRDY sensor signal type
int l3gxxxx_power_down(l3gxxxx_t *dev)
Power down the sensor.
int l3gxxxx_read_raw(const l3gxxxx_t *dev, l3gxxxx_raw_data_t *raw)
Read last sample of raw output data as 16 bit two's complements.
int l3gxxxx_get_hpf_ref(const l3gxxxx_t *dev, int8_t *ref)
Get HPF (high pass filter) reference.
int l3gxxxx_set_fifo_mode(l3gxxxx_t *dev, l3gxxxx_fifo_mode_t mode, uint8_t watermark)
Set FIFO mode and watermark level (threshold)
l3gxxxx_raw_data_t l3gxxxx_raw_data_fifo_t[32]
Raw output data FIFO type.
l3gxxxx_error_codes_t
Definition of error codes.
int l3gxxxx_wake_up(l3gxxxx_t *dev)
Wake-up the sensor.
l3gxxxx_odr_t
Sensor output data rates (ODR) and LPF2 cutoff frequencies.
int l3gxxxx_get_int_event_cfg(const l3gxxxx_t *dev, l3gxxxx_int_event_cfg_t *cfg)
Get current configuration of event interrupt generation.
int l3gxxxx_set_scale(l3gxxxx_t *dev, l3gxxxx_scale_t scale)
Set full scale.
@ L3GXXXX_INT_FIFO_OVERRUN
Data interrupt on signal INT2/DRDY: FIFO is completely filled.
@ L3GXXXX_INT_EVENT
Event interrupt on signal INT1: Angular rate of one or more axes is lower or higher than the configur...
@ L3GXXXX_INT_FIFO_EMPTY
Data interrupt on signal INT2/DRDY: FIFO becomes empty.
@ L3GXXXX_INT_DATA_READY
Data interrupt on signal INT2/DRDY: Output data are ready to be read.
@ L3GXXXX_INT_FIFO_WATERMARK
Data interrupt on signal INT2/DRDY: FIFO filling exceeds the watermark level (threshold)
@ L3GXXXX_HIGH
INT signals are High active (default)
@ L3GXXXX_LOW
INT signals are Low active.
@ L3GXXXX_HPF_AUTORESET
Autoreset mode, HPF is automatically reset when a configured event interrupt occurs.
@ L3GXXXX_HPF_REFERENCE
Reference mode, output data are the difference to the REFERENCE register.
@ L3GXXXX_HPF_NORMAL
Normal mode, HPF is reset by reading the REFERENCE register.
@ L3GXXXX_NO_FILTER
HPF not used, LPF2 not used (default)
@ L3GXXXX_HPF_ONLY
HPF used, LPF2 not used.
@ L3GXXXX_HPF_AND_LPF2
HPF used, LPF2 used.
@ L3GXXXX_LPF2_ONLY
HPF not used, LPF2 used.
@ L3GXXXX_SCALE_2000_DPS
2000 dps
@ L3GXXXX_SCALE_245_DPS
245 dps (default)
@ L3GXXXX_SCALE_500_DPS
500 dps
@ L3GXXXX_STREAM_TO_FIFO
FIFO is used in Stream mode until an interrupt, switches then to FIFO mode (L3GD20H and L3GD20 only)
@ L3GXXXX_STREAM
FIFO is used as ring buffer and newest data samples are stored continuously.
@ L3GXXXX_DYNAMIC_STREAM
like Stream mode, but differs in reading the first data sample after emptying (L3GD20H only)
@ L3GXXXX_BYPASS_TO_FIFO
FIFO is not used until an interrupt, switches then to FIFO mode (L3GD20H only)
@ L3GXXXX_BYPASS
FIFO is not used (default)
@ L3GXXXX_BYPASS_TO_STREAM
FIFO is not used until an interrupt, switches then to Stream mode (L3GD20H and L3GD20 only)
@ L3GXXXX_FIFO
Data samples are stored in the FIFO until it is full.
@ L3GXXXX_SPI
SPI interface used.
@ L3GXXXX_I2C
I2C interface used.
@ L3GXXXX_OPEN_DRAIN
INT pins are open-drain.
@ L3GXXXX_PUSH_PULL
INT pins are push/pull outputs (default)
@ L3GXXXX_ERROR_BYPASS_MODE
sensor is in bypass mode
@ L3GXXXX_ERROR_I2C
I2C communication error.
@ L3GXXXX_ERROR_INV_INT_TYPE
invalid interrupt type used
@ L3GXXXX_ERROR_WRONG_CHIP_ID
wrong chip id read from WHO_AM_I reg
@ L3GXXXX_ERROR_RAW_DATA_FIFO
reading raw output data from FIFO failed
@ L3GXXXX_ERROR_SPI
SPI communication error.
@ L3GXXXX_ERROR_NO_INT1_PIN
INT1 signal pin not configured
@ L3GXXXX_ERROR_INV_MODE
sensor mode is invalid or not available
@ L3GXXXX_ERROR_FIFO_MODE
sensor is in FIFO mode
@ L3GXXXX_ERROR_INV_DEV
invalid device type used
@ L3GXXXX_ERROR_NO_INT2_PIN
INT2/DRDY signal pin not configured
@ L3GXXXX_ERROR_RAW_DATA
reading raw output data failed
@ L3GXXXX_ERROR_INV_FIFO_MODE
FIFO mode is invalid or not available.
@ L3GXXXX_ERROR_NO_NEW_DATA
no new data are available
@ L3GXXXX_ODR_800_35
High ODR 400 Hz, LPF1 cutoff 211 Hz, LPF2 cutoff 35 Hz.
@ L3GXXXX_ODR_400_110
High ODR 400 Hz, LPF1 cutoff 128 Hz, LPF2 cutoff 110 Hz.
@ L3GXXXX_ODR_50
Low ODR 50 Hz, LPF1 cutoff 16 Hz, LPF2 cutoff 16.6 Hz.
@ L3GXXXX_ODR_800_50
High ODR 400 Hz, LPF1 cutoff 211 Hz, LPF2 cutoff 50 Hz.
@ L3GXXXX_ODR_200_12
High ODR 200 Hz, LPF1 cutoff 63.3 Hz, LPF2 cutoff 12.5 Hz.
@ L3GXXXX_ODR_800_30
High ODR 400 Hz, LPF1 cutoff 211 Hz, LPF2 cutoff 30 Hz.
@ L3GXXXX_ODR_200_70
High ODR 200 Hz, LPF1 cutoff 63.3 Hz, LPF2 cutoff 70 Hz.
@ L3GXXXX_ODR_400_25
High ODR 400 Hz, LPF1 cutoff 128 Hz, LPF2 cutoff 25 Hz.
@ L3GXXXX_ODR_400_20
High ODR 400 Hz, LPF1 cutoff 128 Hz, LPF2 cutoff 20 Hz.
@ L3GXXXX_ODR_100_12
High ODR 100 Hz, LPF1 cutoff 32 Hz, LPF2 cutoff 12.5 Hz.
@ L3GXXXX_ODR_12
Low ODR 12.5 Hz, LPF1 cutoff 3.9 Hz, LPF2 not used.
@ L3GXXXX_ODR_200_50
High ODR 200 Hz, LPF1 cutoff 63.3 Hz, LPF2 cutoff 50 Hz.
@ L3GXXXX_ODR_800_100
High ODR 400 Hz, LPF1 cutoff 211 Hz, LPF2 cutoff 100 Hz.
@ L3GXXXX_ODR_200_25
High ODR 200 Hz, LPF1 cutoff 63.3 Hz, LPF2 cutoff 25 Hz.
@ L3GXXXX_ODR_25
Low ODR 25 Hz, LPF1 cutoff 7.8 Hz, LPF2 not used.
@ L3GXXXX_ODR_400_50
High ODR 400 Hz, LPF1 cutoff 128 Hz, LPF2 cutoff 50 Hz.
@ L3GXXXX_ODR_100_25
High ODR 100 Hz, LPF1 cutoff 32 Hz, LPF2 cutoff 25 Hz.
uint_fast8_t i2c_t
Default i2c_t type definition.
Low-level I2C peripheral driver interface definition.
Register definitions for ST L3Gxxxx 3-axis gyroscope sensor family.
#define L3GXXXX_INT2_WTM
L3GXXXX_REG_CTRL3<2>
#define L3GXXXX_INT2_ORUN
L3GXXXX_REG_CTRL3<1>
#define L3GXXXX_INT2_EMPTY
L3GXXXX_REG_CTRL3<0>
#define L3GXXXX_INT2_DRDY
L3GXXXX_REG_CTRL3<3>
#define L3GXXXX_INT1_IG
L3GXXXX_REG_CTRL3<7>
Mutex for thread synchronization.
Low-level SPI peripheral driver interface definition.
Angular rates in millidegrees per seconds (mdps)
int32_t z
Z angular rate (yaw)
int32_t y
Y angular rate (pitch)
int32_t x
X angular rate (roll)
L3Gxxxx I2C interface parameters.
i2c_t dev
I2C device used.
uint8_t addr
I2C slave address.
L3Gxxxx Hardware interface parameters union.
l3gxxxx_spi_params_t spi
SPI interface parameters.
l3gxxxx_i2c_params_t i2c
I2C interface parameters.
l3gxxxx_if_t type
I2C/SPI interface type selector.
Event interrupt generator configuration (axis movement and wake-up)
bool y_low_enabled
Interrupt enabled for |Y| < Y threshold (Y low event)
bool counter_mode
DCRM is not documented and not used therefore.
bool z_high_enabled
Interrupt enabled for |Z| > Z threshold (Y high event)
uint16_t x_threshold
X threshold value in full scale / INT16_MAX.
bool x_high_enabled
Interrupt enabled for |X| > X threshold (X high event)
l3gxxxx_filter_sel_t filter
HPF and LPF2 filter selection used for threshold comparison.
bool y_high_enabled
Interrupt enabled for |Y| > Y threshold (Y high event)
bool latch
Latch the interrupt when true until the interrupt source has been read by function l3gxxxx_wait_int.
bool and_or
Combination of interrupt events (true=AND, false=OR): AND - all enabled axes passed their thresholds...
uint16_t z_threshold
Z threshold value in full scale / INT16_MAX.
bool wait
When true, duration is also used when interrupt condition in no longer given before interrupt signal ...
bool z_low_enabled
Interrupt enabled for |Z| < Z threshold (Z low event)
uint16_t y_threshold
Y threshold value in full scale / INT16_MAX.
uint8_t duration
Duration in 1/ODR an interrupt condition has to be given before the interrupt is generated.
bool x_low_enabled
Interrupt enabled for |X| < X threshold (X low event)
Composite type for all possible interrupt sources.
l3gxxxx_int_data_src_t data
data interrupt sources
l3gxxxx_int_event_src_t event
event interrupt sources
L3Gxxxx device initialization parameters.
gpio_t int1_pin
MCU GPIO pin for event interrupts on signal INT1
uint8_t hpf_cutoff
HPF cutoff frequency 0..9, see l3gxxxx_config_hpf for details.
gpio_t int2_pin
MCU GPIO pin for data interrupts on signal INT2/DRDY pin.
uint8_t fifo_watermark
FIFO watermark setting 0..31.
l3gxxxx_scale_t scale
Full scale.
l3gxxxx_if_params_t if_params
Interface parameters (I2C/SPI)
l3gxxxx_fifo_mode_t fifo_mode
FIFO operation mode.
l3gxxxx_filter_sel_t filter_sel
HPF/LPF2 filter selection.
l3gxxxx_int_event_cfg_t int1_cfg
event interrupt parameters
l3gxxxx_odr_t odr
ODR and LPF2 cutoff frequency.
l3gxxxx_hpf_mode_t hpf_mode
HPF mode.
Raw output data set as two's complements.
int16_t z
Z angular rate (yaw) as 16 bit two's complements.
int16_t x
X angular rate (roll) as 16 bit two's complements.
int16_t y
Y angular rate (pitch) as 16 bit two's complements.
L3Gxxxx SPI interface parameters.
spi_t dev
SPI device used.
spi_clk_t clk
SPI clock speed.
gpio_t cs
SPI chip Select pin.
L3Gxxxx sensor device data structure type.
mutex_t int_lock
Used to lock the calling thread while waiting for an interrupt.
l3gxxxx_int_types_t int_type
Type of the last interrupt triggered.
l3gxxxx_params_t params
Device initialization parameters.
@ L3GD20H
Sensor detected at runtime.
Data interrupt sources (data ready and FIFO status)
uint8_t fifo_empty
true when FIFO is empty
uint8_t fifo_overrun
true when FIFO is completely filled
uint8_t val
data interrupt sources as value that can be used for bitwise operations
uint8_t fifo_watermark
true when FIFO filling > watermark
uint8_t data_ready
true when data are ready to read
Event interrupt sources (axis movement and wake-up)
uint8_t y_low
true on |Y| < Y threshold (Y low event)
uint8_t y_high
true on |Y| > Y threshold (Y high event)
uint8_t z_low
true on |Z| < Z threshold (Z low event)
uint8_t val
event interrupt sources as value that can be used for bitwise operations
uint8_t x_low
true on |X| < X threshold (X low event)
uint8_t z_high
true on |Z| > Z threshold (Z high event)
uint8_t x_high
true on |X| > X threshold (X high event)
uint8_t active
true when one or more events have been generated