Go to the documentation of this file.
46 #define EX_LIS302DL_VERSION "1.1.1"
51 #define EX_LIS302DL_MAJOR 1
56 #define EX_LIS302DL_MINOR 1
61 #define EX_LIS302DL_PATCH 1
72 #define LIS302DL_ACC_NUMBER_OF_AXES 3U
74 #define LIS302DL_ACC_2G 2.0f
75 #define LIS302DL_ACC_8G 8.0f
77 #define LIS302DL_ACC_SENS_2G 18.0f
78 #define LIS302DL_ACC_SENS_8G 72.0f
80 #define LIS302DL_ACC_BIAS 0.0f
87 #define LIS302DL_DI_MASK 0xFF
88 #define LIS302DL_DI(n) (1 << n)
89 #define LIS302DL_AD_MASK 0x3F
90 #define LIS302DL_AD(n) (1 << n)
91 #define LIS302DL_MS (1 << 6)
92 #define LIS302DL_RW (1 << 7)
99 #define LIS302DL_AD_WHO_AM_I 0x0F
100 #define LIS302DL_AD_CTRL_REG1 0x20
101 #define LIS302DL_AD_CTRL_REG2 0x21
102 #define LIS302DL_AD_CTRL_REG3 0x22
103 #define LIS302DL_AD_HP_FILER_RESET 0x23
104 #define LIS302DL_AD_STATUS_REG 0x27
105 #define LIS302DL_AD_OUT_X 0x29
106 #define LIS302DL_AD_OUT_Y 0x2B
107 #define LIS302DL_AD_OUT_Z 0x2D
108 #define LIS302DL_AD_FF_WU_CFG_1 0x30
109 #define LIS302DL_AD_FF_WU_SRC_1 0x31
110 #define LIS302DL_AD_FF_WU_THS_1 0x32
111 #define LIS302DL_AD_FF_WU_DURATION_1 0x33
112 #define LIS302DL_AD_FF_WU_CFG_2 0x34
113 #define LIS302DL_AD_FF_WU_SRC_2 0x35
114 #define LIS302DL_AD_FF_WU_THS_2 0x36
115 #define LIS302DL_AD_FF_WU_DURATION_2 0x37
116 #define LIS302DL_AD_CLICK_CFG 0x38
117 #define LIS302DL_AD_CLICK_SRC 0x39
118 #define LIS302DL_AD_CLICK_THSY_X 0x3B
119 #define LIS302DL_AD_CLICK_THSZ 0x3C
120 #define LIS302DL_AD_CLICK_TIME_LIMIT 0x3D
121 #define LIS302DL_AD_CLICK_LATENCY 0x3E
122 #define LIS302DL_AD_CLICK_WINDOW 0x3F
129 #define LIS302DL_CTRL_REG1_MASK 0xFF
130 #define LIS302DL_CTRL_REG1_XEN (1 << 0)
131 #define LIS302DL_CTRL_REG1_YEN (1 << 1)
132 #define LIS302DL_CTRL_REG1_ZEN (1 << 2)
133 #define LIS302DL_CTRL_REG1_STM (1 << 3)
134 #define LIS302DL_CTRL_REG1_STP (1 << 4)
135 #define LIS302DL_CTRL_REG1_FS_MASK 0x20
136 #define LIS302DL_CTRL_REG1_FS (1 << 5)
137 #define LIS302DL_CTRL_REG1_PD (1 << 6)
138 #define LIS302DL_CTRL_REG1_DR (1 << 7)
145 #define LIS302DL_CTRL_REG2_MASK 0xDF
146 #define LIS302DL_CTRL_REG2_HPCF1 (1 << 0)
147 #define LIS302DL_CTRL_REG2_HPCF2 (1 << 1)
148 #define LIS302DL_CTRL_REG2_HPFFWU1 (1 << 2)
149 #define LIS302DL_CTRL_REG2_HPFFWU2 (1 << 3)
150 #define LIS302DL_CTRL_REG2_FDS (1 << 4)
151 #define LIS302DL_CTRL_REG2_BOOT (1 << 6)
152 #define LIS302DL_CTRL_REG2_SIM (1 << 7)
159 #define LIS302DL_CTRL_REG3_MASK 0xFF
160 #define LIS302DL_CTRL_REG3_I1CFG0 (1 << 0)
161 #define LIS302DL_CTRL_REG3_I1CFG1 (1 << 1)
162 #define LIS302DL_CTRL_REG3_I1CFG2 (1 << 2)
163 #define LIS302DL_CTRL_REG3_I2CFG0 (1 << 3)
164 #define LIS302DL_CTRL_REG3_I2CFG1 (1 << 4)
165 #define LIS302DL_CTRL_REG3_I2CFG2 (1 << 5)
166 #define LIS302DL_CTRL_REG3_PP_OD (1 << 6)
167 #define LIS302DL_CTRL_REG3_IHL (1 << 7)
183 #if !defined(LIS302DL_USE_SPI) || defined(__DOXYGEN__)
184 #define LIS302DL_USE_SPI TRUE
193 #if !defined(LIS302DL_SHARED_SPI) || defined(__DOXYGEN__)
194 #define LIS302DL_SHARED_SPI FALSE
202 #if !defined(LIS302DL_USE_I2C) || defined(__DOXYGEN__)
203 #define LIS302DL_USE_I2C FALSE
212 #if !defined(LIS302DL_SHARED_I2C) || defined(__DOXYGEN__)
213 #define LIS302DL_SHARED_I2C FALSE
221 #if !defined(LIS302DL_USE_ADVANCED) || defined(__DOXYGEN__)
222 #define LIS302DL_USE_ADVANCED FALSE
230 #if !(LIS302DL_USE_SPI ^ LIS302DL_USE_I2C)
231 #error "LIS302DL_USE_SPI and LIS302DL_USE_I2C cannot be both true or both false"
234 #if LIS302DL_USE_SPI && !HAL_USE_SPI
235 #error "LIS302DL_USE_SPI requires HAL_USE_SPI"
238 #if LIS302DL_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
239 #error "LIS302DL_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
242 #if LIS302DL_USE_I2C && !HAL_USE_I2C
243 #error "LIS302DL_USE_I2C requires HAL_USE_I2C"
246 #if LIS302DL_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
247 #error "LIS302DL_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
254 #error "LIS302DL over I2C still not supported"
311 #if (LIS302DL_USE_SPI) || defined(__DOXYGEN__)
321 #if (LIS302DL_USE_I2C) || defined(__DOXYGEN__)
347 #if LIS302DL_USE_ADVANCED || defined(__DOXYGEN__)
358 #define _lis302dl_methods_alone \
360 msg_t (*set_full_scale)(LIS302DLDriver *devp, lis302dl_acc_fs_t fs);
366 #define _lis302dl_methods \
367 _base_object_methods \
368 _lis302dl_methods_alone
382 #define _lis302dl_data \
384 lis302dl_state_t state; \
386 const LIS302DLConfig *config; \
390 float accsensitivity[LIS302DL_ACC_NUMBER_OF_AXES]; \
392 int32_t accbias[LIS302DL_ACC_NUMBER_OF_AXES]; \
421 #define lis302dlAccelerometerGetAxesNumber(devp) \
422 accelerometerGetAxesNumber(&((devp)->acc_if))
442 #define lis302dlAccelerometerReadRaw(devp, axes) \
443 accelerometerReadRaw(&((devp)->acc_if), axes)
464 #define lis302dlAccelerometerReadCooked(devp, axes) \
465 accelerometerReadCooked(&((devp)->acc_if), axes)
481 #define lis302dlAccelerometerSetBias(devp, bp) \
482 accelerometerSetBias(&((devp)->acc_if), bp)
496 #define lis302dlAccelerometerResetBias(devp) \
497 accelerometerResetBias(&((devp)->acc_if))
513 #define lis302dlAccelerometerSetSensitivity(devp, sp) \
514 accelerometerSetSensitivity(&((devp)->acc_if), sp)
528 #define lis302dlAccelerometerResetSensitivity(devp) \
529 accelerometerResetSensitivity(&((devp)->acc_if))
546 #define lis302dlAccelerometerSetFullScale(devp, fs) \
547 (devp)->vmt->acc_set_full_scale(devp, fs)
float * accbias
LIS302DL accelerometer subsystem initial bias.
Structure representing an I2C driver.
#define _lis302dl_data
LIS302DLDriver specific data.
lis302dl_acc_fs_t accfullscale
LIS302DL accelerometer subsystem initial full scale.
lis302dl_acc_odr_t
LIS302DL output data rate and bandwidth.
Driver configuration structure.
Structure representing an SPI driver.
@ LIS302DL_ACC_HP_DISABLED
Base accelerometer class.
Generic accelerometer interface header.
void lis302dlStart(LIS302DLDriver *devp, const LIS302DLConfig *config)
Configures and activates LIS302DL Complex Driver peripheral.
lis302dl_acc_fs_t
LIS302DL full scale.
SPIDriver * spip
SPI driver associated to this LIS302DL.
float * accsensitivity
LIS302DL accelerometer subsystem initial sensitivity.
lis302dl_acc_odr_t accoutputdatarate
LIS302DL output data rate selection.
LIS302DL 3-axis accelerometer class.
lis302dl_state_t
Driver state machine possible states.
LIS302DL configuration structure.
const struct LIS302DLVMT * vmt
Virtual Methods Table.
LIS302DL accelerometer virtual methods table.
void lis302dlObjectInit(LIS302DLDriver *devp)
Initializes an instance.
const SPIConfig * spicfg
SPI configuration associated to this LIS302DL.
const I2CConfig * i2ccfg
I2C configuration associated to this LIS302DL.
I2CDriver * i2cp
I2C driver associated to this LIS302DL.
lis302dl_acc_hp_t
LIS302DL high pass filtering.
BaseAccelerometer acc_if
Base accelerometer interface.
#define _lis302dl_methods
LIS302DL specific methods with inherited ones.
lis302dl_acc_hp_t acchighpass
LIS302DL high pass filtering.
Type of I2C driver configuration structure.
void lis302dlStop(LIS302DLDriver *devp)
Deactivates the LIS302DL Complex Driver peripheral.