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 sensor.
10  */
11 
12 #include "WSEN_ISDS_2536030320001.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, .slaveTransmitterMode = 0, .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 /* ISDS_FIFO_STATUS_1_REG */
3425 /* ISDS_FIFO_STATUS_2_REG */
3426 /* ISDS_FIFO_STATUS_3_REG */
3427 /* ISDS_FIFO_STATUS_4_REG */
3428 
3429 /**
3430  * @brief Get overall FIFO status
3431  *
3432  * This is a convenience function querying all FIFO status registers in one read operation.
3433  *
3434  * @param[in] sensorInterface Pointer to sensor interface
3435  * @param[out] status The returned FIFO status flags register
3436  * @param[out] fillLevel The returned FIFO fill level (0-2047)
3437  * @param[out] fifoPattern Word of recursive pattern read at the next read
3438  * @retval Error code
3439  */
ISDS_getFifoStatus(WE_sensorInterface_t * sensorInterface,ISDS_fifoStatus2_t * status,uint16_t * fillLevel,uint16_t * fifoPattern)3440 int8_t ISDS_getFifoStatus(WE_sensorInterface_t* sensorInterface, ISDS_fifoStatus2_t *status, uint16_t *fillLevel, uint16_t *fifoPattern)
3441 {
3442   uint8_t tmp[4];
3443   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_1_REG, 4, tmp))
3444   {
3445     return WE_FAIL;
3446   }
3447 
3448   ISDS_fifoStatus1_t *fifoStatus1 = (ISDS_fifoStatus1_t *) tmp;
3449   ISDS_fifoStatus2_t *fifoStatus2 = (ISDS_fifoStatus2_t *) tmp + 1;
3450   ISDS_fifoStatus3_t *fifoStatus3 = (ISDS_fifoStatus3_t *) tmp + 2;
3451   ISDS_fifoStatus4_t *fifoStatus4 = (ISDS_fifoStatus4_t *) tmp + 3;
3452 
3453   *status = *(ISDS_fifoStatus2_t*) fifoStatus2;
3454 
3455   *fillLevel = ((uint16_t) fifoStatus1->fifoFillLevelLsb) |
3456                (((uint16_t) (fifoStatus2->fifoFillLevelMsb & 0x07)) << 8);
3457 
3458   *fifoPattern = ((uint16_t) fifoStatus3->fifoPatternLsb) |
3459                  (((uint16_t) (fifoStatus4->fifoPatternMsb & 0x03)) << 8);
3460 
3461   return WE_SUCCESS;
3462 }
3463 
3464 /**
3465  * @brief Get FIFO status flags register
3466  * @param[in] sensorInterface Pointer to sensor interface
3467  * @param[out] status The returned FIFO status flags register
3468  * @retval Error code
3469  */
ISDS_getFifoStatus2Register(WE_sensorInterface_t * sensorInterface,ISDS_fifoStatus2_t * status)3470 int8_t ISDS_getFifoStatus2Register(WE_sensorInterface_t* sensorInterface, ISDS_fifoStatus2_t *status)
3471 {
3472   return ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) status);
3473 }
3474 
3475 /**
3476  * @brief Read the FIFO fill level
3477  * @param[in] sensorInterface Pointer to sensor interface
3478  * @param[out] fillLevel The returned FIFO fill level (0-2047)
3479  * @retval Error code
3480  */
ISDS_getFifoFillLevel(WE_sensorInterface_t * sensorInterface,uint16_t * fillLevel)3481 int8_t ISDS_getFifoFillLevel(WE_sensorInterface_t* sensorInterface, uint16_t *fillLevel)
3482 {
3483   uint8_t tmp[2];
3484   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_1_REG, 2, tmp))
3485   {
3486     return WE_FAIL;
3487   }
3488 
3489   ISDS_fifoStatus1_t *fifoStatus1 = (ISDS_fifoStatus1_t *) tmp;
3490   ISDS_fifoStatus2_t *fifoStatus2 = (ISDS_fifoStatus2_t *) tmp + 1;
3491 
3492   *fillLevel = ((uint16_t) fifoStatus1->fifoFillLevelLsb) |
3493                (((uint16_t) (fifoStatus2->fifoFillLevelMsb & 0x07)) << 8);
3494 
3495   return WE_SUCCESS;
3496 }
3497 
3498 /**
3499  * @brief Check if the FIFO is empty
3500  * @param[in] sensorInterface Pointer to sensor interface
3501  * @param[out] empty FIFO empty state
3502  * @retval Error code
3503  */
ISDS_isFifoEmpty(WE_sensorInterface_t * sensorInterface,ISDS_state_t * empty)3504 int8_t ISDS_isFifoEmpty(WE_sensorInterface_t* sensorInterface, ISDS_state_t *empty)
3505 {
3506   ISDS_fifoStatus2_t fifoStatus2;
3507 
3508   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3509   {
3510     return WE_FAIL;
3511   }
3512 
3513   *empty = (ISDS_state_t) fifoStatus2.fifoEmptyState;
3514 
3515   return WE_SUCCESS;
3516 }
3517 
3518 /**
3519  * @brief Check if the FIFO is full
3520  * @param[in] sensorInterface Pointer to sensor interface
3521  * @param[out] full FIFO full state
3522  * @retval Error code
3523  */
ISDS_isFifoFull(WE_sensorInterface_t * sensorInterface,ISDS_state_t * full)3524 int8_t ISDS_isFifoFull(WE_sensorInterface_t* sensorInterface, ISDS_state_t *full)
3525 {
3526   ISDS_fifoStatus2_t fifoStatus2;
3527 
3528   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3529   {
3530     return WE_FAIL;
3531   }
3532 
3533   *full = (ISDS_state_t) fifoStatus2.fifoFullSmartState;
3534 
3535   return WE_SUCCESS;
3536 }
3537 
3538 /**
3539  * @brief Check if a FIFO overrun has occurred
3540  * @param[in] sensorInterface Pointer to sensor interface
3541  * @param[out] overrun FIFO overrun state
3542  * @retval Error code
3543  */
ISDS_getFifoOverrunState(WE_sensorInterface_t * sensorInterface,ISDS_state_t * overrun)3544 int8_t ISDS_getFifoOverrunState(WE_sensorInterface_t* sensorInterface, ISDS_state_t *overrun)
3545 {
3546   ISDS_fifoStatus2_t fifoStatus2;
3547 
3548   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3549   {
3550     return WE_FAIL;
3551   }
3552 
3553   *overrun = (ISDS_state_t) fifoStatus2.fifoOverrunState;
3554 
3555   return WE_SUCCESS;
3556 }
3557 
3558 /**
3559  * @brief Check if the FIFO fill threshold has been reached
3560  * @param[in] sensorInterface Pointer to sensor interface
3561  * @param[out] threshReached FIFO threshold status bit
3562  * @retval Error code
3563  */
ISDS_isFifoThresholdReached(WE_sensorInterface_t * sensorInterface,ISDS_state_t * threshReached)3564 int8_t ISDS_isFifoThresholdReached(WE_sensorInterface_t* sensorInterface, ISDS_state_t *threshReached)
3565 {
3566   ISDS_fifoStatus2_t fifoStatus2;
3567 
3568   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_2_REG, 1, (uint8_t *) &fifoStatus2))
3569   {
3570     return WE_FAIL;
3571   }
3572 
3573   *threshReached = (ISDS_state_t) fifoStatus2.fifoThresholdState;
3574 
3575   return WE_SUCCESS;
3576 }
3577 
3578 /**
3579  * @brief Get the word of recursive pattern read at the next read
3580  * @param[in] sensorInterface Pointer to sensor interface
3581  * @param[out] fifoPattern Word of recursive pattern read at the next read
3582  * @retval Error code
3583  */
ISDS_getFifoPattern(WE_sensorInterface_t * sensorInterface,uint16_t * fifoPattern)3584 int8_t ISDS_getFifoPattern(WE_sensorInterface_t* sensorInterface, uint16_t *fifoPattern)
3585 {
3586   uint8_t tmp[2];
3587   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FIFO_STATUS_3_REG, 2, tmp))
3588   {
3589     return WE_FAIL;
3590   }
3591 
3592   ISDS_fifoStatus3_t *fifoStatus3 = (ISDS_fifoStatus3_t *) tmp;
3593   ISDS_fifoStatus4_t *fifoStatus4 = (ISDS_fifoStatus4_t *) tmp + 1;
3594 
3595   *fifoPattern = ((uint16_t) fifoStatus3->fifoPatternLsb) |
3596                  (((uint16_t) (fifoStatus4->fifoPatternMsb & 0x03)) << 8);
3597 
3598   return WE_SUCCESS;
3599 }
3600 
3601 
3602 /* ISDS_FUNC_SRC_1_REG */
3603 
3604 /**
3605  * @brief Check if a tilt event has occurred
3606  * @param[in] sensorInterface Pointer to sensor interface
3607  * @param[out] tiltEvent Tilt event state
3608  * @retval Error code
3609  */
ISDS_isTiltEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tiltEvent)3610 int8_t ISDS_isTiltEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tiltEvent)
3611 {
3612   ISDS_funcSrc1_t funcSrc1;
3613 
3614   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FUNC_SRC_1_REG, 1, (uint8_t *) &funcSrc1))
3615   {
3616     return WE_FAIL;
3617   }
3618 
3619   *tiltEvent = (ISDS_state_t) funcSrc1.tiltState;
3620 
3621   return WE_SUCCESS;
3622 }
3623 
3624 
3625 /* ISDS_TAP_CFG_REG */
3626 
3627 /**
3628  * @brief Enable/disable latched interrupts
3629  * @param[in] sensorInterface Pointer to sensor interface
3630  * @param[in] lir Latched interrupts state
3631  * @retval Error code
3632  */
ISDS_enableLatchedInterrupt(WE_sensorInterface_t * sensorInterface,ISDS_state_t lir)3633 int8_t ISDS_enableLatchedInterrupt(WE_sensorInterface_t* sensorInterface, ISDS_state_t lir)
3634 {
3635   ISDS_tapCfg_t tapCfg;
3636 
3637   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3638   {
3639     return WE_FAIL;
3640   }
3641 
3642   tapCfg.latchedInterrupt = lir;
3643 
3644   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3645 }
3646 
3647 /**
3648  * @brief Read the latched interrupts state [enabled, disabled]
3649  * @param[in] sensorInterface Pointer to sensor interface
3650  * @param[out] lir The returned latched interrupts state
3651  * @retval Error code
3652  */
ISDS_isLatchedInterruptEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * lir)3653 int8_t ISDS_isLatchedInterruptEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *lir)
3654 {
3655   ISDS_tapCfg_t tapCfg;
3656 
3657   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3658   {
3659     return WE_FAIL;
3660   }
3661 
3662   *lir = (ISDS_state_t) tapCfg.latchedInterrupt;
3663 
3664   return WE_SUCCESS;
3665 }
3666 
3667 /**
3668  * @brief Enable/disable tap recognition in X direction
3669  * @param[in] sensorInterface Pointer to sensor interface
3670  * @param[in] tapX Tap X direction state
3671  * @retval Error code
3672  */
ISDS_enableTapX(WE_sensorInterface_t * sensorInterface,ISDS_state_t tapX)3673 int8_t ISDS_enableTapX(WE_sensorInterface_t* sensorInterface, ISDS_state_t tapX)
3674 {
3675   ISDS_tapCfg_t tapCfg;
3676 
3677   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3678   {
3679     return WE_FAIL;
3680   }
3681 
3682   tapCfg.enTapX = tapX;
3683 
3684   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3685 }
3686 
3687 /**
3688  * @brief Check if detection of tap events in X direction is enabled
3689  * @param[in] sensorInterface Pointer to sensor interface
3690  * @param[out] tapX The returned tap X direction state
3691  * @retval Error code
3692  */
ISDS_isTapXEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapX)3693 int8_t ISDS_isTapXEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapX)
3694 {
3695   ISDS_tapCfg_t tapCfg;
3696 
3697   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3698   {
3699     return WE_FAIL;
3700   }
3701 
3702   *tapX = (ISDS_state_t) tapCfg.enTapX;
3703 
3704   return WE_SUCCESS;
3705 }
3706 
3707 /**
3708  * @brief Enable/disable tap recognition in Y direction
3709  * @param[in] sensorInterface Pointer to sensor interface
3710  * @param[in] tapY Tap Y direction state
3711  * @retval Error code
3712  */
ISDS_enableTapY(WE_sensorInterface_t * sensorInterface,ISDS_state_t tapY)3713 int8_t ISDS_enableTapY(WE_sensorInterface_t* sensorInterface, ISDS_state_t tapY)
3714 {
3715   ISDS_tapCfg_t tapCfg;
3716 
3717   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3718   {
3719     return WE_FAIL;
3720   }
3721 
3722   tapCfg.enTapY = tapY;
3723 
3724   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3725 }
3726 
3727 /**
3728  * @brief Check if detection of tap events in Y direction is enabled
3729  * @param[in] sensorInterface Pointer to sensor interface
3730  * @param[out] tapY The returned tap Y direction state
3731  * @retval Error code
3732  */
ISDS_isTapYEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapY)3733 int8_t ISDS_isTapYEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapY)
3734 {
3735   ISDS_tapCfg_t tapCfg;
3736 
3737   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3738   {
3739     return WE_FAIL;
3740   }
3741 
3742   *tapY = (ISDS_state_t) tapCfg.enTapY;
3743 
3744   return WE_SUCCESS;
3745 }
3746 
3747 /**
3748  * @brief Enable/disable tap recognition in Z direction
3749  * @param[in] sensorInterface Pointer to sensor interface
3750  * @param[in] tapZ Tap Z direction state
3751  * @retval Error code
3752  */
ISDS_enableTapZ(WE_sensorInterface_t * sensorInterface,ISDS_state_t tapZ)3753 int8_t ISDS_enableTapZ(WE_sensorInterface_t* sensorInterface, ISDS_state_t tapZ)
3754 {
3755   ISDS_tapCfg_t tapCfg;
3756 
3757   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3758   {
3759     return WE_FAIL;
3760   }
3761 
3762   tapCfg.enTapZ = tapZ;
3763 
3764   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3765 }
3766 
3767 /**
3768  * @brief Check if detection of tap events in Z direction is enabled
3769  * @param[in] sensorInterface Pointer to sensor interface
3770  * @param[out] tapZ The returned tap Z direction state
3771  * @retval Error code
3772  */
ISDS_isTapZEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * tapZ)3773 int8_t ISDS_isTapZEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *tapZ)
3774 {
3775   ISDS_tapCfg_t tapCfg;
3776 
3777   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3778   {
3779     return WE_FAIL;
3780   }
3781 
3782   *tapZ = (ISDS_state_t) tapCfg.enTapZ;
3783 
3784   return WE_SUCCESS;
3785 }
3786 
3787 /**
3788  * @brief Set activity filter (HPF or SLOPE filter selection on wake-up and activity/inactivity functions)
3789  * @param[in] sensorInterface Pointer to sensor interface
3790  * @param[in] filter Activity filter
3791  * @retval Error code
3792  */
ISDS_setActivityFilter(WE_sensorInterface_t * sensorInterface,ISDS_activityFilter_t filter)3793 int8_t ISDS_setActivityFilter(WE_sensorInterface_t* sensorInterface, ISDS_activityFilter_t filter)
3794 {
3795   ISDS_tapCfg_t tapCfg;
3796 
3797   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3798   {
3799     return WE_FAIL;
3800   }
3801 
3802   tapCfg.filterSelection = filter;
3803 
3804   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3805 }
3806 
3807 /**
3808  * @brief Read activity filter (HPF or SLOPE filter selection on wake-up and activity/inactivity functions)
3809  * @param[in] sensorInterface Pointer to sensor interface
3810  * @param[out] filter The returned activity filter
3811  * @retval Error code
3812  */
ISDS_getActivityFilter(WE_sensorInterface_t * sensorInterface,ISDS_activityFilter_t * filter)3813 int8_t ISDS_getActivityFilter(WE_sensorInterface_t* sensorInterface, ISDS_activityFilter_t *filter)
3814 {
3815   ISDS_tapCfg_t tapCfg;
3816 
3817   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3818   {
3819     return WE_FAIL;
3820   }
3821 
3822   *filter = (ISDS_activityFilter_t) tapCfg.filterSelection;
3823 
3824   return WE_SUCCESS;
3825 }
3826 
3827 /**
3828  * @brief Set inactivity function
3829  * @param[in] sensorInterface Pointer to sensor interface
3830  * @param[in] function Inactivity function
3831  * @retval Error code
3832  */
ISDS_setInactivityFunction(WE_sensorInterface_t * sensorInterface,ISDS_inactivityFunction_t function)3833 int8_t ISDS_setInactivityFunction(WE_sensorInterface_t* sensorInterface, ISDS_inactivityFunction_t function)
3834 {
3835   ISDS_tapCfg_t tapCfg;
3836 
3837   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3838   {
3839     return WE_FAIL;
3840   }
3841 
3842   tapCfg.enInactivity = function;
3843 
3844   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3845 }
3846 
3847 /**
3848  * @brief Read inactivity function
3849  * @param[in] sensorInterface Pointer to sensor interface
3850  * @param[out] function The returned inactivity function
3851  * @retval Error code
3852  */
ISDS_getInactivityFunction(WE_sensorInterface_t * sensorInterface,ISDS_inactivityFunction_t * function)3853 int8_t ISDS_getInactivityFunction(WE_sensorInterface_t* sensorInterface, ISDS_inactivityFunction_t *function)
3854 {
3855   ISDS_tapCfg_t tapCfg;
3856 
3857   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3858   {
3859     return WE_FAIL;
3860   }
3861 
3862   *function = (ISDS_inactivityFunction_t) tapCfg.enInactivity;
3863 
3864   return WE_SUCCESS;
3865 }
3866 
3867 /**
3868  * @brief Enable/disable interrupts
3869  * @param[in] sensorInterface Pointer to sensor interface
3870  * @param[in] interruptsEnable Interrupts enable state
3871  * @retval Error code
3872  */
ISDS_enableInterrupts(WE_sensorInterface_t * sensorInterface,ISDS_state_t interruptsEnable)3873 int8_t ISDS_enableInterrupts(WE_sensorInterface_t* sensorInterface, ISDS_state_t interruptsEnable)
3874 {
3875   ISDS_tapCfg_t tapCfg;
3876 
3877   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3878   {
3879     return WE_FAIL;
3880   }
3881 
3882   tapCfg.enInterrupts = interruptsEnable;
3883 
3884   return ISDS_WriteReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg);
3885 }
3886 
3887 /**
3888  * @brief Check if interrupts are enabled
3889  * @param[in] sensorInterface Pointer to sensor interface
3890  * @param[out] interruptsEnable The returned interrupts enable state.
3891  * @retval Error code
3892  */
ISDS_areInterruptsEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * interruptsEnable)3893 int8_t ISDS_areInterruptsEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *interruptsEnable)
3894 {
3895   ISDS_tapCfg_t tapCfg;
3896 
3897   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_CFG_REG, 1, (uint8_t *) &tapCfg))
3898   {
3899     return WE_FAIL;
3900   }
3901 
3902   *interruptsEnable = (ISDS_state_t) tapCfg.enInterrupts;
3903 
3904   return WE_SUCCESS;
3905 }
3906 
3907 
3908 /* ISDS_TAP_THS_6D_REG */
3909 
3910 /**
3911  * @brief Set the tap threshold
3912  * @param[in] sensorInterface Pointer to sensor interface
3913  * @param[in] tapThreshold Tap threshold (5 bits)
3914  * @retval Error code
3915  */
ISDS_setTapThreshold(WE_sensorInterface_t * sensorInterface,uint8_t tapThreshold)3916 int8_t ISDS_setTapThreshold(WE_sensorInterface_t* sensorInterface, uint8_t tapThreshold)
3917 {
3918   ISDS_tapThs6d_t tapThs6d;
3919 
3920   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3921   {
3922     return WE_FAIL;
3923   }
3924 
3925   tapThs6d.tapThreshold = (tapThreshold & 0x1F);
3926 
3927   return ISDS_WriteReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d);
3928 }
3929 
3930 /**
3931  * @brief Read the tap threshold
3932  * @param[in] sensorInterface Pointer to sensor interface
3933  * @param[out] tapThreshold The returned tap threshold
3934  * @retval Error code
3935  */
ISDS_getTapThreshold(WE_sensorInterface_t * sensorInterface,uint8_t * tapThreshold)3936 int8_t ISDS_getTapThreshold(WE_sensorInterface_t* sensorInterface, uint8_t *tapThreshold)
3937 {
3938   ISDS_tapThs6d_t tapThs6d;
3939 
3940   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3941   {
3942     return WE_FAIL;
3943   }
3944 
3945   *tapThreshold = tapThs6d.tapThreshold;
3946 
3947   return WE_SUCCESS;
3948 }
3949 
3950 /**
3951  * @brief Set the 6D orientation detection threshold (degrees)
3952  * @param[in] sensorInterface Pointer to sensor interface
3953  * @param[in] threshold6D 6D orientation detection threshold
3954  * @retval Error code
3955  */
ISDS_set6DThreshold(WE_sensorInterface_t * sensorInterface,ISDS_sixDThreshold_t threshold6D)3956 int8_t ISDS_set6DThreshold(WE_sensorInterface_t* sensorInterface, ISDS_sixDThreshold_t threshold6D)
3957 {
3958   ISDS_tapThs6d_t tapThs6d;
3959 
3960   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3961   {
3962     return WE_FAIL;
3963   }
3964 
3965   tapThs6d.sixDThreshold = threshold6D;
3966 
3967   return ISDS_WriteReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d);
3968 }
3969 
3970 /**
3971  * @brief Read the 6D orientation detection threshold (degrees)
3972  * @param[in] sensorInterface Pointer to sensor interface
3973  * @param[out] threshold6D The returned 6D orientation detection threshold
3974  * @retval Error code
3975  */
ISDS_get6DThreshold(WE_sensorInterface_t * sensorInterface,ISDS_sixDThreshold_t * threshold6D)3976 int8_t ISDS_get6DThreshold(WE_sensorInterface_t* sensorInterface, ISDS_sixDThreshold_t *threshold6D)
3977 {
3978   ISDS_tapThs6d_t tapThs6d;
3979 
3980   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
3981   {
3982     return WE_FAIL;
3983   }
3984 
3985   *threshold6D = (ISDS_sixDThreshold_t) tapThs6d.sixDThreshold;
3986 
3987   return WE_SUCCESS;
3988 }
3989 
3990 /**
3991  * @brief Enable/disable 4D orientation detection
3992  * @param[in] sensorInterface Pointer to sensor interface
3993  * @param[in] detection4D The 4D orientation detection enable state
3994  * @retval Error code
3995  */
ISDS_enable4DDetection(WE_sensorInterface_t * sensorInterface,ISDS_state_t detection4D)3996 int8_t ISDS_enable4DDetection(WE_sensorInterface_t* sensorInterface, ISDS_state_t detection4D)
3997 {
3998   ISDS_tapThs6d_t tapThs6d;
3999 
4000   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
4001   {
4002     return WE_FAIL;
4003   }
4004 
4005   tapThs6d.fourDDetectionEnabled = detection4D;
4006 
4007   return ISDS_WriteReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d);
4008 }
4009 
4010 /**
4011  * @brief Check if 4D orientation detection is enabled
4012  * @param[in] sensorInterface Pointer to sensor interface
4013  * @param[out] detection4D The returned 4D orientation detection enable state
4014  * @retval Error code
4015  */
ISDS_is4DDetectionEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * detection4D)4016 int8_t ISDS_is4DDetectionEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *detection4D)
4017 {
4018   ISDS_tapThs6d_t tapThs6d;
4019 
4020   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_TAP_THS_6D_REG, 1, (uint8_t *) &tapThs6d))
4021   {
4022     return WE_FAIL;
4023   }
4024 
4025   *detection4D = (ISDS_state_t) tapThs6d.fourDDetectionEnabled;
4026 
4027   return WE_SUCCESS;
4028 }
4029 
4030 
4031 /* ISDS_INT_DUR2_REG */
4032 
4033 /**
4034  * @brief Set the maximum duration time gap for double-tap recognition (LATENCY)
4035  * @param[in] sensorInterface Pointer to sensor interface
4036  * @param[in] latencyTime Latency value (4 bits)
4037  * @retval Error code
4038  */
ISDS_setTapLatencyTime(WE_sensorInterface_t * sensorInterface,uint8_t latencyTime)4039 int8_t ISDS_setTapLatencyTime(WE_sensorInterface_t* sensorInterface, uint8_t latencyTime)
4040 {
4041   ISDS_intDur2_t intDuration;
4042 
4043   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4044   {
4045     return WE_FAIL;
4046   }
4047 
4048   intDuration.latency = (latencyTime & 0x0F);
4049 
4050   return ISDS_WriteReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration);
4051 }
4052 
4053 /**
4054  * @brief Read the maximum duration time gap for double-tap recognition (LATENCY)
4055  * @param[in] sensorInterface Pointer to sensor interface
4056  * @param[out] latencyTime The returned latency time
4057  * @retval Error code
4058  */
ISDS_getTapLatencyTime(WE_sensorInterface_t * sensorInterface,uint8_t * latencyTime)4059 int8_t ISDS_getTapLatencyTime(WE_sensorInterface_t* sensorInterface, uint8_t *latencyTime)
4060 {
4061   ISDS_intDur2_t intDuration;
4062 
4063   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4064   {
4065     return WE_FAIL;
4066   }
4067 
4068   *latencyTime = intDuration.latency;
4069 
4070   return WE_SUCCESS;
4071 }
4072 
4073 /**
4074  * @brief Set the expected quiet time after a tap detection (QUIET)
4075  * @param[in] sensorInterface Pointer to sensor interface
4076  * @param[in] quietTime Quiet time value (2 bits)
4077  * @retval Error code
4078  */
ISDS_setTapQuietTime(WE_sensorInterface_t * sensorInterface,uint8_t quietTime)4079 int8_t ISDS_setTapQuietTime(WE_sensorInterface_t* sensorInterface, uint8_t quietTime)
4080 {
4081   ISDS_intDur2_t intDuration;
4082 
4083   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4084   {
4085     return WE_FAIL;
4086   }
4087 
4088   intDuration.quiet = (quietTime & 0x03);
4089 
4090   return ISDS_WriteReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration);
4091 }
4092 
4093 /**
4094  * @brief Read the expected quiet time after a tap detection (QUIET)
4095  * @param[in] sensorInterface Pointer to sensor interface
4096  * @param[out] quietTime The returned quiet time
4097  * @retval Error code
4098  */
ISDS_getTapQuietTime(WE_sensorInterface_t * sensorInterface,uint8_t * quietTime)4099 int8_t ISDS_getTapQuietTime(WE_sensorInterface_t* sensorInterface, uint8_t *quietTime)
4100 {
4101 
4102   ISDS_intDur2_t intDuration;
4103 
4104   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4105   {
4106     return WE_FAIL;
4107   }
4108 
4109   *quietTime = intDuration.quiet;
4110 
4111   return WE_SUCCESS;
4112 }
4113 
4114 /**
4115  * @brief Set the maximum duration of over-threshold events (SHOCK)
4116  * @param[in] sensorInterface Pointer to sensor interface
4117  * @param[in] shockTime Shock time value (2 bits)
4118  * @retval Error code
4119  */
ISDS_setTapShockTime(WE_sensorInterface_t * sensorInterface,uint8_t shockTime)4120 int8_t ISDS_setTapShockTime(WE_sensorInterface_t* sensorInterface, uint8_t shockTime)
4121 {
4122   ISDS_intDur2_t intDuration;
4123 
4124   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4125   {
4126     return WE_FAIL;
4127   }
4128 
4129   intDuration.shock = (shockTime & 0x03);
4130 
4131   return ISDS_WriteReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration);
4132 }
4133 
4134 /**
4135  * @brief Read the maximum duration of over-threshold events (SHOCK)
4136  * @param[in] sensorInterface Pointer to sensor interface
4137  * @param[out] shockTime The returned shock time.
4138  * @retval Error code
4139  */
ISDS_getTapShockTime(WE_sensorInterface_t * sensorInterface,uint8_t * shockTime)4140 int8_t ISDS_getTapShockTime(WE_sensorInterface_t* sensorInterface, uint8_t *shockTime)
4141 {
4142   ISDS_intDur2_t intDuration;
4143 
4144   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_INT_DUR2_REG, 1, (uint8_t *) &intDuration))
4145   {
4146     return WE_FAIL;
4147   }
4148 
4149   *shockTime = intDuration.shock;
4150 
4151   return WE_SUCCESS;
4152 }
4153 
4154 
4155 /* ISDS_WAKE_UP_THS_REG */
4156 
4157 /**
4158  * @brief Set wake-up threshold
4159  * @param[in] sensorInterface Pointer to sensor interface
4160  * @param[in] thresh Wake-up threshold (six bits)
4161  * @retval Error code
4162  */
ISDS_setWakeUpThreshold(WE_sensorInterface_t * sensorInterface,uint8_t thresh)4163 int8_t ISDS_setWakeUpThreshold(WE_sensorInterface_t* sensorInterface, uint8_t thresh)
4164 {
4165   ISDS_wakeUpThs_t wakeUpThs;
4166 
4167   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4168   {
4169     return WE_FAIL;
4170   }
4171 
4172   wakeUpThs.wakeUpThreshold = (thresh & 0x3F);
4173 
4174   return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs);
4175 }
4176 
4177 /**
4178  * @brief Read the wake-up threshold
4179  * @param[in] sensorInterface Pointer to sensor interface
4180  * @param[out] thresh The returned wake-up threshold.
4181  * @retval Error code
4182  */
ISDS_getWakeUpThreshold(WE_sensorInterface_t * sensorInterface,uint8_t * thresh)4183 int8_t ISDS_getWakeUpThreshold(WE_sensorInterface_t* sensorInterface, uint8_t *thresh)
4184 {
4185   ISDS_wakeUpThs_t wakeUpThs;
4186 
4187   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4188   {
4189     return WE_FAIL;
4190   }
4191 
4192   *thresh = wakeUpThs.wakeUpThreshold;
4193 
4194   return WE_SUCCESS;
4195 }
4196 
4197 /**
4198  * @brief Enable/disable the single and double-tap event OR only single-tap event
4199  * @param[in] sensorInterface Pointer to sensor interface
4200  * @param[in] doubleTapEnable Tap event state [0: only single, 1: single and double-tap]
4201  * @retval Error code
4202  */
ISDS_enableDoubleTapEvent(WE_sensorInterface_t * sensorInterface,ISDS_state_t doubleTapEnable)4203 int8_t ISDS_enableDoubleTapEvent(WE_sensorInterface_t* sensorInterface, ISDS_state_t doubleTapEnable)
4204 {
4205   ISDS_wakeUpThs_t wakeUpThs;
4206 
4207   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4208   {
4209     return WE_FAIL;
4210   }
4211 
4212   wakeUpThs.enDoubleTapEvent = doubleTapEnable;
4213 
4214   return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs);
4215 }
4216 
4217 /**
4218  * @brief Check if double-tap events are enabled
4219  * @param[in] sensorInterface Pointer to sensor interface
4220  * @param[out] doubleTap The returned tap event state [0: only single, 1: single and double-tap]
4221  * @retval Error code
4222  */
ISDS_isDoubleTapEventEnabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * doubleTapEnable)4223 int8_t ISDS_isDoubleTapEventEnabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *doubleTapEnable)
4224 {
4225   ISDS_wakeUpThs_t wakeUpThs;
4226 
4227   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_THS_REG, 1, (uint8_t *) &wakeUpThs))
4228   {
4229     return WE_FAIL;
4230   }
4231 
4232   *doubleTapEnable = (ISDS_state_t) wakeUpThs.enDoubleTapEvent;
4233 
4234   return WE_SUCCESS;
4235 }
4236 
4237 
4238 /* ISDS_WAKE_UP_DUR_REG */
4239 
4240 /**
4241  * @brief Set the sleep mode duration
4242  * @param[in] sensorInterface Pointer to sensor interface
4243  * @param[in] duration Sleep mode duration (4 bits)
4244  * @retval Error code
4245  */
ISDS_setSleepDuration(WE_sensorInterface_t * sensorInterface,uint8_t duration)4246 int8_t ISDS_setSleepDuration(WE_sensorInterface_t* sensorInterface, uint8_t duration)
4247 {
4248   ISDS_wakeUpDur_t wakeUpDur;
4249 
4250   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4251   {
4252     return WE_FAIL;
4253   }
4254 
4255   wakeUpDur.sleepDuration = (duration & 0x0F);
4256 
4257   return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur);
4258 }
4259 
4260 /**
4261  * @brief Read the sleep mode duration
4262  * @param[in] sensorInterface Pointer to sensor interface
4263  * @param[out] duration The returned sleep mode duration
4264  * @retval Error code
4265  */
ISDS_getSleepDuration(WE_sensorInterface_t * sensorInterface,uint8_t * duration)4266 int8_t ISDS_getSleepDuration(WE_sensorInterface_t* sensorInterface, uint8_t *duration)
4267 {
4268   ISDS_wakeUpDur_t wakeUpDur;
4269 
4270   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4271   {
4272     return WE_FAIL;
4273   }
4274 
4275   *duration = wakeUpDur.sleepDuration;
4276 
4277   return WE_SUCCESS;
4278 }
4279 
4280 /**
4281  * @brief Set wake-up duration
4282  * @param[in] sensorInterface Pointer to sensor interface
4283  * @param[in] duration Wake-up duration (two bits)
4284  * @retval Error code
4285  */
ISDS_setWakeUpDuration(WE_sensorInterface_t * sensorInterface,uint8_t duration)4286 int8_t ISDS_setWakeUpDuration(WE_sensorInterface_t* sensorInterface, uint8_t duration)
4287 {
4288   ISDS_wakeUpDur_t wakeUpDur;
4289 
4290   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4291   {
4292     return WE_FAIL;
4293   }
4294 
4295   wakeUpDur.wakeUpDuration = (duration & 0x03);
4296 
4297   return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur);
4298 }
4299 
4300 /**
4301  * @brief Read the wake-up duration
4302  * @param[in] sensorInterface Pointer to sensor interface
4303  * @param[out] duration The returned wake-up duration (two bits)
4304  * @retval Error code
4305  */
ISDS_getWakeUpDuration(WE_sensorInterface_t * sensorInterface,uint8_t * duration)4306 int8_t ISDS_getWakeUpDuration(WE_sensorInterface_t* sensorInterface, uint8_t *duration)
4307 {
4308   ISDS_wakeUpDur_t wakeUpDur;
4309 
4310   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4311   {
4312     return WE_FAIL;
4313   }
4314 
4315   *duration = wakeUpDur.wakeUpDuration;
4316 
4317   return WE_SUCCESS;
4318 }
4319 
4320 
4321 /* ISDS_FREE_FALL_REG */
4322 
4323 /**
4324  * @brief Set free-fall threshold
4325  * @param[in] sensorInterface Pointer to sensor interface
4326  * @param[in] thresh Free-fall threshold value
4327  * @retval Error code
4328  */
ISDS_setFreeFallThreshold(WE_sensorInterface_t * sensorInterface,ISDS_freeFallThreshold_t thresh)4329 int8_t ISDS_setFreeFallThreshold(WE_sensorInterface_t* sensorInterface, ISDS_freeFallThreshold_t thresh)
4330 {
4331   ISDS_freeFall_t freeFall;
4332 
4333   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4334   {
4335     return WE_FAIL;
4336   }
4337 
4338   freeFall.freeFallThreshold = thresh;
4339 
4340   return ISDS_WriteReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall);
4341 }
4342 
4343 /**
4344  * @brief Read the free-fall threshold
4345  * @param[in] sensorInterface Pointer to sensor interface
4346  * @param[in] thresh The returned free-fall threshold value
4347  * @retval Error code
4348  */
ISDS_getFreeFallThreshold(WE_sensorInterface_t * sensorInterface,ISDS_freeFallThreshold_t * thresh)4349 int8_t ISDS_getFreeFallThreshold(WE_sensorInterface_t* sensorInterface, ISDS_freeFallThreshold_t *thresh)
4350 {
4351   ISDS_freeFall_t freeFall;
4352 
4353   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4354   {
4355     return WE_FAIL;
4356   }
4357 
4358   *thresh = (ISDS_freeFallThreshold_t) freeFall.freeFallThreshold;
4359 
4360   return WE_SUCCESS;
4361 }
4362 
4363 /**
4364  * @brief Set the free-fall duration (both LSB and MSB).
4365  * @param[in] sensorInterface Pointer to sensor interface
4366  * @param[in] duration Free-fall duration (6 bits)
4367  * @retval Error code
4368  */
ISDS_setFreeFallDuration(WE_sensorInterface_t * sensorInterface,uint8_t duration)4369 int8_t ISDS_setFreeFallDuration(WE_sensorInterface_t* sensorInterface, uint8_t duration)
4370 {
4371   ISDS_freeFall_t freeFall;
4372   ISDS_wakeUpDur_t wakeUpDur;
4373 
4374   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4375   {
4376     return WE_FAIL;
4377   }
4378   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4379   {
4380     return WE_FAIL;
4381   }
4382 
4383   freeFall.freeFallDurationLSB = (uint8_t) (duration & 0x1F);
4384   wakeUpDur.freeFallDurationMSB = (uint8_t) ((duration >> 5) & 0x01);
4385 
4386   if (WE_FAIL == ISDS_WriteReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4387   {
4388     return WE_FAIL;
4389   }
4390   return ISDS_WriteReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur);
4391 }
4392 
4393 /**
4394  * @brief Read the free-fall duration (both LSB and MSB).
4395  * @param[in] sensorInterface Pointer to sensor interface
4396  * @param[out] duration The returned free-fall duration (6 bits)
4397  * @retval Error code
4398  */
ISDS_getFreeFallDuration(WE_sensorInterface_t * sensorInterface,uint8_t * duration)4399 int8_t ISDS_getFreeFallDuration(WE_sensorInterface_t* sensorInterface, uint8_t *duration)
4400 {
4401   ISDS_freeFall_t freeFall;
4402   ISDS_wakeUpDur_t wakeUpDur;
4403 
4404   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_FREE_FALL_REG, 1, (uint8_t *) &freeFall))
4405   {
4406     return WE_FAIL;
4407   }
4408   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_WAKE_UP_DUR_REG, 1, (uint8_t *) &wakeUpDur))
4409   {
4410     return WE_FAIL;
4411   }
4412 
4413   *duration = ((uint8_t) freeFall.freeFallDurationLSB) |
4414               (((uint8_t) (wakeUpDur.freeFallDurationMSB & 0x01)) << 5);
4415 
4416   return WE_SUCCESS;
4417 }
4418 
4419 /**
4420  * @brief Enable/disable the tilt event interrupt on INT_0
4421  * @param[in] sensorInterface Pointer to sensor interface
4422  * @param[in] int0Tilt Tilt event interrupt enable state
4423  * @retval Error code
4424  */
ISDS_enableTiltINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0Tilt)4425 int8_t ISDS_enableTiltINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0Tilt)
4426 {
4427   ISDS_mde1Cfg_t mde1Cfg;
4428 
4429   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4430   {
4431     return WE_FAIL;
4432   }
4433 
4434   mde1Cfg.int0Tilt = int0Tilt;
4435 
4436   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4437 }
4438 
4439 /**
4440  * @brief Check if the tilt event interrupt on INT_0 is enabled
4441  * @param[in] sensorInterface Pointer to sensor interface
4442  * @param[out] int0Tilt The returned tilt event interrupt enable state
4443  * @retval Error code
4444  */
ISDS_isTiltINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0Tilt)4445 int8_t ISDS_isTiltINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0Tilt)
4446 {
4447   ISDS_mde1Cfg_t mde1Cfg;
4448 
4449   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4450   {
4451     return WE_FAIL;
4452   }
4453 
4454   *int0Tilt = (ISDS_state_t) mde1Cfg.int0Tilt;
4455 
4456   return WE_SUCCESS;
4457 }
4458 
4459 /**
4460  * @brief Enable/disable the 6D orientation change event interrupt on INT_0
4461  * @param[in] sensorInterface Pointer to sensor interface
4462  * @param[in] int06d 6D orientation change event interrupt enable state
4463  * @retval Error code
4464  */
ISDS_enable6dINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int06d)4465 int8_t ISDS_enable6dINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int06d)
4466 {
4467   ISDS_mde1Cfg_t mde1Cfg;
4468 
4469   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4470   {
4471     return WE_FAIL;
4472   }
4473 
4474   mde1Cfg.int06d = int06d;
4475 
4476   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4477 }
4478 
4479 /**
4480  * @brief Check if the 6D orientation change event interrupt on INT_0 is enabled
4481  * @param[in] sensorInterface Pointer to sensor interface
4482  * @param[out] int06d The returned 6D orientation change event interrupt enable state
4483  * @retval Error code
4484  */
ISDS_is6dINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int06d)4485 int8_t ISDS_is6dINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int06d)
4486 {
4487   ISDS_mde1Cfg_t mde1Cfg;
4488 
4489   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4490   {
4491     return WE_FAIL;
4492   }
4493 
4494   *int06d = (ISDS_state_t) mde1Cfg.int06d;
4495 
4496   return WE_SUCCESS;
4497 }
4498 
4499 /**
4500  * @brief Enable/disable the double-tap interrupt on INT_0
4501  * @param[in] sensorInterface Pointer to sensor interface
4502  * @param[in] int0DoubleTap The double-tap interrupt enable state
4503  * @retval Error code
4504  */
ISDS_enableDoubleTapINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0DoubleTap)4505 int8_t ISDS_enableDoubleTapINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0DoubleTap)
4506 {
4507   ISDS_mde1Cfg_t mde1Cfg;
4508 
4509   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4510   {
4511     return WE_FAIL;
4512   }
4513 
4514   mde1Cfg.int0DoubleTap = int0DoubleTap;
4515 
4516   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4517 }
4518 
4519 /**
4520  * @brief Check if the double-tap interrupt on INT_0 is enabled
4521  * @param[in] sensorInterface Pointer to sensor interface
4522  * @param[out] int0DoubleTap The returned double-tap interrupt enable state
4523  * @retval Error code
4524  */
ISDS_isDoubleTapINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0DoubleTap)4525 int8_t ISDS_isDoubleTapINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0DoubleTap)
4526 {
4527   ISDS_mde1Cfg_t mde1Cfg;
4528 
4529   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4530   {
4531     return WE_FAIL;
4532   }
4533 
4534   *int0DoubleTap = (ISDS_state_t) mde1Cfg.int0DoubleTap;
4535 
4536   return WE_SUCCESS;
4537 }
4538 
4539 /**
4540  * @brief Enable/disable the free-fall interrupt on INT_0
4541  * @param[in] sensorInterface Pointer to sensor interface
4542  * @param[in] int0FreeFall Free-fall interrupt enable state
4543  * @retval Error code
4544  */
ISDS_enableFreeFallINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0FreeFall)4545 int8_t ISDS_enableFreeFallINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0FreeFall)
4546 {
4547   ISDS_mde1Cfg_t mde1Cfg;
4548 
4549   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4550   {
4551     return WE_FAIL;
4552   }
4553 
4554   mde1Cfg.int0FreeFall = int0FreeFall;
4555 
4556   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4557 }
4558 
4559 /**
4560  * @brief Check if the free-fall interrupt on INT_0 is enabled
4561  * @param[in] sensorInterface Pointer to sensor interface
4562  * @param[out] int0FreeFall The returned free-fall enable state
4563  * @retval Error code
4564  */
ISDS_isFreeFallINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0FreeFall)4565 int8_t ISDS_isFreeFallINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0FreeFall)
4566 {
4567   ISDS_mde1Cfg_t mde1Cfg;
4568 
4569   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4570   {
4571     return WE_FAIL;
4572   }
4573 
4574   *int0FreeFall = (ISDS_state_t) mde1Cfg.int0FreeFall;
4575 
4576   return WE_SUCCESS;
4577 }
4578 
4579 /**
4580  * @brief Enable/disable the wake-up interrupt on INT_0
4581  * @param[in] sensorInterface Pointer to sensor interface
4582  * @param[in] int0WakeUp Wake-up interrupt enable state
4583  * @retval Error code
4584  */
ISDS_enableWakeUpINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0WakeUp)4585 int8_t ISDS_enableWakeUpINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0WakeUp)
4586 {
4587   ISDS_mde1Cfg_t mde1Cfg;
4588 
4589   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4590   {
4591     return WE_FAIL;
4592   }
4593 
4594   mde1Cfg.int0WakeUp = int0WakeUp;
4595 
4596   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4597 }
4598 
4599 /**
4600  * @brief Check if the wake-up interrupt on INT_0 is enabled
4601  * @param[in] sensorInterface Pointer to sensor interface
4602  * @param[out] int0WakeUp The returned wake-up interrupt enable state
4603  * @retval Error code
4604  */
ISDS_isWakeUpINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0WakeUp)4605 int8_t ISDS_isWakeUpINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0WakeUp)
4606 {
4607   ISDS_mde1Cfg_t mde1Cfg;
4608 
4609   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4610   {
4611     return WE_FAIL;
4612   }
4613 
4614   *int0WakeUp = (ISDS_state_t) mde1Cfg.int0WakeUp;
4615 
4616   return WE_SUCCESS;
4617 }
4618 
4619 /**
4620  * @brief Enable/disable the single-tap interrupt on INT_0
4621  * @param[in] sensorInterface Pointer to sensor interface
4622  * @param[in] int0SingleTap Single-tap interrupt enable state
4623  * @retval Error code
4624  */
ISDS_enableSingleTapINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0SingleTap)4625 int8_t ISDS_enableSingleTapINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0SingleTap)
4626 {
4627   ISDS_mde1Cfg_t mde1Cfg;
4628 
4629   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4630   {
4631     return WE_FAIL;
4632   }
4633 
4634   mde1Cfg.int0SingleTap = int0SingleTap;
4635 
4636   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4637 }
4638 
4639 /**
4640  * @brief Check if the single-tap interrupt on INT_0 is enabled
4641  * @param[in] sensorInterface Pointer to sensor interface
4642  * @param[out] int0SingleTap The returned single-tap interrupt enable state
4643  * @retval Error code
4644  */
ISDS_isSingleTapINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0SingleTap)4645 int8_t ISDS_isSingleTapINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0SingleTap)
4646 {
4647   ISDS_mde1Cfg_t mde1Cfg;
4648 
4649   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4650   {
4651     return WE_FAIL;
4652   }
4653 
4654   *int0SingleTap = (ISDS_state_t) mde1Cfg.int0SingleTap;
4655 
4656   return WE_SUCCESS;
4657 }
4658 
4659 /**
4660  * @brief Enable/disable the inactivity state interrupt on INT_0
4661  * @param[in] sensorInterface Pointer to sensor interface
4662  * @param[in] int0InactivityState Inactivity state interrupt enable state
4663  * @retval Error code
4664  */
ISDS_enableInactivityStateINT0(WE_sensorInterface_t * sensorInterface,ISDS_state_t int0InactivityState)4665 int8_t ISDS_enableInactivityStateINT0(WE_sensorInterface_t* sensorInterface, ISDS_state_t int0InactivityState)
4666 {
4667   ISDS_mde1Cfg_t mde1Cfg;
4668 
4669   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4670   {
4671     return WE_FAIL;
4672   }
4673 
4674   mde1Cfg.int0InactivityState = int0InactivityState;
4675 
4676   return ISDS_WriteReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg);
4677 }
4678 
4679 /**
4680  * @brief Check if the inactivity state interrupt on INT_0 is enabled
4681  * @param[in] sensorInterface Pointer to sensor interface
4682  * @param[out] int0InactivityState The returned inactivity state interrupt enable state
4683  * @retval Error code
4684  */
ISDS_isInactivityStateINT0Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int0InactivityState)4685 int8_t ISDS_isInactivityStateINT0Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int0InactivityState)
4686 {
4687   ISDS_mde1Cfg_t mde1Cfg;
4688 
4689   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD1_CFG_REG, 1, (uint8_t *) &mde1Cfg))
4690   {
4691     return WE_FAIL;
4692   }
4693 
4694   *int0InactivityState = (ISDS_state_t) mde1Cfg.int0InactivityState;
4695 
4696   return WE_SUCCESS;
4697 }
4698 
4699 
4700 /* ISDS_MD2_CFG_REG */
4701 
4702 /**
4703  * @brief Enable/disable the tilt event interrupt on INT_1
4704  * @param[in] sensorInterface Pointer to sensor interface
4705  * @param[in] int1Tilt Tilt event interrupt enable state
4706  * @retval Error code
4707  */
ISDS_enableTiltINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1Tilt)4708 int8_t ISDS_enableTiltINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1Tilt)
4709 {
4710   ISDS_mde2Cfg_t mde2Cfg;
4711 
4712   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4713   {
4714     return WE_FAIL;
4715   }
4716 
4717   mde2Cfg.int1Tilt = int1Tilt;
4718 
4719   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4720 }
4721 
4722 /**
4723  * @brief Check if the tilt event interrupt on INT_1 is enabled
4724  * @param[in] sensorInterface Pointer to sensor interface
4725  * @param[out] int1Tilt The returned tilt event interrupt enable state
4726  * @retval Error code
4727  */
ISDS_isTiltINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1Tilt)4728 int8_t ISDS_isTiltINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1Tilt)
4729 {
4730   ISDS_mde2Cfg_t mde2Cfg;
4731 
4732   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4733   {
4734     return WE_FAIL;
4735   }
4736 
4737   *int1Tilt = (ISDS_state_t) mde2Cfg.int1Tilt;
4738 
4739   return WE_SUCCESS;
4740 }
4741 
4742 /**
4743  * @brief Enable/disable the 6D orientation change event interrupt on INT_1
4744  * @param[in] sensorInterface Pointer to sensor interface
4745  * @param[in] int16d 6D orientation change event interrupt enable state
4746  * @retval Error code
4747  */
ISDS_enable6dINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int16d)4748 int8_t ISDS_enable6dINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int16d)
4749 {
4750   ISDS_mde2Cfg_t mde2Cfg;
4751 
4752   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4753   {
4754     return WE_FAIL;
4755   }
4756 
4757   mde2Cfg.int16d = int16d;
4758 
4759   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4760 }
4761 
4762 /**
4763  * @brief Check if the 6D orientation change event interrupt on INT_1 is enabled
4764  * @param[in] sensorInterface Pointer to sensor interface
4765  * @param[out] int16d The returned 6D orientation change event interrupt enable state
4766  * @retval Error code
4767  */
ISDS_is6dINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int16d)4768 int8_t ISDS_is6dINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int16d)
4769 {
4770   ISDS_mde2Cfg_t mde2Cfg;
4771 
4772   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4773   {
4774     return WE_FAIL;
4775   }
4776 
4777   *int16d = (ISDS_state_t) mde2Cfg.int16d;
4778 
4779   return WE_SUCCESS;
4780 }
4781 
4782 /**
4783  * @brief Enable/disable the double-tap interrupt on INT_1
4784  * @param[in] sensorInterface Pointer to sensor interface
4785  * @param[in] int1DoubleTap The double-tap interrupt enable state
4786  * @retval Error code
4787  */
ISDS_enableDoubleTapINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1DoubleTap)4788 int8_t ISDS_enableDoubleTapINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1DoubleTap)
4789 {
4790   ISDS_mde2Cfg_t mde2Cfg;
4791 
4792   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4793   {
4794     return WE_FAIL;
4795   }
4796 
4797   mde2Cfg.int1DoubleTap = int1DoubleTap;
4798 
4799   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4800 }
4801 
4802 /**
4803  * @brief Check if the double-tap interrupt on INT_1 is enabled
4804  * @param[in] sensorInterface Pointer to sensor interface
4805  * @param[out] int1DoubleTap The returned double-tap interrupt enable state
4806  * @retval Error code
4807  */
ISDS_isDoubleTapINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1DoubleTap)4808 int8_t ISDS_isDoubleTapINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1DoubleTap)
4809 {
4810   ISDS_mde2Cfg_t mde2Cfg;
4811 
4812   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4813   {
4814     return WE_FAIL;
4815   }
4816 
4817   *int1DoubleTap = (ISDS_state_t) mde2Cfg.int1DoubleTap;
4818 
4819   return WE_SUCCESS;
4820 }
4821 
4822 /**
4823  * @brief Enable/disable the free-fall interrupt on INT_1
4824  * @param[in] sensorInterface Pointer to sensor interface
4825  * @param[in] int1FreeFall Free-fall interrupt enable state
4826  * @retval Error code
4827  */
ISDS_enableFreeFallINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1FreeFall)4828 int8_t ISDS_enableFreeFallINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1FreeFall)
4829 {
4830   ISDS_mde2Cfg_t mde2Cfg;
4831 
4832   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4833   {
4834     return WE_FAIL;
4835   }
4836 
4837   mde2Cfg.int1FreeFall = int1FreeFall;
4838 
4839   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4840 }
4841 
4842 /**
4843  * @brief Check if the free-fall interrupt on INT_1 is enabled
4844  * @param[in] sensorInterface Pointer to sensor interface
4845  * @param[out] int1FreeFall The returned free-fall enable state
4846  * @retval Error code
4847  */
ISDS_isFreeFallINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1FreeFall)4848 int8_t ISDS_isFreeFallINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1FreeFall)
4849 {
4850   ISDS_mde2Cfg_t mde2Cfg;
4851 
4852   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4853   {
4854     return WE_FAIL;
4855   }
4856 
4857   *int1FreeFall = (ISDS_state_t) mde2Cfg.int1FreeFall;
4858 
4859   return WE_SUCCESS;
4860 }
4861 
4862 /**
4863  * @brief Enable/disable the wake-up interrupt on INT_1
4864  * @param[in] sensorInterface Pointer to sensor interface
4865  * @param[in] int1WakeUp Wake-up interrupt enable state
4866  * @retval Error code
4867  */
ISDS_enableWakeUpINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1WakeUp)4868 int8_t ISDS_enableWakeUpINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1WakeUp)
4869 {
4870   ISDS_mde2Cfg_t mde2Cfg;
4871 
4872   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4873   {
4874     return WE_FAIL;
4875   }
4876 
4877   mde2Cfg.int1WakeUp = int1WakeUp;
4878 
4879   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4880 }
4881 
4882 /**
4883  * @brief Check if the wake-up interrupt on INT_1 is enabled
4884  * @param[in] sensorInterface Pointer to sensor interface
4885  * @param[out] int1WakeUp The returned wake-up interrupt enable state
4886  * @retval Error code
4887  */
ISDS_isWakeUpINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1WakeUp)4888 int8_t ISDS_isWakeUpINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1WakeUp)
4889 {
4890   ISDS_mde2Cfg_t mde2Cfg;
4891 
4892   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4893   {
4894     return WE_FAIL;
4895   }
4896 
4897   *int1WakeUp = (ISDS_state_t) mde2Cfg.int1WakeUp;
4898 
4899   return WE_SUCCESS;
4900 }
4901 
4902 /**
4903  * @brief Enable/disable the single-tap interrupt on INT_1
4904  * @param[in] sensorInterface Pointer to sensor interface
4905  * @param[in] int1SingleTap Single-tap interrupt enable state
4906  * @retval Error code
4907  */
ISDS_enableSingleTapINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1SingleTap)4908 int8_t ISDS_enableSingleTapINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1SingleTap)
4909 {
4910   ISDS_mde2Cfg_t mde2Cfg;
4911 
4912   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4913   {
4914     return WE_FAIL;
4915   }
4916 
4917   mde2Cfg.int1SingleTap = int1SingleTap;
4918 
4919   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4920 }
4921 
4922 /**
4923  * @brief Check if the single-tap interrupt on INT_1 is enabled
4924  * @param[in] sensorInterface Pointer to sensor interface
4925  * @param[out] int1SingleTap The returned single-tap interrupt enable state
4926  * @retval Error code
4927  */
ISDS_isSingleTapINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1SingleTap)4928 int8_t ISDS_isSingleTapINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1SingleTap)
4929 {
4930   ISDS_mde2Cfg_t mde2Cfg;
4931 
4932   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4933   {
4934     return WE_FAIL;
4935   }
4936 
4937   *int1SingleTap = (ISDS_state_t) mde2Cfg.int1SingleTap;
4938 
4939   return WE_SUCCESS;
4940 }
4941 
4942 /**
4943  * @brief Enable/disable the inactivity state interrupt on INT_1
4944  * @param[in] sensorInterface Pointer to sensor interface
4945  * @param[in] int1InactivityState Inactivity state interrupt enable state
4946  * @retval Error code
4947  */
ISDS_enableInactivityStateINT1(WE_sensorInterface_t * sensorInterface,ISDS_state_t int1InactivityState)4948 int8_t ISDS_enableInactivityStateINT1(WE_sensorInterface_t* sensorInterface, ISDS_state_t int1InactivityState)
4949 {
4950   ISDS_mde2Cfg_t mde2Cfg;
4951 
4952   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4953   {
4954     return WE_FAIL;
4955   }
4956 
4957   mde2Cfg.int1InactivityState = int1InactivityState;
4958 
4959   return ISDS_WriteReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg);
4960 }
4961 
4962 /**
4963  * @brief Check if the inactivity state interrupt on INT_1 is enabled
4964  * @param[in] sensorInterface Pointer to sensor interface
4965  * @param[out] int1InactivityState The returned inactivity state interrupt enable state
4966  * @retval Error code
4967  */
ISDS_isInactivityStateINT1Enabled(WE_sensorInterface_t * sensorInterface,ISDS_state_t * int1InactivityState)4968 int8_t ISDS_isInactivityStateINT1Enabled(WE_sensorInterface_t* sensorInterface, ISDS_state_t *int1InactivityState)
4969 {
4970   ISDS_mde2Cfg_t mde2Cfg;
4971 
4972   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_MD2_CFG_REG, 1, (uint8_t *) &mde2Cfg))
4973   {
4974     return WE_FAIL;
4975   }
4976 
4977   *int1InactivityState = (ISDS_state_t) mde2Cfg.int1InactivityState;
4978 
4979   return WE_SUCCESS;
4980 }
4981 
4982 /* ISDS_X_OFS_USR_REG */
4983 /* ISDS_Y_OFS_USR_REG */
4984 /* ISDS_Z_OFS_USR_REG */
4985 
4986 /**
4987  * @brief Set the user offset for axis X
4988  * @param[in] sensorInterface Pointer to sensor interface
4989  * @param[in] offsetValueXAxis User offset for axis X
4990  * @retval Error code
4991  */
ISDS_setOffsetValueX(WE_sensorInterface_t * sensorInterface,int8_t offsetValueXAxis)4992 int8_t ISDS_setOffsetValueX(WE_sensorInterface_t* sensorInterface, int8_t offsetValueXAxis)
4993 {
4994   return ISDS_WriteReg(sensorInterface, ISDS_X_OFS_USR_REG, 1, (uint8_t *) &offsetValueXAxis);
4995 }
4996 
4997 /**
4998  * @brief Read the user offset for axis X
4999  * @param[in] sensorInterface Pointer to sensor interface
5000  * @param[out] offsetValueXAxis The returned user offset for axis X
5001  * @retval Error code
5002  */
ISDS_getOffsetValueX(WE_sensorInterface_t * sensorInterface,int8_t * offsetValueXAxis)5003 int8_t ISDS_getOffsetValueX(WE_sensorInterface_t* sensorInterface, int8_t *offsetValueXAxis)
5004 {
5005   return ISDS_ReadReg(sensorInterface, ISDS_X_OFS_USR_REG, 1, (uint8_t *) offsetValueXAxis);
5006 }
5007 
5008 /**
5009  * @brief Set the user offset for axis Y
5010  * @param[in] sensorInterface Pointer to sensor interface
5011  * @param[in] offsetValueYAxis User offset for axis Y
5012  * @retval Error code
5013  */
ISDS_setOffsetValueY(WE_sensorInterface_t * sensorInterface,int8_t offsetValueYAxis)5014 int8_t ISDS_setOffsetValueY(WE_sensorInterface_t* sensorInterface, int8_t offsetValueYAxis)
5015 {
5016   return ISDS_WriteReg(sensorInterface, ISDS_Y_OFS_USR_REG, 1, (uint8_t *) &offsetValueYAxis);
5017 }
5018 
5019 /**
5020  * @brief Read the user offset for axis Y
5021  * @param[in] sensorInterface Pointer to sensor interface
5022  * @param[out] offsetValueYAxis The returned user offset for axis Y
5023  * @retval Error code
5024  */
ISDS_getOffsetValueY(WE_sensorInterface_t * sensorInterface,int8_t * offsetValueYAxis)5025 int8_t ISDS_getOffsetValueY(WE_sensorInterface_t* sensorInterface, int8_t *offsetValueYAxis)
5026 {
5027   return ISDS_ReadReg(sensorInterface, ISDS_Y_OFS_USR_REG, 1, (uint8_t *) offsetValueYAxis);
5028 }
5029 
5030 /**
5031  * @brief Set the user offset for axis Z
5032  * @param[in] sensorInterface Pointer to sensor interface
5033  * @param[in] offsetValueZAxis The user offset for axis Z
5034  * @retval Error code
5035  */
ISDS_setOffsetValueZ(WE_sensorInterface_t * sensorInterface,int8_t offsetValueZAxis)5036 int8_t ISDS_setOffsetValueZ(WE_sensorInterface_t* sensorInterface, int8_t offsetValueZAxis)
5037 {
5038   return ISDS_WriteReg(sensorInterface, ISDS_Z_OFS_USR_REG, 1, (uint8_t *) &offsetValueZAxis);
5039 }
5040 
5041 /**
5042  * @brief Read the user offset for axis Z
5043  * @param[in] sensorInterface Pointer to sensor interface
5044  * @param[out] offsetValueZAxis The returned user offset for axis Z
5045  * @retval Error code
5046  */
ISDS_getOffsetValueZ(WE_sensorInterface_t * sensorInterface,int8_t * offsetValueZAxis)5047 int8_t ISDS_getOffsetValueZ(WE_sensorInterface_t* sensorInterface, int8_t *offsetValueZAxis)
5048 {
5049   return ISDS_ReadReg(sensorInterface, ISDS_Z_OFS_USR_REG, 1, (uint8_t *) offsetValueZAxis);
5050 }
5051 
5052 
5053 /* ISDS_FIFO_DATA_OUT_L_REG */
5054 /* ISDS_FIFO_DATA_OUT_H_REG */
5055 
5056 /**
5057  * @brief Reads the specified number of 16 bit values from the FIFO buffer
5058  *
5059  * The type of values read depends on the FIFO configuration and the current
5060  * read position. Get the current FIFO pattern value (e.g. via
5061  * ISDS_getFifoPattern() or ISDS_getFifoStatus()). Before reading FIFO data to
5062  * determine the type of the next value read.
5063  *
5064  * @param[in] sensorInterface Pointer to sensor interface
5065  * @param[in] numSamples The number of values to be read
5066  * @param[out] fifoData The returned values (must provide pointer to buffer of length numSamples)
5067  * @retval Error code
5068  */
ISDS_getFifoData(WE_sensorInterface_t * sensorInterface,uint16_t numSamples,uint16_t * fifoData)5069 int8_t ISDS_getFifoData(WE_sensorInterface_t* sensorInterface, uint16_t numSamples, uint16_t *fifoData)
5070 {
5071   return ISDS_ReadReg(sensorInterface, ISDS_FIFO_DATA_OUT_L_REG, numSamples * 2, (uint8_t *) fifoData);
5072 }
5073 
5074 
5075 /**
5076  * @brief Reads the X-axis angular rate in [mdps]
5077  *
5078  * Note that this functions relies on the current gyroscope full scale value.
5079  * Make sure that the current gyroscope full scale value is known by calling
5080  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5081  * calling this function.
5082  *
5083  * @param[in] sensorInterface Pointer to sensor interface
5084  * @param[out] xRate X-axis angular rate in [mdps]
5085  * @retval Error code
5086  */
ISDS_getAngularRateX_float(WE_sensorInterface_t * sensorInterface,float * xRate)5087 int8_t ISDS_getAngularRateX_float(WE_sensorInterface_t* sensorInterface, float *xRate)
5088 {
5089   int16_t rawRate;
5090   if (WE_FAIL == ISDS_getRawAngularRateX(sensorInterface, &rawRate))
5091   {
5092     return WE_FAIL;
5093   }
5094   *xRate = ISDS_convertAngularRate_float(rawRate, currentGyroFullScale);
5095   return WE_SUCCESS;
5096 }
5097 
5098 /**
5099  * @brief Reads the Y-axis angular rate in [mdps]
5100  *
5101  * Note that this functions relies on the current gyroscope full scale value.
5102  * Make sure that the current gyroscope full scale value is known by calling
5103  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5104  * calling this function.
5105  *
5106  * @param[in] sensorInterface Pointer to sensor interface
5107  * @param[out] yRate Y-axis angular rate in [mdps]
5108  * @retval Error code
5109  */
ISDS_getAngularRateY_float(WE_sensorInterface_t * sensorInterface,float * yRate)5110 int8_t ISDS_getAngularRateY_float(WE_sensorInterface_t* sensorInterface, float *yRate)
5111 {
5112   int16_t rawRate;
5113   if (WE_FAIL == ISDS_getRawAngularRateY(sensorInterface, &rawRate))
5114   {
5115     return WE_FAIL;
5116   }
5117   *yRate = ISDS_convertAngularRate_float(rawRate, currentGyroFullScale);
5118   return WE_SUCCESS;
5119 }
5120 
5121 /**
5122  * @brief Reads the Z-axis angular rate in [mdps]
5123  *
5124  * Note that this functions relies on the current gyroscope full scale value.
5125  * Make sure that the current gyroscope full scale value is known by calling
5126  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5127  * calling this function.
5128  *
5129  * @param[in] sensorInterface Pointer to sensor interface
5130  * @param[out] zRate Z-axis angular rate in [mdps]
5131  * @retval Error code
5132  */
ISDS_getAngularRateZ_float(WE_sensorInterface_t * sensorInterface,float * zRate)5133 int8_t ISDS_getAngularRateZ_float(WE_sensorInterface_t* sensorInterface, float *zRate)
5134 {
5135   int16_t rawRate;
5136   if (WE_FAIL == ISDS_getRawAngularRateZ(sensorInterface, &rawRate))
5137   {
5138     return WE_FAIL;
5139   }
5140   *zRate = ISDS_convertAngularRate_float(rawRate, currentGyroFullScale);
5141   return WE_SUCCESS;
5142 }
5143 
5144 /**
5145  * @brief Read the gyroscope sensor output in [mdps] for all three axes
5146  *
5147  * Note that this functions relies on the current gyroscope full scale value.
5148  * Make sure that the current gyroscope full scale value is known by calling
5149  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5150  * calling this function.
5151  *
5152  * @param[in] sensorInterface Pointer to sensor interface
5153  * @param[out] xRate The returned X-axis angular rate in [mdps]
5154  * @param[out] yRate The returned Y-axis angular rate in [mdps]
5155  * @param[out] zRate The returned Z-axis angular rate in [mdps]
5156  * @retval Error code
5157  */
ISDS_getAngularRates_float(WE_sensorInterface_t * sensorInterface,float * xRate,float * yRate,float * zRate)5158 int8_t ISDS_getAngularRates_float(WE_sensorInterface_t* sensorInterface, float *xRate, float *yRate, float *zRate)
5159 {
5160   int16_t xRawRate, yRawRate, zRawRate;
5161   if (WE_FAIL == ISDS_getRawAngularRates(sensorInterface, &xRawRate, &yRawRate, &zRawRate))
5162   {
5163     return WE_FAIL;
5164   }
5165   *xRate = ISDS_convertAngularRate_float(xRawRate, currentGyroFullScale);
5166   *yRate = ISDS_convertAngularRate_float(yRawRate, currentGyroFullScale);
5167   *zRate = ISDS_convertAngularRate_float(zRawRate, currentGyroFullScale);
5168   return WE_SUCCESS;
5169 }
5170 
5171 /**
5172  * @brief Reads the X-axis angular rate in [mdps]
5173  *
5174  * Note that this functions relies on the current gyroscope full scale value.
5175  * Make sure that the current gyroscope full scale value is known by calling
5176  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5177  * calling this function.
5178  *
5179  * @param[in] sensorInterface Pointer to sensor interface
5180  * @param[out] xRate X-axis angular rate in [mdps]
5181  * @retval Error code
5182  */
ISDS_getAngularRateX_int(WE_sensorInterface_t * sensorInterface,int32_t * xRate)5183 int8_t ISDS_getAngularRateX_int(WE_sensorInterface_t* sensorInterface, int32_t *xRate)
5184 {
5185   int16_t rawRate;
5186   if (WE_FAIL == ISDS_getRawAngularRateX(sensorInterface, &rawRate))
5187   {
5188     return WE_FAIL;
5189   }
5190   *xRate = ISDS_convertAngularRate_int(rawRate, currentGyroFullScale);
5191   return WE_SUCCESS;
5192 }
5193 
5194 /**
5195  * @brief Reads the Y-axis angular rate in [mdps]
5196  *
5197  * Note that this functions relies on the current gyroscope full scale value.
5198  * Make sure that the current gyroscope full scale value is known by calling
5199  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5200  * calling this function.
5201  *
5202  * @param[in] sensorInterface Pointer to sensor interface
5203  * @param[out] yRate Y-axis angular rate in [mdps]
5204  * @retval Error code
5205  */
ISDS_getAngularRateY_int(WE_sensorInterface_t * sensorInterface,int32_t * yRate)5206 int8_t ISDS_getAngularRateY_int(WE_sensorInterface_t* sensorInterface, int32_t *yRate)
5207 {
5208   int16_t rawRate;
5209   if (WE_FAIL == ISDS_getRawAngularRateY(sensorInterface, &rawRate))
5210   {
5211     return WE_FAIL;
5212   }
5213   *yRate = ISDS_convertAngularRate_int(rawRate, currentGyroFullScale);
5214   return WE_SUCCESS;
5215 }
5216 
5217 /**
5218  * @brief Reads the Z-axis angular rate in [mdps]
5219  *
5220  * Note that this functions relies on the current gyroscope full scale value.
5221  * Make sure that the current gyroscope full scale value is known by calling
5222  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5223  * calling this function.
5224  *
5225  * @param[in] sensorInterface Pointer to sensor interface
5226  * @param[out] zRate Z-axis angular rate in [mdps]
5227  * @retval Error code
5228  */
ISDS_getAngularRateZ_int(WE_sensorInterface_t * sensorInterface,int32_t * zRate)5229 int8_t ISDS_getAngularRateZ_int(WE_sensorInterface_t* sensorInterface, int32_t *zRate)
5230 {
5231   int16_t rawRate;
5232   if (WE_FAIL == ISDS_getRawAngularRateZ(sensorInterface, &rawRate))
5233   {
5234     return WE_FAIL;
5235   }
5236   *zRate = ISDS_convertAngularRate_int(rawRate, currentGyroFullScale);
5237   return WE_SUCCESS;
5238 }
5239 
5240 /**
5241  * @brief Read the gyroscope sensor output in [mdps] for all three axes
5242  *
5243  * Note that this functions relies on the current gyroscope full scale value.
5244  * Make sure that the current gyroscope full scale value is known by calling
5245  * ISDS_setGyroFullScale() or ISDS_getGyroFullScale() at least once prior to
5246  * calling this function.
5247  *
5248  * @param[in] sensorInterface Pointer to sensor interface
5249  * @param[out] xRate The returned X-axis angular rate in [mdps]
5250  * @param[out] yRate The returned Y-axis angular rate in [mdps]
5251  * @param[out] zRate The returned Z-axis angular rate in [mdps]
5252  * @retval Error code
5253  */
ISDS_getAngularRates_int(WE_sensorInterface_t * sensorInterface,int32_t * xRate,int32_t * yRate,int32_t * zRate)5254 int8_t ISDS_getAngularRates_int(WE_sensorInterface_t* sensorInterface, int32_t *xRate, int32_t *yRate, int32_t *zRate)
5255 {
5256   int16_t xRawRate, yRawRate, zRawRate;
5257   if (WE_FAIL == ISDS_getRawAngularRates(sensorInterface, &xRawRate, &yRawRate, &zRawRate))
5258   {
5259     return WE_FAIL;
5260   }
5261   *xRate = ISDS_convertAngularRate_int(xRawRate, currentGyroFullScale);
5262   *yRate = ISDS_convertAngularRate_int(yRawRate, currentGyroFullScale);
5263   *zRate = ISDS_convertAngularRate_int(zRawRate, currentGyroFullScale);
5264   return WE_SUCCESS;
5265 }
5266 
5267 /**
5268  * @brief Read the raw X-axis gyroscope sensor output
5269  * @param[in] sensorInterface Pointer to sensor interface
5270  * @param[out] xRawAcc The returned raw X-axis angular rate
5271  * @retval Error code
5272  */
ISDS_getRawAngularRateX(WE_sensorInterface_t * sensorInterface,int16_t * xRawRate)5273 int8_t ISDS_getRawAngularRateX(WE_sensorInterface_t* sensorInterface, int16_t *xRawRate)
5274 {
5275   uint8_t tmp[2] = {0};
5276 
5277   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_GYRO_REG, 2, tmp))
5278   {
5279     return WE_FAIL;
5280   }
5281 
5282   *xRawRate = (int16_t) (tmp[1] << 8);
5283   *xRawRate |= (int16_t) tmp[0];
5284 
5285   return WE_SUCCESS;
5286 }
5287 
5288 /**
5289  * @brief Read the raw Y-axis gyroscope sensor output
5290  * @param[in] sensorInterface Pointer to sensor interface
5291  * @param[out] yRawRate The returned raw Y-axis angular rate
5292  * @retval Error code
5293  */
ISDS_getRawAngularRateY(WE_sensorInterface_t * sensorInterface,int16_t * yRawRate)5294 int8_t ISDS_getRawAngularRateY(WE_sensorInterface_t* sensorInterface, int16_t *yRawRate)
5295 {
5296   uint8_t tmp[2] = {0};
5297 
5298   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Y_OUT_L_GYRO_REG, 2, tmp))
5299   {
5300     return WE_FAIL;
5301   }
5302 
5303   *yRawRate = (int16_t) (tmp[1] << 8);
5304   *yRawRate |= (int16_t) tmp[0];
5305 
5306   return WE_SUCCESS;
5307 }
5308 
5309 /**
5310  * @brief Read the raw Z-axis gyroscope sensor output
5311  * @param[in] sensorInterface Pointer to sensor interface
5312  * @param[out] zRawAcc The returned raw Z-axis angular rate
5313  * @retval Error code
5314  */
ISDS_getRawAngularRateZ(WE_sensorInterface_t * sensorInterface,int16_t * zRawRate)5315 int8_t ISDS_getRawAngularRateZ(WE_sensorInterface_t* sensorInterface, int16_t *zRawRate)
5316 {
5317   uint8_t tmp[2] = {0};
5318 
5319   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Z_OUT_L_GYRO_REG, 2, tmp))
5320   {
5321     return WE_FAIL;
5322   }
5323 
5324   *zRawRate = (int16_t) (tmp[1] << 8);
5325   *zRawRate |= (int16_t) tmp[0];
5326 
5327   return WE_SUCCESS;
5328 }
5329 
5330 /**
5331  * @brief Read the raw gyroscope sensor output for all three axes
5332  * @param[in] sensorInterface Pointer to sensor interface
5333  * @param[out] xRawRate The returned raw X-axis angular rate
5334  * @param[out] yRawRate The returned raw Y-axis angular rate
5335  * @param[out] zRawRate The returned raw Z-axis angular rate
5336  * @retval Error code
5337  */
ISDS_getRawAngularRates(WE_sensorInterface_t * sensorInterface,int16_t * xRawRate,int16_t * yRawRate,int16_t * zRawRate)5338 int8_t ISDS_getRawAngularRates(WE_sensorInterface_t* sensorInterface, int16_t *xRawRate, int16_t *yRawRate, int16_t *zRawRate)
5339 {
5340   uint8_t tmp[6] = {0};
5341 
5342   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_GYRO_REG, 6, tmp))
5343   {
5344     return WE_FAIL;
5345   }
5346 
5347   *xRawRate = (int16_t) (tmp[1] << 8);
5348   *xRawRate |= (int16_t) tmp[0];
5349 
5350   *yRawRate = (int16_t) (tmp[3] << 8);
5351   *yRawRate |= (int16_t) tmp[2];
5352 
5353   *zRawRate = (int16_t) (tmp[5] << 8);
5354   *zRawRate |= (int16_t) tmp[4];
5355 
5356   return WE_SUCCESS;
5357 }
5358 
5359 /**
5360  * @brief Read the X-axis acceleration in [mg]
5361  *
5362  * Note that this functions relies on the current accelerometer full scale value.
5363  * Make sure that the current accelerometer full scale value is known by calling
5364  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5365  * calling this function.
5366  *
5367  * @param[in] sensorInterface Pointer to sensor interface
5368  * @param[out] xAcc X-axis acceleration in [mg]
5369  * @retval Error code
5370  */
ISDS_getAccelerationX_float(WE_sensorInterface_t * sensorInterface,float * xAcc)5371 int8_t ISDS_getAccelerationX_float(WE_sensorInterface_t* sensorInterface, float *xAcc)
5372 {
5373   int16_t rawAcc;
5374   if (WE_FAIL == ISDS_getRawAccelerationX(sensorInterface, &rawAcc))
5375   {
5376     return WE_FAIL;
5377   }
5378   *xAcc = ISDS_convertAcceleration_float(rawAcc, currentAccFullScale);
5379   return WE_SUCCESS;
5380 }
5381 
5382 /**
5383  * @brief Read the Y-axis acceleration in [mg]
5384  *
5385  * Note that this functions relies on the current accelerometer full scale value.
5386  * Make sure that the current accelerometer full scale value is known by calling
5387  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5388  * calling this function.
5389  *
5390  * @param[in] sensorInterface Pointer to sensor interface
5391  * @param[out] yAcc Y-axis acceleration in [mg]
5392  * @retval Error code
5393  */
ISDS_getAccelerationY_float(WE_sensorInterface_t * sensorInterface,float * yAcc)5394 int8_t ISDS_getAccelerationY_float(WE_sensorInterface_t* sensorInterface, float *yAcc)
5395 {
5396   int16_t rawAcc;
5397   if (WE_FAIL == ISDS_getRawAccelerationY(sensorInterface, &rawAcc))
5398   {
5399     return WE_FAIL;
5400   }
5401   *yAcc = ISDS_convertAcceleration_float(rawAcc, currentAccFullScale);
5402   return WE_SUCCESS;
5403 }
5404 
5405 /**
5406  * @brief Read the Z-axis acceleration in [mg]
5407  *
5408  * Note that this functions relies on the current accelerometer full scale value.
5409  * Make sure that the current accelerometer full scale value is known by calling
5410  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5411  * calling this function.
5412  *
5413  * @param[in] sensorInterface Pointer to sensor interface
5414  * @param[out] zAcc Z-axis acceleration in [mg]
5415  * @retval Error code
5416  */
ISDS_getAccelerationZ_float(WE_sensorInterface_t * sensorInterface,float * zAcc)5417 int8_t ISDS_getAccelerationZ_float(WE_sensorInterface_t* sensorInterface, float *zAcc)
5418 {
5419   int16_t rawAcc;
5420   if (WE_FAIL == ISDS_getRawAccelerationZ(sensorInterface, &rawAcc))
5421   {
5422     return WE_FAIL;
5423   }
5424   *zAcc = ISDS_convertAcceleration_float(rawAcc, currentAccFullScale);
5425   return WE_SUCCESS;
5426 }
5427 
5428 /**
5429  * @brief Read the accelerometer sensor output in [mg] for all three axes
5430  *
5431  * Note that this functions relies on the current accelerometer full scale value.
5432  * Make sure that the current accelerometer full scale value is known by calling
5433  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5434  * calling this function.
5435  *
5436  * @param[in] sensorInterface Pointer to sensor interface
5437  * @param[out] xAcc The returned X-axis acceleration in [mg]
5438  * @param[out] yAcc The returned Y-axis acceleration in [mg]
5439  * @param[out] zAcc The returned Z-axis acceleration in [mg]
5440  * @retval Error code
5441  */
ISDS_getAccelerations_float(WE_sensorInterface_t * sensorInterface,float * xAcc,float * yAcc,float * zAcc)5442 int8_t ISDS_getAccelerations_float(WE_sensorInterface_t* sensorInterface, float *xAcc, float *yAcc, float *zAcc)
5443 {
5444   int16_t xRawAcc, yRawAcc, zRawAcc;
5445   if (WE_FAIL == ISDS_getRawAccelerations(sensorInterface, &xRawAcc, &yRawAcc, &zRawAcc))
5446   {
5447     return WE_FAIL;
5448   }
5449   *xAcc = ISDS_convertAcceleration_float(xRawAcc, currentAccFullScale);
5450   *yAcc = ISDS_convertAcceleration_float(yRawAcc, currentAccFullScale);
5451   *zAcc = ISDS_convertAcceleration_float(zRawAcc, currentAccFullScale);
5452   return WE_SUCCESS;
5453 }
5454 
5455 /**
5456  * @brief Read the X-axis acceleration in [mg]
5457  *
5458  * Note that this functions relies on the current accelerometer full scale value.
5459  * Make sure that the current accelerometer full scale value is known by calling
5460  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5461  * calling this function.
5462  *
5463  * @param[in] sensorInterface Pointer to sensor interface
5464  * @param[out] xAcc X-axis acceleration in [mg]
5465  * @retval Error code
5466  */
ISDS_getAccelerationX_int(WE_sensorInterface_t * sensorInterface,int16_t * xAcc)5467 int8_t ISDS_getAccelerationX_int(WE_sensorInterface_t* sensorInterface, int16_t *xAcc)
5468 {
5469   int16_t rawAcc;
5470   if (WE_FAIL == ISDS_getRawAccelerationX(sensorInterface, &rawAcc))
5471   {
5472     return WE_FAIL;
5473   }
5474   *xAcc = ISDS_convertAcceleration_int(rawAcc, currentAccFullScale);
5475   return WE_SUCCESS;
5476 }
5477 
5478 /**
5479  * @brief Read the Y-axis acceleration in [mg]
5480  *
5481  * Note that this functions relies on the current accelerometer full scale value.
5482  * Make sure that the current accelerometer full scale value is known by calling
5483  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5484  * calling this function.
5485  *
5486  * @param[in] sensorInterface Pointer to sensor interface
5487  * @param[out] yAcc Y-axis acceleration in [mg]
5488  * @retval Error code
5489  */
ISDS_getAccelerationY_int(WE_sensorInterface_t * sensorInterface,int16_t * yAcc)5490 int8_t ISDS_getAccelerationY_int(WE_sensorInterface_t* sensorInterface, int16_t *yAcc)
5491 {
5492   int16_t rawAcc;
5493   if (WE_FAIL == ISDS_getRawAccelerationY(sensorInterface, &rawAcc))
5494   {
5495     return WE_FAIL;
5496   }
5497   *yAcc = ISDS_convertAcceleration_int(rawAcc, currentAccFullScale);
5498   return WE_SUCCESS;
5499 }
5500 
5501 /**
5502  * @brief Read the Z-axis acceleration in [mg]
5503  *
5504  * Note that this functions relies on the current accelerometer full scale value.
5505  * Make sure that the current accelerometer full scale value is known by calling
5506  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5507  * calling this function.
5508  *
5509  * @param[in] sensorInterface Pointer to sensor interface
5510  * @param[out] zAcc Z-axis acceleration in [mg]
5511  * @retval Error code
5512  */
ISDS_getAccelerationZ_int(WE_sensorInterface_t * sensorInterface,int16_t * zAcc)5513 int8_t ISDS_getAccelerationZ_int(WE_sensorInterface_t* sensorInterface, int16_t *zAcc)
5514 {
5515   int16_t rawAcc;
5516   if (WE_FAIL == ISDS_getRawAccelerationZ(sensorInterface, &rawAcc))
5517   {
5518     return WE_FAIL;
5519   }
5520   *zAcc = ISDS_convertAcceleration_int(rawAcc, currentAccFullScale);
5521   return WE_SUCCESS;
5522 }
5523 
5524 /**
5525  * @brief Read the accelerometer sensor output in [mg] for all three axes
5526  *
5527  * Note that this functions relies on the current accelerometer full scale value.
5528  * Make sure that the current accelerometer full scale value is known by calling
5529  * ISDS_setAccFullScale() or ISDS_getAccFullScale() at least once prior to
5530  * calling this function.
5531  *
5532  * @param[in] sensorInterface Pointer to sensor interface
5533  * @param[out] xAcc The returned X-axis acceleration in [mg]
5534  * @param[out] yAcc The returned Y-axis acceleration in [mg]
5535  * @param[out] zAcc The returned Z-axis acceleration in [mg]
5536  * @retval Error code
5537  */
ISDS_getAccelerations_int(WE_sensorInterface_t * sensorInterface,int16_t * xAcc,int16_t * yAcc,int16_t * zAcc)5538 int8_t ISDS_getAccelerations_int(WE_sensorInterface_t* sensorInterface, int16_t *xAcc, int16_t *yAcc, int16_t *zAcc)
5539 {
5540   int16_t xRawAcc, yRawAcc, zRawAcc;
5541   if (WE_FAIL == ISDS_getRawAccelerations(sensorInterface, &xRawAcc, &yRawAcc, &zRawAcc))
5542   {
5543     return WE_FAIL;
5544   }
5545   *xAcc = ISDS_convertAcceleration_int(xRawAcc, currentAccFullScale);
5546   *yAcc = ISDS_convertAcceleration_int(yRawAcc, currentAccFullScale);
5547   *zAcc = ISDS_convertAcceleration_int(zRawAcc, currentAccFullScale);
5548   return WE_SUCCESS;
5549 }
5550 
5551 /**
5552  * @brief Read the raw X-axis acceleration sensor output
5553  * @param[in] sensorInterface Pointer to sensor interface
5554  * @param[out] xRawAcc The returned raw X-axis acceleration
5555  * @retval Error code
5556  */
ISDS_getRawAccelerationX(WE_sensorInterface_t * sensorInterface,int16_t * xRawAcc)5557 int8_t ISDS_getRawAccelerationX(WE_sensorInterface_t* sensorInterface, int16_t *xRawAcc)
5558 {
5559   uint8_t tmp[2] = {0};
5560 
5561   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_ACC_REG, 2, tmp))
5562   {
5563     return WE_FAIL;
5564   }
5565 
5566   *xRawAcc = (int16_t) (tmp[1] << 8);
5567   *xRawAcc |= (int16_t) tmp[0];
5568 
5569   return WE_SUCCESS;
5570 }
5571 
5572 /**
5573  * @brief Read the raw Y-axis acceleration sensor output
5574  * @param[in] sensorInterface Pointer to sensor interface
5575  * @param[out] yRawAcc The returned raw Y-axis acceleration
5576  * @retval Error code
5577  */
ISDS_getRawAccelerationY(WE_sensorInterface_t * sensorInterface,int16_t * yRawAcc)5578 int8_t ISDS_getRawAccelerationY(WE_sensorInterface_t* sensorInterface, int16_t *yRawAcc)
5579 {
5580   uint8_t tmp[2] = {0};
5581 
5582   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Y_OUT_L_ACC_REG, 2, tmp))
5583   {
5584     return WE_FAIL;
5585   }
5586 
5587   *yRawAcc = (int16_t) (tmp[1] << 8);
5588   *yRawAcc |= (int16_t) tmp[0];
5589 
5590   return WE_SUCCESS;
5591 }
5592 
5593 /**
5594  * @brief Read the raw Z-axis acceleration sensor output
5595  * @param[in] sensorInterface Pointer to sensor interface
5596  * @param[out] zRawAcc The returned raw Z-axis acceleration
5597  * @retval Error code
5598  */
ISDS_getRawAccelerationZ(WE_sensorInterface_t * sensorInterface,int16_t * zRawAcc)5599 int8_t ISDS_getRawAccelerationZ(WE_sensorInterface_t* sensorInterface, int16_t *zRawAcc)
5600 {
5601   uint8_t tmp[2] = {0};
5602 
5603   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_Z_OUT_L_ACC_REG, 2, tmp))
5604   {
5605     return WE_FAIL;
5606   }
5607 
5608   *zRawAcc = (int16_t) (tmp[1] << 8);
5609   *zRawAcc |= (int16_t) tmp[0];
5610 
5611   return WE_SUCCESS;
5612 }
5613 
5614 /**
5615  * @brief Read the raw accelerometer sensor output for all three axes
5616  * @param[in] sensorInterface Pointer to sensor interface
5617  * @param[out] xRawAcc The returned raw X-axis acceleration
5618  * @param[out] yRawAcc The returned raw Y-axis acceleration
5619  * @param[out] zRawAcc The returned raw Z-axis acceleration
5620  * @retval Error code
5621  */
ISDS_getRawAccelerations(WE_sensorInterface_t * sensorInterface,int16_t * xRawAcc,int16_t * yRawAcc,int16_t * zRawAcc)5622 int8_t ISDS_getRawAccelerations(WE_sensorInterface_t* sensorInterface, int16_t *xRawAcc, int16_t *yRawAcc, int16_t *zRawAcc)
5623 {
5624   uint8_t tmp[6] = {0};
5625 
5626   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_X_OUT_L_ACC_REG, 6, tmp))
5627   {
5628     return WE_FAIL;
5629   }
5630 
5631   *xRawAcc = (int16_t) (tmp[1] << 8);
5632   *xRawAcc |= (int16_t) tmp[0];
5633 
5634   *yRawAcc = (int16_t) (tmp[3] << 8);
5635   *yRawAcc |= (int16_t) tmp[2];
5636 
5637   *zRawAcc = (int16_t) (tmp[5] << 8);
5638   *zRawAcc |= (int16_t) tmp[4];
5639 
5640   return WE_SUCCESS;
5641 }
5642 
5643 /**
5644  * @brief Read the temperature in [°C]
5645  * @param[in] sensorInterface Pointer to sensor interface
5646  * @param[out] temperature Temperature in [°C]
5647  * @retval Error code
5648  */
ISDS_getTemperature_float(WE_sensorInterface_t * sensorInterface,float * temperature)5649 int8_t ISDS_getTemperature_float(WE_sensorInterface_t* sensorInterface, float *temperature)
5650 {
5651   int16_t tempRaw;
5652   if (WE_FAIL == ISDS_getRawTemperature(sensorInterface, &tempRaw))
5653   {
5654     return WE_FAIL;
5655   }
5656   *temperature = ISDS_convertTemperature_float(tempRaw);
5657   return WE_SUCCESS;
5658 }
5659 
5660 /**
5661  * @brief Read the temperature in [°C x 100]
5662  * @param[in] sensorInterface Pointer to sensor interface
5663  * @param[out] temperature Temperature in [°C x 100]
5664  * @retval Error code
5665  */
ISDS_getTemperature_int(WE_sensorInterface_t * sensorInterface,int16_t * temperature)5666 int8_t ISDS_getTemperature_int(WE_sensorInterface_t* sensorInterface, int16_t *temperature)
5667 {
5668   int16_t tempRaw;
5669   if (WE_FAIL == ISDS_getRawTemperature(sensorInterface, &tempRaw))
5670   {
5671     return WE_FAIL;
5672   }
5673   *temperature = ISDS_convertTemperature_int(tempRaw);
5674   return WE_SUCCESS;
5675 }
5676 
5677 /**
5678  * @brief Read the raw temperature
5679  *
5680  * Can be converted to [°C] using ISDS_convertTemperature_float()
5681  *
5682  * @param[in] sensorInterface Pointer to sensor interface
5683  * @param[out] temperature Raw temperature value (temperature sensor output)
5684  * @retval Error code
5685  */
ISDS_getRawTemperature(WE_sensorInterface_t * sensorInterface,int16_t * temperature)5686 int8_t ISDS_getRawTemperature(WE_sensorInterface_t* sensorInterface, int16_t *temperature)
5687 {
5688   uint8_t tmp[2] = {0};
5689 
5690   if (WE_FAIL == ISDS_ReadReg(sensorInterface, ISDS_OUT_TEMP_L_REG, 2, tmp))
5691   {
5692     return WE_FAIL;
5693   }
5694 
5695   *temperature = (int16_t) (tmp[1] << 8);
5696   *temperature |= (int16_t) tmp[0];
5697 
5698   return WE_SUCCESS;
5699 }
5700 
5701 /**
5702  * @brief Converts the supplied raw acceleration into [mg]
5703  * @param[in] acc Raw acceleration value (accelerometer output)
5704  * @param[in] fullScale Accelerometer full scale
5705  * @retval The converted acceleration in [mg]
5706  */
ISDS_convertAcceleration_float(int16_t acc,ISDS_accFullScale_t fullScale)5707 float ISDS_convertAcceleration_float(int16_t acc, ISDS_accFullScale_t fullScale)
5708 {
5709   switch (fullScale)
5710   {
5711   case ISDS_accFullScaleTwoG:
5712     return ISDS_convertAccelerationFs2g_float(acc);
5713 
5714   case ISDS_accFullScaleSixteenG:
5715     return ISDS_convertAccelerationFs16g_float(acc);
5716 
5717   case ISDS_accFullScaleFourG:
5718     return ISDS_convertAccelerationFs4g_float(acc);
5719 
5720   case ISDS_accFullScaleEightG:
5721     return ISDS_convertAccelerationFs8g_float(acc);
5722 
5723   default:
5724     return 0;
5725   }
5726 }
5727 
5728 /**
5729  * @brief Converts the supplied raw acceleration sampled using
5730  * ISDS_accFullScaleTwoG to [mg]
5731  * @param[in] acc Raw acceleration value (accelerometer output)
5732  * @retval The converted acceleration in [mg]
5733  */
ISDS_convertAccelerationFs2g_float(int16_t acc)5734 float ISDS_convertAccelerationFs2g_float(int16_t acc)
5735 {
5736   return ((float) acc * 0.061f);
5737 }
5738 
5739 /**
5740  * @brief Converts the supplied raw acceleration sampled using
5741  * ISDS_accFullScaleFourG to [mg]
5742  * @param[in] acc Raw acceleration value (accelerometer output)
5743  * @retval The converted acceleration in [mg]
5744  */
ISDS_convertAccelerationFs4g_float(int16_t acc)5745 float ISDS_convertAccelerationFs4g_float(int16_t acc)
5746 {
5747   return ((float) acc * 0.122f);
5748 }
5749 
5750 /**
5751  * @brief Converts the supplied raw acceleration sampled using
5752  * ISDS_accFullScaleEightG to [mg]
5753  * @param[in] acc Raw acceleration value (accelerometer output)
5754  * @retval The converted acceleration in [mg]
5755  */
ISDS_convertAccelerationFs8g_float(int16_t acc)5756 float ISDS_convertAccelerationFs8g_float(int16_t acc)
5757 {
5758   return ((float) acc * 0.244f);
5759 }
5760 
5761 /**
5762  * @brief Converts the supplied raw acceleration sampled using
5763  * ISDS_accFullScaleSixteenG to [mg]
5764  * @param[in] acc Raw acceleration value (accelerometer output)
5765  * @retval The converted acceleration in [mg]
5766  */
ISDS_convertAccelerationFs16g_float(int16_t acc)5767 float ISDS_convertAccelerationFs16g_float(int16_t acc)
5768 {
5769   return ((float) acc * 0.488f);
5770 }
5771 
5772 /**
5773  * @brief Converts the supplied raw angular rate into [mdps] (millidegrees per second).
5774  * @param[in] rate Raw angular rate (gyroscope output)
5775  * @param[in] fullScale Gyroscope full scale
5776  * @retval The converted angular rate in [mdps] (millidegrees per second)
5777  */
ISDS_convertAngularRate_float(int16_t rate,ISDS_gyroFullScale_t fullScale)5778 float ISDS_convertAngularRate_float(int16_t rate, ISDS_gyroFullScale_t fullScale)
5779 {
5780   switch (fullScale)
5781   {
5782   case ISDS_gyroFullScale250dps:
5783     return ISDS_convertAngularRateFs250dps_float(rate);
5784 
5785   case ISDS_gyroFullScale125dps:
5786     return ISDS_convertAngularRateFs125dps_float(rate);
5787 
5788   case ISDS_gyroFullScale500dps:
5789     return ISDS_convertAngularRateFs500dps_float(rate);
5790 
5791   case ISDS_gyroFullScale1000dps:
5792     return ISDS_convertAngularRateFs1000dps_float(rate);
5793 
5794   case ISDS_gyroFullScale2000dps:
5795     return ISDS_convertAngularRateFs2000dps_float(rate);
5796 
5797   default:
5798     return 0;
5799   }
5800 }
5801 
5802 /**
5803  * @brief Converts the supplied raw angular rate sampled using
5804  * ISDS_gyroFullScale125dps to [mdps] (millidegrees per second).
5805  * @param[in] rate Raw angular rate (gyroscope output)
5806  * @retval The converted angular rate in [mdps] (millidegrees per second)
5807  */
ISDS_convertAngularRateFs125dps_float(int16_t rate)5808 float ISDS_convertAngularRateFs125dps_float(int16_t rate)
5809 {
5810   return ((float) rate * 4.375f);
5811 }
5812 
5813 /**
5814  * @brief Converts the supplied raw angular rate sampled using
5815  * ISDS_gyroFullScale250dps to [mdps] (millidegrees per second).
5816  * @param[in] rate Raw angular rate (gyroscope output)
5817  * @retval The converted angular rate in [mdps] (millidegrees per second)
5818  */
ISDS_convertAngularRateFs250dps_float(int16_t rate)5819 float ISDS_convertAngularRateFs250dps_float(int16_t rate)
5820 {
5821   return ((float) rate * 8.75f);
5822 }
5823 
5824 /**
5825  * @brief Converts the supplied raw angular rate sampled using
5826  * ISDS_gyroFullScale500dps to [mdps] (millidegrees per second).
5827  * @param[in] rate Raw angular rate (gyroscope output)
5828  * @retval The converted angular rate in [mdps] (millidegrees per second)
5829  */
ISDS_convertAngularRateFs500dps_float(int16_t rate)5830 float ISDS_convertAngularRateFs500dps_float(int16_t rate)
5831 {
5832   return ((float) rate * 17.5f);
5833 }
5834 
5835 /**
5836  * @brief Converts the supplied raw angular rate sampled using
5837  * ISDS_gyroFullScale1000dps to [mdps] (millidegrees per second).
5838  * @param[in] rate Raw angular rate (gyroscope output)
5839  * @retval The converted angular rate in [mdps] (millidegrees per second)
5840  */
ISDS_convertAngularRateFs1000dps_float(int16_t rate)5841 float ISDS_convertAngularRateFs1000dps_float(int16_t rate)
5842 {
5843   return ((float) rate * 35);
5844 }
5845 
5846 /**
5847  * @brief Converts the supplied raw angular rate sampled using
5848  * ISDS_gyroFullScale2000dps 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_convertAngularRateFs2000dps_float(int16_t rate)5852 float ISDS_convertAngularRateFs2000dps_float(int16_t rate)
5853 {
5854   return ((float) rate * 70);
5855 }
5856 
5857 /**
5858  * @brief Converts the supplied raw temperature to [°C].
5859  * @param[in] temperature Raw temperature (temperature sensor output)
5860  * @retval The converted temperature in [°C]
5861  */
ISDS_convertTemperature_float(int16_t temperature)5862 float ISDS_convertTemperature_float(int16_t temperature)
5863 {
5864   return ((((float) temperature) / 256.0f) + 25.0f);
5865 }
5866 
5867 /**
5868  * @brief Converts the supplied raw acceleration into [mg]
5869  * @param[in] acc Raw acceleration value (accelerometer output)
5870  * @param[in] fullScale Accelerometer full scale
5871  * @retval The converted acceleration in [mg]
5872  */
ISDS_convertAcceleration_int(int16_t acc,ISDS_accFullScale_t fullScale)5873 int16_t ISDS_convertAcceleration_int(int16_t acc, ISDS_accFullScale_t fullScale)
5874 {
5875   switch (fullScale)
5876   {
5877   case ISDS_accFullScaleTwoG:
5878     return ISDS_convertAccelerationFs2g_int(acc);
5879 
5880   case ISDS_accFullScaleSixteenG:
5881     return ISDS_convertAccelerationFs16g_int(acc);
5882 
5883   case ISDS_accFullScaleFourG:
5884     return ISDS_convertAccelerationFs4g_int(acc);
5885 
5886   case ISDS_accFullScaleEightG:
5887     return ISDS_convertAccelerationFs8g_int(acc);
5888 
5889   default:
5890     return 0;
5891   }
5892 }
5893 
5894 /**
5895  * @brief Converts the supplied raw acceleration sampled using
5896  * ISDS_accFullScaleTwoG to [mg]
5897  * @param[in] acc Raw acceleration value (accelerometer output)
5898  * @retval The converted acceleration in [mg]
5899  */
ISDS_convertAccelerationFs2g_int(int16_t acc)5900 int16_t ISDS_convertAccelerationFs2g_int(int16_t acc)
5901 {
5902   return (int16_t) ((((int32_t) acc) * 61) / 1000);
5903 }
5904 
5905 /**
5906  * @brief Converts the supplied raw acceleration sampled using
5907  * ISDS_accFullScaleFourG to [mg]
5908  * @param[in] acc Raw acceleration value (accelerometer output)
5909  * @retval The converted acceleration in [mg]
5910  */
ISDS_convertAccelerationFs4g_int(int16_t acc)5911 int16_t ISDS_convertAccelerationFs4g_int(int16_t acc)
5912 {
5913   return (int16_t) ((((int32_t) acc) * 122) / 1000);
5914 }
5915 
5916 /**
5917  * @brief Converts the supplied raw acceleration sampled using
5918  * ISDS_accFullScaleEightG to [mg]
5919  * @param[in] acc Raw acceleration value (accelerometer output)
5920  * @retval The converted acceleration in [mg]
5921  */
ISDS_convertAccelerationFs8g_int(int16_t acc)5922 int16_t ISDS_convertAccelerationFs8g_int(int16_t acc)
5923 {
5924   return (int16_t) ((((int32_t) acc) * 244) / 1000);
5925 }
5926 
5927 /**
5928  * @brief Converts the supplied raw acceleration sampled using
5929  * ISDS_accFullScaleSixteenG to [mg]
5930  * @param[in] acc Raw acceleration value (accelerometer output)
5931  * @retval The converted acceleration in [mg]
5932  */
ISDS_convertAccelerationFs16g_int(int16_t acc)5933 int16_t ISDS_convertAccelerationFs16g_int(int16_t acc)
5934 {
5935   return (int16_t) ((((int32_t) acc) * 488) / 1000);
5936 }
5937 
5938 /**
5939  * @brief Converts the supplied raw angular rate into [mdps] (millidegrees per second).
5940  * @param[in] rate Raw angular rate (gyroscope output)
5941  * @param[in] fullScale Gyroscope full scale
5942  * @retval The converted angular rate in [mdps] (millidegrees per second)
5943  */
ISDS_convertAngularRate_int(int16_t rate,ISDS_gyroFullScale_t fullScale)5944 int32_t ISDS_convertAngularRate_int(int16_t rate, ISDS_gyroFullScale_t fullScale)
5945 {
5946   switch (fullScale)
5947   {
5948   case ISDS_gyroFullScale250dps:
5949     return ISDS_convertAngularRateFs250dps_int(rate);
5950 
5951   case ISDS_gyroFullScale125dps:
5952     return ISDS_convertAngularRateFs125dps_int(rate);
5953 
5954   case ISDS_gyroFullScale500dps:
5955     return ISDS_convertAngularRateFs500dps_int(rate);
5956 
5957   case ISDS_gyroFullScale1000dps:
5958     return ISDS_convertAngularRateFs1000dps_int(rate);
5959 
5960   case ISDS_gyroFullScale2000dps:
5961     return ISDS_convertAngularRateFs2000dps_int(rate);
5962 
5963   default:
5964     return 0;
5965   }
5966 }
5967 
5968 /**
5969  * @brief Converts the supplied raw angular rate sampled using
5970  * ISDS_gyroFullScale125dps to [mdps] (millidegrees per second).
5971  * @param[in] rate Raw angular rate (gyroscope output)
5972  * @retval The converted angular rate in [mdps] (millidegrees per second)
5973  */
ISDS_convertAngularRateFs125dps_int(int16_t rate)5974 int32_t ISDS_convertAngularRateFs125dps_int(int16_t rate)
5975 {
5976   return (((int32_t) rate) * 4375) / 1000;
5977 }
5978 
5979 /**
5980  * @brief Converts the supplied raw angular rate sampled using
5981  * ISDS_gyroFullScale250dps to [mdps] (millidegrees per second).
5982  * @param[in] rate Raw angular rate (gyroscope output)
5983  * @retval The converted angular rate in [mdps] (millidegrees per second)
5984  */
ISDS_convertAngularRateFs250dps_int(int16_t rate)5985 int32_t ISDS_convertAngularRateFs250dps_int(int16_t rate)
5986 {
5987   return (((int32_t) rate) * 875) / 100;
5988 }
5989 
5990 /**
5991  * @brief Converts the supplied raw angular rate sampled using
5992  * ISDS_gyroFullScale500dps to [mdps] (millidegrees per second).
5993  * @param[in] rate Raw angular rate (gyroscope output)
5994  * @retval The converted angular rate in [mdps] (millidegrees per second)
5995  */
ISDS_convertAngularRateFs500dps_int(int16_t rate)5996 int32_t ISDS_convertAngularRateFs500dps_int(int16_t rate)
5997 {
5998   return (((int32_t) rate) * 175) / 10;
5999 }
6000 
6001 /**
6002  * @brief Converts the supplied raw angular rate sampled using
6003  * ISDS_gyroFullScale1000dps to [mdps] (millidegrees per second).
6004  * @param[in] rate Raw angular rate (gyroscope output)
6005  * @retval The converted angular rate in [mdps] (millidegrees per second)
6006  */
ISDS_convertAngularRateFs1000dps_int(int16_t rate)6007 int32_t ISDS_convertAngularRateFs1000dps_int(int16_t rate)
6008 {
6009   return ((int32_t) rate) * 35;
6010 }
6011 
6012 /**
6013  * @brief Converts the supplied raw angular rate sampled using
6014  * ISDS_gyroFullScale2000dps to [mdps] (millidegrees per second).
6015  * @param[in] rate Raw angular rate (gyroscope output)
6016  * @retval The converted angular rate in [mdps] (millidegrees per second)
6017  */
ISDS_convertAngularRateFs2000dps_int(int16_t rate)6018 int32_t ISDS_convertAngularRateFs2000dps_int(int16_t rate)
6019 {
6020   return ((int32_t) rate) * 70;
6021 }
6022 
6023 /**
6024  * @brief Converts the supplied raw temperature to [°C x 100].
6025  * @param[in] temperature Raw temperature (temperature sensor output)
6026  * @retval The converted temperature in [°C x 100]
6027  */
ISDS_convertTemperature_int(int16_t temperature)6028 int16_t ISDS_convertTemperature_int(int16_t temperature)
6029 {
6030   return (((int32_t) temperature) * 100) / 256 + 2500;
6031 }
6032