1 /*
2 * Copyright (c) 2023 Wuerth Elektronik eiSos GmbH & Co. KG
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /**
8 * @file
9 * @brief Driver file for the WSEN-ISDS-2536030320001 sensor.
10 */
11
12 #include "WSEN_ISDS_2536030320001_hal.h"
13
14 #include <stdio.h>
15
16 #include <weplatform.h>
17
18 /**
19 * @brief Default sensor interface configuration.
20 */
21 static WE_sensorInterface_t isdsDefaultSensorInterface = {
22 .sensorType = WE_ISDS,
23 .interfaceType = WE_i2c,
24 .options = {.i2c = {.address = ISDS_ADDRESS_I2C_0, .burstMode = 0, .protocol = WE_i2cProtocol_RegisterBased, .useRegAddrMsbForMultiBytesRead = 0, .reserved = 0},
25 .spi = {.chipSelectPort = 0, .chipSelectPin = 0, .burstMode = 0, .reserved = 0},
26 .readTimeout = 1000,
27 .writeTimeout = 1000},
28 .handle = 0};
29
30
31 /**
32 * @brief Stores the current value of the accelerometer full scale parameter.
33
34 * The value is updated when calling ISDS_setAccFullScale() or
35 * ISDS_getAccFullScale().
36 *
37 */
38 static ISDS_accFullScale_t currentAccFullScale = ISDS_accFullScaleTwoG;
39
40 /**
41 * @brief Stores the current value of the gyroscope full scale parameter.
42
43 * The value is updated when calling ISDS_setGyroFullScale() or
44 * ISDS_getGyroFullScale().
45 *
46 */
47 static ISDS_gyroFullScale_t currentGyroFullScale = ISDS_gyroFullScale250dps;
48
49
50 /**
51 * @brief Read data from sensor.
52 *
53 * @param[in] sensorInterface Pointer to sensor interface
54 * @param[in] regAdr Address of register to read from
55 * @param[in] numBytesToRead Number of bytes to be read
56 * @param[out] data Target buffer
57 * @return Error Code
58 */
ISDS_ReadReg(WE_sensorInterface_t * sensorInterface,uint8_t regAdr,uint16_t numBytesToRead,uint8_t * data)59 static inline int8_t ISDS_ReadReg(WE_sensorInterface_t* sensorInterface,
60 uint8_t regAdr,
61 uint16_t numBytesToRead,
62 uint8_t *data)
63 {
64 return WE_ReadReg(sensorInterface, regAdr, numBytesToRead, data);
65 }
66
67 /**
68 * @brief Write data to sensor.
69 *
70 * @param[in] sensorInterface Pointer to sensor interface
71 * @param[in] regAdr Address of register to write to
72 * @param[in] numBytesToWrite Number of bytes to be written
73 * @param[in] data Source buffer
74 * @return Error Code
75 */
ISDS_WriteReg(WE_sensorInterface_t * sensorInterface,uint8_t regAdr,uint16_t numBytesToWrite,uint8_t * data)76 static inline int8_t ISDS_WriteReg(WE_sensorInterface_t* sensorInterface,
77 uint8_t regAdr,
78 uint16_t numBytesToWrite,
79 uint8_t *data)
80 {
81 return WE_WriteReg(sensorInterface, regAdr, numBytesToWrite, data);
82 }
83
84 /**
85 * @brief Returns the default sensor interface configuration.
86 * @param[out] sensorInterface Sensor interface configuration (output parameter)
87 * @return Error code
88 */
ISDS_getDefaultInterface(WE_sensorInterface_t * sensorInterface)89 int8_t ISDS_getDefaultInterface(WE_sensorInterface_t* sensorInterface)
90 {
91 *sensorInterface = isdsDefaultSensorInterface;
92 return WE_SUCCESS;
93 }
94
95 /**
96 * @brief Read the device ID
97 *
98 * Expected value is ISDS_DEVICE_ID_VALUE.
99 *
100 * @param[in] sensorInterface Pointer to sensor interface
101 * @param[out] deviceID The returned device ID.
102 * @retval Error code
103 */
ISDS_getDeviceID(WE_sensorInterface_t * sensorInterface,uint8_t * deviceID)104 int8_t ISDS_getDeviceID(WE_sensorInterface_t* sensorInterface, uint8_t *deviceID)
105 {
106 return ISDS_ReadReg(sensorInterface, ISDS_DEVICE_ID_REG, 1, deviceID);
107 }
108
109
110 /* ISDS_FIFO_CTRL_1_REG */
111 /* ISDS_FIFO_CTRL_2_REG */
112
113 /**
114 * @brief Set the FIFO threshold of the sensor
115 * @param[in] sensorInterface Pointer to sensor interface
116 * @param[in] threshold FIFO threshold (value between 0 and 127)
117 * @retval Error code
118 */
ISDS_setFifoThreshold(WE_sensorInterface_t * sensorInterface,uint16_t threshold)119 int8_t ISDS_setFifoThreshold(WE_sensorInterface_t* sensorInterface, uint16_t threshold)
120 {
121 ISDS_fifoCtrl1_t fifoCtrl1;
122 ISDS_fifoCtrl2_t fifoCtrl2;
123
124 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_2_REG, 1, (uint8_t *) &fifoCtrl2))
125 {
126 return WE_FAIL;
127 }
128
129 fifoCtrl1.fifoThresholdLsb = (uint8_t) (threshold & 0xFF);
130 fifoCtrl2.fifoThresholdMsb = (uint8_t) ((threshold >> 8) & 0x07);
131
132 if (WE_FAIL == ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_1_REG, 1, (uint8_t *) &fifoCtrl1))
133 {
134 return WE_FAIL;
135 }
136 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_2_REG, 1, (uint8_t *) &fifoCtrl2);
137 }
138
139 /**
140 * @brief Read the FIFO threshold of the sensor
141 * @param[in] sensorInterface Pointer to sensor interface
142 * @param[out] threshold The returned FIFO threshold
143 * @retval Error code
144 */
ISDS_getFifoThreshold(WE_sensorInterface_t * sensorInterface,uint16_t * threshold)145 int8_t ISDS_getFifoThreshold(WE_sensorInterface_t* sensorInterface, uint16_t *threshold)
146 {
147 ISDS_fifoCtrl1_t fifoCtrl1;
148 ISDS_fifoCtrl2_t fifoCtrl2;
149
150 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_1_REG, 1, (uint8_t *) &fifoCtrl1))
151 {
152 return WE_FAIL;
153 }
154 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_2_REG, 1, (uint8_t *) &fifoCtrl2))
155 {
156 return WE_FAIL;
157 }
158
159 *threshold = ((uint16_t) fifoCtrl1.fifoThresholdLsb) |
160 (((uint16_t) (fifoCtrl2.fifoThresholdMsb & 0x07)) << 8);
161
162 return WE_SUCCESS;
163 }
164
165 /**
166 * @brief Enable storage of temperature data in FIFO.
167 * @param[in] sensorInterface Pointer to sensor interface
168 * @param[in] fifoTemp The storage of temperature data in FIFO enable state
169 * @retval Error code
170 */
ISDS_enableFifoTemperature(WE_sensorInterface_t * sensorInterface,ISDS_state_t fifoTemp)171 int8_t ISDS_enableFifoTemperature(WE_sensorInterface_t* sensorInterface, ISDS_state_t fifoTemp)
172 {
173 ISDS_fifoCtrl2_t fifoCtrl2;
174
175 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_2_REG, 1, (uint8_t *) &fifoCtrl2))
176 {
177 return WE_FAIL;
178 }
179
180 fifoCtrl2.enFifoTemperature = fifoTemp;
181
182 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_2_REG, 1, (uint8_t *) &fifoCtrl2);
183 }
184
185 /**
186 * @brief Check if storage of temperature data in FIFO is enabled.
187 * @param[in] sensorInterface Pointer to sensor interface
188 * @param[out] fifoTemp The returned storage of temperature data in FIFO enable state
189 * @retval Error code
190 */
ISDS_isFifoTemperatureEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * fifoTemp)191 int8_t ISDS_isFifoTemperatureEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *fifoTemp)
192 {
193 ISDS_fifoCtrl2_t fifoCtrl2;
194
195 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_2_REG, 1, (uint8_t *) &fifoCtrl2))
196 {
197 return WE_FAIL;
198 }
199
200 *fifoTemp = (ISDS_state_t) fifoCtrl2.enFifoTemperature;
201
202 return WE_SUCCESS;
203 }
204
205 /* ISDS_FIFO_CTRL_3_REG */
206
207 /**
208 * @brief Set decimation of acceleration data in FIFO (second data set in FIFO)
209 * @param[in] sensorInterface Pointer to sensor interface
210 * @param[in] decimation FIFO acceleration data decimation setting
211 * @retval Error code
212 */
ISDS_setFifoAccDecimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t decimation)213 int8_t ISDS_setFifoAccDecimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t decimation)
214 {
215 ISDS_fifoCtrl3_t fifoCtrl3;
216
217 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_3_REG, 1, (uint8_t *) &fifoCtrl3))
218 {
219 return WE_FAIL;
220 }
221
222 fifoCtrl3.fifoAccDecimation = (uint8_t) decimation;
223
224 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_3_REG, 1, (uint8_t *) &fifoCtrl3);
225 }
226
227 /**
228 * @brief Read decimation of acceleration data in FIFO (second data set in FIFO) setting
229 * @param[in] sensorInterface Pointer to sensor interface
230 * @param[out] decimation The returned FIFO acceleration data decimation setting
231 * @retval Error code
232 */
ISDS_getFifoAccDecimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t * decimation)233 int8_t ISDS_getFifoAccDecimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t *decimation)
234 {
235 ISDS_fifoCtrl3_t fifoCtrl3;
236
237 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_3_REG, 1, (uint8_t *) &fifoCtrl3))
238 {
239 return WE_FAIL;
240 }
241
242 *decimation = (ISDS_fifoDecimation_t) fifoCtrl3.fifoAccDecimation;
243
244 return WE_SUCCESS;
245 }
246
247 /**
248 * @brief Set decimation of gyroscope data in FIFO (first data set in FIFO)
249 * @param[in] sensorInterface Pointer to sensor interface
250 * @param[in] decimation FIFO gyroscope data decimation setting
251 * @retval Error code
252 */
ISDS_setFifoGyroDecimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t decimation)253 int8_t ISDS_setFifoGyroDecimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t decimation)
254 {
255 ISDS_fifoCtrl3_t fifoCtrl3;
256
257 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_3_REG, 1, (uint8_t *) &fifoCtrl3))
258 {
259 return WE_FAIL;
260 }
261
262 fifoCtrl3.fifoGyroDecimation = (uint8_t) decimation;
263
264 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_3_REG, 1, (uint8_t *) &fifoCtrl3);
265 }
266
267 /**
268 * @brief Read decimation of gyroscope data in FIFO (first data set in FIFO) setting
269 * @param[in] sensorInterface Pointer to sensor interface
270 * @param[out] decimation The returned FIFO gyroscope data decimation setting
271 * @retval Error code
272 */
ISDS_getFifoGyroDecimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t * decimation)273 int8_t ISDS_getFifoGyroDecimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t *decimation)
274 {
275 ISDS_fifoCtrl3_t fifoCtrl3;
276
277 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_3_REG, 1, (uint8_t *) &fifoCtrl3))
278 {
279 return WE_FAIL;
280 }
281
282 *decimation = (ISDS_fifoDecimation_t) fifoCtrl3.fifoGyroDecimation;
283
284 return WE_SUCCESS;
285 }
286
287
288 /* ISDS_FIFO_CTRL_4_REG */
289
290 /**
291 * @brief Set decimation of third data set in FIFO
292 * @param[in] sensorInterface Pointer to sensor interface
293 * @param[in] decimation FIFO third data set decimation setting
294 * @retval Error code
295 */
ISDS_setFifoDataset3Decimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t decimation)296 int8_t ISDS_setFifoDataset3Decimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t decimation)
297 {
298 ISDS_fifoCtrl4_t fifoCtrl4;
299
300 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
301 {
302 return WE_FAIL;
303 }
304
305 fifoCtrl4.fifoThirdDecimation = (uint8_t) decimation;
306
307 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4);
308 }
309
310 /**
311 * @brief Read decimation of third data set in FIFO setting
312 * @param[in] sensorInterface Pointer to sensor interface
313 * @param[out] decimation The returned FIFO third data set decimation setting
314 * @retval Error code
315 */
ISDS_getFifoDataset3Decimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t * decimation)316 int8_t ISDS_getFifoDataset3Decimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t *decimation)
317 {
318 ISDS_fifoCtrl4_t fifoCtrl4;
319
320 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
321 {
322 return WE_FAIL;
323 }
324
325 *decimation = (ISDS_fifoDecimation_t) fifoCtrl4.fifoThirdDecimation;
326
327 return WE_SUCCESS;
328 }
329
330 /**
331 * @brief Set decimation of fourth data set in FIFO
332 * @param[in] sensorInterface Pointer to sensor interface
333 * @param[in] decimation FIFO fourth data set decimation setting
334 * @retval Error code
335 */
ISDS_setFifoDataset4Decimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t decimation)336 int8_t ISDS_setFifoDataset4Decimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t decimation)
337 {
338 ISDS_fifoCtrl4_t fifoCtrl4;
339
340 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
341 {
342 return WE_FAIL;
343 }
344
345 fifoCtrl4.fifoFourthDecimation = (uint8_t) decimation;
346
347 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4);
348 }
349
350 /**
351 * @brief Read decimation of fourth data set in FIFO setting
352 * @param[in] sensorInterface Pointer to sensor interface
353 * @param[out] decimation The returned FIFO fourth data set decimation setting
354 * @retval Error code
355 */
ISDS_getFifoDataset4Decimation(WE_sensorInterface_t * sensorInterface,ISDS_fifoDecimation_t * decimation)356 int8_t ISDS_getFifoDataset4Decimation(WE_sensorInterface_t* sensorInterface, ISDS_fifoDecimation_t *decimation)
357 {
358 ISDS_fifoCtrl4_t fifoCtrl4;
359
360 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
361 {
362 return WE_FAIL;
363 }
364
365 *decimation = (ISDS_fifoDecimation_t) fifoCtrl4.fifoFourthDecimation;
366
367 return WE_SUCCESS;
368 }
369
370 /**
371 * @brief Enable storage of MSB only (8-bit) in FIFO
372 * @param[in] sensorInterface Pointer to sensor interface
373 * @param[in] onlyHighData MSB only enable state
374 * @retval Error code
375 */
ISDS_enableFifoOnlyHighData(WE_sensorInterface_t * sensorInterface,ISDS_state_t onlyHighData)376 int8_t ISDS_enableFifoOnlyHighData(WE_sensorInterface_t* sensorInterface, ISDS_state_t onlyHighData)
377 {
378 ISDS_fifoCtrl4_t fifoCtrl4;
379
380 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
381 {
382 return WE_FAIL;
383 }
384
385 fifoCtrl4.enOnlyHighData = onlyHighData;
386
387 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4);
388 }
389
390 /**
391 * @brief Check if storage of MSB only (8-bit) in FIFO is enabled
392 * @param[in] sensorInterface Pointer to sensor interface
393 * @param[out] onlyHighData The returned MSB only enable state
394 * @retval Error code
395 */
ISDS_isFifoOnlyHighDataEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * onlyHighData)396 int8_t ISDS_isFifoOnlyHighDataEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *onlyHighData)
397 {
398 ISDS_fifoCtrl4_t fifoCtrl4;
399
400 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
401 {
402 return WE_FAIL;
403 }
404
405 *onlyHighData = (ISDS_state_t) fifoCtrl4.enOnlyHighData;
406
407 return WE_SUCCESS;
408 }
409
410 /**
411 * @brief Enable stop when FIFO threshold is reached
412 * @param[in] sensorInterface Pointer to sensor interface
413 * @param[in] stopOnThreshold FIFO stop on threshold enable state
414 * @retval Error code
415 */
ISDS_enableFifoStopOnThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t stopOnThreshold)416 int8_t ISDS_enableFifoStopOnThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t stopOnThreshold)
417 {
418 ISDS_fifoCtrl4_t fifoCtrl4;
419
420 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
421 {
422 return WE_FAIL;
423 }
424
425 fifoCtrl4.enStopOnThreshold = stopOnThreshold;
426
427 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4);
428 }
429
430 /**
431 * @brief Check if stop when FIFO threshold is reached is enabled
432 * @param[in] sensorInterface Pointer to sensor interface
433 * @param[out] stopOnThreshold The returned FIFO stop on threshold enable state
434 * @retval Error code
435 */
ISDS_isFifoStopOnThresholdEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * stopOnThreshold)436 int8_t ISDS_isFifoStopOnThresholdEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *stopOnThreshold)
437 {
438 ISDS_fifoCtrl4_t fifoCtrl4;
439
440 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_4_REG, 1, (uint8_t *) &fifoCtrl4))
441 {
442 return WE_FAIL;
443 }
444
445 *stopOnThreshold = (ISDS_state_t) fifoCtrl4.enStopOnThreshold;
446
447 return WE_SUCCESS;
448 }
449
450
451 /* ISDS_FIFO_CTRL_5_REG */
452
453 /**
454 * @brief Set the FIFO mode
455 * @param[in] sensorInterface Pointer to sensor interface
456 * @param[in] fifoMode FIFO mode
457 * @retval Error code
458 */
ISDS_setFifoMode(WE_sensorInterface_t * sensorInterface,ISDS_fifoMode_t fifoMode)459 int8_t ISDS_setFifoMode(WE_sensorInterface_t* sensorInterface, ISDS_fifoMode_t fifoMode)
460 {
461 ISDS_fifoCtrl5_t fifoCtrl5;
462
463 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_5_REG, 1, (uint8_t *) &fifoCtrl5))
464 {
465 return WE_FAIL;
466 }
467
468 fifoCtrl5.fifoMode = (uint8_t) fifoMode;
469
470 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_5_REG, 1, (uint8_t *) &fifoCtrl5);
471 }
472
473 /**
474 * @brief Read the FIFO mode
475 * @param[in] sensorInterface Pointer to sensor interface
476 * @param[out] fifoMode The returned FIFO mode
477 * @retval Error code
478 */
ISDS_getFifoMode(WE_sensorInterface_t * sensorInterface,ISDS_fifoMode_t * fifoMode)479 int8_t ISDS_getFifoMode(WE_sensorInterface_t* sensorInterface, ISDS_fifoMode_t *fifoMode)
480 {
481 ISDS_fifoCtrl5_t fifoCtrl5;
482
483 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_5_REG, 1, (uint8_t *) &fifoCtrl5))
484 {
485 return WE_FAIL;
486 }
487
488 *fifoMode = (ISDS_fifoMode_t) fifoCtrl5.fifoMode;
489
490 return WE_SUCCESS;
491 }
492
493 /**
494 * @brief Set the FIFO output data rate
495 * @param[in] sensorInterface Pointer to sensor interface
496 * @param[in] fifoOdr FIFO output data rate
497 * @retval Error code
498 */
ISDS_setFifoOutputDataRate(WE_sensorInterface_t * sensorInterface,ISDS_fifoOutputDataRate_t fifoOdr)499 int8_t ISDS_setFifoOutputDataRate(WE_sensorInterface_t* sensorInterface, ISDS_fifoOutputDataRate_t fifoOdr)
500 {
501 ISDS_fifoCtrl5_t fifoCtrl5;
502
503 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_5_REG, 1, (uint8_t *) &fifoCtrl5))
504 {
505 return WE_FAIL;
506 }
507
508 fifoCtrl5.fifoOdr = (uint8_t) fifoOdr;
509
510 return ISDS_WriteReg(sensorInterface, ISDS_FIFO_CTRL_5_REG, 1, (uint8_t *) &fifoCtrl5);
511 }
512
513 /**
514 * @brief Read the FIFO output data rate
515 * @param[in] sensorInterface Pointer to sensor interface
516 * @param[out] fifoOdr The returned FIFO output data rate
517 * @retval Error code
518 */
ISDS_getFifoOutputDataRate(WE_sensorInterface_t * sensorInterface,ISDS_fifoOutputDataRate_t * fifoOdr)519 int8_t ISDS_getFifoOutputDataRate(WE_sensorInterface_t* sensorInterface, ISDS_fifoOutputDataRate_t *fifoOdr)
520 {
521 ISDS_fifoCtrl5_t fifoCtrl5;
522
523 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_CTRL_5_REG, 1, (uint8_t *) &fifoCtrl5))
524 {
525 return WE_FAIL;
526 }
527
528 *fifoOdr = (ISDS_fifoOutputDataRate_t) fifoCtrl5.fifoOdr;
529
530 return WE_SUCCESS;
531 }
532
533
534 /* ISDS_DRDY_PULSE_CFG_REG */
535
536 /**
537 * @brief Enable pulsed data ready mode
538 * @param[in] sensorInterface Pointer to sensor interface
539 * @param[in] dataReadyPulsed Data ready pulsed mode enable state
540 * @retval Error code
541 */
ISDS_enableDataReadyPulsed(WE_sensorInterface_t * sensorInterface,ISDS_state_t dataReadyPulsed)542 int8_t ISDS_enableDataReadyPulsed(WE_sensorInterface_t* sensorInterface, ISDS_state_t dataReadyPulsed)
543 {
544 ISDS_dataReadyPulseCfg_t dataReadyPulseCfg;
545
546 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_DRDY_PULSE_CFG_REG, 1, (uint8_t *) &dataReadyPulseCfg))
547 {
548 return WE_FAIL;
549 }
550
551 dataReadyPulseCfg.enDataReadyPulsed = (uint8_t) dataReadyPulsed;
552
553 return ISDS_WriteReg(sensorInterface, ISDS_DRDY_PULSE_CFG_REG, 1, (uint8_t *) &dataReadyPulseCfg);
554 }
555
556 /**
557 * @brief Check if pulsed data ready mode is enabled
558 * @param[in] sensorInterface Pointer to sensor interface
559 * @param[out] dataReadyPulsed The returned data ready pulsed mode enable state
560 * @retval Error code
561 */
ISDS_isDataReadyPulsedEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * dataReadyPulsed)562 int8_t ISDS_isDataReadyPulsedEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *dataReadyPulsed)
563 {
564 ISDS_dataReadyPulseCfg_t dataReadyPulseCfg;
565
566 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_DRDY_PULSE_CFG_REG, 1, (uint8_t *) &dataReadyPulseCfg))
567 {
568 return WE_FAIL;
569 }
570
571 *dataReadyPulsed = (ISDS_state_t) dataReadyPulseCfg.enDataReadyPulsed;
572
573 return WE_SUCCESS;
574 }
575
576
577 /* ISDS_INT0_CTRL_REG */
578
579 /**
580 * @brief Enable/disable the acceleration data ready interrupt on INT_0
581 * @param[in] sensorInterface Pointer to sensor interface
582 * @param[in] int0AccDataReady Acceleration data ready interrupt enable state
583 * @retval Error code
584 */
ISDS_enableAccDataReadyINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0AccDataReady)585 int8_t ISDS_enableAccDataReadyINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0AccDataReady)
586 {
587 ISDS_int0Ctrl_t int0Ctrl;
588
589 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
590 {
591 return WE_FAIL;
592 }
593
594 int0Ctrl.int0AccDataReady = (uint8_t) int0AccDataReady;
595
596 return ISDS_WriteReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl);
597 }
598
599 /**
600 * @brief Check if the acceleration data ready interrupt on INT_0 is enabled
601 * @param[in] sensorInterface Pointer to sensor interface
602 * @param[out] int0AccDataReady The returned acceleration data ready interrupt enable state
603 * @retval Error code
604 */
ISDS_isAccDataReadyINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0AccDataReady)605 int8_t ISDS_isAccDataReadyINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0AccDataReady)
606 {
607 ISDS_int0Ctrl_t int0Ctrl;
608
609 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
610 {
611 return WE_FAIL;
612 }
613
614 *int0AccDataReady = (ISDS_state_t) int0Ctrl.int0AccDataReady;
615
616 return WE_SUCCESS;
617 }
618
619 /**
620 * @brief Enable/disable the gyroscope data ready interrupt on INT_0
621 * @param[in] sensorInterface Pointer to sensor interface
622 * @param[in] int0GyroDataReady Gyroscope data ready interrupt enable state
623 * @retval Error code
624 */
ISDS_enableGyroDataReadyINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0GyroDataReady)625 int8_t ISDS_enableGyroDataReadyINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0GyroDataReady)
626 {
627 ISDS_int0Ctrl_t int0Ctrl;
628
629 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
630 {
631 return WE_FAIL;
632 }
633
634 int0Ctrl.int0GyroDataReady = (uint8_t) int0GyroDataReady;
635
636 return ISDS_WriteReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl);
637 }
638
639 /**
640 * @brief Check if the gyroscope data ready interrupt on INT_0 is enabled
641 * @param[in] sensorInterface Pointer to sensor interface
642 * @param[out] int0GyroDataReady The returned gyroscope data ready interrupt enable state
643 * @retval Error code
644 */
ISDS_isGyroDataReadyINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0GyroDataReady)645 int8_t ISDS_isGyroDataReadyINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0GyroDataReady)
646 {
647 ISDS_int0Ctrl_t int0Ctrl;
648
649 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
650 {
651 return WE_FAIL;
652 }
653
654 *int0GyroDataReady = (ISDS_state_t) int0Ctrl.int0GyroDataReady;
655
656 return WE_SUCCESS;
657 }
658
659 /**
660 * @brief Enable/disable the boot status interrupt on INT_0
661 * @param[in] sensorInterface Pointer to sensor interface
662 * @param[in] int0BootStatus Boot status interrupt enable state
663 * @retval Error code
664 */
ISDS_enableBootStatusINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0BootStatus)665 int8_t ISDS_enableBootStatusINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0BootStatus)
666 {
667 ISDS_int0Ctrl_t int0Ctrl;
668
669 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
670 {
671 return WE_FAIL;
672 }
673
674 int0Ctrl.int0Boot = (uint8_t) int0BootStatus;
675
676 return ISDS_WriteReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl);
677 }
678
679 /**
680 * @brief Check if the boot status interrupt on INT_0 is enabled
681 * @param[in] sensorInterface Pointer to sensor interface
682 * @param[out] int0BootStatus The returned boot status interrupt enable state
683 * @retval Error code
684 */
ISDS_isBootStatusINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0BootStatus)685 int8_t ISDS_isBootStatusINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0BootStatus)
686 {
687 ISDS_int0Ctrl_t int0Ctrl;
688
689 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
690 {
691 return WE_FAIL;
692 }
693
694 *int0BootStatus = (ISDS_state_t) int0Ctrl.int0Boot;
695
696 return WE_SUCCESS;
697 }
698
699 /**
700 * @brief Enable/disable the FIFO threshold reached interrupt on INT_0
701 * @param[in] sensorInterface Pointer to sensor interface
702 * @param[in] int0FifoThreshold FIFO threshold reached interrupt enable state
703 * @retval Error code
704 */
ISDS_enableFifoThresholdINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0FifoThreshold)705 int8_t ISDS_enableFifoThresholdINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0FifoThreshold)
706 {
707 ISDS_int0Ctrl_t int0Ctrl;
708
709 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
710 {
711 return WE_FAIL;
712 }
713
714 int0Ctrl.int0FifoThreshold = (uint8_t) int0FifoThreshold;
715
716 return ISDS_WriteReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl);
717 }
718
719 /**
720 * @brief Check if the FIFO threshold reached interrupt on INT_0 is enabled
721 * @param[in] sensorInterface Pointer to sensor interface
722 * @param[out] int0FifoThreshold The returned FIFO threshold reached interrupt enable state
723 * @retval Error code
724 */
ISDS_isFifoThresholdINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0FifoThreshold)725 int8_t ISDS_isFifoThresholdINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0FifoThreshold)
726 {
727 ISDS_int0Ctrl_t int0Ctrl;
728
729 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
730 {
731 return WE_FAIL;
732 }
733
734 *int0FifoThreshold = (ISDS_state_t) int0Ctrl.int0FifoThreshold;
735
736 return WE_SUCCESS;
737 }
738
739 /**
740 * @brief Enable/disable the FIFO overrun interrupt on INT_0
741 * @param[in] sensorInterface Pointer to sensor interface
742 * @param[in] int0FifoOverrun FIFO overrun interrupt enable state
743 * @retval Error code
744 */
ISDS_enableFifoOverrunINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0FifoOverrun)745 int8_t ISDS_enableFifoOverrunINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0FifoOverrun)
746 {
747 ISDS_int0Ctrl_t int0Ctrl;
748
749 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
750 {
751 return WE_FAIL;
752 }
753
754 int0Ctrl.int0FifoOverrun = (uint8_t) int0FifoOverrun;
755
756 return ISDS_WriteReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl);
757 }
758
759 /**
760 * @brief Check if the FIFO overrun interrupt on INT_0 is enabled
761 * @param[in] sensorInterface Pointer to sensor interface
762 * @param[out] int0FifoOverrun The returned FIFO overrun interrupt enable state
763 * @retval Error code
764 */
ISDS_isFifoOverrunINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0FifoOverrun)765 int8_t ISDS_isFifoOverrunINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0FifoOverrun)
766 {
767 ISDS_int0Ctrl_t int0Ctrl;
768
769 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
770 {
771 return WE_FAIL;
772 }
773
774 *int0FifoOverrun = (ISDS_state_t) int0Ctrl.int0FifoOverrun;
775
776 return WE_SUCCESS;
777 }
778
779 /**
780 * @brief Enable/disable the FIFO full interrupt on INT_0
781 * @param[in] sensorInterface Pointer to sensor interface
782 * @param[in] int0FifoFull FIFO full interrupt enable state
783 * @retval Error code
784 */
ISDS_enableFifoFullINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0FifoFull)785 int8_t ISDS_enableFifoFullINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0FifoFull)
786 {
787 ISDS_int0Ctrl_t int0Ctrl;
788
789 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
790 {
791 return WE_FAIL;
792 }
793
794 int0Ctrl.int0FifoFull = (uint8_t) int0FifoFull;
795
796 return ISDS_WriteReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl);
797 }
798
799 /**
800 * @brief Check if the FIFO full interrupt on INT_0 is enabled
801 * @param[in] sensorInterface Pointer to sensor interface
802 * @param[out] int0FifoFull The returned FIFO full interrupt enable state
803 * @retval Error code
804 */
ISDS_isFifoFullINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0FifoFull)805 int8_t ISDS_isFifoFullINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0FifoFull)
806 {
807 ISDS_int0Ctrl_t int0Ctrl;
808
809 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT0_CTRL_REG, 1, (uint8_t *) &int0Ctrl))
810 {
811 return WE_FAIL;
812 }
813
814 *int0FifoFull = (ISDS_state_t) int0Ctrl.int0FifoFull;
815
816 return WE_SUCCESS;
817 }
818
819
820 /* ISDS_INT1_CTRL_REG */
821
822 /**
823 * @brief Enable/disable the acceleration data ready interrupt on INT_1
824 * @param[in] sensorInterface Pointer to sensor interface
825 * @param[in] int1AccDataReady Acceleration data ready interrupt enable state
826 * @retval Error code
827 */
ISDS_enableAccDataReadyINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1AccDataReady)828 int8_t ISDS_enableAccDataReadyINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1AccDataReady)
829 {
830 ISDS_int1Ctrl_t int1Ctrl;
831
832 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
833 {
834 return WE_FAIL;
835 }
836
837 int1Ctrl.int1AccDataReady = (uint8_t) int1AccDataReady;
838
839 return ISDS_WriteReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl);
840 }
841
842 /**
843 * @brief Check if the acceleration data ready interrupt on INT_1 is enabled
844 * @param[in] sensorInterface Pointer to sensor interface
845 * @param[out] int1AccDataReady The returned acceleration data ready interrupt enable state
846 * @retval Error code
847 */
ISDS_isAccDataReadyINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1AccDataReady)848 int8_t ISDS_isAccDataReadyINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1AccDataReady)
849 {
850 ISDS_int1Ctrl_t int1Ctrl;
851
852 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
853 {
854 return WE_FAIL;
855 }
856
857 *int1AccDataReady = (ISDS_state_t) int1Ctrl.int1AccDataReady;
858
859 return WE_SUCCESS;
860 }
861
862 /**
863 * @brief Enable/disable the gyroscope data ready interrupt on INT_1
864 * @param[in] sensorInterface Pointer to sensor interface
865 * @param[in] int1GyroDataReady Gyroscope data ready interrupt enable state
866 * @retval Error code
867 */
ISDS_enableGyroDataReadyINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1GyroDataReady)868 int8_t ISDS_enableGyroDataReadyINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1GyroDataReady)
869 {
870 ISDS_int1Ctrl_t int1Ctrl;
871
872 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
873 {
874 return WE_FAIL;
875 }
876
877 int1Ctrl.int1GyroDataReady = (uint8_t) int1GyroDataReady;
878
879 return ISDS_WriteReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl);
880 }
881
882 /**
883 * @brief Check if the gyroscope data ready interrupt on INT_1 is enabled
884 * @param[in] sensorInterface Pointer to sensor interface
885 * @param[out] int1GyroDataReady The returned gyroscope data ready interrupt enable state
886 * @retval Error code
887 */
ISDS_isGyroDataReadyINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1GyroDataReady)888 int8_t ISDS_isGyroDataReadyINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1GyroDataReady)
889 {
890 ISDS_int1Ctrl_t int1Ctrl;
891
892 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
893 {
894 return WE_FAIL;
895 }
896
897 *int1GyroDataReady = (ISDS_state_t) int1Ctrl.int1GyroDataReady;
898
899 return WE_SUCCESS;
900 }
901
902 /**
903 * @brief Enable/disable the temperature data ready interrupt on INT_1
904 * @param[in] sensorInterface Pointer to sensor interface
905 * @param[in] int1TempDataReady Temperature data ready interrupt enable state
906 * @retval Error code
907 */
ISDS_enableTemperatureDataReadyINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1TempDataReady)908 int8_t ISDS_enableTemperatureDataReadyINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1TempDataReady)
909 {
910 ISDS_int1Ctrl_t int1Ctrl;
911
912 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
913 {
914 return WE_FAIL;
915 }
916
917 int1Ctrl.int1TempDataReady = (uint8_t) int1TempDataReady;
918
919 return ISDS_WriteReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl);
920 }
921
922 /**
923 * @brief Check if the temperature data ready interrupt on INT_1 is enabled
924 * @param[in] sensorInterface Pointer to sensor interface
925 * @param[out] int1TempDataReady The returned temperature data ready interrupt enable state
926 * @retval Error code
927 */
ISDS_isTemperatureDataReadyINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1TempDataReady)928 int8_t ISDS_isTemperatureDataReadyINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1TempDataReady)
929 {
930 ISDS_int1Ctrl_t int1Ctrl;
931
932 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
933 {
934 return WE_FAIL;
935 }
936
937 *int1TempDataReady = (ISDS_state_t) int1Ctrl.int1TempDataReady;
938
939 return WE_SUCCESS;
940 }
941
942 /**
943 * @brief Enable/disable the FIFO threshold reached interrupt on INT_1
944 * @param[in] sensorInterface Pointer to sensor interface
945 * @param[in] int1FifoThreshold FIFO threshold reached interrupt enable state
946 * @retval Error code
947 */
ISDS_enableFifoThresholdINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1FifoThreshold)948 int8_t ISDS_enableFifoThresholdINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1FifoThreshold)
949 {
950 ISDS_int1Ctrl_t int1Ctrl;
951
952 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
953 {
954 return WE_FAIL;
955 }
956
957 int1Ctrl.int1FifoThreshold = (uint8_t) int1FifoThreshold;
958
959 return ISDS_WriteReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl);
960 }
961
962 /**
963 * @brief Check if the FIFO threshold reached interrupt on INT_1 is enabled
964 * @param[in] sensorInterface Pointer to sensor interface
965 * @param[out] int1FifoThreshold The returned FIFO threshold reached interrupt enable state
966 * @retval Error code
967 */
ISDS_isFifoThresholdINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1FifoThreshold)968 int8_t ISDS_isFifoThresholdINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1FifoThreshold)
969 {
970 ISDS_int1Ctrl_t int1Ctrl;
971
972 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
973 {
974 return WE_FAIL;
975 }
976
977 *int1FifoThreshold = (ISDS_state_t) int1Ctrl.int1FifoThreshold;
978
979 return WE_SUCCESS;
980 }
981
982 /**
983 * @brief Enable/disable the FIFO overrun interrupt on INT_1
984 * @param[in] sensorInterface Pointer to sensor interface
985 * @param[in] int1FifoOverrun FIFO overrun interrupt enable state
986 * @retval Error code
987 */
ISDS_enableFifoOverrunINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1FifoOverrun)988 int8_t ISDS_enableFifoOverrunINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1FifoOverrun)
989 {
990 ISDS_int1Ctrl_t int1Ctrl;
991
992 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
993 {
994 return WE_FAIL;
995 }
996
997 int1Ctrl.int1FifoOverrun = (uint8_t) int1FifoOverrun;
998
999 return ISDS_WriteReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl);
1000 }
1001
1002 /**
1003 * @brief Check if the FIFO overrun interrupt on INT_1 is enabled
1004 * @param[in] sensorInterface Pointer to sensor interface
1005 * @param[out] int1FifoOverrun The returned FIFO overrun interrupt enable state
1006 * @retval Error code
1007 */
ISDS_isFifoOverrunINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1FifoOverrun)1008 int8_t ISDS_isFifoOverrunINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1FifoOverrun)
1009 {
1010 ISDS_int1Ctrl_t int1Ctrl;
1011
1012 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
1013 {
1014 return WE_FAIL;
1015 }
1016
1017 *int1FifoOverrun = (ISDS_state_t) int1Ctrl.int1FifoOverrun;
1018
1019 return WE_SUCCESS;
1020 }
1021
1022 /**
1023 * @brief Enable/disable the FIFO full interrupt on INT_1
1024 * @param[in] sensorInterface Pointer to sensor interface
1025 * @param[in] int1FifoFull FIFO full interrupt enable state
1026 * @retval Error code
1027 */
ISDS_enableFifoFullINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1FifoFull)1028 int8_t ISDS_enableFifoFullINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1FifoFull)
1029 {
1030 ISDS_int1Ctrl_t int1Ctrl;
1031
1032 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
1033 {
1034 return WE_FAIL;
1035 }
1036
1037 int1Ctrl.int1FifoFull = (uint8_t) int1FifoFull;
1038
1039 return ISDS_WriteReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl);
1040 }
1041
1042 /**
1043 * @brief Check if the FIFO full interrupt on INT_1 is enabled
1044 * @param[in] sensorInterface Pointer to sensor interface
1045 * @param[out] int1FifoFull The returned FIFO full interrupt enable state
1046 * @retval Error code
1047 */
ISDS_isFifoFullINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1FifoFull)1048 int8_t ISDS_isFifoFullINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1FifoFull)
1049 {
1050 ISDS_int1Ctrl_t int1Ctrl;
1051
1052 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT1_CTRL_REG, 1, (uint8_t *) &int1Ctrl))
1053 {
1054 return WE_FAIL;
1055 }
1056
1057 *int1FifoFull = (ISDS_state_t) int1Ctrl.int1FifoFull;
1058
1059 return WE_SUCCESS;
1060 }
1061
1062
1063 /* ISDS_DEVICE_ID_REG */
1064
1065
1066 /* ISDS_CTRL_1_REG */
1067
1068 /**
1069 * @brief Set the accelerometer analog chain bandwidth
1070 * @param[in] sensorInterface Pointer to sensor interface
1071 * @param[in] bandwidth Accelerometer analog chain bandwidth
1072 * @retval Error code
1073 */
ISDS_setAccAnalogChainBandwidth(WE_sensorInterface_t * sensorInterface,ISDS_accAnalogChainBandwidth_t bandwidth)1074 int8_t ISDS_setAccAnalogChainBandwidth(WE_sensorInterface_t* sensorInterface, ISDS_accAnalogChainBandwidth_t bandwidth)
1075 {
1076 ISDS_ctrl1_t ctrl1;
1077
1078 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1079 {
1080 return WE_FAIL;
1081 }
1082
1083 ctrl1.accAnalogBandwidth = bandwidth;
1084
1085 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
1086 }
1087
1088 /**
1089 * @brief Read the accelerometer analog chain bandwidth
1090 * @param[in] sensorInterface Pointer to sensor interface
1091 * @param[out] bandwidth The returned accelerometer analog chain bandwidth
1092 * @retval Error code
1093 */
ISDS_getAccAnalogChainBandwidth(WE_sensorInterface_t * sensorInterface,ISDS_accAnalogChainBandwidth_t * bandwidth)1094 int8_t ISDS_getAccAnalogChainBandwidth(WE_sensorInterface_t* sensorInterface, ISDS_accAnalogChainBandwidth_t *bandwidth)
1095 {
1096 ISDS_ctrl1_t ctrl1;
1097
1098 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1099 {
1100 return WE_FAIL;
1101 }
1102
1103 *bandwidth = (ISDS_accAnalogChainBandwidth_t) ctrl1.accAnalogBandwidth;
1104
1105 return WE_SUCCESS;
1106 }
1107
1108 /**
1109 * @brief Set the accelerometer digital LPF (LPF1) bandwidth
1110 * @param[in] sensorInterface Pointer to sensor interface
1111 * @param[in] bandwidth Accelerometer digital LPF (LPF1) bandwidth
1112 * @retval Error code
1113 */
ISDS_setAccDigitalLpfBandwidth(WE_sensorInterface_t * sensorInterface,ISDS_accDigitalLpfBandwidth_t bandwidth)1114 int8_t ISDS_setAccDigitalLpfBandwidth(WE_sensorInterface_t* sensorInterface, ISDS_accDigitalLpfBandwidth_t bandwidth)
1115 {
1116 ISDS_ctrl1_t ctrl1;
1117
1118 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1119 {
1120 return WE_FAIL;
1121 }
1122
1123 ctrl1.accDigitalBandwidth = bandwidth;
1124
1125 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
1126 }
1127
1128 /**
1129 * @brief Read the accelerometer digital LPF (LPF1) bandwidth
1130 * @param[in] sensorInterface Pointer to sensor interface
1131 * @param[out] bandwidth The returned accelerometer digital LPF (LPF1) bandwidth
1132 * @retval Error code
1133 */
ISDS_getAccDigitalLpfBandwidth(WE_sensorInterface_t * sensorInterface,ISDS_accDigitalLpfBandwidth_t * bandwidth)1134 int8_t ISDS_getAccDigitalLpfBandwidth(WE_sensorInterface_t* sensorInterface, ISDS_accDigitalLpfBandwidth_t *bandwidth)
1135 {
1136 ISDS_ctrl1_t ctrl1;
1137
1138 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1139 {
1140 return WE_FAIL;
1141 }
1142
1143 *bandwidth = (ISDS_accDigitalLpfBandwidth_t) ctrl1.accDigitalBandwidth;
1144
1145 return WE_SUCCESS;
1146 }
1147
1148 /**
1149 * @brief Set the accelerometer full scale
1150 * @param[in] sensorInterface Pointer to sensor interface
1151 * @param[in] fullScale Accelerometer full scale
1152 * @retval Error code
1153 */
ISDS_setAccFullScale(WE_sensorInterface_t * sensorInterface,ISDS_accFullScale_t fullScale)1154 int8_t ISDS_setAccFullScale(WE_sensorInterface_t* sensorInterface, ISDS_accFullScale_t fullScale)
1155 {
1156 ISDS_ctrl1_t ctrl1;
1157
1158 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1159 {
1160 return WE_FAIL;
1161 }
1162
1163 ctrl1.accFullScale = fullScale;
1164
1165 int8_t errCode = ISDS_WriteReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
1166
1167 /* Store current full scale value to allow convenient conversion of sensor readings */
1168 if (WE_SUCCESS == errCode)
1169 {
1170 currentAccFullScale = fullScale;
1171 }
1172
1173 return errCode;
1174 }
1175
1176 /**
1177 * @brief Read the accelerometer full scale
1178 * @param[in] sensorInterface Pointer to sensor interface
1179 * @param[out] fullScale The returned accelerometer full scale
1180 * @retval Error code
1181 */
ISDS_getAccFullScale(WE_sensorInterface_t * sensorInterface,ISDS_accFullScale_t * fullScale)1182 int8_t ISDS_getAccFullScale(WE_sensorInterface_t* sensorInterface, ISDS_accFullScale_t *fullScale)
1183 {
1184 ISDS_ctrl1_t ctrl1;
1185
1186 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1187 {
1188 return WE_FAIL;
1189 }
1190
1191 *fullScale = (ISDS_accFullScale_t) ctrl1.accFullScale;
1192
1193 /* Store current full scale value to allow convenient conversion of sensor readings */
1194 currentAccFullScale = *fullScale;
1195
1196 return WE_SUCCESS;
1197 }
1198
1199 /**
1200 * @brief Set the accelerometer output data rate
1201 * @param[in] sensorInterface Pointer to sensor interface
1202 * @param[in] odr Output data rate
1203 * @retval Error code
1204 */
ISDS_setAccOutputDataRate(WE_sensorInterface_t * sensorInterface,ISDS_accOutputDataRate_t odr)1205 int8_t ISDS_setAccOutputDataRate(WE_sensorInterface_t* sensorInterface, ISDS_accOutputDataRate_t odr)
1206 {
1207 ISDS_ctrl1_t ctrl1;
1208
1209 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1210 {
1211 return WE_FAIL;
1212 }
1213
1214 ctrl1.accOutputDataRate = odr;
1215
1216 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
1217 }
1218
1219 /**
1220 * @brief Read the accelerometer output data rate
1221 * @param[in] sensorInterface Pointer to sensor interface
1222 * @param[out] odr The returned output data rate
1223 * @retval Error code
1224 */
ISDS_getAccOutputDataRate(WE_sensorInterface_t * sensorInterface,ISDS_accOutputDataRate_t * odr)1225 int8_t ISDS_getAccOutputDataRate(WE_sensorInterface_t* sensorInterface, ISDS_accOutputDataRate_t *odr)
1226 {
1227 ISDS_ctrl1_t ctrl1;
1228
1229 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1230 {
1231 return WE_FAIL;
1232 }
1233
1234 *odr = (ISDS_accOutputDataRate_t) ctrl1.accOutputDataRate;
1235
1236 return WE_SUCCESS;
1237 }
1238
1239
1240 /* ISDS_CTRL_2_REG */
1241
1242 /**
1243 * @brief Set the gyroscope full scale
1244 * @param[in] sensorInterface Pointer to sensor interface
1245 * @param[in] fullScale gyroscope full scale
1246 * @retval Error code
1247 */
ISDS_setGyroFullScale(WE_sensorInterface_t * sensorInterface,ISDS_gyroFullScale_t fullScale)1248 int8_t ISDS_setGyroFullScale(WE_sensorInterface_t* sensorInterface, ISDS_gyroFullScale_t fullScale)
1249 {
1250 ISDS_ctrl2_t ctrl2;
1251
1252 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1253 {
1254 return WE_FAIL;
1255 }
1256
1257 ctrl2.gyroFullScale = fullScale;
1258
1259 int8_t errCode = ISDS_WriteReg(sensorInterface, ISDS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1260
1261 /* Store current full scale value to allow convenient conversion of sensor readings */
1262 if (WE_SUCCESS == errCode)
1263 {
1264 currentGyroFullScale = fullScale;
1265 }
1266
1267 return errCode;
1268 }
1269
1270 /**
1271 * @brief Read the gyroscope full scale
1272 * @param[in] sensorInterface Pointer to sensor interface
1273 * @param[out] fullScale The returned gyroscope full scale
1274 * @retval Error code
1275 */
ISDS_getGyroFullScale(WE_sensorInterface_t * sensorInterface,ISDS_gyroFullScale_t * fullScale)1276 int8_t ISDS_getGyroFullScale(WE_sensorInterface_t* sensorInterface, ISDS_gyroFullScale_t *fullScale)
1277 {
1278 ISDS_ctrl2_t ctrl2;
1279
1280 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1281 {
1282 return WE_FAIL;
1283 }
1284
1285 *fullScale = (ISDS_gyroFullScale_t) ctrl2.gyroFullScale;
1286
1287 /* Store current full scale value to allow convenient conversion of sensor readings */
1288 currentGyroFullScale = *fullScale;
1289
1290 return WE_SUCCESS;
1291 }
1292
1293 /**
1294 * @brief Set the gyroscope output data rate
1295 * @param[in] sensorInterface Pointer to sensor interface
1296 * @param[in] odr Output data rate
1297 * @retval Error code
1298 */
ISDS_setGyroOutputDataRate(WE_sensorInterface_t * sensorInterface,ISDS_gyroOutputDataRate_t odr)1299 int8_t ISDS_setGyroOutputDataRate(WE_sensorInterface_t* sensorInterface, ISDS_gyroOutputDataRate_t odr)
1300 {
1301 ISDS_ctrl2_t ctrl2;
1302
1303 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1304 {
1305 return WE_FAIL;
1306 }
1307
1308 ctrl2.gyroOutputDataRate = odr;
1309
1310 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1311 }
1312
1313 /**
1314 * @brief Read the gyroscope output data rate
1315 * @param[in] sensorInterface Pointer to sensor interface
1316 * @param[out] odr The returned output data rate.
1317 * @retval Error code
1318 */
ISDS_getGyroOutputDataRate(WE_sensorInterface_t * sensorInterface,ISDS_gyroOutputDataRate_t * odr)1319 int8_t ISDS_getGyroOutputDataRate(WE_sensorInterface_t* sensorInterface, ISDS_gyroOutputDataRate_t *odr)
1320 {
1321 ISDS_ctrl2_t ctrl2;
1322
1323 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1324 {
1325 return WE_FAIL;
1326 }
1327
1328 *odr = (ISDS_gyroOutputDataRate_t) ctrl2.gyroOutputDataRate;
1329
1330 return WE_SUCCESS;
1331 }
1332
1333
1334 /* ISDS_CTRL_3_REG */
1335
1336 /**
1337 * @brief Set software reset [enabled, disabled]
1338 * @param[in] sensorInterface Pointer to sensor interface
1339 * @param[in] swReset Software reset state
1340 * @retval Error code
1341 */
ISDS_softReset(WE_sensorInterface_t * sensorInterface,ISDS_state_t swReset)1342 int8_t ISDS_softReset(WE_sensorInterface_t* sensorInterface, ISDS_state_t swReset)
1343 {
1344 ISDS_ctrl3_t ctrl3;
1345
1346 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1347 {
1348 return WE_FAIL;
1349 }
1350
1351 ctrl3.softReset = swReset;
1352
1353 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1354 }
1355
1356 /**
1357 * @brief Read the software reset state [enabled, disabled]
1358 * @param[in] sensorInterface Pointer to sensor interface
1359 * @param[out] swReset The returned software reset state
1360 * @retval Error code
1361 */
ISDS_getSoftResetState(WE_sensorInterface_t * sensorInterface,ISDS_state_t * swReset)1362 int8_t ISDS_getSoftResetState(WE_sensorInterface_t* sensorInterface, ISDS_state_t *swReset)
1363 {
1364 ISDS_ctrl3_t ctrl3;
1365
1366 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1367 {
1368 return WE_FAIL;
1369 }
1370
1371 *swReset = (ISDS_state_t) ctrl3.softReset;
1372
1373 return WE_SUCCESS;
1374 }
1375
1376 /**
1377 * @brief Enable/disable auto increment mode
1378 * @param[in] sensorInterface Pointer to sensor interface
1379 * @param[in] autoIncr Auto increment mode enable state
1380 * @retval Error code
1381 */
ISDS_enableAutoIncrement(WE_sensorInterface_t * sensorInterface,ISDS_state_t autoIncr)1382 int8_t ISDS_enableAutoIncrement(WE_sensorInterface_t* sensorInterface, ISDS_state_t autoIncr)
1383 {
1384 ISDS_ctrl3_t ctrl3;
1385
1386 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1387 {
1388 return WE_FAIL;
1389 }
1390
1391 ctrl3.autoAddIncr = autoIncr;
1392
1393 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1394 }
1395
1396 /**
1397 * @brief Read the auto increment mode state
1398 * @param[in] sensorInterface Pointer to sensor interface
1399 * @param[out] autoIncr The returned auto increment mode enable state
1400 * @retval Error code
1401 */
ISDS_isAutoIncrementEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * autoIncr)1402 int8_t ISDS_isAutoIncrementEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *autoIncr)
1403 {
1404 ISDS_ctrl3_t ctrl3;
1405
1406 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1407 {
1408 return WE_FAIL;
1409 }
1410
1411 *autoIncr = (ISDS_state_t) ctrl3.autoAddIncr;
1412
1413 return WE_SUCCESS;
1414 }
1415
1416 /**
1417 * @brief Set the SPI serial interface mode
1418 * @param[in] sensorInterface Pointer to sensor interface
1419 * @param[in] spiMode SPI serial interface mode
1420 * @retval Error code
1421 */
ISDS_setSpiMode(WE_sensorInterface_t * sensorInterface,ISDS_spiMode_t spiMode)1422 int8_t ISDS_setSpiMode(WE_sensorInterface_t* sensorInterface, ISDS_spiMode_t spiMode)
1423 {
1424 ISDS_ctrl3_t ctrl3;
1425
1426 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1427 {
1428 return WE_FAIL;
1429 }
1430
1431 ctrl3.spiMode = spiMode;
1432
1433 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1434 }
1435
1436 /**
1437 * @brief Read the SPI serial interface mode
1438 * @param[in] sensorInterface Pointer to sensor interface
1439 * @param[out] spiMode The returned SPI serial interface mode
1440 * @retval Error code
1441 */
ISDS_getSpiMode(WE_sensorInterface_t * sensorInterface,ISDS_spiMode_t * spiMode)1442 int8_t ISDS_getSpiMode(WE_sensorInterface_t* sensorInterface, ISDS_spiMode_t *spiMode)
1443 {
1444 ISDS_ctrl3_t ctrl3;
1445
1446 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1447 {
1448 return WE_FAIL;
1449 }
1450
1451 *spiMode = (ISDS_spiMode_t) ctrl3.spiMode;
1452
1453 return WE_SUCCESS;
1454 }
1455
1456 /**
1457 * @brief Set the interrupt pin type [push-pull/open-drain]
1458 * @param[in] sensorInterface Pointer to sensor interface
1459 * @param[in] pinType Interrupt pin type
1460 * @retval Error code
1461 */
ISDS_setInterruptPinType(WE_sensorInterface_t * sensorInterface,ISDS_interruptPinConfig_t pinType)1462 int8_t ISDS_setInterruptPinType(WE_sensorInterface_t* sensorInterface, ISDS_interruptPinConfig_t pinType)
1463 {
1464 ISDS_ctrl3_t ctrl3;
1465
1466 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1467 {
1468 return WE_FAIL;
1469 }
1470
1471 ctrl3.intPinConf = pinType;
1472
1473 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1474 }
1475
1476 /**
1477 * @brief Read the interrupt pin type [push-pull/open-drain]
1478 * @param[in] sensorInterface Pointer to sensor interface
1479 * @param[out] pinType The returned interrupt pin type
1480 * @retval Error code
1481 */
ISDS_getInterruptPinType(WE_sensorInterface_t * sensorInterface,ISDS_interruptPinConfig_t * pinType)1482 int8_t ISDS_getInterruptPinType(WE_sensorInterface_t* sensorInterface, ISDS_interruptPinConfig_t *pinType)
1483 {
1484 ISDS_ctrl3_t ctrl3;
1485
1486 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1487 {
1488 return WE_FAIL;
1489 }
1490
1491 *pinType = (ISDS_interruptPinConfig_t) ctrl3.intPinConf;
1492
1493 return WE_SUCCESS;
1494 }
1495
1496 /**
1497 * @brief Set the interrupt active level [active high/active low]
1498 * @param[in] sensorInterface Pointer to sensor interface
1499 * @param[in] level Interrupt active level
1500 * @retval Error code
1501 */
ISDS_setInterruptActiveLevel(WE_sensorInterface_t * sensorInterface,ISDS_interruptActiveLevel_t level)1502 int8_t ISDS_setInterruptActiveLevel(WE_sensorInterface_t* sensorInterface, ISDS_interruptActiveLevel_t level)
1503 {
1504 ISDS_ctrl3_t ctrl3;
1505
1506 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1507 {
1508 return WE_FAIL;
1509 }
1510
1511 ctrl3.intActiveLevel = level;
1512
1513 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1514 }
1515
1516 /**
1517 * @brief Read the interrupt active level
1518 * @param[in] sensorInterface Pointer to sensor interface
1519 * @param[out] level The returned interrupt active level
1520 * @retval Error code
1521 */
ISDS_getInterruptActiveLevel(WE_sensorInterface_t * sensorInterface,ISDS_interruptActiveLevel_t * level)1522 int8_t ISDS_getInterruptActiveLevel(WE_sensorInterface_t* sensorInterface, ISDS_interruptActiveLevel_t *level)
1523 {
1524 ISDS_ctrl3_t ctrl3;
1525
1526 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1527 {
1528 return WE_FAIL;
1529 }
1530
1531 *level = (ISDS_interruptActiveLevel_t) ctrl3.intActiveLevel;
1532
1533 return WE_SUCCESS;
1534 }
1535
1536 /**
1537 * @brief Enable/disable block data update mode
1538 * @param[in] sensorInterface Pointer to sensor interface
1539 * @param[in] bdu Block data update enable state
1540 * @retval Error code
1541 */
ISDS_enableBlockDataUpdate(WE_sensorInterface_t * sensorInterface,ISDS_state_t bdu)1542 int8_t ISDS_enableBlockDataUpdate(WE_sensorInterface_t* sensorInterface, ISDS_state_t bdu)
1543 {
1544 ISDS_ctrl3_t ctrl3;
1545
1546 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1547 {
1548 return WE_FAIL;
1549 }
1550
1551 ctrl3.blockDataUpdate = bdu;
1552
1553 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1554 }
1555
1556 /**
1557 * @brief Read the block data update state
1558 * @param[in] sensorInterface Pointer to sensor interface
1559 * @param[out] bdu The returned block data update enable state
1560 * @retval Error code
1561 */
ISDS_isBlockDataUpdateEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * bdu)1562 int8_t ISDS_isBlockDataUpdateEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *bdu)
1563 {
1564 ISDS_ctrl3_t ctrl3;
1565
1566 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1567 {
1568 return WE_FAIL;
1569 }
1570
1571 *bdu = (ISDS_state_t) ctrl3.blockDataUpdate;
1572
1573 return WE_SUCCESS;
1574 }
1575
1576 /**
1577 * @brief (Re)boot the device [enabled, disabled]
1578 * @param[in] sensorInterface Pointer to sensor interface
1579 * @param[in] reboot Reboot state
1580 * @retval Error code
1581 */
ISDS_reboot(WE_sensorInterface_t * sensorInterface,ISDS_state_t reboot)1582 int8_t ISDS_reboot(WE_sensorInterface_t* sensorInterface, ISDS_state_t reboot)
1583 {
1584 ISDS_ctrl3_t ctrl3;
1585
1586 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1587 {
1588 return WE_FAIL;
1589 }
1590
1591 ctrl3.boot = reboot;
1592
1593 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
1594 }
1595
1596 /**
1597 * @brief Read the reboot state
1598 * @param[in] sensorInterface Pointer to sensor interface
1599 * @param[out] rebooting The returned reboot state
1600 * @retval Error code
1601 */
ISDS_isRebooting(WE_sensorInterface_t * sensorInterface,ISDS_state_t * rebooting)1602 int8_t ISDS_isRebooting(WE_sensorInterface_t* sensorInterface, ISDS_state_t *rebooting)
1603 {
1604 ISDS_ctrl3_t ctrl3;
1605
1606 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
1607 {
1608 return WE_FAIL;
1609 }
1610
1611 *rebooting = (ISDS_state_t) ctrl3.boot;
1612
1613 return WE_SUCCESS;
1614 }
1615
1616
1617 /* ISDS_CTRL_4_REG */
1618
1619 /**
1620 * @brief Enable gyroscope digital LPF1
1621 * @param[in] sensorInterface Pointer to sensor interface
1622 * @param[in] enable Gyroscope digital LPF1 enable state
1623 * @retval Error code
1624 */
ISDS_enableGyroDigitalLpf1(WE_sensorInterface_t * sensorInterface,ISDS_state_t enable)1625 int8_t ISDS_enableGyroDigitalLpf1(WE_sensorInterface_t* sensorInterface, ISDS_state_t enable)
1626 {
1627 ISDS_ctrl4_t ctrl4;
1628
1629 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1630 {
1631 return WE_FAIL;
1632 }
1633
1634 ctrl4.enGyroLPF1 = enable;
1635
1636 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1637 }
1638
1639 /**
1640 * @brief Check if gyroscope digital LPF1 is enabled
1641 * @param[in] sensorInterface Pointer to sensor interface
1642 * @param[out] enable The returned gyroscope digital LPF1 enable state
1643 * @retval Error code
1644 */
ISDS_isGyroDigitalLpf1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * enable)1645 int8_t ISDS_isGyroDigitalLpf1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *enable)
1646 {
1647 ISDS_ctrl4_t ctrl4;
1648
1649 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1650 {
1651 return WE_FAIL;
1652 }
1653
1654 *enable = (ISDS_state_t) ctrl4.enGyroLPF1;
1655
1656 return WE_SUCCESS;
1657 }
1658
1659 /**
1660 * @brief Disable the I2C interface
1661 * @param[in] sensorInterface Pointer to sensor interface
1662 * @param[in] i2cDisable I2C interface disable state (0: I2C enabled, 1: I2C disabled)
1663 * @retval Error code
1664 */
ISDS_disableI2CInterface(WE_sensorInterface_t * sensorInterface,ISDS_state_t i2cDisable)1665 int8_t ISDS_disableI2CInterface(WE_sensorInterface_t* sensorInterface, ISDS_state_t i2cDisable)
1666 {
1667 ISDS_ctrl4_t ctrl4;
1668
1669 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1670 {
1671 return WE_FAIL;
1672 }
1673
1674 ctrl4.i2cDisable = i2cDisable;
1675
1676 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1677 }
1678
1679 /**
1680 * @brief Read the I2C interface disable state [enabled, disabled]
1681 * @param[in] sensorInterface Pointer to sensor interface
1682 * @param[out] i2cDisabled The returned I2C interface disable state (0: I2C enabled, 1: I2C disabled)
1683 * @retval Error code
1684 */
ISDS_isI2CInterfaceDisabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * i2cDisabled)1685 int8_t ISDS_isI2CInterfaceDisabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *i2cDisabled)
1686 {
1687 ISDS_ctrl4_t ctrl4;
1688
1689 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1690 {
1691 return WE_FAIL;
1692 }
1693
1694 *i2cDisabled = (ISDS_state_t) ctrl4.i2cDisable;
1695
1696 return WE_SUCCESS;
1697 }
1698
1699 /**
1700 * @brief Enable masking of the accelerometer and gyroscope data-ready signals
1701 * until the settling of the sensor filters is completed
1702 * @param[in] sensorInterface Pointer to sensor interface
1703 * @param[in] dataReadyMask Masking enable state
1704 * @retval Error code
1705 */
ISDS_enableDataReadyMask(WE_sensorInterface_t * sensorInterface,ISDS_state_t dataReadyMask)1706 int8_t ISDS_enableDataReadyMask(WE_sensorInterface_t* sensorInterface, ISDS_state_t dataReadyMask)
1707 {
1708 ISDS_ctrl4_t ctrl4;
1709
1710 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1711 {
1712 return WE_FAIL;
1713 }
1714
1715 ctrl4.dataReadyMask = dataReadyMask;
1716
1717 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1718 }
1719
1720 /**
1721 * @brief Check if masking of the accelerometer and gyroscope data-ready signals
1722 * until the settling of the sensor filters is completed is enabled
1723 * @param[in] sensorInterface Pointer to sensor interface
1724 * @param[out] dataReadyMask The returned masking enable state
1725 * @retval Error code
1726 */
ISDS_isDataReadyMaskEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * dataReadyMask)1727 int8_t ISDS_isDataReadyMaskEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *dataReadyMask)
1728 {
1729 ISDS_ctrl4_t ctrl4;
1730
1731 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1732 {
1733 return WE_FAIL;
1734 }
1735
1736 *dataReadyMask = (ISDS_state_t) ctrl4.dataReadyMask;
1737
1738 return WE_SUCCESS;
1739 }
1740
1741 /**
1742 * @brief Enable/disable the data enable (DEN) data ready interrupt on INT_0
1743 * @param[in] sensorInterface Pointer to sensor interface
1744 * @param[in] int0DataReady Data enable data (DEN) ready interrupt enable state
1745 * @retval Error code
1746 */
ISDS_enableDataEnableDataReadyINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0DataReady)1747 int8_t ISDS_enableDataEnableDataReadyINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0DataReady)
1748 {
1749 ISDS_ctrl4_t ctrl4;
1750
1751 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1752 {
1753 return WE_FAIL;
1754 }
1755
1756 ctrl4.dataEnableDataReadyOnInt0 = int0DataReady;
1757
1758 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1759 }
1760
1761 /**
1762 * @brief Check if the data enable (DEN) data ready interrupt on INT_0 is enabled
1763 * @param[in] sensorInterface Pointer to sensor interface
1764 * @param[out] int0DataReady The returned data enable (DEN) data ready interrupt enable state
1765 * @retval Error code
1766 */
ISDS_isDataEnableDataReadyINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0DataReady)1767 int8_t ISDS_isDataEnableDataReadyINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0DataReady)
1768 {
1769 ISDS_ctrl4_t ctrl4;
1770
1771 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1772 {
1773 return WE_FAIL;
1774 }
1775
1776 *int0DataReady = (ISDS_state_t) ctrl4.dataEnableDataReadyOnInt0;
1777
1778 return WE_SUCCESS;
1779 }
1780
1781 /**
1782 * @brief Enable signal routing from INT_1 to INT_0
1783 * @param[in] sensorInterface Pointer to sensor interface
1784 * @param[in] int1OnInt0 Signal routing INT_1 to INT_0 state
1785 * @retval Error code
1786 */
ISDS_setInt1OnInt0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1OnInt0)1787 int8_t ISDS_setInt1OnInt0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1OnInt0)
1788 {
1789 ISDS_ctrl4_t ctrl4;
1790
1791 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1792 {
1793 return WE_FAIL;
1794 }
1795
1796 ctrl4.int1OnInt0 = int1OnInt0;
1797
1798 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1799 }
1800
1801 /**
1802 * @brief Check if signal routing from INT_1 to INT_0 is enabled
1803 * @param[in] sensorInterface Pointer to sensor interface
1804 * @param[out] int1OnInt0 The returned routing enable state.
1805 * @retval Error code
1806 */
ISDS_getInt1OnInt0(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1OnInt0)1807 int8_t ISDS_getInt1OnInt0(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1OnInt0)
1808 {
1809 ISDS_ctrl4_t ctrl4;
1810
1811 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1812 {
1813 return WE_FAIL;
1814 }
1815
1816 *int1OnInt0 = (ISDS_state_t) ctrl4.int1OnInt0;
1817
1818 return WE_SUCCESS;
1819 }
1820
1821 /**
1822 * @brief Enable gyroscope sleep mode
1823 * @param[in] sensorInterface Pointer to sensor interface
1824 * @param[in] gyroSleepMode Gyroscope sleep mode enable state
1825 * @retval Error code
1826 */
ISDS_enableGyroSleepMode(WE_sensorInterface_t * sensorInterface,ISDS_state_t gyroSleepMode)1827 int8_t ISDS_enableGyroSleepMode(WE_sensorInterface_t* sensorInterface, ISDS_state_t gyroSleepMode)
1828 {
1829 ISDS_ctrl4_t ctrl4;
1830
1831 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1832 {
1833 return WE_FAIL;
1834 }
1835
1836 ctrl4.enGyroSleepMode = gyroSleepMode;
1837
1838 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1839 }
1840
1841 /**
1842 * @brief Check if gyroscope sleep mode is enabled
1843 * @param[in] sensorInterface Pointer to sensor interface
1844 * @param[out] gyroSleepMode The returned gyroscope sleep mode enable state
1845 * @retval Error code
1846 */
ISDS_isGyroSleepModeEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * gyroSleepMode)1847 int8_t ISDS_isGyroSleepModeEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *gyroSleepMode)
1848 {
1849 ISDS_ctrl4_t ctrl4;
1850
1851 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1852 {
1853 return WE_FAIL;
1854 }
1855
1856 *gyroSleepMode = (ISDS_state_t) ctrl4.enGyroSleepMode;
1857
1858 return WE_SUCCESS;
1859 }
1860
1861 /**
1862 * @brief Enable/disable extension of the data enable (DEN) functionality to accelerometer sensor
1863 * @param[in] sensorInterface Pointer to sensor interface
1864 * @param[in] extendToAcc Extension of data enable (DEN) functionality enable state
1865 * @retval Error code
1866 */
ISDS_extendDataEnableToAcc(WE_sensorInterface_t * sensorInterface,ISDS_state_t extendToAcc)1867 int8_t ISDS_extendDataEnableToAcc(WE_sensorInterface_t* sensorInterface, ISDS_state_t extendToAcc)
1868 {
1869 ISDS_ctrl4_t ctrl4;
1870
1871 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1872 {
1873 return WE_FAIL;
1874 }
1875
1876 ctrl4.dataEnableExtendToAcc = extendToAcc;
1877
1878 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4);
1879 }
1880
1881 /**
1882 * @brief Check if extension of the data enable (DEN) functionality to accelerometer sensor is enabled
1883 * @param[in] sensorInterface Pointer to sensor interface
1884 * @param[out] extendToAcc The returned extension of data enable (DEN) functionality enable state
1885 * @retval Error code
1886 */
ISDS_isDataEnableExtendedToAcc(WE_sensorInterface_t * sensorInterface,ISDS_state_t * extendToAcc)1887 int8_t ISDS_isDataEnableExtendedToAcc(WE_sensorInterface_t* sensorInterface, ISDS_state_t *extendToAcc)
1888 {
1889 ISDS_ctrl4_t ctrl4;
1890
1891 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_4_REG, 1, (uint8_t *) &ctrl4))
1892 {
1893 return WE_FAIL;
1894 }
1895
1896 *extendToAcc = (ISDS_state_t) ctrl4.dataEnableExtendToAcc;
1897
1898 return WE_SUCCESS;
1899 }
1900
1901
1902 /* ISDS_CTRL_5_REG */
1903
1904 /**
1905 * @brief Set the accelerometer self test mode
1906 * @param[in] sensorInterface Pointer to sensor interface
1907 * @param[in] selfTest Accelerometer self test mode
1908 * @retval Error code
1909 */
ISDS_setAccSelfTestMode(WE_sensorInterface_t * sensorInterface,ISDS_accSelfTestMode_t selfTest)1910 int8_t ISDS_setAccSelfTestMode(WE_sensorInterface_t* sensorInterface, ISDS_accSelfTestMode_t selfTest)
1911 {
1912 ISDS_ctrl5_t ctrl5;
1913
1914 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
1915 {
1916 return WE_FAIL;
1917 }
1918
1919 ctrl5.accSelfTest = selfTest;
1920
1921 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5);
1922 }
1923
1924 /**
1925 * @brief Read the accelerometer self test mode
1926 * @param[in] sensorInterface Pointer to sensor interface
1927 * @param[out] selfTest The returned accelerometer self test mode
1928 * @retval Error code
1929 */
ISDS_getAccSelfTestMode(WE_sensorInterface_t * sensorInterface,ISDS_accSelfTestMode_t * selfTest)1930 int8_t ISDS_getAccSelfTestMode(WE_sensorInterface_t* sensorInterface, ISDS_accSelfTestMode_t *selfTest)
1931 {
1932 ISDS_ctrl5_t ctrl5;
1933
1934 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
1935 {
1936 return WE_FAIL;
1937 }
1938
1939 *selfTest = (ISDS_accSelfTestMode_t) ctrl5.accSelfTest;
1940
1941 return WE_SUCCESS;
1942 }
1943
1944 /**
1945 * @brief Set the gyroscope self test mode
1946 * @param[in] sensorInterface Pointer to sensor interface
1947 * @param[in] selfTest Gyroscope self test mode
1948 * @retval Error code
1949 */
ISDS_setGyroSelfTestMode(WE_sensorInterface_t * sensorInterface,ISDS_gyroSelfTestMode_t selfTest)1950 int8_t ISDS_setGyroSelfTestMode(WE_sensorInterface_t* sensorInterface, ISDS_gyroSelfTestMode_t selfTest)
1951 {
1952 ISDS_ctrl5_t ctrl5;
1953
1954 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
1955 {
1956 return WE_FAIL;
1957 }
1958
1959 ctrl5.gyroSelfTest = selfTest;
1960
1961 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5);
1962 }
1963
1964 /**
1965 * @brief Read the gyroscope self test mode
1966 * @param[in] sensorInterface Pointer to sensor interface
1967 * @param[out] selfTest The returned gyroscope self test mode
1968 * @retval Error code
1969 */
ISDS_getGyroSelfTestMode(WE_sensorInterface_t * sensorInterface,ISDS_gyroSelfTestMode_t * selfTest)1970 int8_t ISDS_getGyroSelfTestMode(WE_sensorInterface_t* sensorInterface, ISDS_gyroSelfTestMode_t *selfTest)
1971 {
1972 ISDS_ctrl5_t ctrl5;
1973
1974 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
1975 {
1976 return WE_FAIL;
1977 }
1978
1979 *selfTest = (ISDS_gyroSelfTestMode_t) ctrl5.gyroSelfTest;
1980
1981 return WE_SUCCESS;
1982 }
1983
1984 /**
1985 * @brief Set the data enable (DEN) active level
1986 * @param[in] sensorInterface Pointer to sensor interface
1987 * @param[in] activeHigh Data enable (DEN) active level (0: active low, 1: active high)
1988 * @retval Error code
1989 */
ISDS_setDataEnableActiveHigh(WE_sensorInterface_t * sensorInterface,ISDS_state_t activeHigh)1990 int8_t ISDS_setDataEnableActiveHigh(WE_sensorInterface_t* sensorInterface, ISDS_state_t activeHigh)
1991 {
1992 ISDS_ctrl5_t ctrl5;
1993
1994 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
1995 {
1996 return WE_FAIL;
1997 }
1998
1999 ctrl5.dataEnableActiveLevel = activeHigh;
2000
2001 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5);
2002 }
2003
2004 /**
2005 * @brief Get the data enable (DEN) active level
2006 * @param[in] sensorInterface Pointer to sensor interface
2007 * @param[out] activeHigh The returned data enable (DEN) active level (0: active low, 1: active high)
2008 * @retval Error code
2009 */
ISDS_isDataEnableActiveHigh(WE_sensorInterface_t * sensorInterface,ISDS_state_t * activeHigh)2010 int8_t ISDS_isDataEnableActiveHigh(WE_sensorInterface_t* sensorInterface, ISDS_state_t *activeHigh)
2011 {
2012 ISDS_ctrl5_t ctrl5;
2013
2014 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
2015 {
2016 return WE_FAIL;
2017 }
2018
2019 *activeHigh = (ISDS_state_t) ctrl5.dataEnableActiveLevel;
2020
2021 return WE_SUCCESS;
2022 }
2023
2024 /**
2025 * @brief Set the circular burst-mode (rounding) pattern
2026 * @param[in] sensorInterface Pointer to sensor interface
2027 * @param[in] roundingPattern Rounding pattern
2028 * @retval Error code
2029 */
ISDS_setRoundingPattern(WE_sensorInterface_t * sensorInterface,ISDS_roundingPattern_t roundingPattern)2030 int8_t ISDS_setRoundingPattern(WE_sensorInterface_t* sensorInterface, ISDS_roundingPattern_t roundingPattern)
2031 {
2032 ISDS_ctrl5_t ctrl5;
2033
2034 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
2035 {
2036 return WE_FAIL;
2037 }
2038
2039 ctrl5.rounding = roundingPattern;
2040
2041 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5);
2042 }
2043
2044 /**
2045 * @brief Read the circular burst-mode (rounding) pattern
2046 * @param[in] sensorInterface Pointer to sensor interface
2047 * @param[out] roundingPattern The returned rounding pattern
2048 * @retval Error code
2049 */
ISDS_getRoundingPattern(WE_sensorInterface_t * sensorInterface,ISDS_roundingPattern_t * roundingPattern)2050 int8_t ISDS_getRoundingPattern(WE_sensorInterface_t* sensorInterface, ISDS_roundingPattern_t *roundingPattern)
2051 {
2052 ISDS_ctrl5_t ctrl5;
2053
2054 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_5_REG, 1, (uint8_t *) &ctrl5))
2055 {
2056 return WE_FAIL;
2057 }
2058
2059 *roundingPattern = (ISDS_roundingPattern_t) ctrl5.rounding;
2060
2061 return WE_SUCCESS;
2062 }
2063
2064
2065 /* ISDS_CTRL_6_REG */
2066
2067 /**
2068 * @brief Set the gyroscope low-pass filter (LPF1) bandwidth
2069 * @param[in] sensorInterface Pointer to sensor interface
2070 * @param[in] bandwidth Low-pass filter bandwidth
2071 * @retval Error code
2072 */
ISDS_setGyroLowPassFilterBandwidth(WE_sensorInterface_t * sensorInterface,ISDS_gyroLPF_t bandwidth)2073 int8_t ISDS_setGyroLowPassFilterBandwidth(WE_sensorInterface_t* sensorInterface, ISDS_gyroLPF_t bandwidth)
2074 {
2075 ISDS_ctrl6_t ctrl6;
2076
2077 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2078 {
2079 return WE_FAIL;
2080 }
2081
2082 ctrl6.gyroLowPassFilterType = bandwidth;
2083
2084 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6);
2085 }
2086
2087 /**
2088 * @brief Read the gyroscope low-pass filter (LPF1) bandwidth
2089 * @param[in] sensorInterface Pointer to sensor interface
2090 * @param[out] bandwidth The returned low-pass filter bandwidth
2091 * @retval Error code
2092 */
ISDS_getGyroLowPassFilterBandwidth(WE_sensorInterface_t * sensorInterface,ISDS_gyroLPF_t * bandwidth)2093 int8_t ISDS_getGyroLowPassFilterBandwidth(WE_sensorInterface_t* sensorInterface, ISDS_gyroLPF_t *bandwidth)
2094 {
2095 ISDS_ctrl6_t ctrl6;
2096
2097 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2098 {
2099 return WE_FAIL;
2100 }
2101
2102 *bandwidth = (ISDS_gyroLPF_t) ctrl6.gyroLowPassFilterType;
2103
2104 return WE_SUCCESS;
2105 }
2106
2107 /**
2108 * @brief Set the weight of the user offset words
2109 * @param[in] sensorInterface Pointer to sensor interface
2110 * @param[in] offsetWeight Offset weight
2111 * @retval Error code
2112 */
ISDS_setOffsetWeight(WE_sensorInterface_t * sensorInterface,ISDS_state_t offsetWeight)2113 int8_t ISDS_setOffsetWeight(WE_sensorInterface_t* sensorInterface, ISDS_state_t offsetWeight)
2114 {
2115 ISDS_ctrl6_t ctrl6;
2116
2117 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2118 {
2119 return WE_FAIL;
2120 }
2121
2122 ctrl6.userOffsetsWeight = offsetWeight;
2123
2124 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6);
2125 }
2126
2127 /**
2128 * @brief Read the weight of the user offset words
2129 * @param[in] sensorInterface Pointer to sensor interface
2130 * @param[out] offsetWeight The returned offset weight
2131 * @retval Error code
2132 */
ISDS_getOffsetWeight(WE_sensorInterface_t * sensorInterface,ISDS_state_t * offsetWeight)2133 int8_t ISDS_getOffsetWeight(WE_sensorInterface_t* sensorInterface, ISDS_state_t *offsetWeight)
2134 {
2135 ISDS_ctrl6_t ctrl6;
2136
2137 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2138 {
2139 return WE_FAIL;
2140 }
2141
2142 *offsetWeight = (ISDS_state_t) ctrl6.userOffsetsWeight;
2143
2144 return WE_SUCCESS;
2145 }
2146
2147 /**
2148 * @brief Disable the accelerometer high performance mode
2149 * @param[in] sensorInterface Pointer to sensor interface
2150 * @param[in] disable Accelerometer high performance mode disable state
2151 * @retval Error code
2152 */
ISDS_disableAccHighPerformanceMode(WE_sensorInterface_t * sensorInterface,ISDS_state_t disable)2153 int8_t ISDS_disableAccHighPerformanceMode(WE_sensorInterface_t* sensorInterface, ISDS_state_t disable)
2154 {
2155 ISDS_ctrl6_t ctrl6;
2156
2157 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2158 {
2159 return WE_FAIL;
2160 }
2161
2162 ctrl6.accHighPerformanceModeDisable = disable;
2163
2164 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6);
2165 }
2166
2167 /**
2168 * @brief Check if the accelerometer high performance mode is disabled
2169 * @param[in] sensorInterface Pointer to sensor interface
2170 * @param[out] disable The returned accelerometer high performance mode disable state
2171 * @retval Error code
2172 */
ISDS_isAccHighPerformanceModeDisabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * disable)2173 int8_t ISDS_isAccHighPerformanceModeDisabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *disable)
2174 {
2175 ISDS_ctrl6_t ctrl6;
2176
2177 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2178 {
2179 return WE_FAIL;
2180 }
2181
2182 *disable = (ISDS_state_t) ctrl6.accHighPerformanceModeDisable;
2183
2184 return WE_SUCCESS;
2185 }
2186
2187 /**
2188 * @brief Set the data enable (DEN) trigger mode
2189 * @param[in] sensorInterface Pointer to sensor interface
2190 * @param[in] triggerMode Data enable (DEN) trigger mode
2191 * @retval Error code
2192 */
ISDS_setDataEnableTriggerMode(WE_sensorInterface_t * sensorInterface,ISDS_dataEnableTriggerMode_t triggerMode)2193 int8_t ISDS_setDataEnableTriggerMode(WE_sensorInterface_t* sensorInterface, ISDS_dataEnableTriggerMode_t triggerMode)
2194 {
2195 ISDS_ctrl6_t ctrl6;
2196
2197 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2198 {
2199 return WE_FAIL;
2200 }
2201
2202 ctrl6.dataEnableTriggerMode = triggerMode;
2203
2204 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6);
2205 }
2206
2207 /**
2208 * @brief Read the data enable (DEN) trigger mode
2209 * @param[in] sensorInterface Pointer to sensor interface
2210 * @param[out] triggerMode The returned data enable (DEN) trigger mode
2211 * @retval Error code
2212 */
ISDS_getDataEnableTriggerMode(WE_sensorInterface_t * sensorInterface,ISDS_dataEnableTriggerMode_t * triggerMode)2213 int8_t ISDS_getDataEnableTriggerMode(WE_sensorInterface_t* sensorInterface, ISDS_dataEnableTriggerMode_t *triggerMode)
2214 {
2215 ISDS_ctrl6_t ctrl6;
2216
2217 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_6_REG, 1, (uint8_t *) &ctrl6))
2218 {
2219 return WE_FAIL;
2220 }
2221
2222 *triggerMode = (ISDS_dataEnableTriggerMode_t) ctrl6.dataEnableTriggerMode;
2223
2224 return WE_SUCCESS;
2225 }
2226
2227
2228 /* ISDS_CTRL_7_REG */
2229
2230 /**
2231 * @brief Enable/disable the source register rounding function
2232 * @param[in] sensorInterface Pointer to sensor interface
2233 * @param[in] rounding Rounding enable state
2234 * @retval Error code
2235 */
ISDS_enableRounding(WE_sensorInterface_t * sensorInterface,ISDS_state_t rounding)2236 int8_t ISDS_enableRounding(WE_sensorInterface_t* sensorInterface, ISDS_state_t rounding)
2237 {
2238 ISDS_ctrl7_t ctrl7;
2239
2240 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2241 {
2242 return WE_FAIL;
2243 }
2244
2245 ctrl7.enRounding = rounding;
2246
2247 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7);
2248 }
2249
2250 /**
2251 * @brief Check if the source register rounding function is enabled
2252 * @param[in] sensorInterface Pointer to sensor interface
2253 * @param[out] rounding The returned rounding enable state
2254 * @retval Error code
2255 */
ISDS_isRoundingEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * rounding)2256 int8_t ISDS_isRoundingEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *rounding)
2257 {
2258 ISDS_ctrl7_t ctrl7;
2259
2260 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2261 {
2262 return WE_FAIL;
2263 }
2264
2265 *rounding = (ISDS_state_t) ctrl7.enRounding;
2266
2267 return WE_SUCCESS;
2268 }
2269
2270 /**
2271 * @brief Set the gyroscope digital high pass filter cutoff
2272 * @param[in] sensorInterface Pointer to sensor interface
2273 * @param[in] cutoff Gyroscope digital high pass filter cutoff
2274 * @retval Error code
2275 */
ISDS_setGyroDigitalHighPassCutoff(WE_sensorInterface_t * sensorInterface,ISDS_gyroDigitalHighPassCutoff_t cutoff)2276 int8_t ISDS_setGyroDigitalHighPassCutoff(WE_sensorInterface_t* sensorInterface, ISDS_gyroDigitalHighPassCutoff_t cutoff)
2277 {
2278 ISDS_ctrl7_t ctrl7;
2279
2280 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2281 {
2282 return WE_FAIL;
2283 }
2284
2285 ctrl7.gyroDigitalHighPassCutoff = cutoff;
2286
2287 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7);
2288 }
2289
2290 /**
2291 * @brief Read the gyroscope digital high pass filter cutoff
2292 * @param[in] sensorInterface Pointer to sensor interface
2293 * @param[out] cutoff The returned gyroscope digital high pass filter cutoff
2294 * @retval Error code
2295 */
ISDS_getGyroDigitalHighPassCutoff(WE_sensorInterface_t * sensorInterface,ISDS_gyroDigitalHighPassCutoff_t * cutoff)2296 int8_t ISDS_getGyroDigitalHighPassCutoff(WE_sensorInterface_t* sensorInterface, ISDS_gyroDigitalHighPassCutoff_t *cutoff)
2297 {
2298 ISDS_ctrl7_t ctrl7;
2299
2300 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2301 {
2302 return WE_FAIL;
2303 }
2304
2305 *cutoff = (ISDS_gyroDigitalHighPassCutoff_t) ctrl7.gyroDigitalHighPassCutoff;
2306
2307 return WE_SUCCESS;
2308 }
2309
2310 /**
2311 * @brief Enable the gyroscope digital high pass filter
2312 * @param[in] sensorInterface Pointer to sensor interface
2313 * @param[in] highPass Gyroscope digital high pass filter enable state
2314 * @retval Error code
2315 */
ISDS_enableGyroDigitalHighPass(WE_sensorInterface_t * sensorInterface,ISDS_state_t highPass)2316 int8_t ISDS_enableGyroDigitalHighPass(WE_sensorInterface_t* sensorInterface, ISDS_state_t highPass)
2317 {
2318 ISDS_ctrl7_t ctrl7;
2319
2320 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2321 {
2322 return WE_FAIL;
2323 }
2324
2325 ctrl7.gyroDigitalHighPassEnable = highPass;
2326
2327 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7);
2328 }
2329
2330 /**
2331 * @brief Check if the gyroscope digital high pass filter is enabled
2332 * @param[in] sensorInterface Pointer to sensor interface
2333 * @param[out] highPass The returned gyroscope digital high pass filter enable state
2334 * @retval Error code
2335 */
ISDS_isGyroDigitalHighPassEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * highPass)2336 int8_t ISDS_isGyroDigitalHighPassEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *highPass)
2337 {
2338 ISDS_ctrl7_t ctrl7;
2339
2340 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2341 {
2342 return WE_FAIL;
2343 }
2344
2345 *highPass = (ISDS_state_t) ctrl7.gyroDigitalHighPassEnable;
2346
2347 return WE_SUCCESS;
2348 }
2349
2350 /**
2351 * @brief Disable the gyroscope high performance mode
2352 * @param[in] sensorInterface Pointer to sensor interface
2353 * @param[in] disable Gyroscope high performance mode disable state
2354 * @retval Error code
2355 */
ISDS_disableGyroHighPerformanceMode(WE_sensorInterface_t * sensorInterface,ISDS_state_t disable)2356 int8_t ISDS_disableGyroHighPerformanceMode(WE_sensorInterface_t* sensorInterface, ISDS_state_t disable)
2357 {
2358 ISDS_ctrl7_t ctrl7;
2359
2360 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2361 {
2362 return WE_FAIL;
2363 }
2364
2365 ctrl7.gyroHighPerformanceModeDisable = disable;
2366
2367 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7);
2368 }
2369
2370 /**
2371 * @brief Check if the gyroscope high performance mode is disabled
2372 * @param[in] sensorInterface Pointer to sensor interface
2373 * @param[out] disable The returned gyroscope high performance mode disable state
2374 * @retval Error code
2375 */
ISDS_isGyroHighPerformanceModeDisabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * disable)2376 int8_t ISDS_isGyroHighPerformanceModeDisabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *disable)
2377 {
2378 ISDS_ctrl7_t ctrl7;
2379
2380 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_7_REG, 1, (uint8_t *) &ctrl7))
2381 {
2382 return WE_FAIL;
2383 }
2384
2385 *disable = (ISDS_state_t) ctrl7.gyroHighPerformanceModeDisable;
2386
2387 return WE_SUCCESS;
2388 }
2389
2390
2391 /* ISDS_CTRL_8_REG */
2392
2393 /**
2394 * @brief Enable/disable the low pass filter for 6D orientation detection
2395 * @param[in] sensorInterface Pointer to sensor interface
2396 * @param[in] lowPass Low pass filter enable state
2397 * @retval Error code
2398 */
ISDS_enable6dLowPass(WE_sensorInterface_t * sensorInterface,ISDS_state_t lowPass)2399 int8_t ISDS_enable6dLowPass(WE_sensorInterface_t* sensorInterface, ISDS_state_t lowPass)
2400 {
2401 ISDS_ctrl8_t ctrl8;
2402
2403 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2404 {
2405 return WE_FAIL;
2406 }
2407
2408 ctrl8.en6dLowPass = lowPass;
2409
2410 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8);
2411 }
2412
2413 /**
2414 * @brief Check if the low pass filter for 6D orientation detection is enabled
2415 * @param[in] sensorInterface Pointer to sensor interface
2416 * @param[out] lowPass The returned low pass filter enable state
2417 * @retval Error code
2418 */
ISDS_is6dLowPassEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * lowPass)2419 int8_t ISDS_is6dLowPassEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *lowPass)
2420 {
2421 ISDS_ctrl8_t ctrl8;
2422
2423 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2424 {
2425 return WE_FAIL;
2426 }
2427
2428 *lowPass = (ISDS_state_t) ctrl8.en6dLowPass;
2429
2430 return WE_SUCCESS;
2431 }
2432
2433 /**
2434 * @brief Enable/disable the accelerometer high pass / slope filter
2435 * (i.e. the high-pass path of the composite filter block).
2436 * @param[in] sensorInterface Pointer to sensor interface
2437 * @param[in] filterEnable HP / slope filter enable state (0: select low-pass path; 1: select high-pass path)
2438 * @retval Error code
2439 */
ISDS_enableAccHighPassSlopeFilter(WE_sensorInterface_t * sensorInterface,ISDS_state_t filterEnable)2440 int8_t ISDS_enableAccHighPassSlopeFilter(WE_sensorInterface_t* sensorInterface, ISDS_state_t filterEnable)
2441 {
2442 ISDS_ctrl8_t ctrl8;
2443
2444 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2445 {
2446 return WE_FAIL;
2447 }
2448
2449 ctrl8.enAccHighPassSlopeFilter = filterEnable;
2450
2451 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8);
2452 }
2453
2454 /**
2455 * @brief Check if the accelerometer slope filter / high pass filter is enabled
2456 * @param[in] sensorInterface Pointer to sensor interface
2457 * @param[out] filterEnable The returned filter enable state
2458 * @retval Error code
2459 */
ISDS_isAccHighPassSlopeFilterEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * filterEnable)2460 int8_t ISDS_isAccHighPassSlopeFilterEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *filterEnable)
2461 {
2462 ISDS_ctrl8_t ctrl8;
2463
2464 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2465 {
2466 return WE_FAIL;
2467 }
2468
2469 *filterEnable = (ISDS_state_t) ctrl8.enAccHighPassSlopeFilter;
2470
2471 return WE_SUCCESS;
2472 }
2473
2474 /**
2475 * @brief Set composite filter input
2476 * @param[in] sensorInterface Pointer to sensor interface
2477 * @param[in] inputCompositeFilter Composite filter input
2478 * @retval Error code
2479 */
ISDS_setInputCompositeFilter(WE_sensorInterface_t * sensorInterface,ISDS_inputCompositeFilter_t inputCompositeFilter)2480 int8_t ISDS_setInputCompositeFilter(WE_sensorInterface_t* sensorInterface, ISDS_inputCompositeFilter_t inputCompositeFilter)
2481 {
2482 ISDS_ctrl8_t ctrl8;
2483
2484 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2485 {
2486 return WE_FAIL;
2487 }
2488
2489 ctrl8.inputComposite = inputCompositeFilter;
2490
2491 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8);
2492 }
2493
2494 /**
2495 * @brief Read composite filter input
2496 * @param[in] sensorInterface Pointer to sensor interface
2497 * @param[out] inputCompositeFilter The returned composite filter input
2498 * @retval Error code
2499 */
ISDS_getInputCompositeFilter(WE_sensorInterface_t * sensorInterface,ISDS_inputCompositeFilter_t * inputCompositeFilter)2500 int8_t ISDS_getInputCompositeFilter(WE_sensorInterface_t* sensorInterface, ISDS_inputCompositeFilter_t *inputCompositeFilter)
2501 {
2502 ISDS_ctrl8_t ctrl8;
2503
2504 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2505 {
2506 return WE_FAIL;
2507 }
2508
2509 *inputCompositeFilter = (ISDS_inputCompositeFilter_t) ctrl8.inputComposite;
2510
2511 return WE_SUCCESS;
2512 }
2513
2514 /**
2515 * @brief Enable/disable high pass filter reference mode
2516 *
2517 * Note that for reference mode to be enabled, it is also required to call
2518 * ISDS_enableAccHighPassSlopeFilter(ISDS_enable) and call
2519 * ISDS_setAccFilterConfig() with a non-zero argument.
2520 *
2521 * The first accelerometer output sample after enabling reference mode has to be discarded.
2522 *
2523 * @param[in] sensorInterface Pointer to sensor interface
2524 * @param[in] refMode High pass filter reference mode enable state
2525 * @retval Error code
2526 */
ISDS_enableHighPassFilterRefMode(WE_sensorInterface_t * sensorInterface,ISDS_state_t refMode)2527 int8_t ISDS_enableHighPassFilterRefMode(WE_sensorInterface_t* sensorInterface, ISDS_state_t refMode)
2528 {
2529 ISDS_ctrl8_t ctrl8;
2530
2531 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2532 {
2533 return WE_FAIL;
2534 }
2535
2536 ctrl8.highPassFilterRefMode = refMode;
2537
2538 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8);
2539 }
2540
2541 /**
2542 * @brief Check if the high pass filter reference mode is enabled
2543 * @param[in] sensorInterface Pointer to sensor interface
2544 * @param[out] refMode The returned high pass filter reference mode enable state
2545 * @retval Error code
2546 */
ISDS_isHighPassFilterRefModeEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * refMode)2547 int8_t ISDS_isHighPassFilterRefModeEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *refMode)
2548 {
2549 ISDS_ctrl8_t ctrl8;
2550
2551 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2552 {
2553 return WE_FAIL;
2554 }
2555
2556 *refMode = (ISDS_state_t) ctrl8.highPassFilterRefMode;
2557
2558 return WE_SUCCESS;
2559 }
2560
2561 /**
2562 * @brief Set accelerometer LPF2 and high pass filter configuration and cutoff setting
2563 * @param[in] sensorInterface Pointer to sensor interface
2564 * @param[in] filterConfig Filter configuration
2565 * @retval Error code
2566 */
ISDS_setAccFilterConfig(WE_sensorInterface_t * sensorInterface,ISDS_accFilterConfig_t filterConfig)2567 int8_t ISDS_setAccFilterConfig(WE_sensorInterface_t* sensorInterface, ISDS_accFilterConfig_t filterConfig)
2568 {
2569 ISDS_ctrl8_t ctrl8;
2570
2571 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2572 {
2573 return WE_FAIL;
2574 }
2575
2576 ctrl8.accFilterConfig = filterConfig;
2577
2578 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8);
2579 }
2580
2581 /**
2582 * @brief Read the accelerometer LPF2 and high pass filter configuration and cutoff setting
2583 * @param[in] sensorInterface Pointer to sensor interface
2584 * @param[out] filterConfig The returned filter configuration
2585 * @retval Error code
2586 */
ISDS_getAccFilterConfig(WE_sensorInterface_t * sensorInterface,ISDS_accFilterConfig_t * filterConfig)2587 int8_t ISDS_getAccFilterConfig(WE_sensorInterface_t* sensorInterface, ISDS_accFilterConfig_t *filterConfig)
2588 {
2589 ISDS_ctrl8_t ctrl8;
2590
2591 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2592 {
2593 return WE_FAIL;
2594 }
2595
2596 *filterConfig = (ISDS_accFilterConfig_t) ctrl8.accFilterConfig;
2597
2598 return WE_SUCCESS;
2599 }
2600
2601 /**
2602 * @brief Enable/disable the accelerometer low pass filter (LPF2)
2603 * @param[in] sensorInterface Pointer to sensor interface
2604 * @param[in] lowPass Filter enable state
2605 * @retval Error code
2606 */
ISDS_enableAccLowPass(WE_sensorInterface_t * sensorInterface,ISDS_state_t lowPass)2607 int8_t ISDS_enableAccLowPass(WE_sensorInterface_t* sensorInterface, ISDS_state_t lowPass)
2608 {
2609 ISDS_ctrl8_t ctrl8;
2610
2611 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2612 {
2613 return WE_FAIL;
2614 }
2615
2616 ctrl8.enAccLowPass = lowPass;
2617
2618 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8);
2619 }
2620
2621 /**
2622 * @brief Check if the accelerometer low pass filter (LPF2) is enabled
2623 * @param[in] sensorInterface Pointer to sensor interface
2624 * @param[out] lowPass The returned filter enable state
2625 * @retval Error code
2626 */
ISDS_isAccLowPassEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * lowPass)2627 int8_t ISDS_isAccLowPassEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *lowPass)
2628 {
2629 ISDS_ctrl8_t ctrl8;
2630
2631 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_8_REG, 1, (uint8_t *) &ctrl8))
2632 {
2633 return WE_FAIL;
2634 }
2635
2636 *lowPass = (ISDS_state_t) ctrl8.enAccLowPass;
2637
2638 return WE_SUCCESS;
2639 }
2640
2641
2642 /* ISDS_CTRL_9_REG */
2643
2644 /**
2645 * @brief Set the data enable (DEN) stamping sensor
2646 * @param[in] sensorInterface Pointer to sensor interface
2647 * @param[in] sensor Data enable (DEN) stamping sensor
2648 * @retval Error code
2649 */
ISDS_setDataEnableStampingSensor(WE_sensorInterface_t * sensorInterface,ISDS_dataEnableStampingSensor_t sensor)2650 int8_t ISDS_setDataEnableStampingSensor(WE_sensorInterface_t* sensorInterface, ISDS_dataEnableStampingSensor_t sensor)
2651 {
2652 ISDS_ctrl9_t ctrl9;
2653
2654 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2655 {
2656 return WE_FAIL;
2657 }
2658
2659 ctrl9.dataEnableStampingSensor = sensor;
2660
2661 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9);
2662 }
2663
2664 /**
2665 * @brief Get the data enable (DEN) stamping sensor
2666 * @param[in] sensorInterface Pointer to sensor interface
2667 * @param[out] sensor The returned data enable (DEN) stamping sensor
2668 * @retval Error code
2669 */
ISDS_getDataEnableStampingSensor(WE_sensorInterface_t * sensorInterface,ISDS_dataEnableStampingSensor_t * sensor)2670 int8_t ISDS_getDataEnableStampingSensor(WE_sensorInterface_t* sensorInterface, ISDS_dataEnableStampingSensor_t *sensor)
2671 {
2672 ISDS_ctrl9_t ctrl9;
2673
2674 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2675 {
2676 return WE_FAIL;
2677 }
2678
2679 *sensor = (ISDS_dataEnableStampingSensor_t) ctrl9.dataEnableStampingSensor;
2680
2681 return WE_SUCCESS;
2682 }
2683
2684 /**
2685 * @brief Enable/disable storage of data enable (DEN) value in LSB of Z-axis
2686 * @param[in] sensorInterface Pointer to sensor interface
2687 * @param[in] enable Storage of DEN value in LSB of Z-axis enable state
2688 * @retval Error code
2689 */
ISDS_storeDataEnableValueInZAxisLSB(WE_sensorInterface_t * sensorInterface,ISDS_state_t enable)2690 int8_t ISDS_storeDataEnableValueInZAxisLSB(WE_sensorInterface_t* sensorInterface, ISDS_state_t enable)
2691 {
2692 ISDS_ctrl9_t ctrl9;
2693
2694 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2695 {
2696 return WE_FAIL;
2697 }
2698
2699 ctrl9.dataEnableValueZ = enable;
2700
2701 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9);
2702 }
2703
2704 /**
2705 * @brief Check if storage of data enable (DEN) value in LSB of Z-axis is enabled
2706 * @param[in] sensorInterface Pointer to sensor interface
2707 * @param[out] enable The returned storage of DEN value in LSB of Z-axis enable state
2708 * @retval Error code
2709 */
ISDS_isStoreDataEnableValueInZAxisLSB(WE_sensorInterface_t * sensorInterface,ISDS_state_t * enable)2710 int8_t ISDS_isStoreDataEnableValueInZAxisLSB(WE_sensorInterface_t* sensorInterface, ISDS_state_t *enable)
2711 {
2712 ISDS_ctrl9_t ctrl9;
2713
2714 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2715 {
2716 return WE_FAIL;
2717 }
2718
2719 *enable = (ISDS_state_t) ctrl9.dataEnableValueZ;
2720
2721 return WE_SUCCESS;
2722 }
2723
2724 /**
2725 * @brief Enable/disable storage of data enable (DEN) value in LSB of Y-axis
2726 * @param[in] sensorInterface Pointer to sensor interface
2727 * @param[in] enable Storage of DEN value in LSB of Y-axis enable state
2728 * @retval Error code
2729 */
ISDS_storeDataEnableValueInYAxisLSB(WE_sensorInterface_t * sensorInterface,ISDS_state_t enable)2730 int8_t ISDS_storeDataEnableValueInYAxisLSB(WE_sensorInterface_t* sensorInterface, ISDS_state_t enable)
2731 {
2732 ISDS_ctrl9_t ctrl9;
2733
2734 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2735 {
2736 return WE_FAIL;
2737 }
2738
2739 ctrl9.dataEnableValueY = enable;
2740
2741 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9);
2742 }
2743
2744 /**
2745 * @brief Check if storage of data enable (DEN) value in LSB of Y-axis is enabled
2746 * @param[in] sensorInterface Pointer to sensor interface
2747 * @param[out] enable The returned storage of DEN value in LSB of Y-axis enable state
2748 * @retval Error code
2749 */
ISDS_isStoreDataEnableValueInYAxisLSB(WE_sensorInterface_t * sensorInterface,ISDS_state_t * enable)2750 int8_t ISDS_isStoreDataEnableValueInYAxisLSB(WE_sensorInterface_t* sensorInterface, ISDS_state_t *enable)
2751 {
2752 ISDS_ctrl9_t ctrl9;
2753
2754 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2755 {
2756 return WE_FAIL;
2757 }
2758
2759 *enable = (ISDS_state_t) ctrl9.dataEnableValueY;
2760
2761 return WE_SUCCESS;
2762 }
2763
2764 /**
2765 * @brief Enable/disable storage of data enable (DEN) value in LSB of X-axis
2766 * @param[in] sensorInterface Pointer to sensor interface
2767 * @param[in] enable Storage of DEN value in LSB of X-axis enable state
2768 * @retval Error code
2769 */
ISDS_storeDataEnableValueInXAxisLSB(WE_sensorInterface_t * sensorInterface,ISDS_state_t enable)2770 int8_t ISDS_storeDataEnableValueInXAxisLSB(WE_sensorInterface_t* sensorInterface, ISDS_state_t enable)
2771 {
2772 ISDS_ctrl9_t ctrl9;
2773
2774 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2775 {
2776 return WE_FAIL;
2777 }
2778
2779 ctrl9.dataEnableValueX = enable;
2780
2781 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9);
2782 }
2783
2784 /**
2785 * @brief Check if storage of data enable (DEN) value in LSB of X-axis is enabled
2786 * @param[in] sensorInterface Pointer to sensor interface
2787 * @param[out] enable The returned storage of DEN value in LSB of X-axis enable state
2788 * @retval Error code
2789 */
ISDS_isStoreDataEnableValueInXAxisLSB(WE_sensorInterface_t * sensorInterface,ISDS_state_t * enable)2790 int8_t ISDS_isStoreDataEnableValueInXAxisLSB(WE_sensorInterface_t* sensorInterface, ISDS_state_t *enable)
2791 {
2792 ISDS_ctrl9_t ctrl9;
2793
2794 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_9_REG, 1, (uint8_t *) &ctrl9))
2795 {
2796 return WE_FAIL;
2797 }
2798
2799 *enable = (ISDS_state_t) ctrl9.dataEnableValueX;
2800
2801 return WE_SUCCESS;
2802 }
2803
2804
2805 /* ISDS_CTRL_10_REG */
2806
2807 /**
2808 * @brief Enable/disable embedded functionalities (tilt)
2809 * @param[in] sensorInterface Pointer to sensor interface
2810 * @param[in] embeddedFuncEnable Embedded functionalities enable state
2811 * @retval Error code
2812 */
ISDS_enableEmbeddedFunctionalities(WE_sensorInterface_t * sensorInterface,ISDS_state_t embeddedFuncEnable)2813 int8_t ISDS_enableEmbeddedFunctionalities(WE_sensorInterface_t* sensorInterface, ISDS_state_t embeddedFuncEnable)
2814 {
2815 ISDS_ctrl10_t ctrl10;
2816
2817 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_10_REG, 1, (uint8_t *) &ctrl10))
2818 {
2819 return WE_FAIL;
2820 }
2821
2822 ctrl10.enEmbeddedFunc = embeddedFuncEnable;
2823
2824 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_10_REG, 1, (uint8_t *) &ctrl10);
2825 }
2826
2827 /**
2828 * @brief Check if embedded functionalities (tilt) are enabled
2829 * @param[in] sensorInterface Pointer to sensor interface
2830 * @param[out] embeddedFuncEnable The returned embedded functionalities enable state
2831 * @retval Error code
2832 */
ISDS_areEmbeddedFunctionalitiesEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * embeddedFuncEnable)2833 int8_t ISDS_areEmbeddedFunctionalitiesEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *embeddedFuncEnable)
2834 {
2835 ISDS_ctrl10_t ctrl10;
2836
2837 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_10_REG, 1, (uint8_t *) &ctrl10))
2838 {
2839 return WE_FAIL;
2840 }
2841
2842 *embeddedFuncEnable = (ISDS_state_t) ctrl10.enEmbeddedFunc;
2843
2844 return WE_SUCCESS;
2845 }
2846
2847 /**
2848 * @brief Enable/disable tilt calculation
2849 * @param[in] sensorInterface Pointer to sensor interface
2850 * @param[in] tiltCalc Tilt calculation enable state
2851 * @retval Error code
2852 */
ISDS_enableTiltCalculation(WE_sensorInterface_t * sensorInterface,ISDS_state_t tiltCalc)2853 int8_t ISDS_enableTiltCalculation(WE_sensorInterface_t* sensorInterface, ISDS_state_t tiltCalc)
2854 {
2855 ISDS_ctrl10_t ctrl10;
2856
2857 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_10_REG, 1, (uint8_t *) &ctrl10))
2858 {
2859 return WE_FAIL;
2860 }
2861
2862 ctrl10.enTiltCalculation = tiltCalc;
2863
2864 return ISDS_WriteReg(sensorInterface, ISDS_CTRL_10_REG, 1, (uint8_t *) &ctrl10);
2865 }
2866
2867 /**
2868 * @brief Check if tilt calculation is enabled
2869 * @param[in] sensorInterface Pointer to sensor interface
2870 * @param[out] tiltCalc The returned tilt calculation enable state
2871 * @retval Error code
2872 */
ISDS_isTiltCalculationEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tiltCalc)2873 int8_t ISDS_isTiltCalculationEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tiltCalc)
2874 {
2875 ISDS_ctrl10_t ctrl10;
2876
2877 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_CTRL_10_REG, 1, (uint8_t *) &ctrl10))
2878 {
2879 return WE_FAIL;
2880 }
2881
2882 *tiltCalc = (ISDS_state_t) ctrl10.enTiltCalculation;
2883
2884 return WE_SUCCESS;
2885 }
2886
2887 /* ISDS_WAKE_UP_EVENT_REG */
2888
2889 /**
2890 * @brief Read the overall wake-up event status
2891 * @param[in] sensorInterface Pointer to sensor interface
2892 * @param[out] status The returned wake-up event status
2893 * @retval Error code
2894 */
ISDS_getWakeUpEventRegister(WE_sensorInterface_t * sensorInterface,ISDS_wakeUpEvent_t * status)2895 int8_t ISDS_getWakeUpEventRegister(WE_sensorInterface_t* sensorInterface, ISDS_wakeUpEvent_t *status)
2896 {
2897 return ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) status);
2898 }
2899
2900 /**
2901 * @brief Read the wake-up event detection status on axis X
2902 * @param[in] sensorInterface Pointer to sensor interface
2903 * @param[out] wakeUpX The returned wake-up event detection status on axis X
2904 * @retval Error code
2905 */
ISDS_isWakeUpXEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * wakeUpX)2906 int8_t ISDS_isWakeUpXEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *wakeUpX)
2907 {
2908 ISDS_wakeUpEvent_t status;
2909
2910 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) &status))
2911 {
2912 return WE_FAIL;
2913 }
2914
2915 *wakeUpX = (ISDS_state_t) status.wakeUpX;
2916
2917 return WE_SUCCESS;
2918 }
2919
2920 /**
2921 * @brief Read the wake-up event detection status on axis Y
2922 * @param[in] sensorInterface Pointer to sensor interface
2923 * @param[out] wakeUpY The returned wake-up event detection status on axis Y
2924 * @retval Error code
2925 */
ISDS_isWakeUpYEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * wakeUpY)2926 int8_t ISDS_isWakeUpYEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *wakeUpY)
2927 {
2928 ISDS_wakeUpEvent_t status;
2929
2930 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) &status))
2931 {
2932 return WE_FAIL;
2933 }
2934
2935 *wakeUpY = (ISDS_state_t) status.wakeUpY;
2936
2937 return WE_SUCCESS;
2938 }
2939
2940 /**
2941 * @brief Read the wake-up event detection status on axis Z
2942 * @param[in] sensorInterface Pointer to sensor interface
2943 * @param[out] wakeUpZ The returned wake-up event detection status on axis Z
2944 * @retval Error code
2945 */
ISDS_isWakeUpZEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * wakeUpZ)2946 int8_t ISDS_isWakeUpZEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *wakeUpZ)
2947 {
2948 ISDS_wakeUpEvent_t status;
2949
2950 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) &status))
2951 {
2952 return WE_FAIL;
2953 }
2954
2955 *wakeUpZ = (ISDS_state_t) status.wakeUpZ;
2956
2957 return WE_SUCCESS;
2958 }
2959
2960 /**
2961 * @brief Read the wake-up event detection status (wake-up event on any axis)
2962 * @param[in] sensorInterface Pointer to sensor interface
2963 * @param[out] wakeUpState The returned wake-up event detection state
2964 * @retval Error code
2965 */
ISDS_isWakeUpEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * wakeUpState)2966 int8_t ISDS_isWakeUpEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *wakeUpState)
2967 {
2968 ISDS_wakeUpEvent_t status;
2969
2970 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) &status))
2971 {
2972 return WE_FAIL;
2973 }
2974
2975 *wakeUpState = (ISDS_state_t) status.wakeUpState;
2976
2977 return WE_SUCCESS;
2978 }
2979
2980 /**
2981 * @brief Read the sleep state [not sleeping/sleeping]
2982 * @param[in] sensorInterface Pointer to sensor interface
2983 * @param[out] sleepState The returned sleep state.
2984 * @retval Error code
2985 */
ISDS_getSleepState(WE_sensorInterface_t * sensorInterface,ISDS_state_t * sleepState)2986 int8_t ISDS_getSleepState(WE_sensorInterface_t* sensorInterface, ISDS_state_t *sleepState)
2987 {
2988 ISDS_wakeUpEvent_t status;
2989
2990 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) &status))
2991 {
2992 return WE_FAIL;
2993 }
2994
2995 *sleepState = (ISDS_state_t) status.sleepState;
2996
2997 return WE_SUCCESS;
2998 }
2999
3000 /**
3001 * @brief Read the free-fall event detection status
3002 * @param[in] sensorInterface Pointer to sensor interface
3003 * @param[out] freeFall The returned free-fall event detection state
3004 * @retval Error code
3005 */
ISDS_isFreeFallEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * freeFall)3006 int8_t ISDS_isFreeFallEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *freeFall)
3007 {
3008 ISDS_wakeUpEvent_t status;
3009
3010 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_EVENT_REG, 1, (uint8_t *) &status))
3011 {
3012 return WE_FAIL;
3013 }
3014
3015 *freeFall = (ISDS_state_t) status.freeFallState;
3016
3017 return WE_SUCCESS;
3018 }
3019
3020
3021 /* ISDS_TAP_EVENT_REG */
3022
3023 /**
3024 * @brief Read the overall tap event status
3025 * @param[in] sensorInterface Pointer to sensor interface
3026 * @param[out] status The returned tap event status
3027 * @retval Error code
3028 */
ISDS_getTapEventRegister(WE_sensorInterface_t * sensorInterface,ISDS_tapEvent_t * status)3029 int8_t ISDS_getTapEventRegister(WE_sensorInterface_t* sensorInterface, ISDS_tapEvent_t *status)
3030 {
3031 return ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) status);
3032 }
3033
3034 /**
3035 * @brief Read the tap event status (tap event on any axis)
3036 * @param[in] sensorInterface Pointer to sensor interface
3037 * @param[out] tapEventState The returned tap event state
3038 * @retval Error code
3039 */
ISDS_isTapEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapEventState)3040 int8_t ISDS_isTapEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapEventState)
3041 {
3042 ISDS_tapEvent_t status;
3043
3044 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3045 {
3046 return WE_FAIL;
3047 }
3048
3049 *tapEventState = (ISDS_state_t) status.tapEventState;
3050
3051 return WE_SUCCESS;
3052 }
3053
3054 /**
3055 * @brief Read the tap event status on axis X
3056 * @param[in] sensorInterface Pointer to sensor interface
3057 * @param[out] tapXAxis The returned tap event status on axis X
3058 * @retval Error code
3059 */
ISDS_isTapEventXAxis(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapXAxis)3060 int8_t ISDS_isTapEventXAxis(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapXAxis)
3061 {
3062 ISDS_tapEvent_t status;
3063
3064 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3065 {
3066 return WE_FAIL;
3067 }
3068
3069 *tapXAxis = (ISDS_state_t) status.tapXAxis;
3070
3071 return WE_SUCCESS;
3072 }
3073
3074 /**
3075 * @brief Read the tap event status on axis Y
3076 * @param[in] sensorInterface Pointer to sensor interface
3077 * @param[out] tapYAxis The returned tap event status on axis Y
3078 * @retval Error code
3079 */
ISDS_isTapEventYAxis(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapYAxis)3080 int8_t ISDS_isTapEventYAxis(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapYAxis)
3081 {
3082 ISDS_tapEvent_t status;
3083
3084 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3085 {
3086 return WE_FAIL;
3087 }
3088
3089 *tapYAxis = (ISDS_state_t) status.tapYAxis;
3090
3091 return WE_SUCCESS;
3092 }
3093
3094 /**
3095 * @brief Read the tap event status on axis Z
3096 * @param[in] sensorInterface Pointer to sensor interface
3097 * @param[out] tapZAxis The returned tap event status on axis Z
3098 * @retval Error code
3099 */
ISDS_isTapEventZAxis(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapZAxis)3100 int8_t ISDS_isTapEventZAxis(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapZAxis)
3101 {
3102 ISDS_tapEvent_t status;
3103
3104 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3105 {
3106 return WE_FAIL;
3107 }
3108
3109 *tapZAxis = (ISDS_state_t) status.tapZAxis;
3110
3111 return WE_SUCCESS;
3112 }
3113
3114 /**
3115 * @brief Read the double-tap event status
3116 * @param[in] sensorInterface Pointer to sensor interface
3117 * @param[out] doubleTap The returned double-tap event status
3118 * @retval Error code
3119 */
ISDS_isDoubleTapEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * doubleTap)3120 int8_t ISDS_isDoubleTapEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *doubleTap)
3121 {
3122 ISDS_tapEvent_t status;
3123
3124 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3125 {
3126 return WE_FAIL;
3127 }
3128
3129 *doubleTap = (ISDS_state_t) status.doubleState;
3130
3131 return WE_SUCCESS;
3132 }
3133
3134 /**
3135 * @brief Read the single-tap event status
3136 * @param[in] sensorInterface Pointer to sensor interface
3137 * @param[out] singleTap The returned single-tap event status
3138 * @retval Error code
3139 */
ISDS_isSingleTapEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * singleTap)3140 int8_t ISDS_isSingleTapEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *singleTap)
3141 {
3142 ISDS_tapEvent_t status;
3143
3144 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3145 {
3146 return WE_FAIL;
3147 }
3148
3149 *singleTap = (ISDS_state_t) status.singleState;
3150
3151 return WE_SUCCESS;
3152 }
3153
3154 /**
3155 * @brief Read the tap event acceleration sign (direction of tap event)
3156 * @param[in] sensorInterface Pointer to sensor interface
3157 * @param[out] tapSign The returned tap event acceleration sign
3158 * @retval Error code
3159 */
ISDS_getTapSign(WE_sensorInterface_t * sensorInterface,ISDS_tapSign_t * tapSign)3160 int8_t ISDS_getTapSign(WE_sensorInterface_t* sensorInterface, ISDS_tapSign_t *tapSign)
3161 {
3162 ISDS_tapEvent_t status;
3163
3164 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_EVENT_REG, 1, (uint8_t *) &status))
3165 {
3166 return WE_FAIL;
3167 }
3168
3169 *tapSign = (ISDS_tapSign_t) status.tapSign;
3170
3171 return WE_SUCCESS;
3172 }
3173
3174
3175 /* ISDS_6D_EVENT_REG */
3176
3177 /**
3178 * @brief Read register containing info on 6D orientation change event
3179 * @param[in] sensorInterface Pointer to sensor interface
3180 * @param[out] status The returned 6D event status
3181 * @retval Error code
3182 */
ISDS_get6dEventRegister(WE_sensorInterface_t * sensorInterface,ISDS_6dEvent_t * status)3183 int8_t ISDS_get6dEventRegister(WE_sensorInterface_t* sensorInterface, ISDS_6dEvent_t *status)
3184 {
3185 return ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) status);
3186 }
3187
3188 /**
3189 * @brief Check if 6D orientation change event has occurred
3190 * @param[in] sensorInterface Pointer to sensor interface
3191 * @param[out] orientationChanged The returned 6D orientation change event status
3192 * @retval Error code
3193 */
ISDS_has6dOrientationChanged(WE_sensorInterface_t * sensorInterface,ISDS_state_t * orientationChanged)3194 int8_t ISDS_has6dOrientationChanged(WE_sensorInterface_t* sensorInterface, ISDS_state_t *orientationChanged)
3195 {
3196 ISDS_6dEvent_t status;
3197
3198 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3199 {
3200 return WE_FAIL;
3201 }
3202
3203 *orientationChanged = (ISDS_state_t) status.sixDChange;
3204
3205 return WE_SUCCESS;
3206 }
3207
3208 /**
3209 * @brief Read the XL over threshold state (6D orientation)
3210 * @param[in] sensorInterface Pointer to sensor interface
3211 * @param[out] xlOverThreshold The returned XL over threshold state
3212 * @retval Error code
3213 */
ISDS_isXLOverThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t * xlOverThreshold)3214 int8_t ISDS_isXLOverThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t *xlOverThreshold)
3215 {
3216 ISDS_6dEvent_t status;
3217
3218 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3219 {
3220 return WE_FAIL;
3221 }
3222
3223 *xlOverThreshold = (ISDS_state_t) status.xlOverThreshold;
3224
3225 return WE_SUCCESS;
3226 }
3227
3228 /**
3229 * @brief Read the XH over threshold state (6D orientation)
3230 * @param[in] sensorInterface Pointer to sensor interface
3231 * @param[out] xhOverThreshold The returned XH over threshold state
3232 * @retval Error code
3233 */
ISDS_isXHOverThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t * xhOverThreshold)3234 int8_t ISDS_isXHOverThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t *xhOverThreshold)
3235 {
3236 ISDS_6dEvent_t status;
3237
3238 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3239 {
3240 return WE_FAIL;
3241 }
3242
3243 *xhOverThreshold = (ISDS_state_t) status.xhOverThreshold;
3244
3245 return WE_SUCCESS;
3246 }
3247
3248 /**
3249 * @brief Read the YL over threshold state (6D orientation)
3250 * @param[in] sensorInterface Pointer to sensor interface
3251 * @param[out] ylOverThreshold The returned YL over threshold state
3252 * @retval Error code
3253 */
ISDS_isYLOverThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t * ylOverThreshold)3254 int8_t ISDS_isYLOverThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t *ylOverThreshold)
3255 {
3256 ISDS_6dEvent_t status;
3257
3258 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3259 {
3260 return WE_FAIL;
3261 }
3262
3263 *ylOverThreshold = (ISDS_state_t) status.ylOverThreshold;
3264
3265 return WE_SUCCESS;
3266 }
3267
3268 /**
3269 * @brief Read the YH over threshold state (6D orientation)
3270 * @param[in] sensorInterface Pointer to sensor interface
3271 * @param[out] yhOverThreshold The returned YH over threshold state
3272 * @retval Error code
3273 */
ISDS_isYHOverThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t * yhOverThreshold)3274 int8_t ISDS_isYHOverThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t *yhOverThreshold)
3275 {
3276 ISDS_6dEvent_t status;
3277
3278 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3279 {
3280 return WE_FAIL;
3281 }
3282
3283 *yhOverThreshold = (ISDS_state_t) status.yhOverThreshold;
3284
3285 return WE_SUCCESS;
3286 }
3287
3288 /**
3289 * @brief Read the ZL over threshold state (6D orientation)
3290 * @param[in] sensorInterface Pointer to sensor interface
3291 * @param[out] zlOverThreshold The returned ZL over threshold state
3292 * @retval Error code
3293 */
ISDS_isZLOverThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t * zlOverThreshold)3294 int8_t ISDS_isZLOverThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t *zlOverThreshold)
3295 {
3296 ISDS_6dEvent_t status;
3297
3298 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3299 {
3300 return WE_FAIL;
3301 }
3302
3303 *zlOverThreshold = (ISDS_state_t) status.zlOverThreshold;
3304
3305 return WE_SUCCESS;
3306 }
3307
3308 /**
3309 * @brief Read the ZH over threshold state (6D orientation)
3310 * @param[in] sensorInterface Pointer to sensor interface
3311 * @param[out] zhOverThreshold The returned ZH over threshold state
3312 * @retval Error code
3313 */
ISDS_isZHOverThreshold(WE_sensorInterface_t * sensorInterface,ISDS_state_t * zhOverThreshold)3314 int8_t ISDS_isZHOverThreshold(WE_sensorInterface_t* sensorInterface, ISDS_state_t *zhOverThreshold)
3315 {
3316 ISDS_6dEvent_t status;
3317
3318 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3319 {
3320 return WE_FAIL;
3321 }
3322
3323 *zhOverThreshold = (ISDS_state_t) status.zhOverThreshold;
3324
3325 return WE_SUCCESS;
3326 }
3327
3328 /**
3329 * @brief Read the data enable (DEN) data ready signal.
3330 * It is set high when data output is related to the data coming from a DEN active condition.
3331 * @param[in] sensorInterface Pointer to sensor interface
3332 * @param[out] dataReady The returned DEN data ready signal state
3333 * @retval Error code
3334 */
ISDS_isDataEnableDataReady(WE_sensorInterface_t * sensorInterface,ISDS_state_t * dataReady)3335 int8_t ISDS_isDataEnableDataReady(WE_sensorInterface_t* sensorInterface, ISDS_state_t *dataReady)
3336 {
3337 ISDS_6dEvent_t status;
3338
3339 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_6D_EVENT_REG, 1, (uint8_t *) &status))
3340 {
3341 return WE_FAIL;
3342 }
3343
3344 *dataReady = (ISDS_state_t) status.dataEnableDataReady;
3345
3346 return WE_SUCCESS;
3347 }
3348
3349
3350 /* ISDS_STATUS_REG */
3351
3352 /**
3353 * @brief Get overall sensor status
3354 * @param[in] sensorInterface Pointer to sensor interface
3355 * @param[out] status The returned sensor event data
3356 * @retval Error code
3357 */
ISDS_getStatusRegister(WE_sensorInterface_t * sensorInterface,ISDS_status_t * status)3358 int8_t ISDS_getStatusRegister(WE_sensorInterface_t* sensorInterface, ISDS_status_t *status)
3359 {
3360 return ISDS_ReadReg(sensorInterface, ISDS_STATUS_REG, 1, (uint8_t *) status);
3361 }
3362
3363 /**
3364 * @brief Check if new acceleration samples are available
3365 * @param[in] sensorInterface Pointer to sensor interface
3366 * @param[out] dataReady The returned data-ready state
3367 * @retval Error code
3368 */
ISDS_isAccelerationDataReady(WE_sensorInterface_t * sensorInterface,ISDS_state_t * dataReady)3369 int8_t ISDS_isAccelerationDataReady(WE_sensorInterface_t* sensorInterface, ISDS_state_t *dataReady)
3370 {
3371 ISDS_status_t statusRegister;
3372
3373 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_STATUS_REG, 1, (uint8_t *) &statusRegister))
3374 {
3375 return WE_FAIL;
3376 }
3377
3378 *dataReady = (ISDS_state_t) statusRegister.accDataReady;
3379
3380 return WE_SUCCESS;
3381 }
3382
3383 /**
3384 * @brief Check if new gyroscope samples are available
3385 * @param[in] sensorInterface Pointer to sensor interface
3386 * @param[out] dataReady The returned data-ready state
3387 * @retval Error code
3388 */
ISDS_isGyroscopeDataReady(WE_sensorInterface_t * sensorInterface,ISDS_state_t * dataReady)3389 int8_t ISDS_isGyroscopeDataReady(WE_sensorInterface_t* sensorInterface, ISDS_state_t *dataReady)
3390 {
3391 ISDS_status_t statusRegister;
3392
3393 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_STATUS_REG, 1, (uint8_t *) &statusRegister))
3394 {
3395 return WE_FAIL;
3396 }
3397
3398 *dataReady = (ISDS_state_t) statusRegister.gyroDataReady;
3399
3400 return WE_SUCCESS;
3401 }
3402
3403 /**
3404 * @brief Check if new temperature samples are available
3405 * @param[in] sensorInterface Pointer to sensor interface
3406 * @param[out] dataReady The returned data-ready state
3407 * @retval Error code
3408 */
ISDS_isTemperatureDataReady(WE_sensorInterface_t * sensorInterface,ISDS_state_t * dataReady)3409 int8_t ISDS_isTemperatureDataReady(WE_sensorInterface_t* sensorInterface, ISDS_state_t *dataReady)
3410 {
3411 ISDS_status_t statusRegister;
3412
3413 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_STATUS_REG, 1, (uint8_t *) &statusRegister))
3414 {
3415 return WE_FAIL;
3416 }
3417
3418 *dataReady = (ISDS_state_t) statusRegister.tempDataReady;
3419
3420 return WE_SUCCESS;
3421 }
3422
3423 /**
3424 * @brief Check if new temperature, gyroscope and acceleration samples are available
3425 * @param[in] sensorInterface Pointer to sensor interface
3426 * @param[out] temp_state The returned data-ready state for the temperature
3427 * @param[out] acc_state The returned data-ready state for the acceleration
3428 * @param[out] gyro_state The returned data-ready state for the gyroscope
3429 * @retval Error code
3430 */
ISDS_isDataReady(WE_sensorInterface_t * sensorInterface,ISDS_state_t * temp_state,ISDS_state_t * acc_state,ISDS_state_t * gyro_state)3431 int8_t ISDS_isDataReady(WE_sensorInterface_t* sensorInterface, ISDS_state_t *temp_state, ISDS_state_t *acc_state, ISDS_state_t *gyro_state)
3432 {
3433 ISDS_status_t statusRegister;
3434
3435 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_STATUS_REG, 1, (uint8_t *) &statusRegister))
3436 {
3437 return WE_FAIL;
3438 }
3439
3440 if(temp_state != NULL)
3441 {
3442 *temp_state = (ISDS_state_t) statusRegister.tempDataReady;
3443 }
3444 if(acc_state != NULL)
3445 {
3446 *acc_state = (ISDS_state_t) statusRegister.accDataReady;
3447 }
3448 if(gyro_state != NULL)
3449 {
3450 *gyro_state = (ISDS_state_t) statusRegister.gyroDataReady;
3451 }
3452
3453 return WE_SUCCESS;
3454 }
3455
3456
3457 /* ISDS_FIFO_STATUS_1_REG */
3458 /* ISDS_FIFO_STATUS_2_REG */
3459 /* ISDS_FIFO_STATUS_3_REG */
3460 /* ISDS_FIFO_STATUS_4_REG */
3461
3462 /**
3463 * @brief Get overall FIFO status
3464 *
3465 * This is a convenience function querying all FIFO status registers in one read operation.
3466 *
3467 * @param[in] sensorInterface Pointer to sensor interface
3468 * @param[out] status The returned FIFO status flags register
3469 * @param[out] fillLevel The returned FIFO fill level (0-2047)
3470 * @param[out] fifoPattern Word of recursive pattern read at the next read
3471 * @retval Error code
3472 */
ISDS_getFifoStatus(WE_sensorInterface_t * sensorInterface,ISDS_fifoStatus2_t * status,uint16_t * fillLevel,uint16_t * fifoPattern)3473 int8_t ISDS_getFifoStatus(WE_sensorInterface_t* sensorInterface, ISDS_fifoStatus2_t *status, uint16_t *fillLevel, uint16_t *fifoPattern)
3474 {
3475 uint8_t tmp[4];
3476 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_1_REG, 4, tmp))
3477 {
3478 return WE_FAIL;
3479 }
3480
3481 ISDS_fifoStatus1_t *fifoStatus1 = (ISDS_fifoStatus1_t *) tmp;
3482 ISDS_fifoStatus2_t *fifoStatus2 = (ISDS_fifoStatus2_t *) tmp + 1;
3483 ISDS_fifoStatus3_t *fifoStatus3 = (ISDS_fifoStatus3_t *) tmp + 2;
3484 ISDS_fifoStatus4_t *fifoStatus4 = (ISDS_fifoStatus4_t *) tmp + 3;
3485
3486 *status = *(ISDS_fifoStatus2_t*) fifoStatus2;
3487
3488 *fillLevel = ((uint16_t) fifoStatus1->fifoFillLevelLsb) |
3489 (((uint16_t) (fifoStatus2->fifoFillLevelMsb & 0x07)) << 8);
3490
3491 *fifoPattern = ((uint16_t) fifoStatus3->fifoPatternLsb) |
3492 (((uint16_t) (fifoStatus4->fifoPatternMsb & 0x03)) << 8);
3493
3494 return WE_SUCCESS;
3495 }
3496
3497 /**
3498 * @brief Get FIFO status flags register
3499 * @param[in] sensorInterface Pointer to sensor interface
3500 * @param[out] status The returned FIFO status flags register
3501 * @retval Error code
3502 */
ISDS_getFifoStatus2Register(WE_sensorInterface_t * sensorInterface,ISDS_fifoStatus2_t * status)3503 int8_t ISDS_getFifoStatus2Register(WE_sensorInterface_t* sensorInterface, ISDS_fifoStatus2_t *status)
3504 {
3505 return ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) status);
3506 }
3507
3508 /**
3509 * @brief Read the FIFO fill level
3510 * @param[in] sensorInterface Pointer to sensor interface
3511 * @param[out] fillLevel The returned FIFO fill level (0-2047)
3512 * @retval Error code
3513 */
ISDS_getFifoFillLevel(WE_sensorInterface_t * sensorInterface,uint16_t * fillLevel)3514 int8_t ISDS_getFifoFillLevel(WE_sensorInterface_t* sensorInterface, uint16_t *fillLevel)
3515 {
3516 uint8_t tmp[2];
3517 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_1_REG, 2, tmp))
3518 {
3519 return WE_FAIL;
3520 }
3521
3522 ISDS_fifoStatus1_t *fifoStatus1 = (ISDS_fifoStatus1_t *) tmp;
3523 ISDS_fifoStatus2_t *fifoStatus2 = (ISDS_fifoStatus2_t *) tmp + 1;
3524
3525 *fillLevel = ((uint16_t) fifoStatus1->fifoFillLevelLsb) |
3526 (((uint16_t) (fifoStatus2->fifoFillLevelMsb & 0x07)) << 8);
3527
3528 return WE_SUCCESS;
3529 }
3530
3531 /**
3532 * @brief Check if the FIFO is empty
3533 * @param[in] sensorInterface Pointer to sensor interface
3534 * @param[out] empty FIFO empty state
3535 * @retval Error code
3536 */
ISDS_isFifoEmpty(WE_sensorInterface_t * sensorInterface,ISDS_state_t * empty)3537 int8_t ISDS_isFifoEmpty(WE_sensorInterface_t* sensorInterface, ISDS_state_t *empty)
3538 {
3539 ISDS_fifoStatus2_t fifoStatus2;
3540
3541 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3542 {
3543 return WE_FAIL;
3544 }
3545
3546 *empty = (ISDS_state_t) fifoStatus2.fifoEmptyState;
3547
3548 return WE_SUCCESS;
3549 }
3550
3551 /**
3552 * @brief Check if the FIFO is full
3553 * @param[in] sensorInterface Pointer to sensor interface
3554 * @param[out] full FIFO full state
3555 * @retval Error code
3556 */
ISDS_isFifoFull(WE_sensorInterface_t * sensorInterface,ISDS_state_t * full)3557 int8_t ISDS_isFifoFull(WE_sensorInterface_t* sensorInterface, ISDS_state_t *full)
3558 {
3559 ISDS_fifoStatus2_t fifoStatus2;
3560
3561 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3562 {
3563 return WE_FAIL;
3564 }
3565
3566 *full = (ISDS_state_t) fifoStatus2.fifoFullSmartState;
3567
3568 return WE_SUCCESS;
3569 }
3570
3571 /**
3572 * @brief Check if a FIFO overrun has occurred
3573 * @param[in] sensorInterface Pointer to sensor interface
3574 * @param[out] overrun FIFO overrun state
3575 * @retval Error code
3576 */
ISDS_getFifoOverrunState(WE_sensorInterface_t * sensorInterface,ISDS_state_t * overrun)3577 int8_t ISDS_getFifoOverrunState(WE_sensorInterface_t* sensorInterface, ISDS_state_t *overrun)
3578 {
3579 ISDS_fifoStatus2_t fifoStatus2;
3580
3581 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3582 {
3583 return WE_FAIL;
3584 }
3585
3586 *overrun = (ISDS_state_t) fifoStatus2.fifoOverrunState;
3587
3588 return WE_SUCCESS;
3589 }
3590
3591 /**
3592 * @brief Check if the FIFO fill threshold has been reached
3593 * @param[in] sensorInterface Pointer to sensor interface
3594 * @param[out] threshReached FIFO threshold status bit
3595 * @retval Error code
3596 */
ISDS_isFifoThresholdReached(WE_sensorInterface_t * sensorInterface,ISDS_state_t * threshReached)3597 int8_t ISDS_isFifoThresholdReached(WE_sensorInterface_t* sensorInterface, ISDS_state_t *threshReached)
3598 {
3599 ISDS_fifoStatus2_t fifoStatus2;
3600
3601 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3602 {
3603 return WE_FAIL;
3604 }
3605
3606 *threshReached = (ISDS_state_t) fifoStatus2.fifoThresholdState;
3607
3608 return WE_SUCCESS;
3609 }
3610
3611 /**
3612 * @brief Get the word of recursive pattern read at the next read
3613 * @param[in] sensorInterface Pointer to sensor interface
3614 * @param[out] fifoPattern Word of recursive pattern read at the next read
3615 * @retval Error code
3616 */
ISDS_getFifoPattern(WE_sensorInterface_t * sensorInterface,uint16_t * fifoPattern)3617 int8_t ISDS_getFifoPattern(WE_sensorInterface_t* sensorInterface, uint16_t *fifoPattern)
3618 {
3619 uint8_t tmp[2];
3620 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_3_REG, 2, tmp))
3621 {
3622 return WE_FAIL;
3623 }
3624
3625 ISDS_fifoStatus3_t *fifoStatus3 = (ISDS_fifoStatus3_t *) tmp;
3626 ISDS_fifoStatus4_t *fifoStatus4 = (ISDS_fifoStatus4_t *) tmp + 1;
3627
3628 *fifoPattern = ((uint16_t) fifoStatus3->fifoPatternLsb) |
3629 (((uint16_t) (fifoStatus4->fifoPatternMsb & 0x03)) << 8);
3630
3631 return WE_SUCCESS;
3632 }
3633
3634
3635 /* ISDS_FUNC_SRC_1_REG */
3636
3637 /**
3638 * @brief Check if a tilt event has occurred
3639 * @param[in] sensorInterface Pointer to sensor interface
3640 * @param[out] tiltEvent Tilt event state
3641 * @retval Error code
3642 */
ISDS_isTiltEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tiltEvent)3643 int8_t ISDS_isTiltEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tiltEvent)
3644 {
3645 ISDS_funcSrc1_t funcSrc1;
3646
3647 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FUNC_SRC_1_REG, 1, (uint8_t *) &funcSrc1))
3648 {
3649 return WE_FAIL;
3650 }
3651
3652 *tiltEvent = (ISDS_state_t) funcSrc1.tiltState;
3653
3654 return WE_SUCCESS;
3655 }
3656
3657
3658 /* ISDS_TAP_CFG_REG */
3659
3660 /**
3661 * @brief Enable/disable latched interrupts
3662 * @param[in] sensorInterface Pointer to sensor interface
3663 * @param[in] lir Latched interrupts state
3664 * @retval Error code
3665 */
ISDS_enableLatchedInterrupt(WE_sensorInterface_t * sensorInterface,ISDS_state_t lir)3666 int8_t ISDS_enableLatchedInterrupt(WE_sensorInterface_t* sensorInterface, ISDS_state_t lir)
3667 {
3668 ISDS_tapCfg_t tapCfg;
3669
3670 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3671 {
3672 return WE_FAIL;
3673 }
3674
3675 tapCfg.latchedInterrupt = lir;
3676
3677 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3678 }
3679
3680 /**
3681 * @brief Read the latched interrupts state [enabled, disabled]
3682 * @param[in] sensorInterface Pointer to sensor interface
3683 * @param[out] lir The returned latched interrupts state
3684 * @retval Error code
3685 */
ISDS_isLatchedInterruptEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * lir)3686 int8_t ISDS_isLatchedInterruptEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *lir)
3687 {
3688 ISDS_tapCfg_t tapCfg;
3689
3690 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3691 {
3692 return WE_FAIL;
3693 }
3694
3695 *lir = (ISDS_state_t) tapCfg.latchedInterrupt;
3696
3697 return WE_SUCCESS;
3698 }
3699
3700 /**
3701 * @brief Enable/disable tap recognition in X direction
3702 * @param[in] sensorInterface Pointer to sensor interface
3703 * @param[in] tapX Tap X direction state
3704 * @retval Error code
3705 */
ISDS_enableTapX(WE_sensorInterface_t * sensorInterface,ISDS_state_t tapX)3706 int8_t ISDS_enableTapX(WE_sensorInterface_t* sensorInterface, ISDS_state_t tapX)
3707 {
3708 ISDS_tapCfg_t tapCfg;
3709
3710 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3711 {
3712 return WE_FAIL;
3713 }
3714
3715 tapCfg.enTapX = tapX;
3716
3717 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3718 }
3719
3720 /**
3721 * @brief Check if detection of tap events in X direction is enabled
3722 * @param[in] sensorInterface Pointer to sensor interface
3723 * @param[out] tapX The returned tap X direction state
3724 * @retval Error code
3725 */
ISDS_isTapXEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapX)3726 int8_t ISDS_isTapXEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapX)
3727 {
3728 ISDS_tapCfg_t tapCfg;
3729
3730 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3731 {
3732 return WE_FAIL;
3733 }
3734
3735 *tapX = (ISDS_state_t) tapCfg.enTapX;
3736
3737 return WE_SUCCESS;
3738 }
3739
3740 /**
3741 * @brief Enable/disable tap recognition in Y direction
3742 * @param[in] sensorInterface Pointer to sensor interface
3743 * @param[in] tapY Tap Y direction state
3744 * @retval Error code
3745 */
ISDS_enableTapY(WE_sensorInterface_t * sensorInterface,ISDS_state_t tapY)3746 int8_t ISDS_enableTapY(WE_sensorInterface_t* sensorInterface, ISDS_state_t tapY)
3747 {
3748 ISDS_tapCfg_t tapCfg;
3749
3750 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3751 {
3752 return WE_FAIL;
3753 }
3754
3755 tapCfg.enTapY = tapY;
3756
3757 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3758 }
3759
3760 /**
3761 * @brief Check if detection of tap events in Y direction is enabled
3762 * @param[in] sensorInterface Pointer to sensor interface
3763 * @param[out] tapY The returned tap Y direction state
3764 * @retval Error code
3765 */
ISDS_isTapYEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapY)3766 int8_t ISDS_isTapYEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapY)
3767 {
3768 ISDS_tapCfg_t tapCfg;
3769
3770 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3771 {
3772 return WE_FAIL;
3773 }
3774
3775 *tapY = (ISDS_state_t) tapCfg.enTapY;
3776
3777 return WE_SUCCESS;
3778 }
3779
3780 /**
3781 * @brief Enable/disable tap recognition in Z direction
3782 * @param[in] sensorInterface Pointer to sensor interface
3783 * @param[in] tapZ Tap Z direction state
3784 * @retval Error code
3785 */
ISDS_enableTapZ(WE_sensorInterface_t * sensorInterface,ISDS_state_t tapZ)3786 int8_t ISDS_enableTapZ(WE_sensorInterface_t* sensorInterface, ISDS_state_t tapZ)
3787 {
3788 ISDS_tapCfg_t tapCfg;
3789
3790 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3791 {
3792 return WE_FAIL;
3793 }
3794
3795 tapCfg.enTapZ = tapZ;
3796
3797 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3798 }
3799
3800 /**
3801 * @brief Check if detection of tap events in Z direction is enabled
3802 * @param[in] sensorInterface Pointer to sensor interface
3803 * @param[out] tapZ The returned tap Z direction state
3804 * @retval Error code
3805 */
ISDS_isTapZEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapZ)3806 int8_t ISDS_isTapZEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapZ)
3807 {
3808 ISDS_tapCfg_t tapCfg;
3809
3810 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3811 {
3812 return WE_FAIL;
3813 }
3814
3815 *tapZ = (ISDS_state_t) tapCfg.enTapZ;
3816
3817 return WE_SUCCESS;
3818 }
3819
3820 /**
3821 * @brief Set activity filter (HPF or SLOPE filter selection on wake-up and activity/inactivity functions)
3822 * @param[in] sensorInterface Pointer to sensor interface
3823 * @param[in] filter Activity filter
3824 * @retval Error code
3825 */
ISDS_setActivityFilter(WE_sensorInterface_t * sensorInterface,ISDS_activityFilter_t filter)3826 int8_t ISDS_setActivityFilter(WE_sensorInterface_t* sensorInterface, ISDS_activityFilter_t filter)
3827 {
3828 ISDS_tapCfg_t tapCfg;
3829
3830 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3831 {
3832 return WE_FAIL;
3833 }
3834
3835 tapCfg.filterSelection = filter;
3836
3837 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3838 }
3839
3840 /**
3841 * @brief Read activity filter (HPF or SLOPE filter selection on wake-up and activity/inactivity functions)
3842 * @param[in] sensorInterface Pointer to sensor interface
3843 * @param[out] filter The returned activity filter
3844 * @retval Error code
3845 */
ISDS_getActivityFilter(WE_sensorInterface_t * sensorInterface,ISDS_activityFilter_t * filter)3846 int8_t ISDS_getActivityFilter(WE_sensorInterface_t* sensorInterface, ISDS_activityFilter_t *filter)
3847 {
3848 ISDS_tapCfg_t tapCfg;
3849
3850 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3851 {
3852 return WE_FAIL;
3853 }
3854
3855 *filter = (ISDS_activityFilter_t) tapCfg.filterSelection;
3856
3857 return WE_SUCCESS;
3858 }
3859
3860 /**
3861 * @brief Set inactivity function
3862 * @param[in] sensorInterface Pointer to sensor interface
3863 * @param[in] function Inactivity function
3864 * @retval Error code
3865 */
ISDS_setInactivityFunction(WE_sensorInterface_t * sensorInterface,ISDS_inactivityFunction_t function)3866 int8_t ISDS_setInactivityFunction(WE_sensorInterface_t* sensorInterface, ISDS_inactivityFunction_t function)
3867 {
3868 ISDS_tapCfg_t tapCfg;
3869
3870 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3871 {
3872 return WE_FAIL;
3873 }
3874
3875 tapCfg.enInactivity = function;
3876
3877 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3878 }
3879
3880 /**
3881 * @brief Read inactivity function
3882 * @param[in] sensorInterface Pointer to sensor interface
3883 * @param[out] function The returned inactivity function
3884 * @retval Error code
3885 */
ISDS_getInactivityFunction(WE_sensorInterface_t * sensorInterface,ISDS_inactivityFunction_t * function)3886 int8_t ISDS_getInactivityFunction(WE_sensorInterface_t* sensorInterface, ISDS_inactivityFunction_t *function)
3887 {
3888 ISDS_tapCfg_t tapCfg;
3889
3890 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3891 {
3892 return WE_FAIL;
3893 }
3894
3895 *function = (ISDS_inactivityFunction_t) tapCfg.enInactivity;
3896
3897 return WE_SUCCESS;
3898 }
3899
3900 /**
3901 * @brief Enable/disable interrupts
3902 * @param[in] sensorInterface Pointer to sensor interface
3903 * @param[in] interruptsEnable Interrupts enable state
3904 * @retval Error code
3905 */
ISDS_enableInterrupts(WE_sensorInterface_t * sensorInterface,ISDS_state_t interruptsEnable)3906 int8_t ISDS_enableInterrupts(WE_sensorInterface_t* sensorInterface, ISDS_state_t interruptsEnable)
3907 {
3908 ISDS_tapCfg_t tapCfg;
3909
3910 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3911 {
3912 return WE_FAIL;
3913 }
3914
3915 tapCfg.enInterrupts = interruptsEnable;
3916
3917 return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3918 }
3919
3920 /**
3921 * @brief Check if interrupts are enabled
3922 * @param[in] sensorInterface Pointer to sensor interface
3923 * @param[out] interruptsEnable The returned interrupts enable state.
3924 * @retval Error code
3925 */
ISDS_areInterruptsEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * interruptsEnable)3926 int8_t ISDS_areInterruptsEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *interruptsEnable)
3927 {
3928 ISDS_tapCfg_t tapCfg;
3929
3930 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3931 {
3932 return WE_FAIL;
3933 }
3934
3935 *interruptsEnable = (ISDS_state_t) tapCfg.enInterrupts;
3936
3937 return WE_SUCCESS;
3938 }
3939
3940
3941 /* ISDS_TAP_THS_6D_REG */
3942
3943 /**
3944 * @brief Set the tap threshold
3945 * @param[in] sensorInterface Pointer to sensor interface
3946 * @param[in] tapThreshold Tap threshold (5 bits)
3947 * @retval Error code
3948 */
ISDS_setTapThreshold(WE_sensorInterface_t * sensorInterface,uint8_t tapThreshold)3949 int8_t ISDS_setTapThreshold(WE_sensorInterface_t* sensorInterface, uint8_t tapThreshold)
3950 {
3951 ISDS_tapThs6d_t tapThs6d;
3952
3953 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3954 {
3955 return WE_FAIL;
3956 }
3957
3958 tapThs6d.tapThreshold = (tapThreshold & 0x1F);
3959
3960 return ISDS_WriteReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d);
3961 }
3962
3963 /**
3964 * @brief Read the tap threshold
3965 * @param[in] sensorInterface Pointer to sensor interface
3966 * @param[out] tapThreshold The returned tap threshold
3967 * @retval Error code
3968 */
ISDS_getTapThreshold(WE_sensorInterface_t * sensorInterface,uint8_t * tapThreshold)3969 int8_t ISDS_getTapThreshold(WE_sensorInterface_t* sensorInterface, uint8_t *tapThreshold)
3970 {
3971 ISDS_tapThs6d_t tapThs6d;
3972
3973 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3974 {
3975 return WE_FAIL;
3976 }
3977
3978 *tapThreshold = tapThs6d.tapThreshold;
3979
3980 return WE_SUCCESS;
3981 }
3982
3983 /**
3984 * @brief Set the 6D orientation detection threshold (degrees)
3985 * @param[in] sensorInterface Pointer to sensor interface
3986 * @param[in] threshold6D 6D orientation detection threshold
3987 * @retval Error code
3988 */
ISDS_set6DThreshold(WE_sensorInterface_t * sensorInterface,ISDS_sixDThreshold_t threshold6D)3989 int8_t ISDS_set6DThreshold(WE_sensorInterface_t* sensorInterface, ISDS_sixDThreshold_t threshold6D)
3990 {
3991 ISDS_tapThs6d_t tapThs6d;
3992
3993 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3994 {
3995 return WE_FAIL;
3996 }
3997
3998 tapThs6d.sixDThreshold = threshold6D;
3999
4000 return ISDS_WriteReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d);
4001 }
4002
4003 /**
4004 * @brief Read the 6D orientation detection threshold (degrees)
4005 * @param[in] sensorInterface Pointer to sensor interface
4006 * @param[out] threshold6D The returned 6D orientation detection threshold
4007 * @retval Error code
4008 */
ISDS_get6DThreshold(WE_sensorInterface_t * sensorInterface,ISDS_sixDThreshold_t * threshold6D)4009 int8_t ISDS_get6DThreshold(WE_sensorInterface_t* sensorInterface, ISDS_sixDThreshold_t *threshold6D)
4010 {
4011 ISDS_tapThs6d_t tapThs6d;
4012
4013 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
4014 {
4015 return WE_FAIL;
4016 }
4017
4018 *threshold6D = (ISDS_sixDThreshold_t) tapThs6d.sixDThreshold;
4019
4020 return WE_SUCCESS;
4021 }
4022
4023 /**
4024 * @brief Enable/disable 4D orientation detection
4025 * @param[in] sensorInterface Pointer to sensor interface
4026 * @param[in] detection4D The 4D orientation detection enable state
4027 * @retval Error code
4028 */
ISDS_enable4DDetection(WE_sensorInterface_t * sensorInterface,ISDS_state_t detection4D)4029 int8_t ISDS_enable4DDetection(WE_sensorInterface_t* sensorInterface, ISDS_state_t detection4D)
4030 {
4031 ISDS_tapThs6d_t tapThs6d;
4032
4033 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
4034 {
4035 return WE_FAIL;
4036 }
4037
4038 tapThs6d.fourDDetectionEnabled = detection4D;
4039
4040 return ISDS_WriteReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d);
4041 }
4042
4043 /**
4044 * @brief Check if 4D orientation detection is enabled
4045 * @param[in] sensorInterface Pointer to sensor interface
4046 * @param[out] detection4D The returned 4D orientation detection enable state
4047 * @retval Error code
4048 */
ISDS_is4DDetectionEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * detection4D)4049 int8_t ISDS_is4DDetectionEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *detection4D)
4050 {
4051 ISDS_tapThs6d_t tapThs6d;
4052
4053 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
4054 {
4055 return WE_FAIL;
4056 }
4057
4058 *detection4D = (ISDS_state_t) tapThs6d.fourDDetectionEnabled;
4059
4060 return WE_SUCCESS;
4061 }
4062
4063
4064 /* ISDS_INT_DUR2_REG */
4065
4066 /**
4067 * @brief Set the maximum duration time gap for double-tap recognition (LATENCY)
4068 * @param[in] sensorInterface Pointer to sensor interface
4069 * @param[in] latencyTime Latency value (4 bits)
4070 * @retval Error code
4071 */
ISDS_setTapLatencyTime(WE_sensorInterface_t * sensorInterface,uint8_t latencyTime)4072 int8_t ISDS_setTapLatencyTime(WE_sensorInterface_t* sensorInterface, uint8_t latencyTime)
4073 {
4074 ISDS_intDur2_t intDuration;
4075
4076 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4077 {
4078 return WE_FAIL;
4079 }
4080
4081 intDuration.latency = (latencyTime & 0x0F);
4082
4083 return ISDS_WriteReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration);
4084 }
4085
4086 /**
4087 * @brief Read the maximum duration time gap for double-tap recognition (LATENCY)
4088 * @param[in] sensorInterface Pointer to sensor interface
4089 * @param[out] latencyTime The returned latency time
4090 * @retval Error code
4091 */
ISDS_getTapLatencyTime(WE_sensorInterface_t * sensorInterface,uint8_t * latencyTime)4092 int8_t ISDS_getTapLatencyTime(WE_sensorInterface_t* sensorInterface, uint8_t *latencyTime)
4093 {
4094 ISDS_intDur2_t intDuration;
4095
4096 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4097 {
4098 return WE_FAIL;
4099 }
4100
4101 *latencyTime = intDuration.latency;
4102
4103 return WE_SUCCESS;
4104 }
4105
4106 /**
4107 * @brief Set the expected quiet time after a tap detection (QUIET)
4108 * @param[in] sensorInterface Pointer to sensor interface
4109 * @param[in] quietTime Quiet time value (2 bits)
4110 * @retval Error code
4111 */
ISDS_setTapQuietTime(WE_sensorInterface_t * sensorInterface,uint8_t quietTime)4112 int8_t ISDS_setTapQuietTime(WE_sensorInterface_t* sensorInterface, uint8_t quietTime)
4113 {
4114 ISDS_intDur2_t intDuration;
4115
4116 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4117 {
4118 return WE_FAIL;
4119 }
4120
4121 intDuration.quiet = (quietTime & 0x03);
4122
4123 return ISDS_WriteReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration);
4124 }
4125
4126 /**
4127 * @brief Read the expected quiet time after a tap detection (QUIET)
4128 * @param[in] sensorInterface Pointer to sensor interface
4129 * @param[out] quietTime The returned quiet time
4130 * @retval Error code
4131 */
ISDS_getTapQuietTime(WE_sensorInterface_t * sensorInterface,uint8_t * quietTime)4132 int8_t ISDS_getTapQuietTime(WE_sensorInterface_t* sensorInterface, uint8_t *quietTime)
4133 {
4134
4135 ISDS_intDur2_t intDuration;
4136
4137 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4138 {
4139 return WE_FAIL;
4140 }
4141
4142 *quietTime = intDuration.quiet;
4143
4144 return WE_SUCCESS;
4145 }
4146
4147 /**
4148 * @brief Set the maximum duration of over-threshold events (SHOCK)
4149 * @param[in] sensorInterface Pointer to sensor interface
4150 * @param[in] shockTime Shock time value (2 bits)
4151 * @retval Error code
4152 */
ISDS_setTapShockTime(WE_sensorInterface_t * sensorInterface,uint8_t shockTime)4153 int8_t ISDS_setTapShockTime(WE_sensorInterface_t* sensorInterface, uint8_t shockTime)
4154 {
4155 ISDS_intDur2_t intDuration;
4156
4157 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4158 {
4159 return WE_FAIL;
4160 }
4161
4162 intDuration.shock = (shockTime & 0x03);
4163
4164 return ISDS_WriteReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration);
4165 }
4166
4167 /**
4168 * @brief Read the maximum duration of over-threshold events (SHOCK)
4169 * @param[in] sensorInterface Pointer to sensor interface
4170 * @param[out] shockTime The returned shock time.
4171 * @retval Error code
4172 */
ISDS_getTapShockTime(WE_sensorInterface_t * sensorInterface,uint8_t * shockTime)4173 int8_t ISDS_getTapShockTime(WE_sensorInterface_t* sensorInterface, uint8_t *shockTime)
4174 {
4175 ISDS_intDur2_t intDuration;
4176
4177 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4178 {
4179 return WE_FAIL;
4180 }
4181
4182 *shockTime = intDuration.shock;
4183
4184 return WE_SUCCESS;
4185 }
4186
4187
4188 /* ISDS_WAKE_UP_THS_REG */
4189
4190 /**
4191 * @brief Set wake-up threshold
4192 * @param[in] sensorInterface Pointer to sensor interface
4193 * @param[in] thresh Wake-up threshold (six bits)
4194 * @retval Error code
4195 */
ISDS_setWakeUpThreshold(WE_sensorInterface_t * sensorInterface,uint8_t thresh)4196 int8_t ISDS_setWakeUpThreshold(WE_sensorInterface_t* sensorInterface, uint8_t thresh)
4197 {
4198 ISDS_wakeUpThs_t wakeUpThs;
4199
4200 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4201 {
4202 return WE_FAIL;
4203 }
4204
4205 wakeUpThs.wakeUpThreshold = (thresh & 0x3F);
4206
4207 return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs);
4208 }
4209
4210 /**
4211 * @brief Read the wake-up threshold
4212 * @param[in] sensorInterface Pointer to sensor interface
4213 * @param[out] thresh The returned wake-up threshold.
4214 * @retval Error code
4215 */
ISDS_getWakeUpThreshold(WE_sensorInterface_t * sensorInterface,uint8_t * thresh)4216 int8_t ISDS_getWakeUpThreshold(WE_sensorInterface_t* sensorInterface, uint8_t *thresh)
4217 {
4218 ISDS_wakeUpThs_t wakeUpThs;
4219
4220 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4221 {
4222 return WE_FAIL;
4223 }
4224
4225 *thresh = wakeUpThs.wakeUpThreshold;
4226
4227 return WE_SUCCESS;
4228 }
4229
4230 /**
4231 * @brief Enable/disable the single and double-tap event OR only single-tap event
4232 * @param[in] sensorInterface Pointer to sensor interface
4233 * @param[in] doubleTapEnable Tap event state [0: only single, 1: single and double-tap]
4234 * @retval Error code
4235 */
ISDS_enableDoubleTapEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t doubleTapEnable)4236 int8_t ISDS_enableDoubleTapEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t doubleTapEnable)
4237 {
4238 ISDS_wakeUpThs_t wakeUpThs;
4239
4240 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4241 {
4242 return WE_FAIL;
4243 }
4244
4245 wakeUpThs.enDoubleTapEvent = doubleTapEnable;
4246
4247 return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs);
4248 }
4249
4250 /**
4251 * @brief Check if double-tap events are enabled
4252 * @param[in] sensorInterface Pointer to sensor interface
4253 * @param[out] doubleTap The returned tap event state [0: only single, 1: single and double-tap]
4254 * @retval Error code
4255 */
ISDS_isDoubleTapEventEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * doubleTapEnable)4256 int8_t ISDS_isDoubleTapEventEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *doubleTapEnable)
4257 {
4258 ISDS_wakeUpThs_t wakeUpThs;
4259
4260 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4261 {
4262 return WE_FAIL;
4263 }
4264
4265 *doubleTapEnable = (ISDS_state_t) wakeUpThs.enDoubleTapEvent;
4266
4267 return WE_SUCCESS;
4268 }
4269
4270
4271 /* ISDS_WAKE_UP_DUR_REG */
4272
4273 /**
4274 * @brief Set the sleep mode duration
4275 * @param[in] sensorInterface Pointer to sensor interface
4276 * @param[in] duration Sleep mode duration (4 bits)
4277 * @retval Error code
4278 */
ISDS_setSleepDuration(WE_sensorInterface_t * sensorInterface,uint8_t duration)4279 int8_t ISDS_setSleepDuration(WE_sensorInterface_t* sensorInterface, uint8_t duration)
4280 {
4281 ISDS_wakeUpDur_t wakeUpDur;
4282
4283 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4284 {
4285 return WE_FAIL;
4286 }
4287
4288 wakeUpDur.sleepDuration = (duration & 0x0F);
4289
4290 return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur);
4291 }
4292
4293 /**
4294 * @brief Read the sleep mode duration
4295 * @param[in] sensorInterface Pointer to sensor interface
4296 * @param[out] duration The returned sleep mode duration
4297 * @retval Error code
4298 */
ISDS_getSleepDuration(WE_sensorInterface_t * sensorInterface,uint8_t * duration)4299 int8_t ISDS_getSleepDuration(WE_sensorInterface_t* sensorInterface, uint8_t *duration)
4300 {
4301 ISDS_wakeUpDur_t wakeUpDur;
4302
4303 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4304 {
4305 return WE_FAIL;
4306 }
4307
4308 *duration = wakeUpDur.sleepDuration;
4309
4310 return WE_SUCCESS;
4311 }
4312
4313 /**
4314 * @brief Set wake-up duration
4315 * @param[in] sensorInterface Pointer to sensor interface
4316 * @param[in] duration Wake-up duration (two bits)
4317 * @retval Error code
4318 */
ISDS_setWakeUpDuration(WE_sensorInterface_t * sensorInterface,uint8_t duration)4319 int8_t ISDS_setWakeUpDuration(WE_sensorInterface_t* sensorInterface, uint8_t duration)
4320 {
4321 ISDS_wakeUpDur_t wakeUpDur;
4322
4323 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4324 {
4325 return WE_FAIL;
4326 }
4327
4328 wakeUpDur.wakeUpDuration = (duration & 0x03);
4329
4330 return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur);
4331 }
4332
4333 /**
4334 * @brief Read the wake-up duration
4335 * @param[in] sensorInterface Pointer to sensor interface
4336 * @param[out] duration The returned wake-up duration (two bits)
4337 * @retval Error code
4338 */
ISDS_getWakeUpDuration(WE_sensorInterface_t * sensorInterface,uint8_t * duration)4339 int8_t ISDS_getWakeUpDuration(WE_sensorInterface_t* sensorInterface, uint8_t *duration)
4340 {
4341 ISDS_wakeUpDur_t wakeUpDur;
4342
4343 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4344 {
4345 return WE_FAIL;
4346 }
4347
4348 *duration = wakeUpDur.wakeUpDuration;
4349
4350 return WE_SUCCESS;
4351 }
4352
4353
4354 /* ISDS_FREE_FALL_REG */
4355
4356 /**
4357 * @brief Set free-fall threshold
4358 * @param[in] sensorInterface Pointer to sensor interface
4359 * @param[in] thresh Free-fall threshold value
4360 * @retval Error code
4361 */
ISDS_setFreeFallThreshold(WE_sensorInterface_t * sensorInterface,ISDS_freeFallThreshold_t thresh)4362 int8_t ISDS_setFreeFallThreshold(WE_sensorInterface_t* sensorInterface, ISDS_freeFallThreshold_t thresh)
4363 {
4364 ISDS_freeFall_t freeFall;
4365
4366 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4367 {
4368 return WE_FAIL;
4369 }
4370
4371 freeFall.freeFallThreshold = thresh;
4372
4373 return ISDS_WriteReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall);
4374 }
4375
4376 /**
4377 * @brief Read the free-fall threshold
4378 * @param[in] sensorInterface Pointer to sensor interface
4379 * @param[in] thresh The returned free-fall threshold value
4380 * @retval Error code
4381 */
ISDS_getFreeFallThreshold(WE_sensorInterface_t * sensorInterface,ISDS_freeFallThreshold_t * thresh)4382 int8_t ISDS_getFreeFallThreshold(WE_sensorInterface_t* sensorInterface, ISDS_freeFallThreshold_t *thresh)
4383 {
4384 ISDS_freeFall_t freeFall;
4385
4386 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4387 {
4388 return WE_FAIL;
4389 }
4390
4391 *thresh = (ISDS_freeFallThreshold_t) freeFall.freeFallThreshold;
4392
4393 return WE_SUCCESS;
4394 }
4395
4396 /**
4397 * @brief Set the free-fall duration (both LSB and MSB).
4398 * @param[in] sensorInterface Pointer to sensor interface
4399 * @param[in] duration Free-fall duration (6 bits)
4400 * @retval Error code
4401 */
ISDS_setFreeFallDuration(WE_sensorInterface_t * sensorInterface,uint8_t duration)4402 int8_t ISDS_setFreeFallDuration(WE_sensorInterface_t* sensorInterface, uint8_t duration)
4403 {
4404 ISDS_freeFall_t freeFall;
4405 ISDS_wakeUpDur_t wakeUpDur;
4406
4407 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4408 {
4409 return WE_FAIL;
4410 }
4411 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4412 {
4413 return WE_FAIL;
4414 }
4415
4416 freeFall.freeFallDurationLSB = (uint8_t) (duration & 0x1F);
4417 wakeUpDur.freeFallDurationMSB = (uint8_t) ((duration >> 5) & 0x01);
4418
4419 if (WE_FAIL == ISDS_WriteReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4420 {
4421 return WE_FAIL;
4422 }
4423 return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur);
4424 }
4425
4426 /**
4427 * @brief Read the free-fall duration (both LSB and MSB).
4428 * @param[in] sensorInterface Pointer to sensor interface
4429 * @param[out] duration The returned free-fall duration (6 bits)
4430 * @retval Error code
4431 */
ISDS_getFreeFallDuration(WE_sensorInterface_t * sensorInterface,uint8_t * duration)4432 int8_t ISDS_getFreeFallDuration(WE_sensorInterface_t* sensorInterface, uint8_t *duration)
4433 {
4434 ISDS_freeFall_t freeFall;
4435 ISDS_wakeUpDur_t wakeUpDur;
4436
4437 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4438 {
4439 return WE_FAIL;
4440 }
4441 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4442 {
4443 return WE_FAIL;
4444 }
4445
4446 *duration = ((uint8_t) freeFall.freeFallDurationLSB) |
4447 (((uint8_t) (wakeUpDur.freeFallDurationMSB & 0x01)) << 5);
4448
4449 return WE_SUCCESS;
4450 }
4451
4452 /**
4453 * @brief Enable/disable the tilt event interrupt on INT_0
4454 * @param[in] sensorInterface Pointer to sensor interface
4455 * @param[in] int0Tilt Tilt event interrupt enable state
4456 * @retval Error code
4457 */
ISDS_enableTiltINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0Tilt)4458 int8_t ISDS_enableTiltINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0Tilt)
4459 {
4460 ISDS_mde1Cfg_t mde1Cfg;
4461
4462 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4463 {
4464 return WE_FAIL;
4465 }
4466
4467 mde1Cfg.int0Tilt = int0Tilt;
4468
4469 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4470 }
4471
4472 /**
4473 * @brief Check if the tilt event interrupt on INT_0 is enabled
4474 * @param[in] sensorInterface Pointer to sensor interface
4475 * @param[out] int0Tilt The returned tilt event interrupt enable state
4476 * @retval Error code
4477 */
ISDS_isTiltINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0Tilt)4478 int8_t ISDS_isTiltINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0Tilt)
4479 {
4480 ISDS_mde1Cfg_t mde1Cfg;
4481
4482 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4483 {
4484 return WE_FAIL;
4485 }
4486
4487 *int0Tilt = (ISDS_state_t) mde1Cfg.int0Tilt;
4488
4489 return WE_SUCCESS;
4490 }
4491
4492 /**
4493 * @brief Enable/disable the 6D orientation change event interrupt on INT_0
4494 * @param[in] sensorInterface Pointer to sensor interface
4495 * @param[in] int06d 6D orientation change event interrupt enable state
4496 * @retval Error code
4497 */
ISDS_enable6dINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int06d)4498 int8_t ISDS_enable6dINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int06d)
4499 {
4500 ISDS_mde1Cfg_t mde1Cfg;
4501
4502 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4503 {
4504 return WE_FAIL;
4505 }
4506
4507 mde1Cfg.int06d = int06d;
4508
4509 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4510 }
4511
4512 /**
4513 * @brief Check if the 6D orientation change event interrupt on INT_0 is enabled
4514 * @param[in] sensorInterface Pointer to sensor interface
4515 * @param[out] int06d The returned 6D orientation change event interrupt enable state
4516 * @retval Error code
4517 */
ISDS_is6dINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int06d)4518 int8_t ISDS_is6dINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int06d)
4519 {
4520 ISDS_mde1Cfg_t mde1Cfg;
4521
4522 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4523 {
4524 return WE_FAIL;
4525 }
4526
4527 *int06d = (ISDS_state_t) mde1Cfg.int06d;
4528
4529 return WE_SUCCESS;
4530 }
4531
4532 /**
4533 * @brief Enable/disable the double-tap interrupt on INT_0
4534 * @param[in] sensorInterface Pointer to sensor interface
4535 * @param[in] int0DoubleTap The double-tap interrupt enable state
4536 * @retval Error code
4537 */
ISDS_enableDoubleTapINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0DoubleTap)4538 int8_t ISDS_enableDoubleTapINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0DoubleTap)
4539 {
4540 ISDS_mde1Cfg_t mde1Cfg;
4541
4542 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4543 {
4544 return WE_FAIL;
4545 }
4546
4547 mde1Cfg.int0DoubleTap = int0DoubleTap;
4548
4549 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4550 }
4551
4552 /**
4553 * @brief Check if the double-tap interrupt on INT_0 is enabled
4554 * @param[in] sensorInterface Pointer to sensor interface
4555 * @param[out] int0DoubleTap The returned double-tap interrupt enable state
4556 * @retval Error code
4557 */
ISDS_isDoubleTapINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0DoubleTap)4558 int8_t ISDS_isDoubleTapINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0DoubleTap)
4559 {
4560 ISDS_mde1Cfg_t mde1Cfg;
4561
4562 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4563 {
4564 return WE_FAIL;
4565 }
4566
4567 *int0DoubleTap = (ISDS_state_t) mde1Cfg.int0DoubleTap;
4568
4569 return WE_SUCCESS;
4570 }
4571
4572 /**
4573 * @brief Enable/disable the free-fall interrupt on INT_0
4574 * @param[in] sensorInterface Pointer to sensor interface
4575 * @param[in] int0FreeFall Free-fall interrupt enable state
4576 * @retval Error code
4577 */
ISDS_enableFreeFallINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0FreeFall)4578 int8_t ISDS_enableFreeFallINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0FreeFall)
4579 {
4580 ISDS_mde1Cfg_t mde1Cfg;
4581
4582 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4583 {
4584 return WE_FAIL;
4585 }
4586
4587 mde1Cfg.int0FreeFall = int0FreeFall;
4588
4589 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4590 }
4591
4592 /**
4593 * @brief Check if the free-fall interrupt on INT_0 is enabled
4594 * @param[in] sensorInterface Pointer to sensor interface
4595 * @param[out] int0FreeFall The returned free-fall enable state
4596 * @retval Error code
4597 */
ISDS_isFreeFallINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0FreeFall)4598 int8_t ISDS_isFreeFallINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0FreeFall)
4599 {
4600 ISDS_mde1Cfg_t mde1Cfg;
4601
4602 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4603 {
4604 return WE_FAIL;
4605 }
4606
4607 *int0FreeFall = (ISDS_state_t) mde1Cfg.int0FreeFall;
4608
4609 return WE_SUCCESS;
4610 }
4611
4612 /**
4613 * @brief Enable/disable the wake-up interrupt on INT_0
4614 * @param[in] sensorInterface Pointer to sensor interface
4615 * @param[in] int0WakeUp Wake-up interrupt enable state
4616 * @retval Error code
4617 */
ISDS_enableWakeUpINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0WakeUp)4618 int8_t ISDS_enableWakeUpINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0WakeUp)
4619 {
4620 ISDS_mde1Cfg_t mde1Cfg;
4621
4622 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4623 {
4624 return WE_FAIL;
4625 }
4626
4627 mde1Cfg.int0WakeUp = int0WakeUp;
4628
4629 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4630 }
4631
4632 /**
4633 * @brief Check if the wake-up interrupt on INT_0 is enabled
4634 * @param[in] sensorInterface Pointer to sensor interface
4635 * @param[out] int0WakeUp The returned wake-up interrupt enable state
4636 * @retval Error code
4637 */
ISDS_isWakeUpINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0WakeUp)4638 int8_t ISDS_isWakeUpINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0WakeUp)
4639 {
4640 ISDS_mde1Cfg_t mde1Cfg;
4641
4642 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4643 {
4644 return WE_FAIL;
4645 }
4646
4647 *int0WakeUp = (ISDS_state_t) mde1Cfg.int0WakeUp;
4648
4649 return WE_SUCCESS;
4650 }
4651
4652 /**
4653 * @brief Enable/disable the single-tap interrupt on INT_0
4654 * @param[in] sensorInterface Pointer to sensor interface
4655 * @param[in] int0SingleTap Single-tap interrupt enable state
4656 * @retval Error code
4657 */
ISDS_enableSingleTapINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0SingleTap)4658 int8_t ISDS_enableSingleTapINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0SingleTap)
4659 {
4660 ISDS_mde1Cfg_t mde1Cfg;
4661
4662 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4663 {
4664 return WE_FAIL;
4665 }
4666
4667 mde1Cfg.int0SingleTap = int0SingleTap;
4668
4669 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4670 }
4671
4672 /**
4673 * @brief Check if the single-tap interrupt on INT_0 is enabled
4674 * @param[in] sensorInterface Pointer to sensor interface
4675 * @param[out] int0SingleTap The returned single-tap interrupt enable state
4676 * @retval Error code
4677 */
ISDS_isSingleTapINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0SingleTap)4678 int8_t ISDS_isSingleTapINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0SingleTap)
4679 {
4680 ISDS_mde1Cfg_t mde1Cfg;
4681
4682 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4683 {
4684 return WE_FAIL;
4685 }
4686
4687 *int0SingleTap = (ISDS_state_t) mde1Cfg.int0SingleTap;
4688
4689 return WE_SUCCESS;
4690 }
4691
4692 /**
4693 * @brief Enable/disable the inactivity state interrupt on INT_0
4694 * @param[in] sensorInterface Pointer to sensor interface
4695 * @param[in] int0InactivityState Inactivity state interrupt enable state
4696 * @retval Error code
4697 */
ISDS_enableInactivityStateINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0InactivityState)4698 int8_t ISDS_enableInactivityStateINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0InactivityState)
4699 {
4700 ISDS_mde1Cfg_t mde1Cfg;
4701
4702 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4703 {
4704 return WE_FAIL;
4705 }
4706
4707 mde1Cfg.int0InactivityState = int0InactivityState;
4708
4709 return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4710 }
4711
4712 /**
4713 * @brief Check if the inactivity state interrupt on INT_0 is enabled
4714 * @param[in] sensorInterface Pointer to sensor interface
4715 * @param[out] int0InactivityState The returned inactivity state interrupt enable state
4716 * @retval Error code
4717 */
ISDS_isInactivityStateINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0InactivityState)4718 int8_t ISDS_isInactivityStateINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0InactivityState)
4719 {
4720 ISDS_mde1Cfg_t mde1Cfg;
4721
4722 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4723 {
4724 return WE_FAIL;
4725 }
4726
4727 *int0InactivityState = (ISDS_state_t) mde1Cfg.int0InactivityState;
4728
4729 return WE_SUCCESS;
4730 }
4731
4732
4733 /* ISDS_MD2_CFG_REG */
4734
4735 /**
4736 * @brief Enable/disable the tilt event interrupt on INT_1
4737 * @param[in] sensorInterface Pointer to sensor interface
4738 * @param[in] int1Tilt Tilt event interrupt enable state
4739 * @retval Error code
4740 */
ISDS_enableTiltINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1Tilt)4741 int8_t ISDS_enableTiltINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1Tilt)
4742 {
4743 ISDS_mde2Cfg_t mde2Cfg;
4744
4745 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4746 {
4747 return WE_FAIL;
4748 }
4749
4750 mde2Cfg.int1Tilt = int1Tilt;
4751
4752 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4753 }
4754
4755 /**
4756 * @brief Check if the tilt event interrupt on INT_1 is enabled
4757 * @param[in] sensorInterface Pointer to sensor interface
4758 * @param[out] int1Tilt The returned tilt event interrupt enable state
4759 * @retval Error code
4760 */
ISDS_isTiltINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1Tilt)4761 int8_t ISDS_isTiltINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1Tilt)
4762 {
4763 ISDS_mde2Cfg_t mde2Cfg;
4764
4765 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4766 {
4767 return WE_FAIL;
4768 }
4769
4770 *int1Tilt = (ISDS_state_t) mde2Cfg.int1Tilt;
4771
4772 return WE_SUCCESS;
4773 }
4774
4775 /**
4776 * @brief Enable/disable the 6D orientation change event interrupt on INT_1
4777 * @param[in] sensorInterface Pointer to sensor interface
4778 * @param[in] int16d 6D orientation change event interrupt enable state
4779 * @retval Error code
4780 */
ISDS_enable6dINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int16d)4781 int8_t ISDS_enable6dINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int16d)
4782 {
4783 ISDS_mde2Cfg_t mde2Cfg;
4784
4785 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4786 {
4787 return WE_FAIL;
4788 }
4789
4790 mde2Cfg.int16d = int16d;
4791
4792 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4793 }
4794
4795 /**
4796 * @brief Check if the 6D orientation change event interrupt on INT_1 is enabled
4797 * @param[in] sensorInterface Pointer to sensor interface
4798 * @param[out] int16d The returned 6D orientation change event interrupt enable state
4799 * @retval Error code
4800 */
ISDS_is6dINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int16d)4801 int8_t ISDS_is6dINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int16d)
4802 {
4803 ISDS_mde2Cfg_t mde2Cfg;
4804
4805 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4806 {
4807 return WE_FAIL;
4808 }
4809
4810 *int16d = (ISDS_state_t) mde2Cfg.int16d;
4811
4812 return WE_SUCCESS;
4813 }
4814
4815 /**
4816 * @brief Enable/disable the double-tap interrupt on INT_1
4817 * @param[in] sensorInterface Pointer to sensor interface
4818 * @param[in] int1DoubleTap The double-tap interrupt enable state
4819 * @retval Error code
4820 */
ISDS_enableDoubleTapINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1DoubleTap)4821 int8_t ISDS_enableDoubleTapINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1DoubleTap)
4822 {
4823 ISDS_mde2Cfg_t mde2Cfg;
4824
4825 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4826 {
4827 return WE_FAIL;
4828 }
4829
4830 mde2Cfg.int1DoubleTap = int1DoubleTap;
4831
4832 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4833 }
4834
4835 /**
4836 * @brief Check if the double-tap interrupt on INT_1 is enabled
4837 * @param[in] sensorInterface Pointer to sensor interface
4838 * @param[out] int1DoubleTap The returned double-tap interrupt enable state
4839 * @retval Error code
4840 */
ISDS_isDoubleTapINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1DoubleTap)4841 int8_t ISDS_isDoubleTapINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1DoubleTap)
4842 {
4843 ISDS_mde2Cfg_t mde2Cfg;
4844
4845 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4846 {
4847 return WE_FAIL;
4848 }
4849
4850 *int1DoubleTap = (ISDS_state_t) mde2Cfg.int1DoubleTap;
4851
4852 return WE_SUCCESS;
4853 }
4854
4855 /**
4856 * @brief Enable/disable the free-fall interrupt on INT_1
4857 * @param[in] sensorInterface Pointer to sensor interface
4858 * @param[in] int1FreeFall Free-fall interrupt enable state
4859 * @retval Error code
4860 */
ISDS_enableFreeFallINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1FreeFall)4861 int8_t ISDS_enableFreeFallINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1FreeFall)
4862 {
4863 ISDS_mde2Cfg_t mde2Cfg;
4864
4865 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4866 {
4867 return WE_FAIL;
4868 }
4869
4870 mde2Cfg.int1FreeFall = int1FreeFall;
4871
4872 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4873 }
4874
4875 /**
4876 * @brief Check if the free-fall interrupt on INT_1 is enabled
4877 * @param[in] sensorInterface Pointer to sensor interface
4878 * @param[out] int1FreeFall The returned free-fall enable state
4879 * @retval Error code
4880 */
ISDS_isFreeFallINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1FreeFall)4881 int8_t ISDS_isFreeFallINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1FreeFall)
4882 {
4883 ISDS_mde2Cfg_t mde2Cfg;
4884
4885 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4886 {
4887 return WE_FAIL;
4888 }
4889
4890 *int1FreeFall = (ISDS_state_t) mde2Cfg.int1FreeFall;
4891
4892 return WE_SUCCESS;
4893 }
4894
4895 /**
4896 * @brief Enable/disable the wake-up interrupt on INT_1
4897 * @param[in] sensorInterface Pointer to sensor interface
4898 * @param[in] int1WakeUp Wake-up interrupt enable state
4899 * @retval Error code
4900 */
ISDS_enableWakeUpINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1WakeUp)4901 int8_t ISDS_enableWakeUpINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1WakeUp)
4902 {
4903 ISDS_mde2Cfg_t mde2Cfg;
4904
4905 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4906 {
4907 return WE_FAIL;
4908 }
4909
4910 mde2Cfg.int1WakeUp = int1WakeUp;
4911
4912 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4913 }
4914
4915 /**
4916 * @brief Check if the wake-up interrupt on INT_1 is enabled
4917 * @param[in] sensorInterface Pointer to sensor interface
4918 * @param[out] int1WakeUp The returned wake-up interrupt enable state
4919 * @retval Error code
4920 */
ISDS_isWakeUpINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1WakeUp)4921 int8_t ISDS_isWakeUpINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1WakeUp)
4922 {
4923 ISDS_mde2Cfg_t mde2Cfg;
4924
4925 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4926 {
4927 return WE_FAIL;
4928 }
4929
4930 *int1WakeUp = (ISDS_state_t) mde2Cfg.int1WakeUp;
4931
4932 return WE_SUCCESS;
4933 }
4934
4935 /**
4936 * @brief Enable/disable the single-tap interrupt on INT_1
4937 * @param[in] sensorInterface Pointer to sensor interface
4938 * @param[in] int1SingleTap Single-tap interrupt enable state
4939 * @retval Error code
4940 */
ISDS_enableSingleTapINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1SingleTap)4941 int8_t ISDS_enableSingleTapINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1SingleTap)
4942 {
4943 ISDS_mde2Cfg_t mde2Cfg;
4944
4945 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4946 {
4947 return WE_FAIL;
4948 }
4949
4950 mde2Cfg.int1SingleTap = int1SingleTap;
4951
4952 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4953 }
4954
4955 /**
4956 * @brief Check if the single-tap interrupt on INT_1 is enabled
4957 * @param[in] sensorInterface Pointer to sensor interface
4958 * @param[out] int1SingleTap The returned single-tap interrupt enable state
4959 * @retval Error code
4960 */
ISDS_isSingleTapINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1SingleTap)4961 int8_t ISDS_isSingleTapINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1SingleTap)
4962 {
4963 ISDS_mde2Cfg_t mde2Cfg;
4964
4965 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4966 {
4967 return WE_FAIL;
4968 }
4969
4970 *int1SingleTap = (ISDS_state_t) mde2Cfg.int1SingleTap;
4971
4972 return WE_SUCCESS;
4973 }
4974
4975 /**
4976 * @brief Enable/disable the inactivity state interrupt on INT_1
4977 * @param[in] sensorInterface Pointer to sensor interface
4978 * @param[in] int1InactivityState Inactivity state interrupt enable state
4979 * @retval Error code
4980 */
ISDS_enableInactivityStateINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1InactivityState)4981 int8_t ISDS_enableInactivityStateINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1InactivityState)
4982 {
4983 ISDS_mde2Cfg_t mde2Cfg;
4984
4985 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4986 {
4987 return WE_FAIL;
4988 }
4989
4990 mde2Cfg.int1InactivityState = int1InactivityState;
4991
4992 return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4993 }
4994
4995 /**
4996 * @brief Check if the inactivity state interrupt on INT_1 is enabled
4997 * @param[in] sensorInterface Pointer to sensor interface
4998 * @param[out] int1InactivityState The returned inactivity state interrupt enable state
4999 * @retval Error code
5000 */
ISDS_isInactivityStateINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1InactivityState)5001 int8_t ISDS_isInactivityStateINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1InactivityState)
5002 {
5003 ISDS_mde2Cfg_t mde2Cfg;
5004
5005 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
5006 {
5007 return WE_FAIL;
5008 }
5009
5010 *int1InactivityState = (ISDS_state_t) mde2Cfg.int1InactivityState;
5011
5012 return WE_SUCCESS;
5013 }
5014
5015 /* ISDS_X_OFS_USR_REG */
5016 /* ISDS_Y_OFS_USR_REG */
5017 /* ISDS_Z_OFS_USR_REG */
5018
5019 /**
5020 * @brief Set the user offset for axis X
5021 * @param[in] sensorInterface Pointer to sensor interface
5022 * @param[in] offsetValueXAxis User offset for axis X
5023 * @retval Error code
5024 */
ISDS_setOffsetValueX(WE_sensorInterface_t * sensorInterface,int8_t offsetValueXAxis)5025 int8_t ISDS_setOffsetValueX(WE_sensorInterface_t* sensorInterface, int8_t offsetValueXAxis)
5026 {
5027 return ISDS_WriteReg(sensorInterface, ISDS_X_OFS_USR_REG, 1, (uint8_t *) &offsetValueXAxis);
5028 }
5029
5030 /**
5031 * @brief Read the user offset for axis X
5032 * @param[in] sensorInterface Pointer to sensor interface
5033 * @param[out] offsetValueXAxis The returned user offset for axis X
5034 * @retval Error code
5035 */
ISDS_getOffsetValueX(WE_sensorInterface_t * sensorInterface,int8_t * offsetValueXAxis)5036 int8_t ISDS_getOffsetValueX(WE_sensorInterface_t* sensorInterface, int8_t *offsetValueXAxis)
5037 {
5038 return ISDS_ReadReg(sensorInterface, ISDS_X_OFS_USR_REG, 1, (uint8_t *) offsetValueXAxis);
5039 }
5040
5041 /**
5042 * @brief Set the user offset for axis Y
5043 * @param[in] sensorInterface Pointer to sensor interface
5044 * @param[in] offsetValueYAxis User offset for axis Y
5045 * @retval Error code
5046 */
ISDS_setOffsetValueY(WE_sensorInterface_t * sensorInterface,int8_t offsetValueYAxis)5047 int8_t ISDS_setOffsetValueY(WE_sensorInterface_t* sensorInterface, int8_t offsetValueYAxis)
5048 {
5049 return ISDS_WriteReg(sensorInterface, ISDS_Y_OFS_USR_REG, 1, (uint8_t *) &offsetValueYAxis);
5050 }
5051
5052 /**
5053 * @brief Read the user offset for axis Y
5054 * @param[in] sensorInterface Pointer to sensor interface
5055 * @param[out] offsetValueYAxis The returned user offset for axis Y
5056 * @retval Error code
5057 */
ISDS_getOffsetValueY(WE_sensorInterface_t * sensorInterface,int8_t * offsetValueYAxis)5058 int8_t ISDS_getOffsetValueY(WE_sensorInterface_t* sensorInterface, int8_t *offsetValueYAxis)
5059 {
5060 return ISDS_ReadReg(sensorInterface, ISDS_Y_OFS_USR_REG, 1, (uint8_t *) offsetValueYAxis);
5061 }
5062
5063 /**
5064 * @brief Set the user offset for axis Z
5065 * @param[in] sensorInterface Pointer to sensor interface
5066 * @param[in] offsetValueZAxis The user offset for axis Z
5067 * @retval Error code
5068 */
ISDS_setOffsetValueZ(WE_sensorInterface_t * sensorInterface,int8_t offsetValueZAxis)5069 int8_t ISDS_setOffsetValueZ(WE_sensorInterface_t* sensorInterface, int8_t offsetValueZAxis)
5070 {
5071 return ISDS_WriteReg(sensorInterface, ISDS_Z_OFS_USR_REG, 1, (uint8_t *) &offsetValueZAxis);
5072 }
5073
5074 /**
5075 * @brief Read the user offset for axis Z
5076 * @param[in] sensorInterface Pointer to sensor interface
5077 * @param[out] offsetValueZAxis The returned user offset for axis Z
5078 * @retval Error code
5079 */
ISDS_getOffsetValueZ(WE_sensorInterface_t * sensorInterface,int8_t * offsetValueZAxis)5080 int8_t ISDS_getOffsetValueZ(WE_sensorInterface_t* sensorInterface, int8_t *offsetValueZAxis)
5081 {
5082 return ISDS_ReadReg(sensorInterface, ISDS_Z_OFS_USR_REG, 1, (uint8_t *) offsetValueZAxis);
5083 }
5084
5085
5086 /* ISDS_FIFO_DATA_OUT_L_REG */
5087 /* ISDS_FIFO_DATA_OUT_H_REG */
5088
5089 /**
5090 * @brief Reads the specified number of 16 bit values from the FIFO buffer
5091 *
5092 * The type of values read depends on the FIFO configuration and the current
5093 * read position. Get the current FIFO pattern value (e.g. via
5094 * ISDS_getFifoPattern() or ISDS_getFifoStatus()). Before reading FIFO data to
5095 * determine the type of the next value read.
5096 *
5097 * @param[in] sensorInterface Pointer to sensor interface
5098 * @param[in] numSamples The number of values to be read
5099 * @param[out] fifoData The returned values (must provide pointer to buffer of length numSamples)
5100 * @retval Error code
5101 */
ISDS_getFifoData(WE_sensorInterface_t * sensorInterface,uint16_t numSamples,uint16_t * fifoData)5102 int8_t ISDS_getFifoData(WE_sensorInterface_t* sensorInterface, uint16_t numSamples, uint16_t *fifoData)
5103 {
5104 return ISDS_ReadReg(sensorInterface, ISDS_FIFO_DATA_OUT_L_REG, numSamples * 2, (uint8_t *) fifoData);
5105 }
5106
5107
5108 #ifdef WE_USE_FLOAT
5109 /**
5110 * @brief Reads the X-axis angular rate in [mdps]
5111 *
5112 * Note that this functions relies on the current gyroscope full scale value.
5113 * Make sure that the current gyroscope full scale value is known by calling
5114 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5115 * calling this function.
5116 *
5117 * @param[in] sensorInterface Pointer to sensor interface
5118 * @param[out] xRate X-axis angular rate in [mdps]
5119 * @retval Error code
5120 */
ISDS_getAngularRateX_float(WE_sensorInterface_t * sensorInterface,float * xRate)5121 int8_t ISDS_getAngularRateX_float(WE_sensorInterface_t* sensorInterface, float *xRate)
5122 {
5123 int16_t rawRate;
5124 if (WE_FAIL == ISDS_getRawAngularRateX(sensorInterface, &rawRate))
5125 {
5126 return WE_FAIL;
5127 }
5128 *xRate = ISDS_convertAngularRate_float(rawRate, currentGyroFullScale);
5129 return WE_SUCCESS;
5130 }
5131
5132 /**
5133 * @brief Reads the Y-axis angular rate in [mdps]
5134 *
5135 * Note that this functions relies on the current gyroscope full scale value.
5136 * Make sure that the current gyroscope full scale value is known by calling
5137 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5138 * calling this function.
5139 *
5140 * @param[in] sensorInterface Pointer to sensor interface
5141 * @param[out] yRate Y-axis angular rate in [mdps]
5142 * @retval Error code
5143 */
ISDS_getAngularRateY_float(WE_sensorInterface_t * sensorInterface,float * yRate)5144 int8_t ISDS_getAngularRateY_float(WE_sensorInterface_t* sensorInterface, float *yRate)
5145 {
5146 int16_t rawRate;
5147 if (WE_FAIL == ISDS_getRawAngularRateY(sensorInterface, &rawRate))
5148 {
5149 return WE_FAIL;
5150 }
5151 *yRate = ISDS_convertAngularRate_float(rawRate, currentGyroFullScale);
5152 return WE_SUCCESS;
5153 }
5154
5155 /**
5156 * @brief Reads the Z-axis angular rate in [mdps]
5157 *
5158 * Note that this functions relies on the current gyroscope full scale value.
5159 * Make sure that the current gyroscope full scale value is known by calling
5160 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5161 * calling this function.
5162 *
5163 * @param[in] sensorInterface Pointer to sensor interface
5164 * @param[out] zRate Z-axis angular rate in [mdps]
5165 * @retval Error code
5166 */
ISDS_getAngularRateZ_float(WE_sensorInterface_t * sensorInterface,float * zRate)5167 int8_t ISDS_getAngularRateZ_float(WE_sensorInterface_t* sensorInterface, float *zRate)
5168 {
5169 int16_t rawRate;
5170 if (WE_FAIL == ISDS_getRawAngularRateZ(sensorInterface, &rawRate))
5171 {
5172 return WE_FAIL;
5173 }
5174 *zRate = ISDS_convertAngularRate_float(rawRate, currentGyroFullScale);
5175 return WE_SUCCESS;
5176 }
5177
5178 /**
5179 * @brief Read the gyroscope sensor output in [mdps] for all three axes
5180 *
5181 * Note that this functions relies on the current gyroscope full scale value.
5182 * Make sure that the current gyroscope full scale value is known by calling
5183 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5184 * calling this function.
5185 *
5186 * @param[in] sensorInterface Pointer to sensor interface
5187 * @param[out] xRate The returned X-axis angular rate in [mdps]
5188 * @param[out] yRate The returned Y-axis angular rate in [mdps]
5189 * @param[out] zRate The returned Z-axis angular rate in [mdps]
5190 * @retval Error code
5191 */
ISDS_getAngularRates_float(WE_sensorInterface_t * sensorInterface,float * xRate,float * yRate,float * zRate)5192 int8_t ISDS_getAngularRates_float(WE_sensorInterface_t* sensorInterface, float *xRate, float *yRate, float *zRate)
5193 {
5194 int16_t xRawRate, yRawRate, zRawRate;
5195 if (WE_FAIL == ISDS_getRawAngularRates(sensorInterface, &xRawRate, &yRawRate, &zRawRate))
5196 {
5197 return WE_FAIL;
5198 }
5199 *xRate = ISDS_convertAngularRate_float(xRawRate, currentGyroFullScale);
5200 *yRate = ISDS_convertAngularRate_float(yRawRate, currentGyroFullScale);
5201 *zRate = ISDS_convertAngularRate_float(zRawRate, currentGyroFullScale);
5202 return WE_SUCCESS;
5203 }
5204 #endif /* WE_USE_FLOAT */
5205
5206 /**
5207 * @brief Reads the X-axis angular rate in [mdps]
5208 *
5209 * Note that this functions relies on the current gyroscope full scale value.
5210 * Make sure that the current gyroscope full scale value is known by calling
5211 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5212 * calling this function.
5213 *
5214 * @param[in] sensorInterface Pointer to sensor interface
5215 * @param[out] xRate X-axis angular rate in [mdps]
5216 * @retval Error code
5217 */
ISDS_getAngularRateX_int(WE_sensorInterface_t * sensorInterface,int32_t * xRate)5218 int8_t ISDS_getAngularRateX_int(WE_sensorInterface_t* sensorInterface, int32_t *xRate)
5219 {
5220 int16_t rawRate;
5221 if (WE_FAIL == ISDS_getRawAngularRateX(sensorInterface, &rawRate))
5222 {
5223 return WE_FAIL;
5224 }
5225 *xRate = ISDS_convertAngularRate_int(rawRate, currentGyroFullScale);
5226 return WE_SUCCESS;
5227 }
5228
5229 /**
5230 * @brief Reads the Y-axis angular rate in [mdps]
5231 *
5232 * Note that this functions relies on the current gyroscope full scale value.
5233 * Make sure that the current gyroscope full scale value is known by calling
5234 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5235 * calling this function.
5236 *
5237 * @param[in] sensorInterface Pointer to sensor interface
5238 * @param[out] yRate Y-axis angular rate in [mdps]
5239 * @retval Error code
5240 */
ISDS_getAngularRateY_int(WE_sensorInterface_t * sensorInterface,int32_t * yRate)5241 int8_t ISDS_getAngularRateY_int(WE_sensorInterface_t* sensorInterface, int32_t *yRate)
5242 {
5243 int16_t rawRate;
5244 if (WE_FAIL == ISDS_getRawAngularRateY(sensorInterface, &rawRate))
5245 {
5246 return WE_FAIL;
5247 }
5248 *yRate = ISDS_convertAngularRate_int(rawRate, currentGyroFullScale);
5249 return WE_SUCCESS;
5250 }
5251
5252 /**
5253 * @brief Reads the Z-axis angular rate in [mdps]
5254 *
5255 * Note that this functions relies on the current gyroscope full scale value.
5256 * Make sure that the current gyroscope full scale value is known by calling
5257 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5258 * calling this function.
5259 *
5260 * @param[in] sensorInterface Pointer to sensor interface
5261 * @param[out] zRate Z-axis angular rate in [mdps]
5262 * @retval Error code
5263 */
ISDS_getAngularRateZ_int(WE_sensorInterface_t * sensorInterface,int32_t * zRate)5264 int8_t ISDS_getAngularRateZ_int(WE_sensorInterface_t* sensorInterface, int32_t *zRate)
5265 {
5266 int16_t rawRate;
5267 if (WE_FAIL == ISDS_getRawAngularRateZ(sensorInterface, &rawRate))
5268 {
5269 return WE_FAIL;
5270 }
5271 *zRate = ISDS_convertAngularRate_int(rawRate, currentGyroFullScale);
5272 return WE_SUCCESS;
5273 }
5274
5275 /**
5276 * @brief Read the gyroscope sensor output in [mdps] for all three axes
5277 *
5278 * Note that this functions relies on the current gyroscope full scale value.
5279 * Make sure that the current gyroscope full scale value is known by calling
5280 * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5281 * calling this function.
5282 *
5283 * @param[in] sensorInterface Pointer to sensor interface
5284 * @param[out] xRate The returned X-axis angular rate in [mdps]
5285 * @param[out] yRate The returned Y-axis angular rate in [mdps]
5286 * @param[out] zRate The returned Z-axis angular rate in [mdps]
5287 * @retval Error code
5288 */
ISDS_getAngularRates_int(WE_sensorInterface_t * sensorInterface,int32_t * xRate,int32_t * yRate,int32_t * zRate)5289 int8_t ISDS_getAngularRates_int(WE_sensorInterface_t* sensorInterface, int32_t *xRate, int32_t *yRate, int32_t *zRate)
5290 {
5291 int16_t xRawRate, yRawRate, zRawRate;
5292 if (WE_FAIL == ISDS_getRawAngularRates(sensorInterface, &xRawRate, &yRawRate, &zRawRate))
5293 {
5294 return WE_FAIL;
5295 }
5296 *xRate = ISDS_convertAngularRate_int(xRawRate, currentGyroFullScale);
5297 *yRate = ISDS_convertAngularRate_int(yRawRate, currentGyroFullScale);
5298 *zRate = ISDS_convertAngularRate_int(zRawRate, currentGyroFullScale);
5299 return WE_SUCCESS;
5300 }
5301
5302 /**
5303 * @brief Read the raw X-axis gyroscope sensor output
5304 * @param[in] sensorInterface Pointer to sensor interface
5305 * @param[out] xRawAcc The returned raw X-axis angular rate
5306 * @retval Error code
5307 */
ISDS_getRawAngularRateX(WE_sensorInterface_t * sensorInterface,int16_t * xRawRate)5308 int8_t ISDS_getRawAngularRateX(WE_sensorInterface_t* sensorInterface, int16_t *xRawRate)
5309 {
5310 uint8_t tmp[2] = {0};
5311
5312 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_GYRO_REG, 2, tmp))
5313 {
5314 return WE_FAIL;
5315 }
5316
5317 *xRawRate = (int16_t) (tmp[1] << 8);
5318 *xRawRate |= (int16_t) tmp[0];
5319
5320 return WE_SUCCESS;
5321 }
5322
5323 /**
5324 * @brief Read the raw Y-axis gyroscope sensor output
5325 * @param[in] sensorInterface Pointer to sensor interface
5326 * @param[out] yRawRate The returned raw Y-axis angular rate
5327 * @retval Error code
5328 */
ISDS_getRawAngularRateY(WE_sensorInterface_t * sensorInterface,int16_t * yRawRate)5329 int8_t ISDS_getRawAngularRateY(WE_sensorInterface_t* sensorInterface, int16_t *yRawRate)
5330 {
5331 uint8_t tmp[2] = {0};
5332
5333 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Y_OUT_L_GYRO_REG, 2, tmp))
5334 {
5335 return WE_FAIL;
5336 }
5337
5338 *yRawRate = (int16_t) (tmp[1] << 8);
5339 *yRawRate |= (int16_t) tmp[0];
5340
5341 return WE_SUCCESS;
5342 }
5343
5344 /**
5345 * @brief Read the raw Z-axis gyroscope sensor output
5346 * @param[in] sensorInterface Pointer to sensor interface
5347 * @param[out] zRawAcc The returned raw Z-axis angular rate
5348 * @retval Error code
5349 */
ISDS_getRawAngularRateZ(WE_sensorInterface_t * sensorInterface,int16_t * zRawRate)5350 int8_t ISDS_getRawAngularRateZ(WE_sensorInterface_t* sensorInterface, int16_t *zRawRate)
5351 {
5352 uint8_t tmp[2] = {0};
5353
5354 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Z_OUT_L_GYRO_REG, 2, tmp))
5355 {
5356 return WE_FAIL;
5357 }
5358
5359 *zRawRate = (int16_t) (tmp[1] << 8);
5360 *zRawRate |= (int16_t) tmp[0];
5361
5362 return WE_SUCCESS;
5363 }
5364
5365 /**
5366 * @brief Read the raw gyroscope sensor output for all three axes
5367 * @param[in] sensorInterface Pointer to sensor interface
5368 * @param[out] xRawRate The returned raw X-axis angular rate
5369 * @param[out] yRawRate The returned raw Y-axis angular rate
5370 * @param[out] zRawRate The returned raw Z-axis angular rate
5371 * @retval Error code
5372 */
ISDS_getRawAngularRates(WE_sensorInterface_t * sensorInterface,int16_t * xRawRate,int16_t * yRawRate,int16_t * zRawRate)5373 int8_t ISDS_getRawAngularRates(WE_sensorInterface_t* sensorInterface, int16_t *xRawRate, int16_t *yRawRate, int16_t *zRawRate)
5374 {
5375 uint8_t tmp[6] = {0};
5376
5377 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_GYRO_REG, 6, tmp))
5378 {
5379 return WE_FAIL;
5380 }
5381
5382 *xRawRate = (int16_t) (tmp[1] << 8);
5383 *xRawRate |= (int16_t) tmp[0];
5384
5385 *yRawRate = (int16_t) (tmp[3] << 8);
5386 *yRawRate |= (int16_t) tmp[2];
5387
5388 *zRawRate = (int16_t) (tmp[5] << 8);
5389 *zRawRate |= (int16_t) tmp[4];
5390
5391 return WE_SUCCESS;
5392 }
5393
5394 #ifdef WE_USE_FLOAT
5395 /**
5396 * @brief Read the X-axis acceleration in [mg]
5397 *
5398 * Note that this functions relies on the current accelerometer full scale value.
5399 * Make sure that the current accelerometer full scale value is known by calling
5400 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5401 * calling this function.
5402 *
5403 * @param[in] sensorInterface Pointer to sensor interface
5404 * @param[out] xAcc X-axis acceleration in [mg]
5405 * @retval Error code
5406 */
ISDS_getAccelerationX_float(WE_sensorInterface_t * sensorInterface,float * xAcc)5407 int8_t ISDS_getAccelerationX_float(WE_sensorInterface_t* sensorInterface, float *xAcc)
5408 {
5409 int16_t rawAcc;
5410 if (WE_FAIL == ISDS_getRawAccelerationX(sensorInterface, &rawAcc))
5411 {
5412 return WE_FAIL;
5413 }
5414 *xAcc = ISDS_convertAcceleration_float(rawAcc, currentAccFullScale);
5415 return WE_SUCCESS;
5416 }
5417
5418 /**
5419 * @brief Read the Y-axis acceleration in [mg]
5420 *
5421 * Note that this functions relies on the current accelerometer full scale value.
5422 * Make sure that the current accelerometer full scale value is known by calling
5423 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5424 * calling this function.
5425 *
5426 * @param[in] sensorInterface Pointer to sensor interface
5427 * @param[out] yAcc Y-axis acceleration in [mg]
5428 * @retval Error code
5429 */
ISDS_getAccelerationY_float(WE_sensorInterface_t * sensorInterface,float * yAcc)5430 int8_t ISDS_getAccelerationY_float(WE_sensorInterface_t* sensorInterface, float *yAcc)
5431 {
5432 int16_t rawAcc;
5433 if (WE_FAIL == ISDS_getRawAccelerationY(sensorInterface, &rawAcc))
5434 {
5435 return WE_FAIL;
5436 }
5437 *yAcc = ISDS_convertAcceleration_float(rawAcc, currentAccFullScale);
5438 return WE_SUCCESS;
5439 }
5440
5441 /**
5442 * @brief Read the Z-axis acceleration in [mg]
5443 *
5444 * Note that this functions relies on the current accelerometer full scale value.
5445 * Make sure that the current accelerometer full scale value is known by calling
5446 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5447 * calling this function.
5448 *
5449 * @param[in] sensorInterface Pointer to sensor interface
5450 * @param[out] zAcc Z-axis acceleration in [mg]
5451 * @retval Error code
5452 */
ISDS_getAccelerationZ_float(WE_sensorInterface_t * sensorInterface,float * zAcc)5453 int8_t ISDS_getAccelerationZ_float(WE_sensorInterface_t* sensorInterface, float *zAcc)
5454 {
5455 int16_t rawAcc;
5456 if (WE_FAIL == ISDS_getRawAccelerationZ(sensorInterface, &rawAcc))
5457 {
5458 return WE_FAIL;
5459 }
5460 *zAcc = ISDS_convertAcceleration_float(rawAcc, currentAccFullScale);
5461 return WE_SUCCESS;
5462 }
5463
5464 /**
5465 * @brief Read the accelerometer sensor output in [mg] for all three axes
5466 *
5467 * Note that this functions relies on the current accelerometer full scale value.
5468 * Make sure that the current accelerometer full scale value is known by calling
5469 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5470 * calling this function.
5471 *
5472 * @param[in] sensorInterface Pointer to sensor interface
5473 * @param[out] xAcc The returned X-axis acceleration in [mg]
5474 * @param[out] yAcc The returned Y-axis acceleration in [mg]
5475 * @param[out] zAcc The returned Z-axis acceleration in [mg]
5476 * @retval Error code
5477 */
ISDS_getAccelerations_float(WE_sensorInterface_t * sensorInterface,float * xAcc,float * yAcc,float * zAcc)5478 int8_t ISDS_getAccelerations_float(WE_sensorInterface_t* sensorInterface, float *xAcc, float *yAcc, float *zAcc)
5479 {
5480 int16_t xRawAcc, yRawAcc, zRawAcc;
5481 if (WE_FAIL == ISDS_getRawAccelerations(sensorInterface, &xRawAcc, &yRawAcc, &zRawAcc))
5482 {
5483 return WE_FAIL;
5484 }
5485 *xAcc = ISDS_convertAcceleration_float(xRawAcc, currentAccFullScale);
5486 *yAcc = ISDS_convertAcceleration_float(yRawAcc, currentAccFullScale);
5487 *zAcc = ISDS_convertAcceleration_float(zRawAcc, currentAccFullScale);
5488 return WE_SUCCESS;
5489 }
5490 #endif /* WE_USE_FLOAT */
5491
5492 /**
5493 * @brief Read the X-axis acceleration in [mg]
5494 *
5495 * Note that this functions relies on the current accelerometer full scale value.
5496 * Make sure that the current accelerometer full scale value is known by calling
5497 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5498 * calling this function.
5499 *
5500 * @param[in] sensorInterface Pointer to sensor interface
5501 * @param[out] xAcc X-axis acceleration in [mg]
5502 * @retval Error code
5503 */
ISDS_getAccelerationX_int(WE_sensorInterface_t * sensorInterface,int16_t * xAcc)5504 int8_t ISDS_getAccelerationX_int(WE_sensorInterface_t* sensorInterface, int16_t *xAcc)
5505 {
5506 int16_t rawAcc;
5507 if (WE_FAIL == ISDS_getRawAccelerationX(sensorInterface, &rawAcc))
5508 {
5509 return WE_FAIL;
5510 }
5511 *xAcc = ISDS_convertAcceleration_int(rawAcc, currentAccFullScale);
5512 return WE_SUCCESS;
5513 }
5514
5515 /**
5516 * @brief Read the Y-axis acceleration in [mg]
5517 *
5518 * Note that this functions relies on the current accelerometer full scale value.
5519 * Make sure that the current accelerometer full scale value is known by calling
5520 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5521 * calling this function.
5522 *
5523 * @param[in] sensorInterface Pointer to sensor interface
5524 * @param[out] yAcc Y-axis acceleration in [mg]
5525 * @retval Error code
5526 */
ISDS_getAccelerationY_int(WE_sensorInterface_t * sensorInterface,int16_t * yAcc)5527 int8_t ISDS_getAccelerationY_int(WE_sensorInterface_t* sensorInterface, int16_t *yAcc)
5528 {
5529 int16_t rawAcc;
5530 if (WE_FAIL == ISDS_getRawAccelerationY(sensorInterface, &rawAcc))
5531 {
5532 return WE_FAIL;
5533 }
5534 *yAcc = ISDS_convertAcceleration_int(rawAcc, currentAccFullScale);
5535 return WE_SUCCESS;
5536 }
5537
5538 /**
5539 * @brief Read the Z-axis acceleration in [mg]
5540 *
5541 * Note that this functions relies on the current accelerometer full scale value.
5542 * Make sure that the current accelerometer full scale value is known by calling
5543 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5544 * calling this function.
5545 *
5546 * @param[in] sensorInterface Pointer to sensor interface
5547 * @param[out] zAcc Z-axis acceleration in [mg]
5548 * @retval Error code
5549 */
ISDS_getAccelerationZ_int(WE_sensorInterface_t * sensorInterface,int16_t * zAcc)5550 int8_t ISDS_getAccelerationZ_int(WE_sensorInterface_t* sensorInterface, int16_t *zAcc)
5551 {
5552 int16_t rawAcc;
5553 if (WE_FAIL == ISDS_getRawAccelerationZ(sensorInterface, &rawAcc))
5554 {
5555 return WE_FAIL;
5556 }
5557 *zAcc = ISDS_convertAcceleration_int(rawAcc, currentAccFullScale);
5558 return WE_SUCCESS;
5559 }
5560
5561 /**
5562 * @brief Read the accelerometer sensor output in [mg] for all three axes
5563 *
5564 * Note that this functions relies on the current accelerometer full scale value.
5565 * Make sure that the current accelerometer full scale value is known by calling
5566 * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5567 * calling this function.
5568 *
5569 * @param[in] sensorInterface Pointer to sensor interface
5570 * @param[out] xAcc The returned X-axis acceleration in [mg]
5571 * @param[out] yAcc The returned Y-axis acceleration in [mg]
5572 * @param[out] zAcc The returned Z-axis acceleration in [mg]
5573 * @retval Error code
5574 */
ISDS_getAccelerations_int(WE_sensorInterface_t * sensorInterface,int16_t * xAcc,int16_t * yAcc,int16_t * zAcc)5575 int8_t ISDS_getAccelerations_int(WE_sensorInterface_t* sensorInterface, int16_t *xAcc, int16_t *yAcc, int16_t *zAcc)
5576 {
5577 int16_t xRawAcc, yRawAcc, zRawAcc;
5578 if (WE_FAIL == ISDS_getRawAccelerations(sensorInterface, &xRawAcc, &yRawAcc, &zRawAcc))
5579 {
5580 return WE_FAIL;
5581 }
5582 *xAcc = ISDS_convertAcceleration_int(xRawAcc, currentAccFullScale);
5583 *yAcc = ISDS_convertAcceleration_int(yRawAcc, currentAccFullScale);
5584 *zAcc = ISDS_convertAcceleration_int(zRawAcc, currentAccFullScale);
5585 return WE_SUCCESS;
5586 }
5587
5588 /**
5589 * @brief Read the raw X-axis acceleration sensor output
5590 * @param[in] sensorInterface Pointer to sensor interface
5591 * @param[out] xRawAcc The returned raw X-axis acceleration
5592 * @retval Error code
5593 */
ISDS_getRawAccelerationX(WE_sensorInterface_t * sensorInterface,int16_t * xRawAcc)5594 int8_t ISDS_getRawAccelerationX(WE_sensorInterface_t* sensorInterface, int16_t *xRawAcc)
5595 {
5596 uint8_t tmp[2] = {0};
5597
5598 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_ACC_REG, 2, tmp))
5599 {
5600 return WE_FAIL;
5601 }
5602
5603 *xRawAcc = (int16_t) (tmp[1] << 8);
5604 *xRawAcc |= (int16_t) tmp[0];
5605
5606 return WE_SUCCESS;
5607 }
5608
5609 /**
5610 * @brief Read the raw Y-axis acceleration sensor output
5611 * @param[in] sensorInterface Pointer to sensor interface
5612 * @param[out] yRawAcc The returned raw Y-axis acceleration
5613 * @retval Error code
5614 */
ISDS_getRawAccelerationY(WE_sensorInterface_t * sensorInterface,int16_t * yRawAcc)5615 int8_t ISDS_getRawAccelerationY(WE_sensorInterface_t* sensorInterface, int16_t *yRawAcc)
5616 {
5617 uint8_t tmp[2] = {0};
5618
5619 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Y_OUT_L_ACC_REG, 2, tmp))
5620 {
5621 return WE_FAIL;
5622 }
5623
5624 *yRawAcc = (int16_t) (tmp[1] << 8);
5625 *yRawAcc |= (int16_t) tmp[0];
5626
5627 return WE_SUCCESS;
5628 }
5629
5630 /**
5631 * @brief Read the raw Z-axis acceleration sensor output
5632 * @param[in] sensorInterface Pointer to sensor interface
5633 * @param[out] zRawAcc The returned raw Z-axis acceleration
5634 * @retval Error code
5635 */
ISDS_getRawAccelerationZ(WE_sensorInterface_t * sensorInterface,int16_t * zRawAcc)5636 int8_t ISDS_getRawAccelerationZ(WE_sensorInterface_t* sensorInterface, int16_t *zRawAcc)
5637 {
5638 uint8_t tmp[2] = {0};
5639
5640 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Z_OUT_L_ACC_REG, 2, tmp))
5641 {
5642 return WE_FAIL;
5643 }
5644
5645 *zRawAcc = (int16_t) (tmp[1] << 8);
5646 *zRawAcc |= (int16_t) tmp[0];
5647
5648 return WE_SUCCESS;
5649 }
5650
5651 /**
5652 * @brief Read the raw accelerometer sensor output for all three axes
5653 * @param[in] sensorInterface Pointer to sensor interface
5654 * @param[out] xRawAcc The returned raw X-axis acceleration
5655 * @param[out] yRawAcc The returned raw Y-axis acceleration
5656 * @param[out] zRawAcc The returned raw Z-axis acceleration
5657 * @retval Error code
5658 */
ISDS_getRawAccelerations(WE_sensorInterface_t * sensorInterface,int16_t * xRawAcc,int16_t * yRawAcc,int16_t * zRawAcc)5659 int8_t ISDS_getRawAccelerations(WE_sensorInterface_t* sensorInterface, int16_t *xRawAcc, int16_t *yRawAcc, int16_t *zRawAcc)
5660 {
5661 uint8_t tmp[6] = {0};
5662
5663 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_ACC_REG, 6, tmp))
5664 {
5665 return WE_FAIL;
5666 }
5667
5668 *xRawAcc = (int16_t) (tmp[1] << 8);
5669 *xRawAcc |= (int16_t) tmp[0];
5670
5671 *yRawAcc = (int16_t) (tmp[3] << 8);
5672 *yRawAcc |= (int16_t) tmp[2];
5673
5674 *zRawAcc = (int16_t) (tmp[5] << 8);
5675 *zRawAcc |= (int16_t) tmp[4];
5676
5677 return WE_SUCCESS;
5678 }
5679
5680 #ifdef WE_USE_FLOAT
5681
5682 /**
5683 * @brief Read the temperature in [°C]
5684 * @param[in] sensorInterface Pointer to sensor interface
5685 * @param[out] temperature Temperature in [°C]
5686 * @retval Error code
5687 */
ISDS_getTemperature_float(WE_sensorInterface_t * sensorInterface,float * temperature)5688 int8_t ISDS_getTemperature_float(WE_sensorInterface_t* sensorInterface, float *temperature)
5689 {
5690 int16_t tempRaw;
5691 if (WE_FAIL == ISDS_getRawTemperature(sensorInterface, &tempRaw))
5692 {
5693 return WE_FAIL;
5694 }
5695 *temperature = ISDS_convertTemperature_float(tempRaw);
5696 return WE_SUCCESS;
5697 }
5698
5699 /**
5700 * @brief Read the temperature in [°C x 100]
5701 * @param[in] sensorInterface Pointer to sensor interface
5702 * @param[out] temperature Temperature in [°C x 100]
5703 * @retval Error code
5704 */
ISDS_getTemperature_int(WE_sensorInterface_t * sensorInterface,int16_t * temperature)5705 int8_t ISDS_getTemperature_int(WE_sensorInterface_t* sensorInterface, int16_t *temperature)
5706 {
5707 int16_t tempRaw;
5708 if (WE_FAIL == ISDS_getRawTemperature(sensorInterface, &tempRaw))
5709 {
5710 return WE_FAIL;
5711 }
5712 *temperature = ISDS_convertTemperature_int(tempRaw);
5713 return WE_SUCCESS;
5714 }
5715
5716 #endif /* WE_USE_FLOAT */
5717
5718 /**
5719 * @brief Read the raw temperature
5720 *
5721 * Can be converted to [°C] using ISDS_convertTemperature_float()
5722 *
5723 * @param[in] sensorInterface Pointer to sensor interface
5724 * @param[out] temperature Raw temperature value (temperature sensor output)
5725 * @retval Error code
5726 */
ISDS_getRawTemperature(WE_sensorInterface_t * sensorInterface,int16_t * temperature)5727 int8_t ISDS_getRawTemperature(WE_sensorInterface_t* sensorInterface, int16_t *temperature)
5728 {
5729 uint8_t tmp[2] = {0};
5730
5731 if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_OUT_TEMP_L_REG, 2, tmp))
5732 {
5733 return WE_FAIL;
5734 }
5735
5736 *temperature = (int16_t) (tmp[1] << 8);
5737 *temperature |= (int16_t) tmp[0];
5738
5739 return WE_SUCCESS;
5740 }
5741
5742
5743 #ifdef WE_USE_FLOAT
5744 /**
5745 * @brief Converts the supplied raw acceleration into [mg]
5746 * @param[in] acc Raw acceleration value (accelerometer output)
5747 * @param[in] fullScale Accelerometer full scale
5748 * @retval The converted acceleration in [mg]
5749 */
ISDS_convertAcceleration_float(int16_t acc,ISDS_accFullScale_t fullScale)5750 float ISDS_convertAcceleration_float(int16_t acc, ISDS_accFullScale_t fullScale)
5751 {
5752 switch (fullScale)
5753 {
5754 case ISDS_accFullScaleTwoG:
5755 return ISDS_convertAccelerationFs2g_float(acc);
5756
5757 case ISDS_accFullScaleSixteenG:
5758 return ISDS_convertAccelerationFs16g_float(acc);
5759
5760 case ISDS_accFullScaleFourG:
5761 return ISDS_convertAccelerationFs4g_float(acc);
5762
5763 case ISDS_accFullScaleEightG:
5764 return ISDS_convertAccelerationFs8g_float(acc);
5765
5766 case ISDS_accFullScaleInvalid:
5767 default:
5768 return 0;
5769 }
5770 }
5771
5772 /**
5773 * @brief Converts the supplied raw acceleration sampled using
5774 * ISDS_accFullScaleTwoG to [mg]
5775 * @param[in] acc Raw acceleration value (accelerometer output)
5776 * @retval The converted acceleration in [mg]
5777 */
ISDS_convertAccelerationFs2g_float(int16_t acc)5778 float ISDS_convertAccelerationFs2g_float(int16_t acc)
5779 {
5780 return ((float) acc * 0.061f);
5781 }
5782
5783 /**
5784 * @brief Converts the supplied raw acceleration sampled using
5785 * ISDS_accFullScaleFourG to [mg]
5786 * @param[in] acc Raw acceleration value (accelerometer output)
5787 * @retval The converted acceleration in [mg]
5788 */
ISDS_convertAccelerationFs4g_float(int16_t acc)5789 float ISDS_convertAccelerationFs4g_float(int16_t acc)
5790 {
5791 return ((float) acc * 0.122f);
5792 }
5793
5794 /**
5795 * @brief Converts the supplied raw acceleration sampled using
5796 * ISDS_accFullScaleEightG to [mg]
5797 * @param[in] acc Raw acceleration value (accelerometer output)
5798 * @retval The converted acceleration in [mg]
5799 */
ISDS_convertAccelerationFs8g_float(int16_t acc)5800 float ISDS_convertAccelerationFs8g_float(int16_t acc)
5801 {
5802 return ((float) acc * 0.244f);
5803 }
5804
5805 /**
5806 * @brief Converts the supplied raw acceleration sampled using
5807 * ISDS_accFullScaleSixteenG to [mg]
5808 * @param[in] acc Raw acceleration value (accelerometer output)
5809 * @retval The converted acceleration in [mg]
5810 */
ISDS_convertAccelerationFs16g_float(int16_t acc)5811 float ISDS_convertAccelerationFs16g_float(int16_t acc)
5812 {
5813 return ((float) acc * 0.488f);
5814 }
5815
5816 /**
5817 * @brief Converts the supplied raw angular rate into [mdps] (millidegrees per second).
5818 * @param[in] rate Raw angular rate (gyroscope output)
5819 * @param[in] fullScale Gyroscope full scale
5820 * @retval The converted angular rate in [mdps] (millidegrees per second)
5821 */
ISDS_convertAngularRate_float(int16_t rate,ISDS_gyroFullScale_t fullScale)5822 float ISDS_convertAngularRate_float(int16_t rate, ISDS_gyroFullScale_t fullScale)
5823 {
5824 switch (fullScale)
5825 {
5826 case ISDS_gyroFullScale250dps:
5827 return ISDS_convertAngularRateFs250dps_float(rate);
5828
5829 case ISDS_gyroFullScale125dps:
5830 return ISDS_convertAngularRateFs125dps_float(rate);
5831
5832 case ISDS_gyroFullScale500dps:
5833 return ISDS_convertAngularRateFs500dps_float(rate);
5834
5835 case ISDS_gyroFullScale1000dps:
5836 return ISDS_convertAngularRateFs1000dps_float(rate);
5837
5838 case ISDS_gyroFullScale2000dps:
5839 return ISDS_convertAngularRateFs2000dps_float(rate);
5840
5841 default:
5842 return 0;
5843 }
5844 }
5845
5846 /**
5847 * @brief Converts the supplied raw angular rate sampled using
5848 * ISDS_gyroFullScale125dps to [mdps] (millidegrees per second).
5849 * @param[in] rate Raw angular rate (gyroscope output)
5850 * @retval The converted angular rate in [mdps] (millidegrees per second)
5851 */
ISDS_convertAngularRateFs125dps_float(int16_t rate)5852 float ISDS_convertAngularRateFs125dps_float(int16_t rate)
5853 {
5854 return ((float) rate * 4.375f);
5855 }
5856
5857 /**
5858 * @brief Converts the supplied raw angular rate sampled using
5859 * ISDS_gyroFullScale250dps to [mdps] (millidegrees per second).
5860 * @param[in] rate Raw angular rate (gyroscope output)
5861 * @retval The converted angular rate in [mdps] (millidegrees per second)
5862 */
ISDS_convertAngularRateFs250dps_float(int16_t rate)5863 float ISDS_convertAngularRateFs250dps_float(int16_t rate)
5864 {
5865 return ((float) rate * 8.75f);
5866 }
5867
5868 /**
5869 * @brief Converts the supplied raw angular rate sampled using
5870 * ISDS_gyroFullScale500dps to [mdps] (millidegrees per second).
5871 * @param[in] rate Raw angular rate (gyroscope output)
5872 * @retval The converted angular rate in [mdps] (millidegrees per second)
5873 */
ISDS_convertAngularRateFs500dps_float(int16_t rate)5874 float ISDS_convertAngularRateFs500dps_float(int16_t rate)
5875 {
5876 return ((float) rate * 17.5f);
5877 }
5878
5879 /**
5880 * @brief Converts the supplied raw angular rate sampled using
5881 * ISDS_gyroFullScale1000dps to [mdps] (millidegrees per second).
5882 * @param[in] rate Raw angular rate (gyroscope output)
5883 * @retval The converted angular rate in [mdps] (millidegrees per second)
5884 */
ISDS_convertAngularRateFs1000dps_float(int16_t rate)5885 float ISDS_convertAngularRateFs1000dps_float(int16_t rate)
5886 {
5887 return ((float) rate * 35);
5888 }
5889
5890 /**
5891 * @brief Converts the supplied raw angular rate sampled using
5892 * ISDS_gyroFullScale2000dps to [mdps] (millidegrees per second).
5893 * @param[in] rate Raw angular rate (gyroscope output)
5894 * @retval The converted angular rate in [mdps] (millidegrees per second)
5895 */
ISDS_convertAngularRateFs2000dps_float(int16_t rate)5896 float ISDS_convertAngularRateFs2000dps_float(int16_t rate)
5897 {
5898 return ((float) rate * 70);
5899 }
5900
5901 /**
5902 * @brief Converts the supplied raw temperature to [°C].
5903 * @param[in] temperature Raw temperature (temperature sensor output)
5904 * @retval The converted temperature in [°C]
5905 */
ISDS_convertTemperature_float(int16_t temperature)5906 float ISDS_convertTemperature_float(int16_t temperature)
5907 {
5908 return ((((float) temperature) / 256.0f) + 25.0f);
5909 }
5910 #endif /* WE_USE_FLOAT */
5911
5912
5913 /**
5914 * @brief Converts the supplied raw acceleration into [mg]
5915 * @param[in] acc Raw acceleration value (accelerometer output)
5916 * @param[in] fullScale Accelerometer full scale
5917 * @retval The converted acceleration in [mg]
5918 */
ISDS_convertAcceleration_int(int16_t acc,ISDS_accFullScale_t fullScale)5919 int16_t ISDS_convertAcceleration_int(int16_t acc, ISDS_accFullScale_t fullScale)
5920 {
5921 switch (fullScale)
5922 {
5923 case ISDS_accFullScaleTwoG:
5924 return ISDS_convertAccelerationFs2g_int(acc);
5925
5926 case ISDS_accFullScaleSixteenG:
5927 return ISDS_convertAccelerationFs16g_int(acc);
5928
5929 case ISDS_accFullScaleFourG:
5930 return ISDS_convertAccelerationFs4g_int(acc);
5931
5932 case ISDS_accFullScaleEightG:
5933 return ISDS_convertAccelerationFs8g_int(acc);
5934
5935 case ISDS_accFullScaleInvalid:
5936 default:
5937 return 0;
5938 }
5939 }
5940
5941 /**
5942 * @brief Converts the supplied raw acceleration sampled using
5943 * ISDS_accFullScaleTwoG to [mg]
5944 * @param[in] acc Raw acceleration value (accelerometer output)
5945 * @retval The converted acceleration in [mg]
5946 */
ISDS_convertAccelerationFs2g_int(int16_t acc)5947 int16_t ISDS_convertAccelerationFs2g_int(int16_t acc)
5948 {
5949 return (int16_t) ((((int32_t) acc) * 61) / 1000);
5950 }
5951
5952 /**
5953 * @brief Converts the supplied raw acceleration sampled using
5954 * ISDS_accFullScaleFourG to [mg]
5955 * @param[in] acc Raw acceleration value (accelerometer output)
5956 * @retval The converted acceleration in [mg]
5957 */
ISDS_convertAccelerationFs4g_int(int16_t acc)5958 int16_t ISDS_convertAccelerationFs4g_int(int16_t acc)
5959 {
5960 return (int16_t) ((((int32_t) acc) * 122) / 1000);
5961 }
5962
5963 /**
5964 * @brief Converts the supplied raw acceleration sampled using
5965 * ISDS_accFullScaleEightG to [mg]
5966 * @param[in] acc Raw acceleration value (accelerometer output)
5967 * @retval The converted acceleration in [mg]
5968 */
ISDS_convertAccelerationFs8g_int(int16_t acc)5969 int16_t ISDS_convertAccelerationFs8g_int(int16_t acc)
5970 {
5971 return (int16_t) ((((int32_t) acc) * 244) / 1000);
5972 }
5973
5974 /**
5975 * @brief Converts the supplied raw acceleration sampled using
5976 * ISDS_accFullScaleSixteenG to [mg]
5977 * @param[in] acc Raw acceleration value (accelerometer output)
5978 * @retval The converted acceleration in [mg]
5979 */
ISDS_convertAccelerationFs16g_int(int16_t acc)5980 int16_t ISDS_convertAccelerationFs16g_int(int16_t acc)
5981 {
5982 return (int16_t) ((((int32_t) acc) * 488) / 1000);
5983 }
5984
5985 /**
5986 * @brief Converts the supplied raw angular rate into [mdps] (millidegrees per second).
5987 * @param[in] rate Raw angular rate (gyroscope output)
5988 * @param[in] fullScale Gyroscope full scale
5989 * @retval The converted angular rate in [mdps] (millidegrees per second)
5990 */
ISDS_convertAngularRate_int(int16_t rate,ISDS_gyroFullScale_t fullScale)5991 int32_t ISDS_convertAngularRate_int(int16_t rate, ISDS_gyroFullScale_t fullScale)
5992 {
5993 switch (fullScale)
5994 {
5995 case ISDS_gyroFullScale250dps:
5996 return ISDS_convertAngularRateFs250dps_int(rate);
5997
5998 case ISDS_gyroFullScale125dps:
5999 return ISDS_convertAngularRateFs125dps_int(rate);
6000
6001 case ISDS_gyroFullScale500dps:
6002 return ISDS_convertAngularRateFs500dps_int(rate);
6003
6004 case ISDS_gyroFullScale1000dps:
6005 return ISDS_convertAngularRateFs1000dps_int(rate);
6006
6007 case ISDS_gyroFullScale2000dps:
6008 return ISDS_convertAngularRateFs2000dps_int(rate);
6009
6010 default:
6011 return 0;
6012 }
6013 }
6014
6015 /**
6016 * @brief Converts the supplied raw angular rate sampled using
6017 * ISDS_gyroFullScale125dps to [mdps] (millidegrees per second).
6018 * @param[in] rate Raw angular rate (gyroscope output)
6019 * @retval The converted angular rate in [mdps] (millidegrees per second)
6020 */
ISDS_convertAngularRateFs125dps_int(int16_t rate)6021 int32_t ISDS_convertAngularRateFs125dps_int(int16_t rate)
6022 {
6023 return (((int32_t) rate) * 4375) / 1000;
6024 }
6025
6026 /**
6027 * @brief Converts the supplied raw angular rate sampled using
6028 * ISDS_gyroFullScale250dps to [mdps] (millidegrees per second).
6029 * @param[in] rate Raw angular rate (gyroscope output)
6030 * @retval The converted angular rate in [mdps] (millidegrees per second)
6031 */
ISDS_convertAngularRateFs250dps_int(int16_t rate)6032 int32_t ISDS_convertAngularRateFs250dps_int(int16_t rate)
6033 {
6034 return (((int32_t) rate) * 875) / 100;
6035 }
6036
6037 /**
6038 * @brief Converts the supplied raw angular rate sampled using
6039 * ISDS_gyroFullScale500dps to [mdps] (millidegrees per second).
6040 * @param[in] rate Raw angular rate (gyroscope output)
6041 * @retval The converted angular rate in [mdps] (millidegrees per second)
6042 */
ISDS_convertAngularRateFs500dps_int(int16_t rate)6043 int32_t ISDS_convertAngularRateFs500dps_int(int16_t rate)
6044 {
6045 return (((int32_t) rate) * 175) / 10;
6046 }
6047
6048 /**
6049 * @brief Converts the supplied raw angular rate sampled using
6050 * ISDS_gyroFullScale1000dps to [mdps] (millidegrees per second).
6051 * @param[in] rate Raw angular rate (gyroscope output)
6052 * @retval The converted angular rate in [mdps] (millidegrees per second)
6053 */
ISDS_convertAngularRateFs1000dps_int(int16_t rate)6054 int32_t ISDS_convertAngularRateFs1000dps_int(int16_t rate)
6055 {
6056 return ((int32_t) rate) * 35;
6057 }
6058
6059 /**
6060 * @brief Converts the supplied raw angular rate sampled using
6061 * ISDS_gyroFullScale2000dps to [mdps] (millidegrees per second).
6062 * @param[in] rate Raw angular rate (gyroscope output)
6063 * @retval The converted angular rate in [mdps] (millidegrees per second)
6064 */
ISDS_convertAngularRateFs2000dps_int(int16_t rate)6065 int32_t ISDS_convertAngularRateFs2000dps_int(int16_t rate)
6066 {
6067 return ((int32_t) rate) * 70;
6068 }
6069
6070 /**
6071 * @brief Converts the supplied raw temperature to [°C x 100].
6072 * @param[in] temperature Raw temperature (temperature sensor output)
6073 * @retval The converted temperature in [°C x 100]
6074 */
ISDS_convertTemperature_int(int16_t temperature)6075 int16_t ISDS_convertTemperature_int(int16_t temperature)
6076 {
6077 return (((int32_t) temperature) * 100) / 256 + 2500;
6078 }
6079