Device Driver for ST L3Gxxxx 3-axis gyroscope sensor family. More...
Device Driver for ST L3Gxxxx 3-axis gyroscope sensor family.
INT2/DRDY
] (#l3gxxxx_data_interrupt)INT1
] (#l3gxxxx_event_interrupt)ST L3Gxxxx sensors are low-power 3-axis angular rate sensors connected to I2C or SPI with a full scale of up to 2000 dps. It supports different measuring rates with a user selectable bandwidth.
Main features of the sensor are:
The driver supports the following sensors of the L3Gxxxx 3-axis gyro sensor family. Used sensor variant has to be specified by using the respective pseudomodule.
Sensor Variant | Pseudomodule | Vendor Status |
---|---|---|
L3GD20H | l3gd20h | Not recommended for new designs |
L3GD20 | l3gd20 | Obsolete |
L3G4200D | l3g4200_ng | Obsolete |
A3G4250D | a3g4250d | Active |
I3G4250D | i3g4250d | Active |
The driver is modular and supports different levels of functionality, which can be enabled using pseudomodules according to the requirements of the application. This ensures that the driver only uses as much ROM and RAM as really needed.
As basic functionality the driver supports
The following pseudomodules are used to enable additional functionalities:
Pseudomodule | Functionality |
---|---|
l3gxxxx_i2c | I2C interface enabled |
l3gxxxx_spi | SPI interface enabled |
l3gxxxx_low_odr | Low output data rates enabled (L3GD20H only) |
l3gxxxx_fifo | 32 level FIFO enabled |
l3gxxxx_irq_data | Data interrupt (INT2/DRDY ) handling enabled |
l3gxxxx_irq_event | Event interrupt (INT1 ) handling enabled |
l3gxxxx_sleep | Sleep and wake-up functions enabled |
l3gxxxx_config | Functions for changing configurations at runtime nabled |
The following table shows the mapping of which modules have to be used to enable which functions of the L3Gxxxx.
Feature | Module |
---|---|
16 bit angular rate data output (raw and angular rate) | l3gxxxx |
Full scales of ±245, ±500, and ±2000 dps | l3gxxxx |
Using high-pass filter (HPF) and low-pass filter (LPF1/LPF2) | l3gxxxx |
Output data rates (ODR) from 100 Hz to 800 Hz | l3gxxxx |
Output data rates (ODR) from 12.5 Hz to 50 Hz (L3GD20H only) | l3gxxxx_low_odr |
Polling data | l3gxxxx |
SAUL sensor interface | l3gxxxx |
Power-down and power-up functionality | l3gxxxx |
Sleep and wake-up functionality | l3gxxxx_sleep |
32 level FIFO handling | l3gxxxx_fifo |
Data interrupt (INT2/DRDY ) handling (data ready and FIFO) | l3gxxxx_irq_data |
Event interrupt (INT1 ) handling (Axes movement and wake-up) | l3gxxxx_irq_event |
Configuration of all sensor functions at runtime | l3gxxxx_config |
I2C interface | l3gxxxx_i2c |
SPI interface (SPI mode 3) | l3gxxxx_spi |
l3gxxxx_i2c
or l3gxxxx_spi
, the I2C interface is used by default.l3gxxxx_config
is enabled.l3gxxxx_config
is used.INT2/DRDY
is enabled by module l3gxxxx_irq_data
, it depends on whether module l3gxxxx_fifo
is used, which data interrupts are enabled by default. If l3gxxxx_fifo
is used, L3GXXXX_INT_FIFO_WATERMARK and L3GXXXX_INT_FIFO_OVERRUN interrupts are enabled by default. Otherwise only L3GXXXX_INT_DATA_READY is enabled by default.INT1
is enabled by module l3gxxxx_irq_event
, the high event interrupt is enabled by default for all axes. This means that for each individual axis an interrupt is generated when the absolute value of its angular rate exceeds a threshold value of ~30 dps (high event).INT1
is triggered when the data for one axis becomes greater than the specified threshold (OR condition). The interrupt is latched by default.INT1
signal is a HIGH active push/pull output.L3Gxxxx sensors provide different operating modes.
In normal mode, measurements are performed at a defined output rate (ODR) with a user selectable bandwidth.
L3Gxxxx sensors integrate a combination of two low pass filters (LPF) and one high pass filter (HPF).
First, raw sensor data are always filtered by LPF1 with a cutoff frequency that is fixed for the selected output data rate (ODR), see l3gxxxx_odr_t. Resulting data can then optionally be filtered by HPF and/or LPF2. Both filters can be used or bypassed.
The figure above shows possible filter selections and the driver symbols defined by l3gxxxx_filter_sel_t. These can be used to set the filter combination separately for the output data and the data for event interrupt generation.
Driver symbol | High pass filter (HPF) used | Low pass filter 2 (LPF2) used |
---|---|---|
L3GXXXX_NO_FILTER | - | - |
L3GXXXX_HPF_ONLY | x | - |
L3GXXXX_LPF2_ONLY | - | x |
L3GXXXX_HPF_AND_LPF2 | x | x |
The default filter selection for the output data is L3GXXXX_HPF_AND_LPF2 and is defined by the default configuration parameter CONFIG_L3GXXXX_FILTER_SEL. If the module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_select_output_filter.
The default filter selection for event interrupt generation is L3GXXXX_HPF_AND_LPF2 and is defined by default configuration parameter CONFIG_L3GXXXX_INT1_FILTER. It can be changed at runtime with function l3gxxxx_set_int_event_cfg.
The high pass filter (HPF) can be used in different modes.
Driver symbol | HPF mode |
---|---|
L3GXXXX_HPF_NORMAL | Normal mode |
L3GXXXX_HPF_REFERENCE | Reference mode |
L3GXXXX_HPF_AUTORESET | Auto-reset on interrupt |
In normal mode, the HPF can be reset by reading the REFERENCE register, which instantly deletes the DC component of the angular rate. In reference mode, output data are the difference of raw sensor data and the contents of the REFERENCE register. In autoreset mode, HPF is automatically reset when a configured event interrupt occurs.
The default HPF mode is L3GXXXX_HPF_NORMAL and is defined by the default configuration parameter CONFIG_L3GXXXX_HPF_MODE. If module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_config_hpf.
The cutoff frequencies of LPF1 and LPF2 are determined by used output data rate l3gxxxx_odr_t. The following output data rates (ODR) and the LPF1/LPF2 cutoff frequencies are defined (Reference: Application Note AN4506):
Mode | ODR [Hz] | LPF1 cutoff [Hz] | LPF2 cutoff [Hz] | Driver symbol |
---|---|---|---|---|
Normal | 100 | 32 | 12.5 | L3GXXXX_ODR_100_12 |
Normal | 100 | 32 | 25 | L3GXXXX_ODR_100_25 |
Normal | 200 | 63.3 | 12.5 | L3GXXXX_ODR_200_12 |
Normal | 200 | 63.3 | 25 | L3GXXXX_ODR_200_25 |
Normal | 200 | 63.3 | 50 | L3GXXXX_ODR_200_50 |
Normal | 200 | 63.3 | 70 | L3GXXXX_ODR_200_70 |
Normal | 400 | 128 | 20 | L3GXXXX_ODR_400_20 |
Normal | 400 | 128 | 25 | L3GXXXX_ODR_400_25 |
Normal | 400 | 128 | 50 | L3GXXXX_ODR_400_50 |
Normal | 400 | 128 | 110 | L3GXXXX_ODR_400_110 |
Normal | 800 | 211 | 30 | L3GXXXX_ODR_800_30 |
Normal | 800 | 211 | 35 | L3GXXXX_ODR_800_35 |
Normal | 800 | 211 | 30 | L3GXXXX_ODR_800_30 |
Normal | 800 | 211 | 100 | L3GXXXX_ODR_800_100 |
Low ODR | 12.5 | 3.9 | - | L3GXXXX_ODR_12 |
Low ODR | 25 | 7.8 | - | L3GXXXX_ODR_25 |
Low ODR | 50 | 16 | 16.6 | L3GXXXX_ODR_50 |
l3gxxxx_low_odr
is used.The default output data rate (ODR) is L3GXXXX_ODR_100_12 and defined by the default configuration parameter CONFIG_L3GXXXX_ODR. If module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_set_mode, for example:
The cutoff frequencies of the HPF depend on the selected output data rate (ODR) and are specified by an index from 0 to 9, as shown in the following table. All frequencies are given in Hz.
ODR [Hz] | 12.5 | 25 | 50 | 100 | 200 | 400 | 800 |
---|---|---|---|---|---|---|---|
0 | 1 | 2 | 4 | 8 | 15 | 30 | 56 |
1 | 0.5 | 1 | 2 | 4 | 8 | 15 | 30 |
2 | 0.2 | 0.5 | 1 | 2 | 4 | 8 | 15 |
3 | 0.1 | 0.2 | 0.5 | 1 | 2 | 4 | 8 |
4 | 0.05 | 0.1 | 0.2 | 0.5 | 1 | 2 | 4 |
5 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 | 1 | 2 |
6 | 0.01 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 | 1 |
7 | 0.005 | 0.01 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 |
8 | 0.002 | 0.005 | 0.01 | 0.02 | 0.05 | 0.1 | 0.2 |
9 | 0.001 | 0.002 | 0.005 | 0.01 | 0.02 | 0.05 | 0.1 |
The default cutoff frequency of HPF is 8 Hz (index 0) and set by the default configuration parameter CONFIG_L3GXXXX_HPF_CUTOFF. If module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_config_hpf, for example:
The easiest way to use the driver is simply to initialize the sensor with function l3gxxxx_init using the default configuration parameter set l3gxxxx_params as defined in file l3gxxxx_params.h.
After this initialization, the sensor is fully operational and data can be fetched either by polling or interrupt driven.
The default configuration parameter set defines
l3gxxxx_fifo
is used,INT2/DRDY
) pin if module l3gxxxx_irq_data
is used, andINT1
) configuration if module l3gxxxx_irq_event
is used.Most of these configuration parameters can also be changed at runtime by respective functions if the module l3gxxxx_config
is used or by overriding default configuration parameters. Detailed information about the default configuration can be found in section Configuration.
In normal mode, the sensor determines periodically the angular rate for all axes that are enabled for measurement and produces raw output data with the selected output data rate (ODR).
These raw output data are 16-bit signed integer values in two’s complement representation. Their range and their resolution depend on the sensitivity of the sensor which is selected by the full scale value. L3Gxxxx sensors allow to select the following full scales:
Full Scale | Sensitivity | Driver symbol | Remark |
---|---|---|---|
±245 dps | 8.75 mdps | L3GXXXX_SCALE_245_DPS | |
±500 dps | 17.50 mdps | L3GXXXX_SCALE_500_DPS | not available on A3G4250D |
±2000 dps | 70.00 mdps | L3GXXXX_SCALE_2000_DPS | not available on A3G4250D |
The default full scale value is ±245 dps which is defined by the default configuration parameter CONFIG_L3GXXXX_SCALE. If module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_set_scale, for example:
To get the information whether new data are available, the user task can either use
INT2/DRDY
) which is triggered as soon as new output data are available (see below).Last measurement results can then be fetched either
It is recommended to use function l3gxxxx_read since the driver already converts raw output data to angular rates according to the selected full scale value.
In order to limit the rate at which the host processor has to fetch the data, L3Gxxxx sensors embed a FIFO buffer. This is in particular helpful at high output data rates. The FIFO buffer can work in seven different modes and is able to store up to 32 data samples. Please refer the datasheet or application note for more details.
Driver symbol | FIFO mode | Remark |
---|---|---|
L3GXXXX_BYPASS | Bypass mode | FIFO is not used |
L3GXXXX_FIFO | FIFO mode | |
L3GXXXX_STREAM | Stream mode | |
L3GXXXX_STREAM_TO_FIFO | Stream-to-FIFO mode | L3GD20H and L3GD20 only |
L3GXXXX_BYPASS_TO_STREAM | Bypass-to-Stream mode | L3GD20H and L3GD20 only |
L3GXXXX_DYNAMIC_STREAM | Dynamic Stream mode | L3GD20H only |
L3GXXXX_BYPASS_TO_FIFO | Bypass to FIFO mode | L3GD20H only |
A watermark level (threshold) can be set for the FIFO. If the number of data samples in the FIFO exceeds this value, the watermark flag is set and the interrupt L3GXXXX_INT_FIFO_WATERMARK is triggered, if enabled. This interrupt can be used to gather a minimum number of samples of raw output data before the data are fetched as a single read operation from the sensor.
The default FIFO mode is defined by the default configuration parameter CONFIG_L3GXXXX_FIFO_MODE. The default watermark level (threshold) of the FIFO is defined by the default configuration parameter CONFIG_L3GXXXX_FIFO_WATERMARK.
If module l3gxxxx_config
is used, both configuration parameters can be changed at runtime with function l3gxxxx_set_fifo_mode. This function takes two parameters, the FIFO mode and the watermark level.
To read data from the FIFO, just use either
Both functions clear the FIFO and return the number of samples read from the FIFO.
L3Gxxxx sensors allow to activate interrupts on two different signals:
INT2/DRDY
, andINT1
.Interrupts on signal INT2/DRDY
can be generated by the following sources:
Interrupt source | Driver symbol |
---|---|
Output data are ready to be read | L3GXXXX_INT_DATA_READY |
FIFO content exceeds the watermark level | L3GXXXX_INT_FIFO_WATERMARK |
FIFO is completely filled | L3GXXXX_INT_FIFO_OVERRUN |
FIFO becomes empty | L3GXXXX_INT_FIFO_EMPTY |
L3GXXXX_INT_DATA is the bitwise OR combination of these symbols.
l3gxxxx_irq_data
.Each interrupt source can be enabled or disabled separately with function l3gxxxx_enable_int.
If l3gxxxx_fifo
is used, L3GXXXX_INT_FIFO_WATERMARK and L3GXXXX_INT_FIFO_OVERRUN interrupts are enabled by default. Otherwise only L3GXXXX_INT_DATA_READY is enabled by default.
The MCU GPIO pin used for the INT2/DRDY
interrupt signal has to be defined by the hardware configuration parameter L3GXXXX_INT2_PIN.
Once a data interrupt is enabled, function l3gxxxx_wait_int can be used to wait for an interrupt on signal INT2/DRDY
. This function returns a structure with the interrupt sources of type l3gxxxx_int_src_t which contains a flag for each possible data interrupt source in member l3gxxxx_int_src_t::data that can be tested for true.
If module l3gxxxx_fifo
is used, the corresponding interrupt sources can be tested.
This interrupt signal allows to recognize independent rotations of the X, Y and Z axes. For this purpose, a separate threshold can be defined for each axis. If activated, the angular rate of each axis is compared with its threshold to check whether it is below or above the threshold. The results of all activated comparisons are combined OR or AND to generate the interrupt signal.
The configuration of the thresholds, the activated comparisons and selected AND/OR combination allows to recognize special situations like selective axis movement (SA) or axes movement wake-up (WU).
l3gxxxx_irq_event
.The MCU GPIO pin used for the INT1
interrupt signal is defined by the hardware configuration parameter L3GXXXX_INT1_PIN.
The default configuration for event interrupts is defined by L3GXXXX_INT1_PARAMS. This configuration can be changed either by overriding default configuration parameters CONFIG_L3GXXXX_INT1_X_THRESH, CONFIG_L3GXXXX_INT1_Y_THRESH, CONFIG_L3GXXXX_INT1_Z_THRESH, CONFIG_L3GXXXX_INT1_X_LT_THRESH, CONFIG_L3GXXXX_INT1_X_GT_THRESH, CONFIG_L3GXXXX_INT1_Y_LT_THRESH, CONFIG_L3GXXXX_INT1_Y_GT_THRESH, CONFIG_L3GXXXX_INT1_Z_LT_THRESH, CONFIG_L3GXXXX_INT1_Z_GT_THRESH, CONFIG_L3GXXXX_INT1_FILTER, CONFIG_L3GXXXX_INT1_AND and CONFIG_L3GXXXX_INT1_LATCH or at runtime using function l3gxxxx_set_int_event_cfg with a set of parameters of type l3gxxxx_int_event_cfg_t that contains the configuration. For example, selective axis movement recognition (SA) for the z-axis could be configured as following. With this configuration, the event interrupt is only triggered if all conditions are met.
The data structure l3gxxxx_int_event_cfg_t defines
Function l3gxxxx_enable_int is used to enable or disable the event interrupt generation (L3GXXXX_INT_EVENT).
As with data interrupts function l3gxxxx_wait_int can be used to wait for an interrupt on signal INT1
if event interrupts are enabled. This function returns a structure with the interrupt sources of type l3gxxxx_int_src_t which contains a flag for each possible event interrupt source in member l3gxxxx_int_src_t::event that can be tested for true.
Activating all threshold comparisons and using the OR combination is the most flexible way to realize functions like selective axis movement by combining the different interrupt sources as required by the application.
Following example shows the selective axis movement recognition (SA) for the Z-axis.
All functions of the driver require direct access to the sensor via I2C or SPI which does not work in interrupt context.
Therefore, the driver prevents the direct use of the interrupts and application specific ISRs. The only way to use interrupts is to call the function l3gxxxx_wait_int which enables the interrupt signals for the configured MCU GPIO pins and then blocks the calling thread until an interrupt is triggered.
Once an interrupt is triggered, the driver handles the interrupt with an internal ISR and then returns from the l3gxxxx_wait_int function. The return value is a structure with the interrupt sources of type l3gxxxx_int_src_t, which contains a flag for each possible interrupt source that can be tested for true.
By default, interrupt signals are high active push/pull outputs.
L3Gxxxx sensors offer two modes for power saving:
While in power-down mode almost all internal blocks of the device including the gyros are switched off, in sleep mode only the measuring functions for all three axes are deactivated. Therefore, the time to continue measurements after sleep mode is drastically shorter than after power down.
Starting mode | Target mode | Turn-on time typical |
---|---|---|
Power-down | Normal | 100 ms |
Power-down | Sleep | 100 ms |
Sleep | Normal | 1/ODR when LPF2 disabled 6/ODR when LPF2 enabled |
L3Gxxxx sensors can be powered down when no measurements are required using the function l3gxxxx_power_down. The power consumption is reduced to some uA in power-down mode. To restart the L3Gxxxx in previous measurement mode, the l3gxxxx_power_up function can be used.
If module l3gxxxx_sleep
is enabled, the sleep mode can be activated with function l3gxxxx_sleep. The power consumption is then reduced from 4.8 mA to 2.4 mA and thus to half. The l3gxxxx_wake_up function continues the measurement in previous operation mode.
L3Gxxxx sensors are complex and flexible sensors with a lot of features. It can be used for a big number of different use cases. Since it is impossible to implement a high level interface which is generic enough to cover all the functionality of the sensor for all different use cases, there are two low level interface functions that allow direct read and write access to the registers of the sensor.
Default sensor hardware configurations are set in file l3gxxxx_params.h
using the following defines:
Hardware configuration | Driver name | Default Value |
---|---|---|
I2C device | L3GXXXX_I2C_DEV | I2C_DEV(0) |
I2C address | L3GXXXX_I2C_ADDR | L3GXXXX_I2C_ADDR_2 |
SPI device | L3GXXXX_SPI_DEV | SPI_DEV(0) |
SPI clock frequency | L3GXXXX_SPI_CLK | SPI_CLK_1MHZ |
SPI CS signal | L3GXXXX_SPI_CS | GPIO_PIN(0, 0) |
INT1 MCU pin | L3GXXXX_INT1_PIN | GPIO_PIN(0, 1) |
INT2/DRDY MCU pin | L3GXXXX_INT2_PIN | GPIO_PIN(0, 2) |
These hardware configurations can be overridden either by the board definition or by defining them in the CFLAGS
variable in the make command, for example:
The default configuration of the sensor is defined in file l3gxxxx_params.h
using the following defines:
Configuration parameter | Driver name | Default Value |
---|---|---|
ODR and LPF2 cutoff frequency | CONFIG_L3GXXXX_ODR | L3GXXXX_ODR_100_25 |
Full scale | CONFIG_L3GXXXX_SCALE | L3GXXXX_SCALE_245_DPS |
Filter selection used for output data | CONFIG_L3GXXXX_FILTER_SEL | L3GXXXX_HPF_AND_LPF2 |
HPF mode used for output data | CONFIG_L3GXXXX_HPF_MODE | L3GXXXX_HPF_NORMAL |
HPF cutoff frequency 8 Hz | CONFIG_L3GXXXX_HPF_CUTOFF | 0 |
FIFO mode if FIFO is used | CONFIG_L3GXXXX_FIFO_MODE | L3GXXXX_FIFO |
FIFO threshold value if FIFO is used | CONFIG_L3GXXXX_FIFO_WATERMARK | 23 |
INT1 threshold for X axis (~30 dps) | CONFIG_L3GXXXX_INT1_X_THRESH | 4012 |
INT1 threshold for Y axis (~30 dps) | CONFIG_L3GXXXX_INT1_Y_THRESH | 4012 |
INT1 threshold for Z axis (~30 dps) | CONFIG_L3GXXXX_INT1_Z_THRESH | 4012 |
INT1 interrupt enable for X > X threshold | CONFIG_L3GXXXX_INT1_X_GT_THRESH | true |
INT1 interrupt enable for Y > Y threshold | CONFIG_L3GXXXX_INT1_Y_GT_THRESH | true |
INT1 interrupt enable for Z > Z threshold | CONFIG_L3GXXXX_INT1_Z_GT_THRESH | true |
INT1 interrupt enable for X < X threshold | CONFIG_L3GXXXX_INT1_X_LT_THRESH | false |
INT1 interrupt enable for Y < Y threshold | CONFIG_L3GXXXX_INT1_Y_LT_THRESH | false |
INT1 interrupt enable for Z < Z threshold | CONFIG_L3GXXXX_INT1_Z_LT_THRESH | false |
INT1 filter selection | CONFIG_L3GXXXX_INT1_FILTER | L3GXXXX_HPF_AND_LPF2 |
INT1 interrupt combination | CONFIG_L3GXXXX_INT1_AND | false |
INT1 interrupt latch enabled | CONFIG_L3GXXXX_INT1_LATCH | true |
Single or all parameters of the default configuration can be overridden either by defining them in the variable CFLAGS
in the make command line or by placing a modified file l3gxxxx_params.h
in the application directory, for example:
Files | |
file | l3gxxxx.h |
Device Driver for ST L3Gxxxx 3-axis gyroscope sensor family. | |
file | l3gxxxx_params.h |
Default configuration for ST L3Gxxxx 3-axis gyroscope sensor family. | |
file | l3gxxxx_regs.h |
Register definitions for ST L3Gxxxx 3-axis gyroscope sensor family. | |
Data Structures | |
struct | l3gxxxx_int_event_cfg_t |
Event interrupt generator configuration (axis movement and wake-up) More... | |
union | l3gxxxx_int_event_src_t |
Event interrupt sources (axis movement and wake-up) More... | |
union | l3gxxxx_int_data_src_t |
Data interrupt sources (data ready and FIFO status) More... | |
struct | l3gxxxx_int_src_t |
Composite type for all possible interrupt sources. More... | |
struct | l3gxxxx_raw_data_t |
Raw output data set as two's complements. More... | |
struct | l3gxxxx_data_t |
Angular rates in millidegrees per seconds (mdps) More... | |
struct | l3gxxxx_i2c_params_t |
L3Gxxxx I2C interface parameters. More... | |
struct | l3gxxxx_spi_params_t |
L3Gxxxx SPI interface parameters. More... | |
struct | l3gxxxx_if_params_t |
L3Gxxxx Hardware interface parameters union. More... | |
struct | l3gxxxx_params_t |
L3Gxxxx device initialization parameters. More... | |
struct | l3gxxxx_t |
L3Gxxxx sensor device data structure type. More... | |
Macros | |
#define | L3GXXXX_INT_DATA |
Data interrupts (Data ready and FIFO status) | |
Typedefs | |
typedef l3gxxxx_raw_data_t | l3gxxxx_raw_data_fifo_t[32] |
Raw output data FIFO type. | |
typedef l3gxxxx_data_t | l3gxxxx_data_fifo_t[32] |
Angular rates FIFO type. | |
Sensor initialization and configuration | |
int | l3gxxxx_init (l3gxxxx_t *dev, const l3gxxxx_params_t *params) |
Initialize the L3Gxxxx sensor device. | |
int | l3gxxxx_set_mode (l3gxxxx_t *dev, l3gxxxx_odr_t odr, bool x, bool y, bool z) |
Set sensor mode. | |
int | l3gxxxx_set_scale (l3gxxxx_t *dev, l3gxxxx_scale_t scale) |
Set full scale. | |
Power saving functions | |
int | l3gxxxx_power_down (l3gxxxx_t *dev) |
Power down the sensor. | |
int | l3gxxxx_power_up (l3gxxxx_t *dev) |
Power up the sensor. | |
int | l3gxxxx_sleep (l3gxxxx_t *dev) |
Sleep mode. | |
int | l3gxxxx_wake_up (l3gxxxx_t *dev) |
Wake-up the sensor. | |
Basic sensor data handling | |
int | l3gxxxx_data_ready (const l3gxxxx_t *dev) |
Data ready status function. | |
int | l3gxxxx_read (const l3gxxxx_t *dev, l3gxxxx_data_t *data) |
Read last sample of angular rates in millidegree per second (mpds) | |
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. | |
FIFO handling | |
int | l3gxxxx_set_fifo_mode (l3gxxxx_t *dev, l3gxxxx_fifo_mode_t mode, uint8_t watermark) |
Set FIFO mode and watermark level (threshold) | |
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_read_raw_fifo (const l3gxxxx_t *dev, l3gxxxx_raw_data_fifo_t raw) |
Get all samples of raw output data stored in the FIFO. | |
Filter configuration and handling | |
int | l3gxxxx_select_output_filter (l3gxxxx_t *dev, l3gxxxx_filter_sel_t filter) |
Filter selection for raw output data. | |
int | l3gxxxx_config_hpf (const l3gxxxx_t *dev, l3gxxxx_hpf_mode_t mode, uint8_t cutoff) |
Config HPF (high pass filter) for output data. | |
int | l3gxxxx_set_hpf_ref (const l3gxxxx_t *dev, int8_t ref) |
Set HPF (high pass filter) reference. | |
int | l3gxxxx_get_hpf_ref (const l3gxxxx_t *dev, int8_t *ref) |
Get HPF (high pass filter) reference. | |
Interrupt configuration and handling | |
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_int_src_t | l3gxxxx_wait_int (l3gxxxx_t *dev) |
Wait for event and/or data interrupts on signals INT1 and INT2/DRDY | |
int | l3gxxxx_set_int_event_cfg (const l3gxxxx_t *dev, const l3gxxxx_int_event_cfg_t *cfg) |
Set new configuration for event interrupt generation. | |
int | l3gxxxx_get_int_event_cfg (const l3gxxxx_t *dev, l3gxxxx_int_event_cfg_t *cfg) |
Get current configuration of event interrupt generation. | |
Low level interface functions | |
int | l3gxxxx_reg_write (const l3gxxxx_t *dev, uint8_t reg, const uint8_t *data, uint8_t len) |
Direct write to register. | |
int | l3gxxxx_reg_read (const l3gxxxx_t *dev, uint8_t reg, uint8_t *data, uint8_t len) |
Direct read from register. | |
L3Gxxxx addresses | |
#define | L3GXXXX_I2C_ADDR_1 (0x68) |
SDO pin is low. | |
#define | L3GXXXX_I2C_ADDR_2 (0x69) |
SDO pin is high. | |
L3Gxxxx chip ids | |
#define | L3GXXXX_CHIP_ID_L3GD20H (0xd7) |
Chip ID for L3GD20H. | |
#define | L3GXXXX_CHIP_ID_L3GD20 (0xd4) |
Chip ID for L3GD20. | |
#define | L3GXXXX_CHIP_ID_X3G42XXD (0xd3) |
Chip ID for L3G4200D, I3G4250D, A3G4250D. | |
#define L3GXXXX_CHIP_ID_L3GD20 (0xd4) |
#define L3GXXXX_CHIP_ID_L3GD20H (0xd7) |
#define L3GXXXX_CHIP_ID_X3G42XXD (0xd3) |
#define L3GXXXX_INT_DATA |
Data interrupts (Data ready and FIFO status)
This define combines the data interrupt types of l3gxxxx_int_types_t that use the INT2/DRDY
signal to an ORed value.
typedef l3gxxxx_data_t l3gxxxx_data_fifo_t[32] |
typedef l3gxxxx_raw_data_t l3gxxxx_raw_data_fifo_t[32] |
Definition of error codes.
enum l3gxxxx_fifo_mode_t |
FIFO mode.
The integrated FIFO with up to 32 data samples can be used in different modes. The mode defines the behavior of FIFO when it becomes full.
enum l3gxxxx_filter_sel_t |
High pass filter (HPF) and low pass filter 2 (LPF2) selection.
L3Gxxxx sensors integrate a combination of two low pass filters (LPF) and one high pass filter (HPF).
First, raw sensor data are always filtered by LPF1 with a cutoff frequency that is fixed for the selected output data rate (ODR), see l3gxxxx_odr_t. Resulting data can then optionally be filtered by HPF and/or LPF2. Both filters can be used or bypassed.
l3gxxxx_filter_sel_t defines the possible filter combinations that can be used to select the filters for the output data and for the interrupt generation separately.
The default filter selection for the output data is L3GXXXX_HPF_AND_LPF2 and is defined by the default configuration parameter CONFIG_L3GXXXX_FILTER_SEL. If the module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_select_output_filter.
The default filter selection for event interrupt generation is L3GXXXX_HPF_AND_LPF2 and is defined by default configuration parameter CONFIG_L3GXXXX_INT1_FILTER. It can be changed at runtime with function l3gxxxx_set_int_event_cfg.
The cutoff frequencies of LPF1 and LPF2 are determined by the used output data rate l3gxxxx_odr_t, see section [Output Data Rates and Filters] (#l3gxxxx_odr_filters). The default cutoff frequency of HPF is 8 Hz and set by the default configuration parameter CONFIG_L3GXXXX_HPF_CUTOFF. If module l3gxxxx_config
is used, it can be changed at runtime using function l3gxxxx_config_hpf.
Enumerator | |
---|---|
L3GXXXX_NO_FILTER | HPF not used, LPF2 not used (default) |
L3GXXXX_HPF_ONLY | HPF used, LPF2 not used. |
L3GXXXX_LPF2_ONLY | HPF not used, LPF2 used. |
L3GXXXX_HPF_AND_LPF2 | HPF used, LPF2 used. |
enum l3gxxxx_hpf_mode_t |
HPF (high pass filter) modes.
The high pass filter can be used in different modes.
enum l3gxxxx_if_t |
enum l3gxxxx_int_types_t |
Interrupt types.
L3Gxxxx sensors support different types of interrupts. These are on the one hand the various data interrupts on signal INT2/DRDY
and on the other hand event interrupts on signal INT1
.
The enumeration values correspond to the according bits in register CTRL3 (L3GXXXX_REG_CTRL3).
L3GXXXX_INT_DATA combines the various data interrupts to an ORed value.
enum l3gxxxx_odr_t |
Sensor output data rates (ODR) and LPF2 cutoff frequencies.
The following output data rates (ODR) and the LPF1/LPF2 cutoff frequencies are defined (Reference: Application Note AN4506):
Mode | ODR [Hz] | LPF1 cutoff [Hz] | LPF2 cutoff [Hz] |
---|---|---|---|
High ODR | |||
L3GXXXX_ODR_100_12 | 100 | 32 | 12.5 |
L3GXXXX_ODR_100_25 | 100 | 32 | 25 |
L3GXXXX_ODR_200_12 | 200 | 63.3 | 12.5 |
L3GXXXX_ODR_200_25 | 200 | 63.3 | 25 |
L3GXXXX_ODR_200_50 | 200 | 63.3 | 50 |
L3GXXXX_ODR_200_70 | 200 | 63.3 | 70 |
L3GXXXX_ODR_400_20 | 400 | 128 | 20 |
L3GXXXX_ODR_400_25 | 400 | 128 | 25 |
L3GXXXX_ODR_400_50 | 400 | 128 | 50 |
L3GXXXX_ODR_400_110 | 400 | 128 | 110 |
L3GXXXX_ODR_800_30 | 800 | 211 | 30 |
L3GXXXX_ODR_800_35 | 800 | 211 | 35 |
L3GXXXX_ODR_800_50 | 800 | 211 | 50 |
L3GXXXX_ODR_800_100 | 800 | 211 | 100 |
Low ODR (L3GD20H only) | |||
L3GXXXX_ODR_12 | 12.5 | 3.9 | - |
L3GXXXX_ODR_25 | 25 | 7.8 | - |
L3GXXXX_ODR_50 | 50 | 16 | 16.6 |
Detailed information about the filter chain and possible filter combinations can be found in the section Output data rates and filters.
While LPF1 is always used, LPF2 and HPF have to be explicitly enabled by the configuration parameter l3gxxxx_params_t::filter_sel or the l3gxxxx_select_output_filter function if module l3gxxxx_config
is used. L3GXXXX_ODR_100_25 is used by the default configuration.
enum l3gxxxx_scale_t |
Full scale in degrees per second (dps)
The full scale value determines the sensitivity of the sensor and thus the range and resolution of the sensor's output data. The resolution of the output data is about Full Scale/INT16_MAX.
Enumerator | |
---|---|
L3GXXXX_SCALE_245_DPS | 245 dps (default) |
L3GXXXX_SCALE_500_DPS | 500 dps |
L3GXXXX_SCALE_2000_DPS | 2000 dps |
int l3gxxxx_config_hpf | ( | const l3gxxxx_t * | dev, |
l3gxxxx_hpf_mode_t | mode, | ||
uint8_t | cutoff | ||
) |
Config HPF (high pass filter) for output data.
The cutoff frequency of the HPF depends on the selected output data rate (ODR). The following table shows the possible values of parameter cutoff
and the cutoff frequencies for the according ODRs. All frequencies are given in Hz.
cutoff / ODR | 12.5 | 25 | 50 | 100 | 200 | 400 | 800 |
---|---|---|---|---|---|---|---|
0 | 1 | 2 | 4 | 8 | 15 | 30 | 56 |
1 | 0.5 | 1 | 2 | 4 | 8 | 15 | 30 |
2 | 0.2 | 0.5 | 1 | 2 | 4 | 8 | 15 |
3 | 0.1 | 0.2 | 0.5 | 1 | 2 | 4 | 8 |
4 | 0.05 | 0.1 | 0.2 | 0.5 | 1 | 2 | 4 |
5 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 | 1 | 2 |
6 | 0.01 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 | 1 |
7 | 0.005 | 0.01 | 0.02 | 0.05 | 0.1 | 0.2 | 0.5 |
8 | 0.002 | 0.005 | 0.01 | 0.02 | 0.05 | 0.1 | 0.2 |
9 | 0.001 | 0.002 | 0.005 | 0.01 | 0.02 | 0.05 | 0.1 |
l3gxxxx_config
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | mode | high pass filter mode, see l3gxxxx_hpf_mode_t |
[in] | cutoff | cutoff frequency (depends on ODR) [0 ... 9] |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_data_ready | ( | const l3gxxxx_t * | dev | ) |
Data ready status function.
This function returns the number of new data samples that are ready to be read or 0 if no new data samples are available.
If the FIFO is not used or used in bypass mode (L3GXXXX_BYPASS), the maximum number of available data samples is 1. If another FIFO mode is used, the number of available data samples is equal to the number of new data samples in the FIFO.
[in] | dev | device descriptor of the L3Gxxxx sensor |
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
This function is used to enable or disable interrupts. The parameter mask
is the ORed value of the interrupts that are enabled or disabled by the function call.
INT1
signal respectively the INT2/DRDY
signal have to be defined for enabled interrupts (l3gxxxx_params_t::int1_pin and l3gxxxx_params_t::int2_pin).l3gxxxx_irq_data
and/or module l3gxxxx_irq_event
are used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | mask | interrupts to be enabled or disabled |
[in] | enable | enable the interrupts if true, otherwise disable them |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_get_hpf_ref | ( | const l3gxxxx_t * | dev, |
int8_t * | ref | ||
) |
Get HPF (high pass filter) reference.
Returns the content of the REFERENCE register. In normal mode L3GXXXX_HPF_NORMAL, it is also used to reset the HPF.
l3gxxxx_config
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[out] | ref | reference |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_get_int_event_cfg | ( | const l3gxxxx_t * | dev, |
l3gxxxx_int_event_cfg_t * | cfg | ||
) |
Get current configuration of event interrupt generation.
This function can be used to retrieve the configuration of interrupt conditions currently used to generate event interrupts. See l3gxxxx_int_event_cfg_t for details.
l3gxxxx_irq_event
and module l3gxxxx_irq_config
are used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[out] | cfg | event interrupt generator configuration |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_init | ( | l3gxxxx_t * | dev, |
const l3gxxxx_params_t * | params | ||
) |
Initialize the L3Gxxxx sensor device.
This function resets the sensor and initializes it according to the given configuration parameter set. All registers are reset to their default values. The FIFO is cleared.
[in] | dev | device descriptor of the L3Gxxxx sensor to be initialized |
[in] | params | L3Gxxxx configuration parameters |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_power_down | ( | l3gxxxx_t * | dev | ) |
Power down the sensor.
Changes the sensor operation mode to power-down mode. In this mode almost all internal blocks including the gyros are switched off. I2C and SPI interfaces are still active. The content of the configuration registers is preserved.
[in] | dev | Device descriptor of L3Gxxxx device to read from |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_power_up | ( | l3gxxxx_t * | dev | ) |
Power up the sensor.
Swichtes the sensor back into the last active operation mode. It takes up to 100 ms since the gyros have to be switched on.
[in] | dev | Device descriptor of L3Gxxxx device to read from |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_read | ( | const l3gxxxx_t * | dev, |
l3gxxxx_data_t * | data | ||
) |
Read last sample of angular rates in millidegree per second (mpds)
Raw output data are read from the sensor and converted to angular rates in millidegrees per second (mdps). The resolution of the angular rates depends on the configured full scale value as follows:
Full Scale | Resolution | Driver symbol | Remark |
---|---|---|---|
±245 dps | 8.75 mdps / LSB | L3GXXXX_SCALE_245_DPS | |
±500 dps | 17.50 mdps / LSB | L3GXXXX_SCALE_500_DPS | not available on A3G4250D |
±2000 dps | 70.00 mdps / LSB | L3GXXXX_SCALE_2000_DPS | not available on A3G4250D |
l3gxxxxx_fifo
, the function returns only the last sample. To read all samples from the FIFO, function l3gxxxx_read_fifo has to be used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[out] | data | last sample of angular rates in mdps |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
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)
This function reads all samples of raw output data from the FIFO and converts them to angular rates in millidegrees per second (mdps) according to the configured full scale. For details about the resolution of these angular rates see l3gxxxx_read.
In bypass mode (L3GXXXX_BYPASS), it returns only the last sample.
l3gxxxx_fifo
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[out] | data | array for up to 32 samples of angular rates in mdps |
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.
l3gxxxxx_fifo
, the function returns only the last sample. To read all samples from the FIFO, function l3gxxxx_read_raw_fifo has to be used.[in] | dev | device descriptor of the L3Gxxxx sensor |
raw | last sample of raw output data as 16 bit two's complements |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
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.
This function reads all samples of raw output data from the FIFO. In bypass mode (L3GXXXX_BYPASS), it returns only the last raw output data sample.
l3gxxxx_fifo
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[out] | raw | array for up to 32 raw output data as two's complement |
int l3gxxxx_reg_read | ( | const l3gxxxx_t * | dev, |
uint8_t | reg, | ||
uint8_t * | data, | ||
uint8_t | len | ||
) |
Direct read from register.
[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | reg | address of the first register to be read |
[out] | data | pointer to the data to be read from the register |
[in] | len | number of bytes to be read from the register |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_reg_write | ( | const l3gxxxx_t * | dev, |
uint8_t | reg, | ||
const uint8_t * | data, | ||
uint8_t | len | ||
) |
Direct write to register.
[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | reg | address of the first register to be changed |
[in] | data | pointer to the data to be written to the register |
[in] | len | number of bytes to be written to the register |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_select_output_filter | ( | l3gxxxx_t * | dev, |
l3gxxxx_filter_sel_t | filter | ||
) |
Filter selection for raw output data.
L3Gxxxx supports a combination of a high pass filter (HPF) and a second low pass filter (LPF2). This function selects the combination of the HPF and the LPF2 applied to raw output data.
l3gxxxx_config
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | filter | selected filters for output values |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_set_fifo_mode | ( | l3gxxxx_t * | dev, |
l3gxxxx_fifo_mode_t | mode, | ||
uint8_t | watermark | ||
) |
Set FIFO mode and watermark level (threshold)
The FIFO buffer can work in seven different modes and is able to store up to 32 data samples, see l3gxxxx_fifo_mode_t. The use of the FIFO allows to reduce the interaction events of the MCU with the sensor and thus to save power.
The watermark level can be used to define the number of raw output data samples that have to be stored in the FIFO before the watermark flag is set and the L3GXXXX_INT_FIFO_WATERMARK is triggered, if enabled. The watermark flag is set and the interrupt L3GXXXX_INT_FIFO_WATERMARK is triggered when the number of samples stored in the FIFO becomes greater than this watermark level (threshold).
l3gxxxx_fifo
and l3gxxxx_config
are used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | mode | FIFO mode |
[in] | watermark | FIFO watermark (ignored in bypass mode) |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_set_hpf_ref | ( | const l3gxxxx_t * | dev, |
int8_t | ref | ||
) |
Set HPF (high pass filter) reference.
Used to set the reference for HPF in reference mode L3GXXXX_HPF_REFERENCE and to reset the HPF in autoreset mode L3GXXXX_HPF_AUTORESET. Reference is given as two's complement.
l3gxxxx_config
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | ref | reference in L3GXXXX_HPF_REFERENCE mode, otherwise ignored |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_set_int_event_cfg | ( | const l3gxxxx_t * | dev, |
const l3gxxxx_int_event_cfg_t * | cfg | ||
) |
Set new configuration for event interrupt generation.
The event interrupt generator produces interrupts (axis movement and wake-up) on signal INT1
whenever the angular rate of one or more axes becomes higher or lower than defined thresholds.
This function can be used at runtime to change the configuration of the interrupt conditions for event interrupt generation. This includes thresholds for all axes, enabled threshold interrupts, filter selection used for interrupt generation and other parameters, see l3gxxxx_int_event_cfg_t for details.
l3gxxxx_irq_event
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | cfg | event interrupt generator configuration |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_set_mode | ( | l3gxxxx_t * | dev, |
l3gxxxx_odr_t | odr, | ||
bool | x, | ||
bool | y, | ||
bool | z | ||
) |
Set sensor mode.
l3gxxxx_config
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | odr | output data rate (ODR) and LPF2 cutoff frequency |
[in] | x | enable X axis measurements if true |
[in] | y | enable Y axis measurements if true |
[in] | z | enable Z axis measurements if true |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_set_scale | ( | l3gxxxx_t * | dev, |
l3gxxxx_scale_t | scale | ||
) |
Set full scale.
l3gxxxx_config
is used.[in] | dev | device descriptor of the L3Gxxxx sensor |
[in] | scale | fulle scale |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_sleep | ( | l3gxxxx_t * | dev | ) |
Sleep mode.
Activates the sleep mode of the sensor. In this mode, measurements for all axes are disabled, but the gyroscopes remain on. To return from sleep mode, function l3gxxxx_wake_up is used.
l3gxxxx_sleep
is used.[in] | dev | Device descriptor of L3Gxxxx device to read from |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
l3gxxxx_int_src_t l3gxxxx_wait_int | ( | l3gxxxx_t * | dev | ) |
Wait for event and/or data interrupts on signals INT1
and INT2/DRDY
The function waits for a configured interrupt and returns the sources of triggered interrupts. Since data interrupts (data ready and FIFO status) and event interrupts (axis movement and wake-up) use different signals, both data and event interrupts can occur simultaneously. The return value of type l3gxxxx_int_src_t contains all sources for which the interrupt conditions are fulfilled at the same time.
INT1
signal respectively the INT2/DRDY
signal have to be defined for enabled interrupts (l3gxxxx_params_t::int1_pin and l3gxxxx_params_t::int2_pin).l3gxxxx_irq_data
and/or module l3gxxxx_irq_event
are used.[in] | dev | device descriptor of the L3Gxxxx sensor |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |
int l3gxxxx_wake_up | ( | l3gxxxx_t * | dev | ) |
Wake-up the sensor.
Swichtes the sensor back into the last active operation mode. It takes only 1/ODR when LPF2 is disabled and 6/ODR when LPF2 is enabled to continue measurements.
l3gxxxx_sleep
is used.[in] | dev | Device descriptor of L3Gxxxx device to read from |
L3GXXXX_OK | on success |
L3GXXXX_ERROR_* | negative error code, see l3gxxxx_error_codes_t |