ChibiOS 21.11.4

Detailed Description

Collaboration diagram for L3GD20:

L3GD20 data structures and types.

enum  l3gd20_fs_t { L3GD20_FS_250DPS = 0x00 , L3GD20_FS_500DPS = 0x10 , L3GD20_FS_2000DPS = 0x20 }
 L3GD20 full scale. More...
enum  l3gd20_odr_t { L3GD20_ODR_95HZ = 0x00 , L3GD20_ODR_190HZ = 0x40 , L3GD20_ODR_380HZ = 0x80 , L3GD20_ODR_760HZ = 0xC0 }
 L3GD20 output data rate and bandwidth. More...
enum  l3gd20_bw_t { L3GD20_BW0 = 0x00 , L3GD20_BW1 = 0x40 , L3GD20_BW2 = 0x80 , L3GD20_BW3 = 0xC0 }
 L3GD20 low pass filter 1 bandwidth. More...
enum  l3gd20_bdu_t { L3GD20_BDU_CONTINUOUS = 0x00 , L3GD20_BDU_BLOCKED = 0x80 }
 L3GD20 block data update. More...
enum  l3gd20_hpm_t { L3GD20_HPM_NORMAL = 0x00 , L3GD20_HPM_REFERENCE = 0x10 , L3GD20_HPM_AUTORESET = 0x30 , L3GD20_HPM_BYPASSED = 0xFF }
 L3GD20 HP filter mode. More...
enum  l3gd20_hpcf_t {
  L3GD20_HPCF_0 = 0x00 , L3GD20_HPCF_1 = 0x01 , L3GD20_HPCF_2 = 0x02 , L3GD20_HPCF_3 = 0x03 ,
  L3GD20_HPCF_4 = 0x04 , L3GD20_HPCF_5 = 0x05 , L3GD20_HPCF_6 = 0x06 , L3GD20_HPCF_7 = 0x07 ,
  L3GD20_HPCF_8 = 0x08 , L3GD20_HPCF_9 = 0x09
}
 L3GD20 HP configuration. More...
enum  l3gd20_lp2m_t { L3GD20_LP2M_ON = 0x00 , L3GD20_LP2M_BYPASSED = 0xFF }
 L3GD20 LP2 filter mode. More...
enum  l3gd20_end_t { L3GD20_END_LITTLE = 0x00 , L3GD20_END_BIG = 0x40 }
 L3GD20 endianness. More...
enum  l3gd20_state_t { L3GD20_UNINIT = 0 , L3GD20_STOP = 1 , L3GD20_READY = 2 }
 Driver state machine possible states. More...
typedef struct L3GD20Driver L3GD20Driver
 Structure representing a L3GD20 driver.
#define _l3gd20_methods_alone
 L3GD20 specific methods.
#define _l3gd20_methods
 L3GD20 specific methods with inherited ones.
#define _l3gd20_data
 L3GD20Driver specific data.

Version identification

#define EX_L3GD20_VERSION   "1.1.3"
 L3GD20 driver version string.
#define EX_L3GD20_MAJOR   1
 L3GD20 driver version major number.
#define EX_L3GD20_MINOR   1
 L3GD20 driver version minor number.
#define EX_L3GD20_PATCH   3
 L3GD20 driver version patch number.
#define L3GD20_GYRO_NUMBER_OF_AXES   3U
 L3GD20 gyroscope system characteristics.
#define L3GD20_250DPS   250.0f
#define L3GD20_500DPS   500.0f
#define L3GD20_2000DPS   2000.0f
#define L3GD20_GYRO_SENS_250DPS   0.00875f
#define L3GD20_GYRO_SENS_500DPS   0.01750f
#define L3GD20_GYRO_SENS_2000DPS   0.07000f
#define L3GD20_GYRO_BIAS   0.0f

L3GD20 communication interfaces related bit masks

#define L3GD20_DI_MASK   0xFF
#define L3GD20_DI(n)
#define L3GD20_AD_MASK   0x3F
#define L3GD20_AD(n)
#define L3GD20_MS   (1 << 6)
#define L3GD20_RW   (1 << 7)

L3GD20 register addresses

#define L3GD20_AD_WHO_AM_I   0x0F
#define L3GD20_AD_CTRL_REG1   0x20
#define L3GD20_AD_CTRL_REG2   0x21
#define L3GD20_AD_CTRL_REG3   0x22
#define L3GD20_AD_CTRL_REG4   0x23
#define L3GD20_AD_CTRL_REG5   0x24
#define L3GD20_AD_REFERENCE   0x25
#define L3GD20_AD_OUT_TEMP   0x26
#define L3GD20_AD_STATUS_REG   0x27
#define L3GD20_AD_OUT_X_L   0x28
#define L3GD20_AD_OUT_X_H   0x29
#define L3GD20_AD_OUT_Y_L   0x2A
#define L3GD20_AD_OUT_Y_H   0x2B
#define L3GD20_AD_OUT_Z_L   0x2C
#define L3GD20_AD_OUT_Z_H   0x2D
#define L3GD20_AD_FIFO_CTRL_REG   0x2E
#define L3GD20_AD_FIFO_SRC_REG   0x2F
#define L3GD20_AD_INT1_CFG   0x30
#define L3GD20_AD_INT1_SRC   0x31
#define L3GD20_AD_INT1_THS_XH   0x32
#define L3GD20_AD_INT1_THS_XL   0x33
#define L3GD20_AD_INT1_THS_YH   0x34
#define L3GD20_AD_INT1_THS_YL   0x35
#define L3GD20_AD_INT1_THS_ZH   0x36
#define L3GD20_AD_INT1_THS_ZL   0x37
#define L3GD20_AD_INT1_DURATION   0x38

L3GD20_CTRL_REG1 register bits definitions

#define L3GD20_CTRL_REG1_MASK   0xFF
#define L3GD20_CTRL_REG1_XEN   (1 << 0)
#define L3GD20_CTRL_REG1_YEN   (1 << 1)
#define L3GD20_CTRL_REG1_ZEN   (1 << 2)
#define L3GD20_CTRL_REG1_PD   (1 << 3)
#define L3GD20_CTRL_REG1_BW0   (1 << 4)
#define L3GD20_CTRL_REG1_BW1   (1 << 5)
#define L3GD20_CTRL_REG1_DR0   (1 << 6)
#define L3GD20_CTRL_REG1_DR1   (1 << 7)

L3GD20_CTRL_REG2 register bits definitions

#define L3GD20_CTRL_REG2_MASK   0x3F
#define L3GD20_CTRL_REG2_HPCF0   (1 << 0)
#define L3GD20_CTRL_REG2_HPCF1   (1 << 1)
#define L3GD20_CTRL_REG2_HPCF2   (1 << 2)
#define L3GD20_CTRL_REG2_HPCF3   (1 << 3)
#define L3GD20_CTRL_REG2_HPM0   (1 << 4)
#define L3GD20_CTRL_REG2_HPM1   (1 << 5)

L3GD20_CTRL_REG3 register bits definitions

#define L3GD20_CTRL_REG3_MASK   0xFF
#define L3GD20_CTRL_REG3_I2_EMPTY   (1 << 0)
#define L3GD20_CTRL_REG3_I2_ORUN   (1 << 1)
#define L3GD20_CTRL_REG3_I2_WTM   (1 << 2)
#define L3GD20_CTRL_REG3_I2_DRDY   (1 << 3)
#define L3GD20_CTRL_REG3_PP_OD   (1 << 4)
#define L3GD20_CTRL_REG3_H_LACTIVE   (1 << 5)
#define L3GD20_CTRL_REG3_I1_BOOT   (1 << 6)
#define L3GD20_CTRL_REG3_I1_INT1   (1 << 7)

L3GD20_CTRL_REG4 register bits definitions

#define L3GD20_CTRL_REG4_MASK   0xF1
#define L3GD20_CTRL_REG4_SIM   (1 << 0)
#define L3GD20_CTRL_REG4_FS_MASK   0x30
#define L3GD20_CTRL_REG4_FS0   (1 << 4)
#define L3GD20_CTRL_REG4_FS1   (1 << 5)
#define L3GD20_CTRL_REG4_BLE   (1 << 6)
#define L3GD20_CTRL_REG4_BDU   (1 << 7)

L3GD20_CTRL_REG5 register bits definitions

#define L3GD20_CTRL_REG5_MASK   0xDF
#define L3GD20_CTRL_REG5_OUT_SEL0   (1 << 0)
#define L3GD20_CTRL_REG5_OUT_SEL1   (1 << 1)
#define L3GD20_CTRL_REG5_INT1_SEL0   (1 << 2)
#define L3GD20_CTRL_REG5_INT1_SEL1   (1 << 3)
#define L3GD20_CTRL_REG5_HPEN   (1 << 4)
#define L3GD20_CTRL_REG5_FIFO_EN   (1 << 6)
#define L3GD20_CTRL_REG5_BOOT   (1 << 7)

L3GD20_INT1_CFG register bits definitions

#define L3GD20_INT1_CFG_MASK   0xFF
#define L3GD20_INT1_CFG_XLIE   (1 << 0)
#define L3GD20_INT1_CFG_XHIE   (1 << 1)
#define L3GD20_INT1_CFG_YLIE   (1 << 2)
#define L3GD20_INT1_CFG_YHIE   (1 << 3)
#define L3GD20_INT1_CFG_ZLIE   (1 << 4)
#define L3GD20_INT1_CFG_ZHIE   (1 << 5)
#define L3GD20_INT1_CFG_LIR   (1 << 6)
#define L3GD20_INT1_CFG_AND_OR   (1 << 7)

L3GD20_INT1_SRC register bits definitions

#define L3GD20_INT1_SRC_MASK   0x7F
#define L3GD20_INT1_SRC_XL   (1 << 0)
#define L3GD20_INT1_SRC_XH   (1 << 1)
#define L3GD20_INT1_SRC_YL   (1 << 2)
#define L3GD20_INT1_SRC_YH   (1 << 3)
#define L3GD20_INT1_SRC_ZL   (1 << 4)
#define L3GD20_INT1_SRC_ZH   (1 << 5)
#define L3GD20_INT1_SRC_IA   (1 << 6)

Configuration options

#define L3GD20_USE_SPI   TRUE
 L3GD20 SPI interface switch.
#define L3GD20_SHARED_SPI   FALSE
 L3GD20 shared SPI switch.
#define L3GD20_USE_I2C   FALSE
 L3GD20 I2C interface switch.
#define L3GD20_SHARED_I2C   FALSE
 L3GD20 shared I2C switch.
#define L3GD20_USE_ADVANCED   FALSE
 L3GD20 advanced configurations switch.
#define L3GD20_BIAS_ACQ_TIMES   50
 Number of acquisitions for bias removal.
#define L3GD20_BIAS_SETTLING_US   5000
 Settling time for bias removal.

Data Structures

struct  L3GD20Config
 L3GD20 configuration structure. More...
struct  L3GD20VMT
 L3GD20 virtual methods table. More...
struct  L3GD20Driver
 L3GD20 3-axis gyroscope class. More...

Macros

#define l3gd20GyroscopeGetAxesNumber(devp)
 Return the number of axes of the BaseGyroscope.
#define l3gd20GyroscopeReadRaw(devp, axes)
 Retrieves raw data from the BaseGyroscope.
#define l3gd20GyroscopeReadCooked(devp, axes)
 Retrieves cooked data from the BaseGyroscope.
#define l3gd20GyroscopeSampleBias(devp)
 Samples bias values for the BaseGyroscope.
#define l3gd20GyroscopeSetBias(devp, bp)
 Set bias values for the BaseGyroscope.
#define l3gd20GyroscopeResetBias(devp)
 Reset bias values for the BaseGyroscope.
#define l3gd20GyroscopeSetSensitivity(devp, sp)
 Set sensitivity values for the BaseGyroscope.
#define l3gd20GyroscopeResetSensitivity(devp)
 Reset sensitivity values for the BaseGyroscope.
#define l3gd20GyroscopeSetFullScale(devp, fs)
 Changes the L3GD20Driver gyroscope fullscale value.

Functions

static void l3gd20SPIReadRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
 Reads a generic register value using SPI.
static void l3gd20SPIWriteRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
 Writes a value into a generic register using SPI.
static size_t gyro_get_axes_number (void *ip)
 Return the number of axes of the BaseGyroscope.
static msg_t gyro_read_raw (void *ip, int32_t axes[L3GD20_GYRO_NUMBER_OF_AXES])
 Retrieves raw data from the BaseGyroscope.
static msg_t gyro_read_cooked (void *ip, float axes[])
 Retrieves cooked data from the BaseGyroscope.
static msg_t gyro_sample_bias (void *ip)
 Samples bias values for the BaseGyroscope.
static msg_t gyro_set_bias (void *ip, float *bp)
 Set bias values for the BaseGyroscope.
static msg_t gyro_reset_bias (void *ip)
 Reset bias values for the BaseGyroscope.
static msg_t gyro_set_sensivity (void *ip, float *sp)
 Set sensitivity values for the BaseGyroscope.
static msg_t gyro_reset_sensivity (void *ip)
 Reset sensitivity values for the BaseGyroscope.
static msg_t gyro_set_full_scale (L3GD20Driver *devp, l3gd20_fs_t fs)
 Changes the L3GD20Driver gyroscope fullscale value.
void l3gd20ObjectInit (L3GD20Driver *devp)
 Initializes an instance.
void l3gd20Start (L3GD20Driver *devp, const L3GD20Config *config)
 Configures and activates L3GD20 Complex Driver peripheral.
void l3gd20Stop (L3GD20Driver *devp)
 Deactivates the L3GD20 Complex Driver peripheral.

Variables

static const struct L3GD20VMT vmt_device
static const struct BaseGyroscopeVMT vmt_gyroscope

Macro Definition Documentation

◆ EX_L3GD20_VERSION

#define EX_L3GD20_VERSION   "1.1.3"

L3GD20 driver version string.

Definition at line 45 of file l3gd20.h.

◆ EX_L3GD20_MAJOR

#define EX_L3GD20_MAJOR   1

L3GD20 driver version major number.

Definition at line 50 of file l3gd20.h.

◆ EX_L3GD20_MINOR

#define EX_L3GD20_MINOR   1

L3GD20 driver version minor number.

Definition at line 55 of file l3gd20.h.

◆ EX_L3GD20_PATCH

#define EX_L3GD20_PATCH   3

L3GD20 driver version patch number.

Definition at line 60 of file l3gd20.h.

◆ L3GD20_GYRO_NUMBER_OF_AXES

#define L3GD20_GYRO_NUMBER_OF_AXES   3U

L3GD20 gyroscope system characteristics.

Note
Sensitivity is expressed as DPS/LSB whereas DPS stand for Degree per second [°/s].
Bias is expressed as DPS.

Definition at line 71 of file l3gd20.h.

Referenced by gyro_get_axes_number(), gyro_read_cooked(), gyro_read_raw(), gyro_reset_bias(), gyro_reset_sensivity(), gyro_sample_bias(), gyro_set_bias(), gyro_set_full_scale(), gyro_set_sensivity(), and l3gd20Start().

◆ L3GD20_250DPS

#define L3GD20_250DPS   250.0f

Definition at line 73 of file l3gd20.h.

Referenced by gyro_set_full_scale(), and l3gd20Start().

◆ L3GD20_500DPS

#define L3GD20_500DPS   500.0f

Definition at line 74 of file l3gd20.h.

Referenced by gyro_set_full_scale(), and l3gd20Start().

◆ L3GD20_2000DPS

#define L3GD20_2000DPS   2000.0f

Definition at line 75 of file l3gd20.h.

Referenced by gyro_set_full_scale(), and l3gd20Start().

◆ L3GD20_GYRO_SENS_250DPS

#define L3GD20_GYRO_SENS_250DPS   0.00875f

Definition at line 77 of file l3gd20.h.

Referenced by gyro_reset_sensivity(), and l3gd20Start().

◆ L3GD20_GYRO_SENS_500DPS

#define L3GD20_GYRO_SENS_500DPS   0.01750f

Definition at line 78 of file l3gd20.h.

Referenced by gyro_reset_sensivity(), and l3gd20Start().

◆ L3GD20_GYRO_SENS_2000DPS

#define L3GD20_GYRO_SENS_2000DPS   0.07000f

Definition at line 79 of file l3gd20.h.

Referenced by gyro_reset_sensivity(), and l3gd20Start().

◆ L3GD20_GYRO_BIAS

#define L3GD20_GYRO_BIAS   0.0f

Definition at line 81 of file l3gd20.h.

Referenced by gyro_reset_bias(), and l3gd20Start().

◆ L3GD20_DI_MASK

#define L3GD20_DI_MASK   0xFF

Definition at line 88 of file l3gd20.h.

◆ L3GD20_DI

#define L3GD20_DI ( n)
Value:
(1 << n)

Definition at line 89 of file l3gd20.h.

◆ L3GD20_AD_MASK

#define L3GD20_AD_MASK   0x3F

Definition at line 90 of file l3gd20.h.

◆ L3GD20_AD

#define L3GD20_AD ( n)
Value:
(1 << n)

Definition at line 91 of file l3gd20.h.

◆ L3GD20_MS

#define L3GD20_MS   (1 << 6)

Definition at line 92 of file l3gd20.h.

Referenced by l3gd20SPIReadRegister(), and l3gd20SPIWriteRegister().

◆ L3GD20_RW

#define L3GD20_RW   (1 << 7)

Definition at line 93 of file l3gd20.h.

Referenced by l3gd20SPIReadRegister().

◆ L3GD20_AD_WHO_AM_I

#define L3GD20_AD_WHO_AM_I   0x0F

Definition at line 100 of file l3gd20.h.

◆ L3GD20_AD_CTRL_REG1

#define L3GD20_AD_CTRL_REG1   0x20

Definition at line 101 of file l3gd20.h.

Referenced by l3gd20Start(), and l3gd20Stop().

◆ L3GD20_AD_CTRL_REG2

#define L3GD20_AD_CTRL_REG2   0x21

Definition at line 102 of file l3gd20.h.

◆ L3GD20_AD_CTRL_REG3

#define L3GD20_AD_CTRL_REG3   0x22

Definition at line 103 of file l3gd20.h.

◆ L3GD20_AD_CTRL_REG4

#define L3GD20_AD_CTRL_REG4   0x23

Definition at line 104 of file l3gd20.h.

Referenced by gyro_set_full_scale().

◆ L3GD20_AD_CTRL_REG5

#define L3GD20_AD_CTRL_REG5   0x24

Definition at line 105 of file l3gd20.h.

◆ L3GD20_AD_REFERENCE

#define L3GD20_AD_REFERENCE   0x25

Definition at line 106 of file l3gd20.h.

◆ L3GD20_AD_OUT_TEMP

#define L3GD20_AD_OUT_TEMP   0x26

Definition at line 107 of file l3gd20.h.

◆ L3GD20_AD_STATUS_REG

#define L3GD20_AD_STATUS_REG   0x27

Definition at line 108 of file l3gd20.h.

◆ L3GD20_AD_OUT_X_L

#define L3GD20_AD_OUT_X_L   0x28

Definition at line 109 of file l3gd20.h.

Referenced by gyro_read_raw().

◆ L3GD20_AD_OUT_X_H

#define L3GD20_AD_OUT_X_H   0x29

Definition at line 110 of file l3gd20.h.

◆ L3GD20_AD_OUT_Y_L

#define L3GD20_AD_OUT_Y_L   0x2A

Definition at line 111 of file l3gd20.h.

◆ L3GD20_AD_OUT_Y_H

#define L3GD20_AD_OUT_Y_H   0x2B

Definition at line 112 of file l3gd20.h.

◆ L3GD20_AD_OUT_Z_L

#define L3GD20_AD_OUT_Z_L   0x2C

Definition at line 113 of file l3gd20.h.

◆ L3GD20_AD_OUT_Z_H

#define L3GD20_AD_OUT_Z_H   0x2D

Definition at line 114 of file l3gd20.h.

◆ L3GD20_AD_FIFO_CTRL_REG

#define L3GD20_AD_FIFO_CTRL_REG   0x2E

Definition at line 115 of file l3gd20.h.

◆ L3GD20_AD_FIFO_SRC_REG

#define L3GD20_AD_FIFO_SRC_REG   0x2F

Definition at line 116 of file l3gd20.h.

◆ L3GD20_AD_INT1_CFG

#define L3GD20_AD_INT1_CFG   0x30

Definition at line 117 of file l3gd20.h.

◆ L3GD20_AD_INT1_SRC

#define L3GD20_AD_INT1_SRC   0x31

Definition at line 118 of file l3gd20.h.

◆ L3GD20_AD_INT1_THS_XH

#define L3GD20_AD_INT1_THS_XH   0x32

Definition at line 119 of file l3gd20.h.

◆ L3GD20_AD_INT1_THS_XL

#define L3GD20_AD_INT1_THS_XL   0x33

Definition at line 120 of file l3gd20.h.

◆ L3GD20_AD_INT1_THS_YH

#define L3GD20_AD_INT1_THS_YH   0x34

Definition at line 121 of file l3gd20.h.

◆ L3GD20_AD_INT1_THS_YL

#define L3GD20_AD_INT1_THS_YL   0x35

Definition at line 122 of file l3gd20.h.

◆ L3GD20_AD_INT1_THS_ZH

#define L3GD20_AD_INT1_THS_ZH   0x36

Definition at line 123 of file l3gd20.h.

◆ L3GD20_AD_INT1_THS_ZL

#define L3GD20_AD_INT1_THS_ZL   0x37

Definition at line 124 of file l3gd20.h.

◆ L3GD20_AD_INT1_DURATION

#define L3GD20_AD_INT1_DURATION   0x38

Definition at line 125 of file l3gd20.h.

◆ L3GD20_CTRL_REG1_MASK

#define L3GD20_CTRL_REG1_MASK   0xFF

Definition at line 132 of file l3gd20.h.

◆ L3GD20_CTRL_REG1_XEN

#define L3GD20_CTRL_REG1_XEN   (1 << 0)

Definition at line 133 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG1_YEN

#define L3GD20_CTRL_REG1_YEN   (1 << 1)

Definition at line 134 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG1_ZEN

#define L3GD20_CTRL_REG1_ZEN   (1 << 2)

Definition at line 135 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG1_PD

#define L3GD20_CTRL_REG1_PD   (1 << 3)

Definition at line 136 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG1_BW0

#define L3GD20_CTRL_REG1_BW0   (1 << 4)

Definition at line 137 of file l3gd20.h.

◆ L3GD20_CTRL_REG1_BW1

#define L3GD20_CTRL_REG1_BW1   (1 << 5)

Definition at line 138 of file l3gd20.h.

◆ L3GD20_CTRL_REG1_DR0

#define L3GD20_CTRL_REG1_DR0   (1 << 6)

Definition at line 139 of file l3gd20.h.

◆ L3GD20_CTRL_REG1_DR1

#define L3GD20_CTRL_REG1_DR1   (1 << 7)

Definition at line 140 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_MASK

#define L3GD20_CTRL_REG2_MASK   0x3F

Definition at line 147 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_HPCF0

#define L3GD20_CTRL_REG2_HPCF0   (1 << 0)

Definition at line 148 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_HPCF1

#define L3GD20_CTRL_REG2_HPCF1   (1 << 1)

Definition at line 149 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_HPCF2

#define L3GD20_CTRL_REG2_HPCF2   (1 << 2)

Definition at line 150 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_HPCF3

#define L3GD20_CTRL_REG2_HPCF3   (1 << 3)

Definition at line 151 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_HPM0

#define L3GD20_CTRL_REG2_HPM0   (1 << 4)

Definition at line 152 of file l3gd20.h.

◆ L3GD20_CTRL_REG2_HPM1

#define L3GD20_CTRL_REG2_HPM1   (1 << 5)

Definition at line 153 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_MASK

#define L3GD20_CTRL_REG3_MASK   0xFF

Definition at line 160 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_I2_EMPTY

#define L3GD20_CTRL_REG3_I2_EMPTY   (1 << 0)

Definition at line 161 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_I2_ORUN

#define L3GD20_CTRL_REG3_I2_ORUN   (1 << 1)

Definition at line 162 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_I2_WTM

#define L3GD20_CTRL_REG3_I2_WTM   (1 << 2)

Definition at line 163 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_I2_DRDY

#define L3GD20_CTRL_REG3_I2_DRDY   (1 << 3)

Definition at line 164 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_PP_OD

#define L3GD20_CTRL_REG3_PP_OD   (1 << 4)

Definition at line 165 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_H_LACTIVE

#define L3GD20_CTRL_REG3_H_LACTIVE   (1 << 5)

Definition at line 166 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_I1_BOOT

#define L3GD20_CTRL_REG3_I1_BOOT   (1 << 6)

Definition at line 167 of file l3gd20.h.

◆ L3GD20_CTRL_REG3_I1_INT1

#define L3GD20_CTRL_REG3_I1_INT1   (1 << 7)

Definition at line 168 of file l3gd20.h.

◆ L3GD20_CTRL_REG4_MASK

#define L3GD20_CTRL_REG4_MASK   0xF1

Definition at line 175 of file l3gd20.h.

◆ L3GD20_CTRL_REG4_SIM

#define L3GD20_CTRL_REG4_SIM   (1 << 0)

Definition at line 176 of file l3gd20.h.

◆ L3GD20_CTRL_REG4_FS_MASK

#define L3GD20_CTRL_REG4_FS_MASK   0x30

Definition at line 177 of file l3gd20.h.

Referenced by gyro_set_full_scale().

◆ L3GD20_CTRL_REG4_FS0

#define L3GD20_CTRL_REG4_FS0   (1 << 4)

Definition at line 178 of file l3gd20.h.

◆ L3GD20_CTRL_REG4_FS1

#define L3GD20_CTRL_REG4_FS1   (1 << 5)

Definition at line 179 of file l3gd20.h.

◆ L3GD20_CTRL_REG4_BLE

#define L3GD20_CTRL_REG4_BLE   (1 << 6)

Definition at line 180 of file l3gd20.h.

◆ L3GD20_CTRL_REG4_BDU

#define L3GD20_CTRL_REG4_BDU   (1 << 7)

Definition at line 181 of file l3gd20.h.

◆ L3GD20_CTRL_REG5_MASK

#define L3GD20_CTRL_REG5_MASK   0xDF

Definition at line 188 of file l3gd20.h.

◆ L3GD20_CTRL_REG5_OUT_SEL0

#define L3GD20_CTRL_REG5_OUT_SEL0   (1 << 0)

Definition at line 189 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG5_OUT_SEL1

#define L3GD20_CTRL_REG5_OUT_SEL1   (1 << 1)

Definition at line 190 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG5_INT1_SEL0

#define L3GD20_CTRL_REG5_INT1_SEL0   (1 << 2)

Definition at line 191 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG5_INT1_SEL1

#define L3GD20_CTRL_REG5_INT1_SEL1   (1 << 3)

Definition at line 192 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG5_HPEN

#define L3GD20_CTRL_REG5_HPEN   (1 << 4)

Definition at line 193 of file l3gd20.h.

Referenced by l3gd20Start().

◆ L3GD20_CTRL_REG5_FIFO_EN

#define L3GD20_CTRL_REG5_FIFO_EN   (1 << 6)

Definition at line 194 of file l3gd20.h.

◆ L3GD20_CTRL_REG5_BOOT

#define L3GD20_CTRL_REG5_BOOT   (1 << 7)

Definition at line 195 of file l3gd20.h.

◆ L3GD20_INT1_CFG_MASK

#define L3GD20_INT1_CFG_MASK   0xFF

Definition at line 202 of file l3gd20.h.

◆ L3GD20_INT1_CFG_XLIE

#define L3GD20_INT1_CFG_XLIE   (1 << 0)

Definition at line 203 of file l3gd20.h.

◆ L3GD20_INT1_CFG_XHIE

#define L3GD20_INT1_CFG_XHIE   (1 << 1)

Definition at line 204 of file l3gd20.h.

◆ L3GD20_INT1_CFG_YLIE

#define L3GD20_INT1_CFG_YLIE   (1 << 2)

Definition at line 205 of file l3gd20.h.

◆ L3GD20_INT1_CFG_YHIE

#define L3GD20_INT1_CFG_YHIE   (1 << 3)

Definition at line 206 of file l3gd20.h.

◆ L3GD20_INT1_CFG_ZLIE

#define L3GD20_INT1_CFG_ZLIE   (1 << 4)

Definition at line 207 of file l3gd20.h.

◆ L3GD20_INT1_CFG_ZHIE

#define L3GD20_INT1_CFG_ZHIE   (1 << 5)

Definition at line 208 of file l3gd20.h.

◆ L3GD20_INT1_CFG_LIR

#define L3GD20_INT1_CFG_LIR   (1 << 6)

Definition at line 209 of file l3gd20.h.

◆ L3GD20_INT1_CFG_AND_OR

#define L3GD20_INT1_CFG_AND_OR   (1 << 7)

Definition at line 210 of file l3gd20.h.

◆ L3GD20_INT1_SRC_MASK

#define L3GD20_INT1_SRC_MASK   0x7F

Definition at line 217 of file l3gd20.h.

◆ L3GD20_INT1_SRC_XL

#define L3GD20_INT1_SRC_XL   (1 << 0)

Definition at line 218 of file l3gd20.h.

◆ L3GD20_INT1_SRC_XH

#define L3GD20_INT1_SRC_XH   (1 << 1)

Definition at line 219 of file l3gd20.h.

◆ L3GD20_INT1_SRC_YL

#define L3GD20_INT1_SRC_YL   (1 << 2)

Definition at line 220 of file l3gd20.h.

◆ L3GD20_INT1_SRC_YH

#define L3GD20_INT1_SRC_YH   (1 << 3)

Definition at line 221 of file l3gd20.h.

◆ L3GD20_INT1_SRC_ZL

#define L3GD20_INT1_SRC_ZL   (1 << 4)

Definition at line 222 of file l3gd20.h.

◆ L3GD20_INT1_SRC_ZH

#define L3GD20_INT1_SRC_ZH   (1 << 5)

Definition at line 223 of file l3gd20.h.

◆ L3GD20_INT1_SRC_IA

#define L3GD20_INT1_SRC_IA   (1 << 6)

Definition at line 224 of file l3gd20.h.

◆ L3GD20_USE_SPI

#define L3GD20_USE_SPI   TRUE

L3GD20 SPI interface switch.

If set to TRUE the support for SPI is included.

Note
The default is TRUE.

Definition at line 241 of file l3gd20.h.

◆ L3GD20_SHARED_SPI

#define L3GD20_SHARED_SPI   FALSE

L3GD20 shared SPI switch.

If set to TRUE the device acquires SPI bus ownership on each transaction.

Note
The default is FALSE. Requires SPI_USE_MUTUAL_EXCLUSION.

Definition at line 251 of file l3gd20.h.

◆ L3GD20_USE_I2C

#define L3GD20_USE_I2C   FALSE

L3GD20 I2C interface switch.

If set to TRUE the support for I2C is included.

Note
The default is FALSE.

Definition at line 260 of file l3gd20.h.

◆ L3GD20_SHARED_I2C

#define L3GD20_SHARED_I2C   FALSE

L3GD20 shared I2C switch.

If set to TRUE the device acquires I2C bus ownership on each transaction.

Note
The default is FALSE. Requires I2C_USE_MUTUAL_EXCLUSION.

Definition at line 270 of file l3gd20.h.

◆ L3GD20_USE_ADVANCED

#define L3GD20_USE_ADVANCED   FALSE

L3GD20 advanced configurations switch.

If set to TRUE more configurations are available.

Note
The default is FALSE.

Definition at line 279 of file l3gd20.h.

◆ L3GD20_BIAS_ACQ_TIMES

#define L3GD20_BIAS_ACQ_TIMES   50

Number of acquisitions for bias removal.

This is the number of acquisitions performed to compute the bias. A repetition is required in order to remove noise.

Definition at line 288 of file l3gd20.h.

Referenced by gyro_sample_bias().

◆ L3GD20_BIAS_SETTLING_US

#define L3GD20_BIAS_SETTLING_US   5000

Settling time for bias removal.

This is the time between each bias acquisition.

Definition at line 296 of file l3gd20.h.

Referenced by gyro_sample_bias().

◆ _l3gd20_methods_alone

#define _l3gd20_methods_alone
Value:
/* Change full scale value of L3GD20.*/ \
static msg_t gyro_set_full_scale(L3GD20Driver *devp, l3gd20_fs_t fs)
Changes the L3GD20Driver gyroscope fullscale value.
Definition l3gd20.c:378
l3gd20_fs_t
L3GD20 full scale.
Definition l3gd20.h:347
L3GD20 3-axis gyroscope class.
Definition l3gd20.h:547

L3GD20 specific methods.

Definition at line 506 of file l3gd20.h.

◆ _l3gd20_methods

#define _l3gd20_methods
Value:
_base_object_methods \
_l3gd20_methods_alone

L3GD20 specific methods with inherited ones.

Definition at line 513 of file l3gd20.h.

◆ _l3gd20_data

#define _l3gd20_data
Value:
/* Driver state.*/ \
l3gd20_state_t state; \
/* Current configuration data.*/ \
const L3GD20Config *config; \
/* Gyroscope subsystem axes number.*/ \
size_t gyroaxes; \
/* Gyroscope subsystem current sensitivity.*/ \
float gyrosensitivity[L3GD20_GYRO_NUMBER_OF_AXES]; \
/* Gyroscope subsystem current Bias.*/ \
float gyrobias[L3GD20_GYRO_NUMBER_OF_AXES]; \
/* Gyroscope subsystem current full scale value.*/ \
float gyrofullscale;
#define _base_sensor_data
BaseSensor specific data.
Definition ex_sensors.h:74
#define L3GD20_GYRO_NUMBER_OF_AXES
L3GD20 gyroscope system characteristics.
Definition l3gd20.h:71
l3gd20_state_t
Driver state machine possible states.
Definition l3gd20.h:427
L3GD20 configuration structure.
Definition l3gd20.h:436

L3GD20Driver specific data.

Definition at line 529 of file l3gd20.h.

◆ l3gd20GyroscopeGetAxesNumber

#define l3gd20GyroscopeGetAxesNumber ( devp)
Value:
gyroscopeGetAxesNumber(&((devp)->gyro_if))
#define gyroscopeGetAxesNumber(ip)
Gyroscope get axes number.

Return the number of axes of the BaseGyroscope.

Parameters
[in]devppointer to L3GD20Driver.
Returns
the number of axes.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 569 of file l3gd20.h.

◆ l3gd20GyroscopeReadRaw

#define l3gd20GyroscopeReadRaw ( devp,
axes )
Value:
gyroscopeReadRaw(&((devp)->gyro_if), axes)
#define gyroscopeReadRaw(ip, dp)
Gyroscope read raw data.

Retrieves raw data from the BaseGyroscope.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]devppointer to L3GD20Driver.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 587 of file l3gd20.h.

◆ l3gd20GyroscopeReadCooked

#define l3gd20GyroscopeReadCooked ( devp,
axes )
Value:
gyroscopeReadCooked(&((devp)->gyro_if), axes)
#define gyroscopeReadCooked(ip, dp)
Gyroscope read cooked data.

Retrieves cooked data from the BaseGyroscope.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as DPS.
The axes array must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]devppointer to L3GD20Driver.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 606 of file l3gd20.h.

◆ l3gd20GyroscopeSampleBias

#define l3gd20GyroscopeSampleBias ( devp)
Value:
gyroscopeSampleBias(&((devp)->gyro_if))
#define gyroscopeSampleBias(ip)
Gyroscope bias sampling procedure.

Samples bias values for the BaseGyroscope.

Note
The L3GD20 shall not be moved during the whole procedure.
After this function internal bias is automatically updated.
The behavior of this function depends on L3GD20_BIAS_ACQ_TIMES and L3GD20_BIAS_SETTLING_US.
Parameters
[in]devppointer to L3GD20Driver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 623 of file l3gd20.h.

◆ l3gd20GyroscopeSetBias

#define l3gd20GyroscopeSetBias ( devp,
bp )
Value:
gyroscopeSetBias(&((devp)->gyro_if), bp)
#define gyroscopeSetBias(ip, bp)
Updates gyroscope bias data from received buffer.

Set bias values for the BaseGyroscope.

Note
Bias must be expressed as DPS.
The bias buffer must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]devppointer to L3GD20Driver.
[in]bpa buffer which contains biases.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 640 of file l3gd20.h.

◆ l3gd20GyroscopeResetBias

#define l3gd20GyroscopeResetBias ( devp)
Value:
gyroscopeResetBias(&((devp)->gyro_if))
#define gyroscopeResetBias(ip)
Reset gyroscope bias data restoring it to zero.

Reset bias values for the BaseGyroscope.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]devppointer to L3GD20Driver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 655 of file l3gd20.h.

◆ l3gd20GyroscopeSetSensitivity

#define l3gd20GyroscopeSetSensitivity ( devp,
sp )
Value:
gyroscopeSetSensitivity(&((devp)->gyro_if), sp)
#define gyroscopeSetSensitivity(ip, sp)
Updates gyroscope sensitivity data from received buffer.

Set sensitivity values for the BaseGyroscope.

Note
Sensitivity must be expressed as DPS/LSB.
The sensitivity buffer must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]devppointer to L3GD20Driver.
[in]spa buffer which contains sensitivities.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 672 of file l3gd20.h.

◆ l3gd20GyroscopeResetSensitivity

#define l3gd20GyroscopeResetSensitivity ( devp)
Value:
gyroscopeResetSensitivity(&((devp)->gyro_if))
#define gyroscopeResetSensitivity(ip)
Reset gyroscope sensitivity data restoring it to its typical value.

Reset sensitivity values for the BaseGyroscope.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]devppointer to L3GD20Driver.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 687 of file l3gd20.h.

◆ l3gd20GyroscopeSetFullScale

#define l3gd20GyroscopeSetFullScale ( devp,
fs )
Value:
(devp)->vmt->acc_set_full_scale(devp, fs)
static const struct EFlashDriverVMT vmt
Definition hal_efl.c:71

Changes the L3GD20Driver gyroscope fullscale value.

Note
This function also rescale sensitivities and biases based on previous and next fullscale value.
A recalibration is highly suggested after calling this function.
Parameters
[in]devppointer to L3GD20Driver.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 705 of file l3gd20.h.

Typedef Documentation

◆ L3GD20Driver

typedef struct L3GD20Driver L3GD20Driver

Structure representing a L3GD20 driver.

Definition at line 342 of file l3gd20.h.

Enumeration Type Documentation

◆ l3gd20_fs_t

L3GD20 full scale.

Enumerator
L3GD20_FS_250DPS 

Full scale 250 degree per second.

L3GD20_FS_500DPS 

Full scale 500 degree per second.

L3GD20_FS_2000DPS 

Full scale 2000 degree per second.

Definition at line 347 of file l3gd20.h.

◆ l3gd20_odr_t

L3GD20 output data rate and bandwidth.

Enumerator
L3GD20_ODR_95HZ 

Output data rate 95 Hz.

L3GD20_ODR_190HZ 

Output data rate 190 Hz.

L3GD20_ODR_380HZ 

Output data rate 380 Hz.

L3GD20_ODR_760HZ 

Output data rate 760 Hz.

Definition at line 356 of file l3gd20.h.

◆ l3gd20_bw_t

L3GD20 low pass filter 1 bandwidth.

Enumerator
L3GD20_BW0 

LPF1 bandwidth. Depends on ODR.

L3GD20_BW1 

LPF1 bandwidth. Depends on ODR.

L3GD20_BW2 

LPF1 bandwidth. Depends on ODR.

L3GD20_BW3 

LPF1 bandwidth. Depends on ODR.

Definition at line 366 of file l3gd20.h.

◆ l3gd20_bdu_t

L3GD20 block data update.

Enumerator
L3GD20_BDU_CONTINUOUS 

Block data continuously updated.

L3GD20_BDU_BLOCKED 

Block data updated after reading.

Definition at line 376 of file l3gd20.h.

◆ l3gd20_hpm_t

L3GD20 HP filter mode.

Enumerator
L3GD20_HPM_NORMAL 

Normal mode.

L3GD20_HPM_REFERENCE 

Reference signal for filtering.

L3GD20_HPM_AUTORESET 

Autoreset on interrupt event.

L3GD20_HPM_BYPASSED 

HP filter bypassed

Definition at line 384 of file l3gd20.h.

◆ l3gd20_hpcf_t

L3GD20 HP configuration.

Enumerator
L3GD20_HPCF_0 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_1 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_2 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_3 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_4 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_5 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_6 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_7 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_8 

Depends on ODR (Table 26 for more).

L3GD20_HPCF_9 

Depends on ODR (Table 26 for more).

Definition at line 394 of file l3gd20.h.

◆ l3gd20_lp2m_t

L3GD20 LP2 filter mode.

To activate LP2 HP should be active

Enumerator
L3GD20_LP2M_ON 

LP2 filter activated.

L3GD20_LP2M_BYPASSED 

LP2 filter bypassed.

Definition at line 411 of file l3gd20.h.

◆ l3gd20_end_t

L3GD20 endianness.

Enumerator
L3GD20_END_LITTLE 

Little endian.

L3GD20_END_BIG 

Big endian.

Definition at line 419 of file l3gd20.h.

◆ l3gd20_state_t

Driver state machine possible states.

Enumerator
L3GD20_UNINIT 

Not initialized.

L3GD20_STOP 

Stopped.

L3GD20_READY 

Ready.

Definition at line 427 of file l3gd20.h.

Function Documentation

◆ l3gd20SPIReadRegister()

void l3gd20SPIReadRegister ( SPIDriver * spip,
uint8_t reg,
size_t n,
uint8_t * b )
static

Reads a generic register value using SPI.

Precondition
The SPI interface must be initialized and the driver started.
Parameters
[in]spippointer to the SPI interface
[in]regstarting register address
[in]nnumber of consecutive registers to read
[in]bpointer to an output buffer.

Definition at line 59 of file l3gd20.c.

References L3GD20_MS, L3GD20_RW, spiReceive(), spiSelect(), spiSend(), and spiUnselect().

Referenced by gyro_read_raw(), and gyro_set_full_scale().

Here is the call graph for this function:

◆ l3gd20SPIWriteRegister()

void l3gd20SPIWriteRegister ( SPIDriver * spip,
uint8_t reg,
size_t n,
uint8_t * b )
static

Writes a value into a generic register using SPI.

Precondition
The SPI interface must be initialized and the driver started.
Parameters
[in]spippointer to the SPI interface
[in]regstarting register address
[in]nnumber of adjacent registers to write
[in]bpointer to a buffer of values.

Definition at line 78 of file l3gd20.c.

References L3GD20_MS, spiSelect(), spiSend(), and spiUnselect().

Referenced by gyro_set_full_scale(), l3gd20Start(), and l3gd20Stop().

Here is the call graph for this function:

◆ gyro_get_axes_number()

size_t gyro_get_axes_number ( void * ip)
static

Return the number of axes of the BaseGyroscope.

Parameters
[in]ippointer to BaseGyroscope interface.
Returns
the number of axes.

Definition at line 96 of file l3gd20.c.

References L3GD20_GYRO_NUMBER_OF_AXES.

◆ gyro_read_raw()

msg_t gyro_read_raw ( void * ip,
int32_t axes[L3GD20_GYRO_NUMBER_OF_AXES] )
static

Retrieves raw data from the BaseGyroscope.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]ippointer to BaseGyroscope interface.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 115 of file l3gd20.c.

References L3GD20_AD_OUT_X_L, L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, l3gd20SPIReadRegister(), MSG_OK, objGetInstance, osalDbgAssert, osalDbgCheck, SPI_READY, spiAcquireBus(), spiReleaseBus(), and spiStart().

Referenced by gyro_read_cooked(), and gyro_sample_bias().

Here is the call graph for this function:

◆ gyro_read_cooked()

msg_t gyro_read_cooked ( void * ip,
float axes[] )
static

Retrieves cooked data from the BaseGyroscope.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as DPS.
The axes array must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]ippointer to BaseGyroscope interface.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 167 of file l3gd20.c.

References gyro_read_raw(), L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, objGetInstance, osalDbgAssert, and osalDbgCheck.

Here is the call graph for this function:

◆ gyro_sample_bias()

msg_t gyro_sample_bias ( void * ip)
static

Samples bias values for the BaseGyroscope.

Note
The L3GD20 shall not be moved during the whole procedure.
After this function internal bias is automatically updated.
The behavior of this function depends on L3GD20_BIAS_ACQ_TIMES and L3GD20_BIAS_SETTLING_US.
Parameters
[in]ippointer to BaseGyroscope interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 200 of file l3gd20.c.

References gyro_read_raw(), L3GD20_BIAS_ACQ_TIMES, L3GD20_BIAS_SETTLING_US, L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, MSG_OK, objGetInstance, osalDbgAssert, osalDbgCheck, osalThreadSleepMicroseconds, and SPI_READY.

Here is the call graph for this function:

◆ gyro_set_bias()

msg_t gyro_set_bias ( void * ip,
float * bp )
static

Set bias values for the BaseGyroscope.

Note
Bias must be expressed as DPS.
The bias buffer must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]ippointer to BaseGyroscope interface.
[in]bpa buffer which contains biases.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 248 of file l3gd20.c.

References L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ gyro_reset_bias()

msg_t gyro_reset_bias ( void * ip)
static

Reset bias values for the BaseGyroscope.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]ippointer to BaseGyroscope interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 277 of file l3gd20.c.

References L3GD20_GYRO_BIAS, L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ gyro_set_sensivity()

msg_t gyro_set_sensivity ( void * ip,
float * sp )
static

Set sensitivity values for the BaseGyroscope.

Note
Sensitivity must be expressed as DPS/LSB.
The sensitivity buffer must be at least the same size of the BaseGyroscope axes number.
Parameters
[in]ippointer to BaseGyroscope interface.
[in]spa buffer which contains sensitivities.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.

Definition at line 307 of file l3gd20.c.

References L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, MSG_OK, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ gyro_reset_sensivity()

msg_t gyro_reset_sensivity ( void * ip)
static

Reset sensitivity values for the BaseGyroscope.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]ippointer to BaseGyroscope interface.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 336 of file l3gd20.c.

References FALSE, L3GD20_FS_2000DPS, L3GD20_FS_250DPS, L3GD20_FS_500DPS, L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_GYRO_SENS_2000DPS, L3GD20_GYRO_SENS_250DPS, L3GD20_GYRO_SENS_500DPS, L3GD20_READY, MSG_OK, MSG_RESET, objGetInstance, osalDbgAssert, and osalDbgCheck.

◆ gyro_set_full_scale()

msg_t gyro_set_full_scale ( L3GD20Driver * devp,
l3gd20_fs_t fs )
static

Changes the L3GD20Driver gyroscope fullscale value.

Note
This function also rescale sensitivities and biases based on previous and next fullscale value.
A recalibration is highly suggested after calling this function.
Parameters
[in]devppointer to BaseGyroscope interface.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 378 of file l3gd20.c.

References L3GD20_2000DPS, L3GD20_250DPS, L3GD20_500DPS, L3GD20_AD_CTRL_REG4, L3GD20_CTRL_REG4_FS_MASK, L3GD20_FS_2000DPS, L3GD20_FS_250DPS, L3GD20_FS_500DPS, L3GD20_GYRO_NUMBER_OF_AXES, L3GD20_READY, l3gd20SPIReadRegister(), l3gd20SPIWriteRegister(), MSG_OK, MSG_RESET, osalDbgAssert, osalDbgCheck, SPI_READY, spiAcquireBus(), spiReleaseBus(), and spiStart().

Here is the call graph for this function:

◆ l3gd20ObjectInit()

void l3gd20ObjectInit ( L3GD20Driver * devp)

Initializes an instance.

Parameters
[out]devppointer to the L3GD20Driver object
Function Class:
Object or module nitializer function.

Definition at line 473 of file l3gd20.c.

References L3GD20Driver::gyro_if, L3GD20_STOP, BaseGyroscope::vmt, L3GD20Driver::vmt, vmt_device, and vmt_gyroscope.

◆ l3gd20Start()

void l3gd20Start ( L3GD20Driver * devp,
const L3GD20Config * config )

◆ l3gd20Stop()

void l3gd20Stop ( L3GD20Driver * devp)

Deactivates the L3GD20 Complex Driver peripheral.

Parameters
[in]devppointer to the L3GD20Driver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 613 of file l3gd20.c.

References L3GD20_AD_CTRL_REG1, L3GD20_READY, L3GD20_STOP, l3gd20SPIWriteRegister(), osalDbgAssert, osalDbgCheck, spiAcquireBus(), spiReleaseBus(), spiStart(), and spiStop().

Here is the call graph for this function:

Variable Documentation

◆ vmt_device

const struct L3GD20VMT vmt_device
static
Initial value:
= {
(size_t)0,
}

Definition at line 450 of file l3gd20.c.

◆ vmt_gyroscope

const struct BaseGyroscopeVMT vmt_gyroscope
static
Initial value:
= {
sizeof(struct L3GD20VMT*),
}
static msg_t gyro_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseGyroscope.
Definition l3gd20.c:307
static size_t gyro_get_axes_number(void *ip)
Return the number of axes of the BaseGyroscope.
Definition l3gd20.c:96
static msg_t gyro_read_raw(void *ip, int32_t axes[L3GD20_GYRO_NUMBER_OF_AXES])
Retrieves raw data from the BaseGyroscope.
Definition l3gd20.c:115
static msg_t gyro_sample_bias(void *ip)
Samples bias values for the BaseGyroscope.
Definition l3gd20.c:200
static msg_t gyro_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseGyroscope.
Definition l3gd20.c:167
static msg_t gyro_set_bias(void *ip, float *bp)
Set bias values for the BaseGyroscope.
Definition l3gd20.c:248
static msg_t gyro_reset_sensivity(void *ip)
Reset sensitivity values for the BaseGyroscope.
Definition l3gd20.c:336
static msg_t gyro_reset_bias(void *ip)
Reset bias values for the BaseGyroscope.
Definition l3gd20.c:277
L3GD20 virtual methods table.
Definition l3gd20.h:522

Definition at line 455 of file l3gd20.c.

Referenced by l3gd20ObjectInit(), lsm6ds0ObjectInit(), and lsm6dslObjectInit().