ChibiOS/EX 1.3.0

Detailed Description

Collaboration diagram for LIS302DL:

LIS302DL data structures and types

enum  lis302dl_acc_fs_t { LIS302DL_ACC_FS_2G = 0x00 , LIS302DL_ACC_FS_8G = 0x20 }
 LIS302DL full scale. More...
enum  lis302dl_acc_odr_t { LIS302DL_ACC_ODR_100HZ = 0x00 , LIS302DL_ACC_ODR_400HZ = 0x80 }
 LIS302DL output data rate and bandwidth. More...
enum  lis302dl_acc_hp_t {
  LIS302DL_ACC_HP_DISABLED = 0x00 , LIS302DL_ACC_HP_0 = 0x10 , LIS302DL_ACC_HP_1 = 0x11 , LIS302DL_ACC_HP_2 = 0x12 ,
  LIS302DL_ACC_HP_3 = 0x13
}
 LIS302DL high pass filtering. More...
enum  lis302dl_state_t { LIS302DL_UNINIT = 0 , LIS302DL_STOP = 1 , LIS302DL_READY = 2 }
 Driver state machine possible states. More...
typedef struct LIS302DLDriver LIS302DLDriver
 Structure representing a LIS302DL driver.
#define _lis302dl_methods_alone
 LIS302DL specific methods.
#define _lis302dl_methods
 LIS302DL specific methods with inherited ones.
#define _lis302dl_data
 LIS302DLDriver specific data.

Version identification

#define EX_LIS302DL_VERSION   "1.1.2"
 LIS302DL driver version string.
#define EX_LIS302DL_MAJOR   1
 LIS302DL driver version major number.
#define EX_LIS302DL_MINOR   1
 LIS302DL driver version minor number.
#define EX_LIS302DL_PATCH   2
 LIS302DL driver version patch number.
#define LIS302DL_ACC_NUMBER_OF_AXES   3U
 LIS302DL accelerometer subsystem characteristics.
#define LIS302DL_ACC_2G   2.0f
#define LIS302DL_ACC_8G   8.0f
#define LIS302DL_ACC_SENS_2G   18.0f
#define LIS302DL_ACC_SENS_8G   72.0f
#define LIS302DL_ACC_BIAS   0.0f

LIS302DL communication interfaces related bit masks

#define LIS302DL_DI_MASK   0xFF
#define LIS302DL_DI(n)
#define LIS302DL_AD_MASK   0x3F
#define LIS302DL_AD(n)
#define LIS302DL_MS   (1 << 6)
#define LIS302DL_RW   (1 << 7)

LIS302DL register addresses

#define LIS302DL_AD_WHO_AM_I   0x0F
#define LIS302DL_AD_CTRL_REG1   0x20
#define LIS302DL_AD_CTRL_REG2   0x21
#define LIS302DL_AD_CTRL_REG3   0x22
#define LIS302DL_AD_HP_FILER_RESET   0x23
#define LIS302DL_AD_STATUS_REG   0x27
#define LIS302DL_AD_OUT_X   0x29
#define LIS302DL_AD_OUT_Y   0x2B
#define LIS302DL_AD_OUT_Z   0x2D
#define LIS302DL_AD_FF_WU_CFG_1   0x30
#define LIS302DL_AD_FF_WU_SRC_1   0x31
#define LIS302DL_AD_FF_WU_THS_1   0x32
#define LIS302DL_AD_FF_WU_DURATION_1   0x33
#define LIS302DL_AD_FF_WU_CFG_2   0x34
#define LIS302DL_AD_FF_WU_SRC_2   0x35
#define LIS302DL_AD_FF_WU_THS_2   0x36
#define LIS302DL_AD_FF_WU_DURATION_2   0x37
#define LIS302DL_AD_CLICK_CFG   0x38
#define LIS302DL_AD_CLICK_SRC   0x39
#define LIS302DL_AD_CLICK_THSY_X   0x3B
#define LIS302DL_AD_CLICK_THSZ   0x3C
#define LIS302DL_AD_CLICK_TIME_LIMIT   0x3D
#define LIS302DL_AD_CLICK_LATENCY   0x3E
#define LIS302DL_AD_CLICK_WINDOW   0x3F

LIS302DL_CTRL_REG1 register bits definitions

#define LIS302DL_CTRL_REG1_MASK   0xFF
#define LIS302DL_CTRL_REG1_XEN   (1 << 0)
#define LIS302DL_CTRL_REG1_YEN   (1 << 1)
#define LIS302DL_CTRL_REG1_ZEN   (1 << 2)
#define LIS302DL_CTRL_REG1_STM   (1 << 3)
#define LIS302DL_CTRL_REG1_STP   (1 << 4)
#define LIS302DL_CTRL_REG1_FS_MASK   0x20
#define LIS302DL_CTRL_REG1_FS   (1 << 5)
#define LIS302DL_CTRL_REG1_PD   (1 << 6)
#define LIS302DL_CTRL_REG1_DR   (1 << 7)

LIS302DL_CTRL_REG2 register bits definitions

#define LIS302DL_CTRL_REG2_MASK   0xDF
#define LIS302DL_CTRL_REG2_HPCF1   (1 << 0)
#define LIS302DL_CTRL_REG2_HPCF2   (1 << 1)
#define LIS302DL_CTRL_REG2_HPFFWU1   (1 << 2)
#define LIS302DL_CTRL_REG2_HPFFWU2   (1 << 3)
#define LIS302DL_CTRL_REG2_FDS   (1 << 4)
#define LIS302DL_CTRL_REG2_BOOT   (1 << 6)
#define LIS302DL_CTRL_REG2_SIM   (1 << 7)

LIS302DL_CTRL_REG3 register bits definitions

#define LIS302DL_CTRL_REG3_MASK   0xFF
#define LIS302DL_CTRL_REG3_I1CFG0   (1 << 0)
#define LIS302DL_CTRL_REG3_I1CFG1   (1 << 1)
#define LIS302DL_CTRL_REG3_I1CFG2   (1 << 2)
#define LIS302DL_CTRL_REG3_I2CFG0   (1 << 3)
#define LIS302DL_CTRL_REG3_I2CFG1   (1 << 4)
#define LIS302DL_CTRL_REG3_I2CFG2   (1 << 5)
#define LIS302DL_CTRL_REG3_PP_OD   (1 << 6)
#define LIS302DL_CTRL_REG3_IHL   (1 << 7)

Configuration options

#define LIS302DL_USE_SPI   TRUE
 LIS302DL SPI interface switch.
#define LIS302DL_SHARED_SPI   FALSE
 LIS302DL shared SPI switch.
#define LIS302DL_USE_I2C   FALSE
 LIS302DL I2C interface switch.
#define LIS302DL_SHARED_I2C   FALSE
 LIS302DL shared I2C switch.
#define LIS302DL_USE_ADVANCED   FALSE
 LIS302DL advanced configurations switch.

Data Structures

struct  LIS302DLConfig
 LIS302DL configuration structure. More...
struct  LIS302DLVMT
 LIS302DL accelerometer virtual methods table. More...
struct  LIS302DLDriver
 LIS302DL 3-axis accelerometer class. More...

Macros

#define lis302dlAccelerometerGetAxesNumber(devp)
 Return the number of axes of the BaseAccelerometer.
#define lis302dlAccelerometerReadRaw(devp, axes)
 Retrieves raw data from the BaseAccelerometer.
#define lis302dlAccelerometerReadCooked(devp, axes)
 Retrieves cooked data from the BaseAccelerometer.
#define lis302dlAccelerometerSetBias(devp, bp)
 Set bias values for the BaseAccelerometer.
#define lis302dlAccelerometerResetBias(devp)
 Reset bias values for the BaseAccelerometer.
#define lis302dlAccelerometerSetSensitivity(devp, sp)
 Set sensitivity values for the BaseAccelerometer.
#define lis302dlAccelerometerResetSensitivity(devp)
 Reset sensitivity values for the BaseAccelerometer.
#define lis302dlAccelerometerSetFullScale(devp, fs)
 Changes the LIS302DLDriver accelerometer fullscale value.

Functions

static void lis302dlSPIReadRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
 Reads a generic register value using SPI.
static void lis302dlSPIWriteRegister (SPIDriver *spip, uint8_t reg, size_t n, uint8_t *b)
 Writes a value into a generic register using SPI.
static size_t acc_get_axes_number (void *ip)
 Return the number of axes of the BaseAccelerometer.
static msg_t acc_read_raw (void *ip, int32_t axes[])
 Retrieves raw data from the BaseAccelerometer.
static msg_t acc_read_cooked (void *ip, float axes[])
 Retrieves cooked data from the BaseAccelerometer.
static msg_t acc_set_bias (void *ip, float *bp)
 Set bias values for the BaseAccelerometer.
static msg_t acc_reset_bias (void *ip)
 Reset bias values for the BaseAccelerometer.
static msg_t acc_set_sensivity (void *ip, float *sp)
 Set sensitivity values for the BaseAccelerometer.
static msg_t acc_reset_sensivity (void *ip)
 Reset sensitivity values for the BaseAccelerometer.
static msg_t acc_set_full_scale (LIS302DLDriver *devp, lis302dl_acc_fs_t fs)
 Changes the LIS302DLDriver accelerometer fullscale value.
void lis302dlObjectInit (LIS302DLDriver *devp)
 Initializes an instance.
void lis302dlStart (LIS302DLDriver *devp, const LIS302DLConfig *config)
 Configures and activates LIS302DL Complex Driver peripheral.
void lis302dlStop (LIS302DLDriver *devp)
 Deactivates the LIS302DL Complex Driver peripheral.

Variables

static const struct LIS302DLVMT vmt_device
static const struct BaseAccelerometerVMT vmt_accelerometer

Macro Definition Documentation

◆ EX_LIS302DL_VERSION

#define EX_LIS302DL_VERSION   "1.1.2"

LIS302DL driver version string.

Definition at line 46 of file lis302dl.h.

◆ EX_LIS302DL_MAJOR

#define EX_LIS302DL_MAJOR   1

LIS302DL driver version major number.

Definition at line 51 of file lis302dl.h.

◆ EX_LIS302DL_MINOR

#define EX_LIS302DL_MINOR   1

LIS302DL driver version minor number.

Definition at line 56 of file lis302dl.h.

◆ EX_LIS302DL_PATCH

#define EX_LIS302DL_PATCH   2

LIS302DL driver version patch number.

Definition at line 61 of file lis302dl.h.

◆ LIS302DL_ACC_NUMBER_OF_AXES

#define LIS302DL_ACC_NUMBER_OF_AXES   3U

LIS302DL accelerometer subsystem characteristics.

Note
Sensitivity is expressed as milli-G/LSB whereas 1 milli-G = 0.00980665 m/s^2.
Bias is expressed as milli-G.

Definition at line 72 of file lis302dl.h.

Referenced by acc_get_axes_number(), acc_read_cooked(), acc_read_raw(), acc_reset_bias(), acc_reset_sensivity(), acc_set_bias(), acc_set_full_scale(), acc_set_sensivity(), lis302dlObjectInit(), and lis302dlStart().

◆ LIS302DL_ACC_2G

#define LIS302DL_ACC_2G   2.0f

Definition at line 74 of file lis302dl.h.

Referenced by acc_set_full_scale(), and lis302dlStart().

◆ LIS302DL_ACC_8G

#define LIS302DL_ACC_8G   8.0f

Definition at line 75 of file lis302dl.h.

Referenced by acc_set_full_scale(), and lis302dlStart().

◆ LIS302DL_ACC_SENS_2G

#define LIS302DL_ACC_SENS_2G   18.0f

Definition at line 77 of file lis302dl.h.

Referenced by acc_reset_sensivity(), and lis302dlStart().

◆ LIS302DL_ACC_SENS_8G

#define LIS302DL_ACC_SENS_8G   72.0f

Definition at line 78 of file lis302dl.h.

Referenced by acc_reset_sensivity(), and lis302dlStart().

◆ LIS302DL_ACC_BIAS

#define LIS302DL_ACC_BIAS   0.0f

Definition at line 80 of file lis302dl.h.

Referenced by acc_reset_bias(), and lis302dlStart().

◆ LIS302DL_DI_MASK

#define LIS302DL_DI_MASK   0xFF

Definition at line 87 of file lis302dl.h.

◆ LIS302DL_DI

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

Definition at line 88 of file lis302dl.h.

◆ LIS302DL_AD_MASK

#define LIS302DL_AD_MASK   0x3F

Definition at line 89 of file lis302dl.h.

◆ LIS302DL_AD

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

Definition at line 90 of file lis302dl.h.

◆ LIS302DL_MS

#define LIS302DL_MS   (1 << 6)

Definition at line 91 of file lis302dl.h.

Referenced by lis302dlSPIReadRegister(), and lis302dlSPIWriteRegister().

◆ LIS302DL_RW

#define LIS302DL_RW   (1 << 7)

Definition at line 92 of file lis302dl.h.

Referenced by lis302dlSPIReadRegister().

◆ LIS302DL_AD_WHO_AM_I

#define LIS302DL_AD_WHO_AM_I   0x0F

Definition at line 99 of file lis302dl.h.

◆ LIS302DL_AD_CTRL_REG1

#define LIS302DL_AD_CTRL_REG1   0x20

Definition at line 100 of file lis302dl.h.

Referenced by acc_set_full_scale(), lis302dlStart(), and lis302dlStop().

◆ LIS302DL_AD_CTRL_REG2

#define LIS302DL_AD_CTRL_REG2   0x21

Definition at line 101 of file lis302dl.h.

◆ LIS302DL_AD_CTRL_REG3

#define LIS302DL_AD_CTRL_REG3   0x22

Definition at line 102 of file lis302dl.h.

◆ LIS302DL_AD_HP_FILER_RESET

#define LIS302DL_AD_HP_FILER_RESET   0x23

Definition at line 103 of file lis302dl.h.

◆ LIS302DL_AD_STATUS_REG

#define LIS302DL_AD_STATUS_REG   0x27

Definition at line 104 of file lis302dl.h.

◆ LIS302DL_AD_OUT_X

#define LIS302DL_AD_OUT_X   0x29

Definition at line 105 of file lis302dl.h.

Referenced by acc_read_raw().

◆ LIS302DL_AD_OUT_Y

#define LIS302DL_AD_OUT_Y   0x2B

Definition at line 106 of file lis302dl.h.

◆ LIS302DL_AD_OUT_Z

#define LIS302DL_AD_OUT_Z   0x2D

Definition at line 107 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_CFG_1

#define LIS302DL_AD_FF_WU_CFG_1   0x30

Definition at line 108 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_SRC_1

#define LIS302DL_AD_FF_WU_SRC_1   0x31

Definition at line 109 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_THS_1

#define LIS302DL_AD_FF_WU_THS_1   0x32

Definition at line 110 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_DURATION_1

#define LIS302DL_AD_FF_WU_DURATION_1   0x33

Definition at line 111 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_CFG_2

#define LIS302DL_AD_FF_WU_CFG_2   0x34

Definition at line 112 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_SRC_2

#define LIS302DL_AD_FF_WU_SRC_2   0x35

Definition at line 113 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_THS_2

#define LIS302DL_AD_FF_WU_THS_2   0x36

Definition at line 114 of file lis302dl.h.

◆ LIS302DL_AD_FF_WU_DURATION_2

#define LIS302DL_AD_FF_WU_DURATION_2   0x37

Definition at line 115 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_CFG

#define LIS302DL_AD_CLICK_CFG   0x38

Definition at line 116 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_SRC

#define LIS302DL_AD_CLICK_SRC   0x39

Definition at line 117 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_THSY_X

#define LIS302DL_AD_CLICK_THSY_X   0x3B

Definition at line 118 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_THSZ

#define LIS302DL_AD_CLICK_THSZ   0x3C

Definition at line 119 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_TIME_LIMIT

#define LIS302DL_AD_CLICK_TIME_LIMIT   0x3D

Definition at line 120 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_LATENCY

#define LIS302DL_AD_CLICK_LATENCY   0x3E

Definition at line 121 of file lis302dl.h.

◆ LIS302DL_AD_CLICK_WINDOW

#define LIS302DL_AD_CLICK_WINDOW   0x3F

Definition at line 122 of file lis302dl.h.

◆ LIS302DL_CTRL_REG1_MASK

#define LIS302DL_CTRL_REG1_MASK   0xFF

Definition at line 129 of file lis302dl.h.

◆ LIS302DL_CTRL_REG1_XEN

#define LIS302DL_CTRL_REG1_XEN   (1 << 0)

Definition at line 130 of file lis302dl.h.

Referenced by lis302dlStart().

◆ LIS302DL_CTRL_REG1_YEN

#define LIS302DL_CTRL_REG1_YEN   (1 << 1)

Definition at line 131 of file lis302dl.h.

Referenced by lis302dlStart().

◆ LIS302DL_CTRL_REG1_ZEN

#define LIS302DL_CTRL_REG1_ZEN   (1 << 2)

Definition at line 132 of file lis302dl.h.

Referenced by lis302dlStart().

◆ LIS302DL_CTRL_REG1_STM

#define LIS302DL_CTRL_REG1_STM   (1 << 3)

Definition at line 133 of file lis302dl.h.

◆ LIS302DL_CTRL_REG1_STP

#define LIS302DL_CTRL_REG1_STP   (1 << 4)

Definition at line 134 of file lis302dl.h.

◆ LIS302DL_CTRL_REG1_FS_MASK

#define LIS302DL_CTRL_REG1_FS_MASK   0x20

Definition at line 135 of file lis302dl.h.

Referenced by acc_set_full_scale().

◆ LIS302DL_CTRL_REG1_FS

#define LIS302DL_CTRL_REG1_FS   (1 << 5)

Definition at line 136 of file lis302dl.h.

◆ LIS302DL_CTRL_REG1_PD

#define LIS302DL_CTRL_REG1_PD   (1 << 6)

Definition at line 137 of file lis302dl.h.

Referenced by lis302dlStart().

◆ LIS302DL_CTRL_REG1_DR

#define LIS302DL_CTRL_REG1_DR   (1 << 7)

Definition at line 138 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_MASK

#define LIS302DL_CTRL_REG2_MASK   0xDF

Definition at line 145 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_HPCF1

#define LIS302DL_CTRL_REG2_HPCF1   (1 << 0)

Definition at line 146 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_HPCF2

#define LIS302DL_CTRL_REG2_HPCF2   (1 << 1)

Definition at line 147 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_HPFFWU1

#define LIS302DL_CTRL_REG2_HPFFWU1   (1 << 2)

Definition at line 148 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_HPFFWU2

#define LIS302DL_CTRL_REG2_HPFFWU2   (1 << 3)

Definition at line 149 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_FDS

#define LIS302DL_CTRL_REG2_FDS   (1 << 4)

Definition at line 150 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_BOOT

#define LIS302DL_CTRL_REG2_BOOT   (1 << 6)

Definition at line 151 of file lis302dl.h.

◆ LIS302DL_CTRL_REG2_SIM

#define LIS302DL_CTRL_REG2_SIM   (1 << 7)

Definition at line 152 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_MASK

#define LIS302DL_CTRL_REG3_MASK   0xFF

Definition at line 159 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_I1CFG0

#define LIS302DL_CTRL_REG3_I1CFG0   (1 << 0)

Definition at line 160 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_I1CFG1

#define LIS302DL_CTRL_REG3_I1CFG1   (1 << 1)

Definition at line 161 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_I1CFG2

#define LIS302DL_CTRL_REG3_I1CFG2   (1 << 2)

Definition at line 162 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_I2CFG0

#define LIS302DL_CTRL_REG3_I2CFG0   (1 << 3)

Definition at line 163 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_I2CFG1

#define LIS302DL_CTRL_REG3_I2CFG1   (1 << 4)

Definition at line 164 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_I2CFG2

#define LIS302DL_CTRL_REG3_I2CFG2   (1 << 5)

Definition at line 165 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_PP_OD

#define LIS302DL_CTRL_REG3_PP_OD   (1 << 6)

Definition at line 166 of file lis302dl.h.

◆ LIS302DL_CTRL_REG3_IHL

#define LIS302DL_CTRL_REG3_IHL   (1 << 7)

Definition at line 167 of file lis302dl.h.

◆ LIS302DL_USE_SPI

#define LIS302DL_USE_SPI   TRUE

LIS302DL SPI interface switch.

If set to TRUE the support for SPI is included.

Note
The default is TRUE.

Definition at line 184 of file lis302dl.h.

◆ LIS302DL_SHARED_SPI

#define LIS302DL_SHARED_SPI   FALSE

LIS302DL 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 194 of file lis302dl.h.

◆ LIS302DL_USE_I2C

#define LIS302DL_USE_I2C   FALSE

LIS302DL I2C interface switch.

If set to TRUE the support for I2C is included.

Note
The default is FALSE.

Definition at line 203 of file lis302dl.h.

◆ LIS302DL_SHARED_I2C

#define LIS302DL_SHARED_I2C   FALSE

LIS302DL 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 213 of file lis302dl.h.

◆ LIS302DL_USE_ADVANCED

#define LIS302DL_USE_ADVANCED   FALSE

LIS302DL advanced configurations switch.

If set to TRUE more configurations are available.

Note
The default is FALSE.

Definition at line 222 of file lis302dl.h.

◆ _lis302dl_methods_alone

#define _lis302dl_methods_alone
Value:
/* Change full scale value of LIS302DL .*/ \
msg_t (*set_full_scale)(LIS302DLDriver *devp, lis302dl_acc_fs_t fs);
lis302dl_acc_fs_t
LIS302DL full scale.
Definition lis302dl.h:273
LIS302DL 3-axis accelerometer class.
Definition lis302dl.h:399

LIS302DL specific methods.

Definition at line 358 of file lis302dl.h.

◆ _lis302dl_methods

#define _lis302dl_methods
Value:
_base_object_methods \
_lis302dl_methods_alone

LIS302DL specific methods with inherited ones.

Definition at line 366 of file lis302dl.h.

◆ _lis302dl_data

#define _lis302dl_data
Value:
/* Driver state.*/ \
/* Current configuration data.*/ \
const LIS302DLConfig *config; \
/* Accelerometer subsystem axes number.*/ \
size_t accaxes; \
/* Current sensitivity.*/ \
float accsensitivity[LIS302DL_ACC_NUMBER_OF_AXES]; \
/* Bias data.*/ \
int32_t accbias[LIS302DL_ACC_NUMBER_OF_AXES]; \
/* Current full scale value.*/ \
float accfullscale;
lis302dl_state_t
Driver state machine possible states.
Definition lis302dl.h:300
#define LIS302DL_ACC_NUMBER_OF_AXES
LIS302DL accelerometer subsystem characteristics.
Definition lis302dl.h:72
LIS302DL configuration structure.
Definition lis302dl.h:309

LIS302DLDriver specific data.

Definition at line 382 of file lis302dl.h.

◆ lis302dlAccelerometerGetAxesNumber

#define lis302dlAccelerometerGetAxesNumber ( devp)
Value:
accelerometerGetAxesNumber(&((devp)->acc_if))
#define accelerometerGetAxesNumber(ip)
Accelerometer get axes number.

Return the number of axes of the BaseAccelerometer.

Parameters
[in]devppointer to LIS302DLDriver.
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 421 of file lis302dl.h.

◆ lis302dlAccelerometerReadRaw

#define lis302dlAccelerometerReadRaw ( devp,
axes )
Value:
accelerometerReadRaw(&((devp)->acc_if), axes)
#define accelerometerReadRaw(ip, dp)
Accelerometer read raw data.

Retrieves raw data from the BaseAccelerometer.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS302DLDriver.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 442 of file lis302dl.h.

◆ lis302dlAccelerometerReadCooked

#define lis302dlAccelerometerReadCooked ( devp,
axes )
Value:
accelerometerReadCooked(&((devp)->acc_if), axes)
#define accelerometerReadCooked(ip, dp)
Accelerometer read cooked data.

Retrieves cooked data from the BaseAccelerometer.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as milli-G.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS302DLDriver.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 464 of file lis302dl.h.

◆ lis302dlAccelerometerSetBias

#define lis302dlAccelerometerSetBias ( devp,
bp )
Value:
accelerometerSetBias(&((devp)->acc_if), bp)
#define accelerometerSetBias(ip, bp)
Updates accelerometer bias data from received buffer.

Set bias values for the BaseAccelerometer.

Note
Bias must be expressed as milli-G.
The bias buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS302DLDriver.
[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 481 of file lis302dl.h.

◆ lis302dlAccelerometerResetBias

#define lis302dlAccelerometerResetBias ( devp)
Value:
accelerometerResetBias(&((devp)->acc_if))
#define accelerometerResetBias(ip)
Reset accelerometer bias data restoring it to zero.

Reset bias values for the BaseAccelerometer.

Note
Default biases value are obtained from device datasheet when available otherwise they are considered zero.
Parameters
[in]devppointer to LIS302DLDriver.
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 496 of file lis302dl.h.

◆ lis302dlAccelerometerSetSensitivity

#define lis302dlAccelerometerSetSensitivity ( devp,
sp )
Value:
accelerometerSetSensitivity(&((devp)->acc_if), sp)
#define accelerometerSetSensitivity(ip, sp)
Updates accelerometer sensitivity data from received buffer.

Set sensitivity values for the BaseAccelerometer.

Note
Sensitivity must be expressed as milli-G/LSB.
The sensitivity buffer must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]devppointer to LIS302DLDriver.
[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 513 of file lis302dl.h.

◆ lis302dlAccelerometerResetSensitivity

#define lis302dlAccelerometerResetSensitivity ( devp)
Value:
accelerometerResetSensitivity(&((devp)->acc_if))
#define accelerometerResetSensitivity(ip)
Reset accelerometer sensitivity data restoring it to its typical value.

Reset sensitivity values for the BaseAccelerometer.

Note
Default sensitivities value are obtained from device datasheet.
Parameters
[in]devppointer to LIS302DLDriver.
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 528 of file lis302dl.h.

◆ lis302dlAccelerometerSetFullScale

#define lis302dlAccelerometerSetFullScale ( devp,
fs )
Value:
(devp)->vmt->acc_set_full_scale(devp, fs)

Changes the LIS302DLDriver accelerometer 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 LIS302DLDriver.
[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 546 of file lis302dl.h.

Typedef Documentation

◆ LIS302DLDriver

typedef struct LIS302DLDriver LIS302DLDriver

Structure representing a LIS302DL driver.

Definition at line 268 of file lis302dl.h.

Enumeration Type Documentation

◆ lis302dl_acc_fs_t

LIS302DL full scale.

Enumerator
LIS302DL_ACC_FS_2G 

Full scale �2g.

LIS302DL_ACC_FS_8G 

Full scale �8g.

Definition at line 273 of file lis302dl.h.

◆ lis302dl_acc_odr_t

LIS302DL output data rate and bandwidth.

Enumerator
LIS302DL_ACC_ODR_100HZ 

ODR 100 Hz.

LIS302DL_ACC_ODR_400HZ 

ODR 400 Hz.

Definition at line 281 of file lis302dl.h.

◆ lis302dl_acc_hp_t

LIS302DL high pass filtering.

Enumerator
LIS302DL_ACC_HP_DISABLED 

HP bypassed.

LIS302DL_ACC_HP_0 

HP cutoff 2Hz (ODR 100Hz) or 8Hz

LIS302DL_ACC_HP_1 

HP cutoff 1Hz or 4Hz

LIS302DL_ACC_HP_2 

HP cutoff 0.5Hz or 2Hz

LIS302DL_ACC_HP_3 

HP cutoff 0.25Hz or 1Hz

Definition at line 289 of file lis302dl.h.

◆ lis302dl_state_t

Driver state machine possible states.

Enumerator
LIS302DL_UNINIT 

Not initialized.

LIS302DL_STOP 

Stopped.

LIS302DL_READY 

Ready.

Definition at line 300 of file lis302dl.h.

Function Documentation

◆ lis302dlSPIReadRegister()

void lis302dlSPIReadRegister ( 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 adjacent registers to write
[in]bpointer to a buffer.

Definition at line 59 of file lis302dl.c.

References LIS302DL_MS, and LIS302DL_RW.

Referenced by acc_read_raw(), and acc_set_full_scale().

◆ lis302dlSPIWriteRegister()

void lis302dlSPIWriteRegister ( 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 lis302dl.c.

References LIS302DL_MS.

Referenced by acc_set_full_scale(), lis302dlStart(), and lis302dlStop().

◆ acc_get_axes_number()

size_t acc_get_axes_number ( void * ip)
static

Return the number of axes of the BaseAccelerometer.

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

Definition at line 96 of file lis302dl.c.

References LIS302DL_ACC_NUMBER_OF_AXES.

◆ acc_read_raw()

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

Retrieves raw data from the BaseAccelerometer.

Note
This data is retrieved from MEMS register without any algebraical manipulation.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer interface.
[out]axesa buffer which would be filled with raw data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.

Definition at line 118 of file lis302dl.c.

References LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_AD_OUT_X, LIS302DL_READY, and lis302dlSPIReadRegister().

Referenced by acc_read_cooked().

Here is the call graph for this function:

◆ acc_read_cooked()

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

Retrieves cooked data from the BaseAccelerometer.

Note
This data is manipulated according to the formula cooked = (raw * sensitivity) - bias.
Final data is expressed as milli-G.
The axes array must be at least the same size of the BaseAccelerometer axes number.
Parameters
[in]ippointer to BaseAccelerometer interface.
[out]axesa buffer which would be filled with cooked data.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETif one or more I2C errors occurred, the errors can be retrieved using i2cGetErrors().
MSG_TIMEOUTif a timeout occurred before operation end.

Definition at line 171 of file lis302dl.c.

References acc_read_raw(), LIS302DL_ACC_NUMBER_OF_AXES, and LIS302DL_READY.

Here is the call graph for this function:

◆ acc_set_bias()

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

Set bias values for the BaseAccelerometer.

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

Definition at line 204 of file lis302dl.c.

References LIS302DL_ACC_NUMBER_OF_AXES, and LIS302DL_READY.

◆ acc_reset_bias()

msg_t acc_reset_bias ( void * ip)
static

Reset bias values for the BaseAccelerometer.

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

Definition at line 233 of file lis302dl.c.

References LIS302DL_ACC_BIAS, LIS302DL_ACC_NUMBER_OF_AXES, and LIS302DL_READY.

◆ acc_set_sensivity()

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

Set sensitivity values for the BaseAccelerometer.

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

Definition at line 263 of file lis302dl.c.

References LIS302DL_ACC_NUMBER_OF_AXES, and LIS302DL_READY.

◆ acc_reset_sensivity()

msg_t acc_reset_sensivity ( void * ip)
static

Reset sensitivity values for the BaseAccelerometer.

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

Definition at line 292 of file lis302dl.c.

References LIS302DL_ACC_FS_2G, LIS302DL_ACC_FS_8G, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_ACC_SENS_2G, LIS302DL_ACC_SENS_8G, and LIS302DL_READY.

◆ acc_set_full_scale()

msg_t acc_set_full_scale ( LIS302DLDriver * devp,
lis302dl_acc_fs_t fs )
static

Changes the LIS302DLDriver accelerometer 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 LIS302DLDriver interface.
[in]fsnew fullscale value.
Returns
The operation status.
Return values
MSG_OKif the function succeeded.
MSG_RESETotherwise.

Definition at line 332 of file lis302dl.c.

References LIS302DL_ACC_2G, LIS302DL_ACC_8G, LIS302DL_ACC_FS_2G, LIS302DL_ACC_FS_8G, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_AD_CTRL_REG1, LIS302DL_CTRL_REG1_FS_MASK, LIS302DL_READY, lis302dlSPIReadRegister(), and lis302dlSPIWriteRegister().

Here is the call graph for this function:

◆ lis302dlObjectInit()

void lis302dlObjectInit ( LIS302DLDriver * devp)

Initializes an instance.

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

Definition at line 427 of file lis302dl.c.

References LIS302DLDriver::acc_if, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_STOP, BaseAccelerometer::vmt, LIS302DLDriver::vmt, vmt_accelerometer, and vmt_device.

◆ lis302dlStart()

void lis302dlStart ( LIS302DLDriver * devp,
const LIS302DLConfig * config )

Configures and activates LIS302DL Complex Driver peripheral.

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

Definition at line 446 of file lis302dl.c.

References LIS302DL_ACC_2G, LIS302DL_ACC_8G, LIS302DL_ACC_BIAS, LIS302DL_ACC_FS_2G, LIS302DL_ACC_FS_8G, LIS302DL_ACC_NUMBER_OF_AXES, LIS302DL_ACC_SENS_2G, LIS302DL_ACC_SENS_8G, LIS302DL_AD_CTRL_REG1, LIS302DL_CTRL_REG1_PD, LIS302DL_CTRL_REG1_XEN, LIS302DL_CTRL_REG1_YEN, LIS302DL_CTRL_REG1_ZEN, LIS302DL_READY, LIS302DL_STOP, lis302dlSPIWriteRegister(), and LIS302DLConfig::spip.

Here is the call graph for this function:

◆ lis302dlStop()

void lis302dlStop ( LIS302DLDriver * devp)

Deactivates the LIS302DL Complex Driver peripheral.

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

Definition at line 530 of file lis302dl.c.

References LIS302DL_AD_CTRL_REG1, LIS302DL_READY, LIS302DL_STOP, and lis302dlSPIWriteRegister().

Here is the call graph for this function:

Variable Documentation

◆ vmt_device

const struct LIS302DLVMT vmt_device
static
Initial value:
= {
(size_t)0,
}
static msg_t acc_set_full_scale(ADXL355Driver *devp, adxl355_acc_fs_t fs)
Changes the ADXL355Driver accelerometer fullscale value.
Definition adxl355.c:301

Definition at line 405 of file lis302dl.c.

◆ vmt_accelerometer

const struct BaseAccelerometerVMT vmt_accelerometer
static
Initial value:
= {
sizeof(struct LIS302DLVMT*),
}
static size_t acc_get_axes_number(void *ip)
Return the number of axes of the BaseAccelerometer.
Definition adxl317.c:115
static msg_t acc_reset_sensivity(void *ip)
Reset sensitivity values for the BaseAccelerometer.
Definition adxl317.c:310
static msg_t acc_set_bias(void *ip, float *bp)
Set bias values for the BaseAccelerometer.
Definition adxl317.c:222
static msg_t acc_reset_bias(void *ip)
Reset bias values for the BaseAccelerometer.
Definition adxl317.c:251
static msg_t acc_set_sensivity(void *ip, float *sp)
Set sensitivity values for the BaseAccelerometer.
Definition adxl317.c:281
static msg_t acc_read_cooked(void *ip, float axes[])
Retrieves cooked data from the BaseAccelerometer.
Definition adxl317.c:185
static msg_t acc_read_raw(void *ip, int32_t axes[])
Retrieves raw data from the BaseAccelerometer.
Definition adxl317.c:137
LIS302DL accelerometer virtual methods table.
Definition lis302dl.h:375

Definition at line 410 of file lis302dl.c.