Go to the documentation of this file.
46 #define EX_LIS3DSH_VERSION "1.1.2"
51 #define EX_LIS3DSH_MAJOR 1
56 #define EX_LIS3DSH_MINOR 1
61 #define EX_LIS3DSH_PATCH 2
72 #define LIS3DSH_ACC_NUMBER_OF_AXES 3U
74 #define LIS3DSH_ACC_2G 2.0f
75 #define LIS3DSH_ACC_4G 4.0f
76 #define LIS3DSH_ACC_6G 6.0f
77 #define LIS3DSH_ACC_8G 8.0f
78 #define LIS3DSH_ACC_16G 16.0f
80 #define LIS3DSH_ACC_SENS_2G 0.06f
81 #define LIS3DSH_ACC_SENS_4G 0.12f
82 #define LIS3DSH_ACC_SENS_6G 0.18f
83 #define LIS3DSH_ACC_SENS_8G 0.24f
84 #define LIS3DSH_ACC_SENS_16G 0.73f
86 #define LIS3DSH_ACC_BIAS 0.0f
93 #define LIS3DSH_DI_MASK 0xFF
94 #define LIS3DSH_DI(n) (1 << n)
95 #define LIS3DSH_AD_MASK 0x3F
96 #define LIS3DSH_AD(n) (1 << n)
97 #define LIS3DSH_MS (1 << 6)
98 #define LIS3DSH_RW (1 << 7)
105 #define LIS3DSH_AD_OUT_T 0x0C
106 #define LIS3DSH_AD_INFO1 0x0D
107 #define LIS3DSH_AD_INFO2 0x0E
108 #define LIS3DSH_AD_WHO_AM_I 0x0F
109 #define LIS3DSH_AD_OFF_X 0x10
110 #define LIS3DSH_AD_OFF_Y 0x11
111 #define LIS3DSH_AD_OFF_Z 0x12
112 #define LIS3DSH_AD_CS_X 0x13
113 #define LIS3DSH_AD_CS_Y 0x14
114 #define LIS3DSH_AD_CS_Z 0x15
115 #define LIS3DSH_AD_LC_L 0x16
116 #define LIS3DSH_AD_LC_H 0x17
117 #define LIS3DSH_AD_STAT 0x18
118 #define LIS3DSH_AD_PEAK1 0x19
119 #define LIS3DSH_AD_PEAK2 0x1A
120 #define LIS3DSH_AD_VFC_1 0x1B
121 #define LIS3DSH_AD_VFC_2 0x1C
122 #define LIS3DSH_AD_VFC_3 0x1D
123 #define LIS3DSH_AD_VFC_4 0x1E
124 #define LIS3DSH_AD_THRS3 0x1F
125 #define LIS3DSH_AD_CTRL_REG4 0x20
126 #define LIS3DSH_AD_CTRL_REG1 0x21
127 #define LIS3DSH_AD_CTRL_REG2 0x22
128 #define LIS3DSH_AD_CTRL_REG3 0x23
129 #define LIS3DSH_AD_CTRL_REG5 0x24
130 #define LIS3DSH_AD_CTRL_REG6 0x25
131 #define LIS3DSH_AD_STATUS 0x27
132 #define LIS3DSH_AD_OUT_X_L 0x28
133 #define LIS3DSH_AD_OUT_X_H 0x29
134 #define LIS3DSH_AD_OUT_Y_L 0x2A
135 #define LIS3DSH_AD_OUT_Y_H 0x2B
136 #define LIS3DSH_AD_OUT_Z_L 0x2C
137 #define LIS3DSH_AD_OUT_Z_H 0x2D
138 #define LIS3DSH_AD_FIFO_CTRL 0x2E
139 #define LIS3DSH_AD_FIFO_SRC 0x2F
140 #define LIS3DSH_AD_ST1_0 0x40
141 #define LIS3DSH_AD_ST1_1 0x41
142 #define LIS3DSH_AD_ST1_2 0x42
143 #define LIS3DSH_AD_ST1_3 0x43
144 #define LIS3DSH_AD_ST1_4 0x44
145 #define LIS3DSH_AD_ST1_5 0x45
146 #define LIS3DSH_AD_ST1_6 0x46
147 #define LIS3DSH_AD_ST1_7 0x47
148 #define LIS3DSH_AD_ST1_8 0x48
149 #define LIS3DSH_AD_ST1_9 0x49
150 #define LIS3DSH_AD_ST1_A 0x4A
151 #define LIS3DSH_AD_ST1_B 0x4B
152 #define LIS3DSH_AD_ST1_C 0x4C
153 #define LIS3DSH_AD_ST1_D 0x4D
154 #define LIS3DSH_AD_ST1_E 0x4E
155 #define LIS3DSH_AD_ST1_F 0x4F
156 #define LIS3DSH_AD_TIM4_1 0x50
157 #define LIS3DSH_AD_TIM3_1 0x51
158 #define LIS3DSH_AD_TIM2_1_L 0x52
159 #define LIS3DSH_AD_TIM2_1_H 0x53
160 #define LIS3DSH_AD_TIM1_1_L 0x54
161 #define LIS3DSH_AD_TIM1_1_H 0x55
162 #define LIS3DSH_AD_THRS2_1 0x56
163 #define LIS3DSH_AD_THRS1_1 0x57
164 #define LIS3DSH_AD_MASK1_B 0x59
165 #define LIS3DSH_AD_MASK1_A 0x5A
166 #define LIS3DSH_AD_SETT1 0x5B
167 #define LIS3DSH_AD_PR1 0x5C
168 #define LIS3DSH_AD_TC1_L 0x5D
169 #define LIS3DSH_AD_TC1_H 0x5E
170 #define LIS3DSH_AD_OUTS1 0x5F
171 #define LIS3DSH_AD_ST2_0 0x60
172 #define LIS3DSH_AD_ST2_1 0x61
173 #define LIS3DSH_AD_ST2_2 0x62
174 #define LIS3DSH_AD_ST2_3 0x63
175 #define LIS3DSH_AD_ST2_4 0x64
176 #define LIS3DSH_AD_ST2_5 0x65
177 #define LIS3DSH_AD_ST2_6 0x66
178 #define LIS3DSH_AD_ST2_7 0x67
179 #define LIS3DSH_AD_ST2_8 0x68
180 #define LIS3DSH_AD_ST2_9 0x69
181 #define LIS3DSH_AD_ST2_A 0x6A
182 #define LIS3DSH_AD_ST2_B 0x6B
183 #define LIS3DSH_AD_ST2_C 0x6C
184 #define LIS3DSH_AD_ST2_D 0x6D
185 #define LIS3DSH_AD_ST2_E 0x6E
186 #define LIS3DSH_AD_ST2_F 0x6F
187 #define LIS3DSH_AD_TIM4_2 0x70
188 #define LIS3DSH_AD_TIM3_2 0x71
189 #define LIS3DSH_AD_TIM2_2_L 0x72
190 #define LIS3DSH_AD_TIM2_2_H 0x73
191 #define LIS3DSH_AD_TIM1_2_L 0x74
192 #define LIS3DSH_AD_TIM1_2_H 0x75
193 #define LIS3DSH_AD_THRS2_2 0x76
194 #define LIS3DSH_AD_THRS1_2 0x77
195 #define LIS3DSH_AD_DES2 0x78
196 #define LIS3DSH_AD_MASK2_B 0x79
197 #define LIS3DSH_AD_MASK2_A 0x7A
198 #define LIS3DSH_AD_SETT2 0x7B
199 #define LIS3DSH_AD_PR2 0x7C
200 #define LIS3DSH_AD_TC2_L 0x7D
201 #define LIS3DSH_AD_TC2_H 0x7E
202 #define LIS3DSH_AD_OUTS2 0x7F
209 #define LIS3DSH_CTRL_REG1_MASK 0xE9
210 #define LIS3DSH_CTRL_REG1_SM1_EN (1 << 0)
211 #define LIS3DSH_CTRL_REG1_SM1_PIN (1 << 3)
212 #define LIS3DSH_CTRL_REG1_HYST0_1 (1 << 5)
213 #define LIS3DSH_CTRL_REG1_HYST1_1 (1 << 6)
214 #define LIS3DSH_CTRL_REG1_HYST2_1 (1 << 7)
221 #define LIS3DSH_CTRL_REG2_MASK 0xE9
222 #define LIS3DSH_CTRL_REG2_SM2_EN (1 << 0)
223 #define LIS3DSH_CTRL_REG2_SM2_PIN (1 << 3)
224 #define LIS3DSH_CTRL_REG2_HYST0_2 (1 << 5)
225 #define LIS3DSH_CTRL_REG2_HYST1_2 (1 << 6)
226 #define LIS3DSH_CTRL_REG2_HYST2_2 (1 << 7)
233 #define LIS3DSH_CTRL_REG3_MASK 0xFF
234 #define LIS3DSH_CTRL_REG3_STRT (1 << 0)
235 #define LIS3DSH_CTRL_REG3_VFILT (1 << 2)
236 #define LIS3DSH_CTRL_REG3_INT1_EN (1 << 3)
237 #define LIS3DSH_CTRL_REG3_INT2_EN (1 << 4)
238 #define LIS3DSH_CTRL_REG3_IEL (1 << 5)
239 #define LIS3DSH_CTRL_REG3_IEA (1 << 6)
240 #define LIS3DSH_CTRL_REG3_DR_EN (1 << 7)
247 #define LIS3DSH_CTRL_REG4_MASK 0xFF
248 #define LIS3DSH_CTRL_REG4_XEN (1 << 0)
249 #define LIS3DSH_CTRL_REG4_YEN (1 << 1)
250 #define LIS3DSH_CTRL_REG4_ZEN (1 << 2)
251 #define LIS3DSH_CTRL_REG4_BDU (1 << 3)
252 #define LIS3DSH_CTRL_REG4_ODR_0 (1 << 4)
253 #define LIS3DSH_CTRL_REG4_ODR_1 (1 << 5)
254 #define LIS3DSH_CTRL_REG4_ODR_2 (1 << 6)
255 #define LIS3DSH_CTRL_REG4_ODR_3 (1 << 7)
262 #define LIS3DSH_CTRL_REG5_MASK 0xFF
263 #define LIS3DSH_CTRL_REG5_SIM (1 << 0)
264 #define LIS3DSH_CTRL_REG5_ST1 (1 << 1)
265 #define LIS3DSH_CTRL_REG5_ST2 (1 << 2)
266 #define LIS3DSH_CTRL_REG5_FS_MASK 0x38
267 #define LIS3DSH_CTRL_REG5_FS0 (1 << 3)
268 #define LIS3DSH_CTRL_REG5_FS1 (1 << 4)
269 #define LIS3DSH_CTRL_REG5_FS2 (1 << 5)
270 #define LIS3DSH_CTRL_REG5_BW1 (1 << 6)
271 #define LIS3DSH_CTRL_REG5_BW2 (1 << 7)
278 #define LIS3DSH_CTRL_REG6_MASK 0xFF
279 #define LIS3DSH_CTRL_REG6_P2_BOOT (1 << 0)
280 #define LIS3DSH_CTRL_REG6_P1_OVRUN (1 << 1)
281 #define LIS3DSH_CTRL_REG6_P1_WTM (1 << 2)
282 #define LIS3DSH_CTRL_REG6_P1_EMPTY (1 << 3)
283 #define LIS3DSH_CTRL_REG6_ADD_INC (1 << 4)
284 #define LIS3DSH_CTRL_REG6_WTM_EN (1 << 5)
285 #define LIS3DSH_CTRL_REG6_FIFO_EN (1 << 6)
286 #define LIS3DSH_CTRL_REG6_BOOT (1 << 7)
302 #if !defined(LIS3DSH_USE_SPI) || defined(__DOXYGEN__)
303 #define LIS3DSH_USE_SPI TRUE
312 #if !defined(LIS3DSH_SHARED_SPI) || defined(__DOXYGEN__)
313 #define LIS3DSH_SHARED_SPI FALSE
321 #if !defined(LIS3DSH_USE_I2C) || defined(__DOXYGEN__)
322 #define LIS3DSH_USE_I2C FALSE
331 #if !defined(LIS3DSH_SHARED_I2C) || defined(__DOXYGEN__)
332 #define LIS3DSH_SHARED_I2C FALSE
340 #if !defined(LIS3DSH_USE_ADVANCED) || defined(__DOXYGEN__)
341 #define LIS3DSH_USE_ADVANCED FALSE
349 #if !(LIS3DSH_USE_SPI ^ LIS3DSH_USE_I2C)
350 #error "LIS3DSH_USE_SPI and LIS3DSH_USE_I2C cannot be both true or both false"
353 #if LIS3DSH_USE_SPI && !HAL_USE_SPI
354 #error "LIS3DSH_USE_SPI requires HAL_USE_SPI"
357 #if LIS3DSH_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
358 #error "LIS3DSH_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
361 #if LIS3DSH_USE_I2C && !HAL_USE_I2C
362 #error "LIS3DSH_USE_I2C requires HAL_USE_I2C"
365 #if LIS3DSH_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
366 #error "LIS3DSH_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
373 #error "LIS3DSH over I2C still not supported"
448 #if (LIS3DSH_USE_SPI) || defined(__DOXYGEN__)
458 #if (LIS3DSH_USE_I2C) || defined(__DOXYGEN__)
484 #if LIS3DSH_USE_ADVANCED || defined(__DOXYGEN__)
499 #define _lis3dsh_methods_alone \
501 msg_t (*acc_set_full_scale)(LIS3DSHDriver *devp, lis3dsh_acc_fs_t fs);
507 #define _lis3dsh_methods \
508 _base_object_methods \
509 _lis3dsh_methods_alone
523 #define _lis3dsh_data \
526 lis3dsh_state_t state; \
528 const LIS3DSHConfig *config; \
532 float accsensitivity[LIS3DSH_ACC_NUMBER_OF_AXES]; \
534 float accbias[LIS3DSH_ACC_NUMBER_OF_AXES]; \
563 #define lis3dshAccelerometerGetAxesNumber(devp) \
564 accelerometerGetAxesNumber(&((devp)->acc_if))
584 #define lis3dshAccelerometerReadRaw(devp, axes) \
585 accelerometerReadRaw(&((devp)->acc_if), axes)
606 #define lis3dshAccelerometerReadCooked(devp, axes) \
607 accelerometerReadCooked(&((devp)->acc_if), axes)
623 #define lis3dshAccelerometerSetBias(devp, bp) \
624 accelerometerSetBias(&((devp)->acc_if), bp)
638 #define lis3dshAccelerometerResetBias(devp) \
639 accelerometerResetBias(&((devp)->acc_if))
655 #define lis3dshAccelerometerSetSensitivity(devp, sp) \
656 accelerometerSetSensitivity(&((devp)->acc_if), sp)
670 #define lis3dshAccelerometerResetSensitivity(devp) \
671 accelerometerResetSensitivity(&((devp)->acc_if))
688 #define lis3dshAccelerometerSetFullScale(devp, fs) \
689 (devp)->vmt->acc_set_full_scale(devp, fs)
Structure representing an I2C driver.
@ LIS3DSH_ACC_BDU_BLOCKED
float * accbias
LIS3DSH accelerometer subsystem initial bias.
LIS3DSH configuration structure.
float * accsensitivity
LIS3DSH accelerometer subsystem initial sensitivity.
void lis3dshStart(LIS3DSHDriver *devp, const LIS3DSHConfig *config)
Configures and activates LIS3DSH Complex Driver peripheral.
Driver configuration structure.
Structure representing an SPI driver.
I2CDriver * i2cp
I2C driver associated to this LIS3DSH.
void lis3dshObjectInit(LIS3DSHDriver *devp)
Initializes an instance.
lis3dsh_acc_fs_t accfullscale
LIS3DSH accelerometer subsystem initial full scale.
LIS3DSH 3-axis accelerometer class.
Base accelerometer class.
Generic accelerometer interface header.
lis3dsh_acc_bdu_t accblockdataupdate
LIS3DSH block data update.
lis3dsh_acc_bw_t
LIS3DSH anti-aliasing bandwidth.
void lis3dshStop(LIS3DSHDriver *devp)
Deactivates the LIS3DSH Complex Driver peripheral.
lis3dsh_acc_odr_t accoutputdatarate
LIS3DSH output data rate selection.
LIS3DSH virtual methods table.
lis3dsh_acc_bw_t accantialiasing
LIS3DSH anti-aliasing bandwidth.
#define _lis3dsh_methods
LIS3DSH specific methods with inherited ones.
BaseAccelerometer acc_if
Base accelerometer interface.
SPIDriver * spip
SPI driver associated to this LIS3DSH.
const I2CConfig * i2ccfg
I2C configuration associated to this LIS3DSH.
lis3dsh_acc_odr_t
LIS3DSH output data rate.
lis3dsh_acc_fs_t
LIS3DSH full scale.
@ LIS3DSH_ACC_BDU_CONTINUOUS
#define _lis3dsh_data
LIS3DSHDriver specific data.
const SPIConfig * spicfg
SPI configuration associated to this LIS3DSH.
@ LIS3DSH_ACC_ODR_3_125HZ
lis3dsh_acc_bdu_t
LIS3DSH block data update.
lis3dsh_state_t
Driver state machine possible states.
Type of I2C driver configuration structure.
const struct LIS3DSHVMT * vmt
Virtual Methods Table.