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-PADS-2511020213301 sensor.
10 */
11
12 #include "WSEN_PADS_2511020213301_hal.h"
13
14 #include <stdio.h>
15
16 #include <weplatform.h>
17
18 /**
19 * @brief Default sensor interface configuration.
20 */
21 static WE_sensorInterface_t padsDefaultSensorInterface = {
22 .sensorType = WE_PADS,
23 .interfaceType = WE_i2c,
24 .options = {.i2c = {.address = PADS_ADDRESS_I2C_1, .burstMode = 0, .protocol = WE_i2cProtocol_RegisterBased, .useRegAddrMsbForMultiBytesRead = 0, .reserved = 0},
25 .spi = {.chipSelectPort = 0, .chipSelectPin = 0, .burstMode = 0, .reserved = 0},
26 .readTimeout = 1000,
27 .writeTimeout = 1000},
28 .handle = 0};
29
30 /* FIFO buffer stores pressure (3 bytes) and temperature (2 bytes) values. */
31 uint8_t fifoBuffer[PADS_FIFO_BUFFER_SIZE * 5] = {0};
32
33 /**
34 * @brief Read data from sensor.
35 *
36 * @param[in] sensorInterface Pointer to sensor interface
37 * @param[in] regAdr Address of register to read from
38 * @param[in] numBytesToRead Number of bytes to be read
39 * @param[out] data Target buffer
40 * @return Error Code
41 */
PADS_ReadReg(WE_sensorInterface_t * sensorInterface,uint8_t regAdr,uint16_t numBytesToRead,uint8_t * data)42 static inline int8_t PADS_ReadReg(WE_sensorInterface_t* sensorInterface,
43 uint8_t regAdr,
44 uint16_t numBytesToRead,
45 uint8_t *data)
46 {
47 return WE_ReadReg(sensorInterface, regAdr, numBytesToRead, data);
48 }
49
50 /**
51 * @brief Write data to sensor.
52 *
53 * @param[in] sensorInterface Pointer to sensor interface
54 * @param[in] regAdr Address of register to write to
55 * @param[in] numBytesToWrite Number of bytes to be written
56 * @param[in] data Source buffer
57 * @return Error Code
58 */
PADS_WriteReg(WE_sensorInterface_t * sensorInterface,uint8_t regAdr,uint16_t numBytesToWrite,uint8_t * data)59 static inline int8_t PADS_WriteReg(WE_sensorInterface_t* sensorInterface,
60 uint8_t regAdr,
61 uint16_t numBytesToWrite,
62 uint8_t *data)
63 {
64 return WE_WriteReg(sensorInterface, regAdr, numBytesToWrite, data);
65 }
66
67 /**
68 * @brief Returns the default sensor interface configuration.
69 * @param[out] sensorInterface Sensor interface configuration (output parameter)
70 * @return Error code
71 */
PADS_getDefaultInterface(WE_sensorInterface_t * sensorInterface)72 int8_t PADS_getDefaultInterface(WE_sensorInterface_t* sensorInterface)
73 {
74 *sensorInterface = padsDefaultSensorInterface;
75 return WE_SUCCESS;
76 }
77
78 /**
79 * @brief Read the device ID
80 *
81 * Expected value is PADS_DEVICE_ID_VALUE.
82 *
83 * @param[in] sensorInterface Pointer to sensor interface
84 * @param[out] deviceID The returned device ID.
85 * @retval Error code
86 */
PADS_getDeviceID(WE_sensorInterface_t * sensorInterface,uint8_t * deviceID)87 int8_t PADS_getDeviceID(WE_sensorInterface_t* sensorInterface, uint8_t *deviceID)
88 {
89 return PADS_ReadReg(sensorInterface, PADS_DEVICE_ID_REG, 1, deviceID);
90 }
91
92 /**
93 * @brief Enable the AUTOREFP function
94 *
95 * Note that when enabling AUTOREFP using this function, the AUTOREFP bit
96 * will stay high only until the first conversion is complete. The function will remain
97 * turned on even if the bit is zero.
98 *
99 * The function can be turned off with PADS_resetAutoRefp().
100 *
101 * @param[in] sensorInterface Pointer to sensor interface
102 * @param[in] autoRefp Turns AUTOREFP function on
103 * @retval Error code
104 */
PADS_enableAutoRefp(WE_sensorInterface_t * sensorInterface,PADS_state_t autoRefp)105 int8_t PADS_enableAutoRefp(WE_sensorInterface_t* sensorInterface, PADS_state_t autoRefp)
106 {
107 PADS_interruptConfiguration_t interruptConfigurationReg;
108
109 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
110 {
111 return WE_FAIL;
112 }
113
114 interruptConfigurationReg.autoRefp = autoRefp;
115
116 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
117 }
118
119 /**
120 * @brief Check if the AUTOREFP function is currently being enabled.
121 *
122 * Note that when enabling AUTOREFP using PADS_enableAutoRefp(WE_sensorInterface_t* sensorInterface, ), the AUTOREFP bit
123 * will stay high only until the first conversion is complete. The function will remain
124 * turned on even if the bit is zero.
125 *
126 * The function can be turned off with PADS_resetAutoRefp().
127 *
128 * @param[in] sensorInterface Pointer to sensor interface
129 * @param[out] autoRefp The returned state
130 * @retval Error code
131 */
PADS_isEnablingAutoRefp(WE_sensorInterface_t * sensorInterface,PADS_state_t * autoRefp)132 int8_t PADS_isEnablingAutoRefp(WE_sensorInterface_t* sensorInterface, PADS_state_t *autoRefp)
133 {
134 PADS_interruptConfiguration_t interruptConfigurationReg;
135
136 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
137 {
138 return WE_FAIL;
139 }
140 *autoRefp = (PADS_state_t) interruptConfigurationReg.autoRefp;
141 return WE_SUCCESS;
142 }
143
144 /**
145 * @brief Turn off the AUTOREFP function
146 * @param[in] sensorInterface Pointer to sensor interface
147 * @param[in] reset Reset state
148 * @retval Error code
149 */
PADS_resetAutoRefp(WE_sensorInterface_t * sensorInterface,PADS_state_t reset)150 int8_t PADS_resetAutoRefp(WE_sensorInterface_t* sensorInterface, PADS_state_t reset)
151 {
152 PADS_interruptConfiguration_t interruptConfigurationReg;
153
154 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
155 {
156 return WE_FAIL;
157 }
158
159 interruptConfigurationReg.resetAutoRefp = reset;
160
161 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
162 }
163
164 /**
165 * @brief Enable the AUTOZERO function
166 *
167 * Note that when enabling AUTOZERO using this function, the AUTOZERO bit
168 * will stay high only until the first conversion is complete. The function will remain
169 * turned on even if the bit is zero.
170 *
171 * The function can be turned off with PADS_resetAutoZeroMode().
172 *
173 * @param[in] sensorInterface Pointer to sensor interface
174 * @param[in] autoZero Turns AUTOZERO function on
175 * @retval Error code
176 */
PADS_enableAutoZeroMode(WE_sensorInterface_t * sensorInterface,PADS_state_t autoZero)177 int8_t PADS_enableAutoZeroMode(WE_sensorInterface_t* sensorInterface, PADS_state_t autoZero)
178 {
179 PADS_interruptConfiguration_t interruptConfigurationReg;
180
181 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
182 {
183 return WE_FAIL;
184 }
185
186 interruptConfigurationReg.autoZero = autoZero;
187
188 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
189 }
190
191 /**
192 * @brief Check if the AUTOZERO function is currently being enabled.
193 *
194 * Note that when enabling AUTOZERO using PADS_enableAutoZeroMode(), the AUTOZERO bit
195 * will stay high only until the first conversion is complete. The function will remain
196 * turned on even if the bit is zero.
197 *
198 * The function can be turned off with PADS_resetAutoZeroMode().
199 *
200 * @param[in] sensorInterface Pointer to sensor interface
201 * @param[out] autoZero The returned state
202 * @retval Error code
203 */
PADS_isEnablingAutoZeroMode(WE_sensorInterface_t * sensorInterface,PADS_state_t * autoZero)204 int8_t PADS_isEnablingAutoZeroMode(WE_sensorInterface_t* sensorInterface, PADS_state_t *autoZero)
205 {
206 PADS_interruptConfiguration_t interruptConfigurationReg;
207
208 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
209 {
210 return WE_FAIL;
211 }
212
213 *autoZero = (PADS_state_t) interruptConfigurationReg.autoZero;
214
215 return WE_SUCCESS;
216 }
217
218 /**
219 * @brief Turn off the AUTOZERO function
220 * @param[in] sensorInterface Pointer to sensor interface
221 * @param[in] reset Reset state
222 * @retval Error code
223 */
PADS_resetAutoZeroMode(WE_sensorInterface_t * sensorInterface,PADS_state_t reset)224 int8_t PADS_resetAutoZeroMode(WE_sensorInterface_t* sensorInterface, PADS_state_t reset)
225 {
226 PADS_interruptConfiguration_t interruptConfigurationReg;
227
228 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
229 {
230 return WE_FAIL;
231 }
232
233 interruptConfigurationReg.resetAutoZero = reset;
234
235 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
236 }
237
238 /**
239 * @brief Enable/disable the differential pressure interrupt [enabled,disabled]
240 * @param[in] sensorInterface Pointer to sensor interface
241 * @param[in] diffEn Differential pressure interrupt enable state
242 * @retval Error code
243 */
PADS_enableDiffPressureInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t diffEn)244 int8_t PADS_enableDiffPressureInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t diffEn)
245 {
246 PADS_interruptConfiguration_t interruptConfigurationReg;
247
248 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
249 {
250 return WE_FAIL;
251 }
252
253 interruptConfigurationReg.diffInt = diffEn;
254
255 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
256 }
257
258 /**
259 * @brief Check if the differential pressure interrupt is enabled
260 * @param[in] sensorInterface Pointer to sensor interface
261 * @param[out] diffIntState The returned differential interrupt enable state
262 * @retval Error code
263 */
PADS_isDiffPressureInterruptEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * diffIntState)264 int8_t PADS_isDiffPressureInterruptEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *diffIntState)
265 {
266 PADS_interruptConfiguration_t interruptConfigurationReg;
267
268 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
269 {
270 return WE_FAIL;
271 }
272
273 *diffIntState = (PADS_state_t) interruptConfigurationReg.diffInt;
274
275 return WE_SUCCESS;
276 }
277
278 /**
279 * @brief Enable/disable latched interrupt [enabled, disabled]
280 * @param[in] sensorInterface Pointer to sensor interface
281 * @param[in] state Latched interrupt enable state
282 * @retval Error code
283 */
PADS_enableLatchedInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t state)284 int8_t PADS_enableLatchedInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t state)
285 {
286 PADS_interruptConfiguration_t interruptConfigurationReg;
287
288 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
289 {
290 return WE_FAIL;
291 }
292
293 interruptConfigurationReg.latchedInt = state;
294
295 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
296 }
297
298 /**
299 * @brief Check if latched interrupts are enabled
300 * @param[in] sensorInterface Pointer to sensor interface
301 * @param[out] latchInt The returned latched interrupts enable state
302 * @retval Error code
303 */
PADS_isLatchedInterruptEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * latchInt)304 int8_t PADS_isLatchedInterruptEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *latchInt)
305 {
306 PADS_interruptConfiguration_t interruptConfigurationReg;
307
308 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
309 {
310 return WE_FAIL;
311 }
312
313 *latchInt = (PADS_state_t) interruptConfigurationReg.latchedInt;
314
315 return WE_SUCCESS;
316 }
317
318 /**
319 * @brief Enable/disable the low pressure interrupt [enabled, disabled]
320 * @param[in] sensorInterface Pointer to sensor interface
321 * @param[in] state Low pressure interrupt enable state
322 * @retval Error code
323 */
PADS_enableLowPressureInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t state)324 int8_t PADS_enableLowPressureInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t state)
325 {
326 PADS_interruptConfiguration_t interruptConfigurationReg;
327
328 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
329 {
330 return WE_FAIL;
331 }
332
333 interruptConfigurationReg.lowPresInt = state;
334
335 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
336 }
337
338 /**
339 * @brief Check if the low pressure interrupt is enabled
340 * @param[in] sensorInterface Pointer to sensor interface
341 * @param[out] lpint The returned low pressure interrupt enable state
342 * @retval Error code
343 */
PADS_isLowPressureInterruptEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * lpint)344 int8_t PADS_isLowPressureInterruptEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *lpint)
345 {
346 PADS_interruptConfiguration_t interruptConfigurationReg;
347
348 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
349 {
350 return WE_FAIL;
351 }
352
353 *lpint = (PADS_state_t) interruptConfigurationReg.lowPresInt;
354
355 return WE_SUCCESS;
356 }
357
358 /**
359 * @brief Enable/disable the high pressure interrupt [enabled, disabled]
360 * @param[in] sensorInterface Pointer to sensor interface
361 * @param[in] state High pressure interrupt enable state
362 * @retval Error code
363 */
PADS_enableHighPressureInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t state)364 int8_t PADS_enableHighPressureInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t state)
365 {
366 PADS_interruptConfiguration_t interruptConfigurationReg;
367
368 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
369 {
370 return WE_FAIL;
371 }
372
373 interruptConfigurationReg.highPresInt = state;
374
375 return PADS_WriteReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg);
376 }
377
378 /**
379 * @brief Check if the high pressure interrupt is enabled
380 * @param[in] sensorInterface Pointer to sensor interface
381 * @param[out] hpint The returned high pressure interrupt enable state
382 * @retval Error code
383 */
PADS_isHighPressureInterruptEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * hpint)384 int8_t PADS_isHighPressureInterruptEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *hpint)
385 {
386 PADS_interruptConfiguration_t interruptConfigurationReg;
387
388 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_CFG_REG, 1, (uint8_t *) &interruptConfigurationReg))
389 {
390 return WE_FAIL;
391 }
392
393 *hpint = (PADS_state_t) interruptConfigurationReg.highPresInt;
394
395 return WE_SUCCESS;
396 }
397
398 /**
399 * @brief Read interrupt source register
400 * @param[in] sensorInterface Pointer to sensor interface
401 * @param[out] intSource The returned interrupt source register state
402 * @retval Error code
403 */
PADS_getInterruptSource(WE_sensorInterface_t * sensorInterface,PADS_intSource_t * intSource)404 int8_t PADS_getInterruptSource(WE_sensorInterface_t* sensorInterface, PADS_intSource_t *intSource)
405 {
406 return PADS_ReadReg(sensorInterface, PADS_INT_SOURCE_REG, 1, (uint8_t *) intSource);
407 }
408
409 /**
410 * @brief Read the state of the interrupts
411 * @param[in] sensorInterface Pointer to sensor interface
412 * @param[out] intState Returned state of the interrupts
413 * @retval Error code
414 */
PADS_getInterruptStatus(WE_sensorInterface_t * sensorInterface,PADS_state_t * intState)415 int8_t PADS_getInterruptStatus(WE_sensorInterface_t* sensorInterface, PADS_state_t *intState)
416 {
417 PADS_intSource_t int_source;
418
419 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_SOURCE_REG, 1, (uint8_t *) &int_source))
420 {
421 return WE_FAIL;
422 }
423
424 *intState = (PADS_state_t) int_source.intStatus;
425
426 return WE_SUCCESS;
427 }
428
429 /**
430 * @brief Read the state of the differential low pressure interrupt [not active, active]
431 * @param[in] sensorInterface Pointer to sensor interface
432 * @param[out] lpState The returned state of the differential low pressure interrupt
433 * @retval Error code
434 */
PADS_getLowPressureInterruptStatus(WE_sensorInterface_t * sensorInterface,PADS_state_t * lpState)435 int8_t PADS_getLowPressureInterruptStatus(WE_sensorInterface_t* sensorInterface, PADS_state_t *lpState)
436 {
437 PADS_intSource_t int_source;
438
439 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_SOURCE_REG, 1, (uint8_t *) &int_source))
440 {
441 return WE_FAIL;
442 }
443
444 *lpState = (PADS_state_t) int_source.diffPresLowEvent;
445
446 return WE_SUCCESS;
447 }
448
449 /**
450 * @brief Read the state of the differential high pressure interrupt [not active, active]
451 * @param[in] sensorInterface Pointer to sensor interface
452 * @param[out] hpState The returned state of the differential high pressure interrupt
453 * @retval No error
454 */
PADS_getHighPressureInterruptStatus(WE_sensorInterface_t * sensorInterface,PADS_state_t * hpState)455 int8_t PADS_getHighPressureInterruptStatus(WE_sensorInterface_t* sensorInterface, PADS_state_t *hpState)
456 {
457 PADS_intSource_t int_source;
458
459 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_SOURCE_REG, 1, (uint8_t *) &int_source))
460 {
461 return WE_FAIL;
462 }
463
464 *hpState = int_source.diffPresHighEvent;
465
466 return WE_SUCCESS;
467 }
468
469 /**
470 * @brief Enable/disable the FIFO full interrupt
471 * @param[in] sensorInterface Pointer to sensor interface
472 * @param[in] fullState FIFO full interrupt enable state
473 * @retval Error code
474 */
PADS_enableFifoFullInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t fullState)475 int8_t PADS_enableFifoFullInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t fullState)
476 {
477 PADS_ctrl3_t ctrl3;
478
479 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
480 {
481 return WE_FAIL;
482 }
483
484 ctrl3.fifoFullInt = fullState;
485
486 return PADS_WriteReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
487 }
488
489 /**
490 * @brief Enable/disable the FIFO threshold interrupt
491 * @param[in] sensorInterface Pointer to sensor interface
492 * @param[in] threshState FIFO threshold interrupt enable state
493 * @retval Error code
494 */
PADS_enableFifoThresholdInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t threshState)495 int8_t PADS_enableFifoThresholdInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t threshState)
496 {
497 PADS_ctrl3_t ctrl3;
498
499 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
500 {
501 return WE_FAIL;
502 }
503
504 ctrl3.fifoThresholdInt = threshState;
505
506 return PADS_WriteReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
507 }
508
509 /**
510 * @brief Enable/disable the FIFO overrun interrupt
511 * @param[in] sensorInterface Pointer to sensor interface
512 * @param[in] ovrState FIFO overrun interrupt enable state
513 * @retval Error code
514 */
PADS_enableFifoOverrunInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t ovrState)515 int8_t PADS_enableFifoOverrunInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t ovrState)
516 {
517 PADS_ctrl3_t ctrl3;
518
519 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
520 {
521 return WE_FAIL;
522 }
523
524 ctrl3.fifoOverrunInt = ovrState;
525
526 return PADS_WriteReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
527 }
528
529 /**
530 * @brief Check if FIFO is full [enabled, disabled]
531 * @param[in] sensorInterface Pointer to sensor interface
532 * @param[out] fifoFull The returned FIFO full state
533 * @retval Error code
534 */
PADS_isFifoFull(WE_sensorInterface_t * sensorInterface,PADS_state_t * fifoFull)535 int8_t PADS_isFifoFull(WE_sensorInterface_t* sensorInterface, PADS_state_t *fifoFull)
536 {
537 PADS_fifoStatus2_t fifo_status2;
538
539 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_STATUS2_REG, 1, (uint8_t *) &fifo_status2))
540 {
541 return WE_FAIL;
542 }
543
544 *fifoFull = (PADS_state_t) fifo_status2.fifoFull;
545
546 return WE_SUCCESS;
547 }
548
549 /**
550 * @brief Check if FIFO fill level has exceeded the user defined threshold [enabled, disabled]
551 * @param[in] sensorInterface Pointer to sensor interface
552 * @param[out] fifoWtm The returned FIFO threshold reached state
553 * @retval Error code
554 */
PADS_isFifoThresholdReached(WE_sensorInterface_t * sensorInterface,PADS_state_t * fifoWtm)555 int8_t PADS_isFifoThresholdReached(WE_sensorInterface_t* sensorInterface, PADS_state_t *fifoWtm)
556 {
557 PADS_fifoStatus2_t fifo_status2;
558
559 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_STATUS2_REG, 1, (uint8_t *) &fifo_status2))
560 {
561 return WE_FAIL;
562 }
563
564 *fifoWtm = (PADS_state_t) fifo_status2.fifoWtm;
565
566 return WE_SUCCESS;
567 }
568
569 /**
570 * @brief Read the FIFO overrun state [enabled, disabled]
571 * @param[in] sensorInterface Pointer to sensor interface
572 * @param[out] fifoOvr The returned FIFO overrun state
573 * @retval Error code
574 */
PADS_getFifoOverrunState(WE_sensorInterface_t * sensorInterface,PADS_state_t * fifoOvr)575 int8_t PADS_getFifoOverrunState(WE_sensorInterface_t* sensorInterface, PADS_state_t *fifoOvr)
576 {
577 PADS_fifoStatus2_t fifo_status2;
578
579 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_STATUS2_REG, 1, (uint8_t *) &fifo_status2))
580 {
581 return WE_FAIL;
582 }
583
584 *fifoOvr = (PADS_state_t) fifo_status2.fifoOverrun;
585
586 return WE_SUCCESS;
587 }
588
589 /**
590 * @brief Enable/disable the data ready signal interrupt
591 * @param[in] sensorInterface Pointer to sensor interface
592 * @param[in] drdy Data ready interrupt enable state
593 * @retval Error code
594 */
PADS_enableDataReadyInterrupt(WE_sensorInterface_t * sensorInterface,PADS_state_t drdy)595 int8_t PADS_enableDataReadyInterrupt(WE_sensorInterface_t* sensorInterface, PADS_state_t drdy)
596 {
597 PADS_ctrl3_t ctrl3;
598
599 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
600 {
601 return WE_FAIL;
602 }
603
604 ctrl3.dataReadyInt = drdy;
605
606 return PADS_WriteReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
607 }
608
609 /**
610 * @brief Check if the data ready signal interrupt is enabled [enabled,disabled]
611 * @param[in] sensorInterface Pointer to sensor interface
612 * @param[out] drdy The returned data ready interrupt enable state
613 * @retval Error code
614 */
PADS_isDataReadyInterruptEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * drdy)615 int8_t PADS_isDataReadyInterruptEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *drdy)
616 {
617 PADS_ctrl3_t ctrl3;
618
619 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
620 {
621 return WE_FAIL;
622 }
623
624 *drdy = (PADS_state_t) ctrl3.dataReadyInt;
625
626 return WE_SUCCESS;
627 }
628
629 /**
630 * @brief Configure interrupt events (interrupt event control)
631 * @param[in] sensorInterface Pointer to sensor interface
632 * @param[in] ctr Interrupt event configuration
633 * @retval Error code
634 */
PADS_setInterruptEventControl(WE_sensorInterface_t * sensorInterface,PADS_interruptEventControl_t ctr)635 int8_t PADS_setInterruptEventControl(WE_sensorInterface_t* sensorInterface, PADS_interruptEventControl_t ctr)
636 {
637 PADS_ctrl3_t ctrl3;
638
639 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
640 {
641 return WE_FAIL;
642 }
643
644 ctrl3.intEventCtrl = ctr;
645
646 return PADS_WriteReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3);
647 }
648
649 /**
650 * @brief Read the interrupt event configuration (interrupt event control)
651 * @param[in] sensorInterface Pointer to sensor interface
652 * @param[out] intEvent The returned interrupt event configuration
653 * @retval Error code
654 */
PADS_getInterruptEventControl(WE_sensorInterface_t * sensorInterface,PADS_interruptEventControl_t * intEvent)655 int8_t PADS_getInterruptEventControl(WE_sensorInterface_t* sensorInterface, PADS_interruptEventControl_t *intEvent)
656 {
657 PADS_ctrl3_t ctrl3;
658
659 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_3_REG, 1, (uint8_t *) &ctrl3))
660 {
661 return WE_FAIL;
662 }
663
664 *intEvent = (PADS_interruptEventControl_t) ctrl3.intEventCtrl;
665
666 return WE_SUCCESS;
667 }
668
669 /**
670 * @brief Set the pressure threshold (relative to reference pressure,
671 * both in positive and negative direction).
672 *
673 * @param[in] sensorInterface Pointer to sensor interface
674 * @param[in] thresholdPa Threshold in Pa. Resolution is 6.25 Pa.
675 * @retval Error code
676 */
PADS_setPressureThreshold(WE_sensorInterface_t * sensorInterface,uint32_t thresholdPa)677 int8_t PADS_setPressureThreshold(WE_sensorInterface_t* sensorInterface, uint32_t thresholdPa)
678 {
679 uint32_t thresholdBits = (thresholdPa * 16) / 100;
680 if (WE_FAIL == PADS_setPressureThresholdLSB(sensorInterface, (uint8_t) (thresholdBits & 0xFF)))
681 {
682 return WE_FAIL;
683 }
684 return PADS_setPressureThresholdMSB(sensorInterface, (uint8_t) ((thresholdBits >> 8) & 0xFF));
685 }
686
687 /**
688 * @brief Read the pressure threshold (relative to reference pressure,
689 * both in positive and negative direction).
690 *
691 * @param[in] sensorInterface Pointer to sensor interface
692 * @param[out] thresholdPa The returned threshold in Pa
693 * @retval Error code
694 */
PADS_getPressureThreshold(WE_sensorInterface_t * sensorInterface,uint32_t * thresholdPa)695 int8_t PADS_getPressureThreshold(WE_sensorInterface_t* sensorInterface, uint32_t *thresholdPa)
696 {
697 uint8_t thrLSB, thrMSB;
698 if (WE_FAIL == PADS_getPressureThresholdLSB(sensorInterface, &thrLSB))
699 {
700 return WE_FAIL;
701 }
702 if (WE_FAIL == PADS_getPressureThresholdMSB(sensorInterface, &thrMSB))
703 {
704 return WE_FAIL;
705 }
706 *thresholdPa = (thrLSB & 0xFF) | ((thrMSB & 0xFF) << 8);
707 *thresholdPa = (*thresholdPa * 100) / 16;
708 return WE_SUCCESS;
709 }
710
711 /**
712 * @brief Set the LSB pressure threshold value
713 *
714 * @see PADS_setPressureThreshold()
715 *
716 * @param[in] sensorInterface Pointer to sensor interface
717 * @param[in] thr Pressure threshold LSB
718 * @retval Error code
719 */
PADS_setPressureThresholdLSB(WE_sensorInterface_t * sensorInterface,uint8_t thr)720 int8_t PADS_setPressureThresholdLSB(WE_sensorInterface_t* sensorInterface, uint8_t thr)
721 {
722 return PADS_WriteReg(sensorInterface, PADS_THR_P_L_REG, 1, &thr);
723 }
724
725 /**
726 * @brief Set the MSB pressure threshold value
727 *
728 * @see PADS_setPressureThreshold()
729 *
730 * @param[in] sensorInterface Pointer to sensor interface
731 * @param[in] thr Pressure threshold MSB
732 * @retval Error code
733 */
PADS_setPressureThresholdMSB(WE_sensorInterface_t * sensorInterface,uint8_t thr)734 int8_t PADS_setPressureThresholdMSB(WE_sensorInterface_t* sensorInterface, uint8_t thr)
735 {
736 return PADS_WriteReg(sensorInterface, PADS_THR_P_H_REG, 1, &thr);
737 }
738
739 /**
740 * @brief Read the LSB pressure threshold value
741 *
742 * @see PADS_getPressureThreshold()
743 *
744 * @param[in] sensorInterface Pointer to sensor interface
745 * @param[out] thrLSB The returned pressure threshold LSB value
746 * @retval Error code
747 */
PADS_getPressureThresholdLSB(WE_sensorInterface_t * sensorInterface,uint8_t * thrLSB)748 int8_t PADS_getPressureThresholdLSB(WE_sensorInterface_t* sensorInterface, uint8_t *thrLSB)
749 {
750 return PADS_ReadReg(sensorInterface, PADS_THR_P_L_REG, 1, thrLSB);
751 }
752
753 /**
754 * @brief Read the MSB pressure threshold value
755 *
756 * @see PADS_getPressureThreshold()
757 *
758 * @param[in] sensorInterface Pointer to sensor interface
759 * @param[out] thrMSB The returned pressure threshold MSB value
760 * @retval Error code
761 */
PADS_getPressureThresholdMSB(WE_sensorInterface_t * sensorInterface,uint8_t * thrMSB)762 int8_t PADS_getPressureThresholdMSB(WE_sensorInterface_t* sensorInterface, uint8_t *thrMSB)
763 {
764 return PADS_ReadReg(sensorInterface, PADS_THR_P_H_REG, 1, thrMSB);
765 }
766
767 /**
768 * @brief Disable the I2C interface
769 * @param[in] sensorInterface Pointer to sensor interface
770 * @param[in] i2cDisable I2C interface disable state (0: I2C enabled, 1: I2C disabled)
771 * @retval Error code
772 */
PADS_disableI2CInterface(WE_sensorInterface_t * sensorInterface,PADS_state_t i2cDisable)773 int8_t PADS_disableI2CInterface(WE_sensorInterface_t* sensorInterface, PADS_state_t i2cDisable)
774 {
775 PADS_interfaceCtrl_t interfaceCtrl;
776
777 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
778 {
779 return WE_FAIL;
780 }
781
782 interfaceCtrl.disableI2C = i2cDisable;
783
784 return PADS_WriteReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl);
785 }
786
787 /**
788 * @brief Read the I2C interface disable state [enabled, disabled]
789 * @param[in] sensorInterface Pointer to sensor interface
790 * @param[out] i2cDisabled The returned I2C interface disable state (0: I2C enabled, 1: I2C disabled)
791 * @retval Error code
792 */
PADS_isI2CInterfaceDisabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * i2cDisabled)793 int8_t PADS_isI2CInterfaceDisabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *i2cDisabled)
794 {
795 PADS_interfaceCtrl_t interfaceCtrl;
796
797 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
798 {
799 return WE_FAIL;
800 }
801
802 *i2cDisabled = (PADS_state_t) interfaceCtrl.disableI2C;
803
804 return WE_SUCCESS;
805 }
806
807
808 /**
809 * @brief Disable/enable the internal pull-down on interrupt pin
810 * @param[in] sensorInterface Pointer to sensor interface
811 * @param[in] pullDownState Disable pull-down state (0: PD connected; 1: PD disconnected)
812 * @retval Error code
813 */
PADS_disablePullDownIntPin(WE_sensorInterface_t * sensorInterface,PADS_state_t pullDownState)814 int8_t PADS_disablePullDownIntPin(WE_sensorInterface_t* sensorInterface, PADS_state_t pullDownState)
815 {
816 PADS_interfaceCtrl_t interfaceCtrl;
817
818 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
819 {
820 return WE_FAIL;
821 }
822
823 interfaceCtrl.disPullDownOnIntPin = pullDownState;
824
825 return PADS_WriteReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl);
826 }
827
828 /**
829 * @brief Read the state of the pull down on the interrupt pin
830 * @param[in] sensorInterface Pointer to sensor interface
831 * @param[out] pinState The returned pull-down state (0: PD connected; 1: PD disconnected)
832 * @retval Error code
833 */
PADS_isPullDownIntDisabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * pinState)834 int8_t PADS_isPullDownIntDisabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *pinState)
835 {
836 PADS_interfaceCtrl_t interfaceCtrl;
837
838 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
839 {
840 return WE_FAIL;
841 }
842
843 *pinState = (PADS_state_t) interfaceCtrl.disPullDownOnIntPin;
844
845 return WE_SUCCESS;
846 }
847
848 /**
849 * @brief Set internal pull-up on the SAO pin
850 * @param[in] sensorInterface Pointer to sensor interface
851 * @param[in] saoStatus SAO pull-up state
852 * @retval Error code
853 */
PADS_setSAOPullUp(WE_sensorInterface_t * sensorInterface,PADS_state_t saoStatus)854 int8_t PADS_setSAOPullUp(WE_sensorInterface_t* sensorInterface, PADS_state_t saoStatus)
855 {
856 PADS_interfaceCtrl_t interfaceCtrl;
857 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
858 {
859 return WE_FAIL;
860 }
861
862 interfaceCtrl.pullUpOnSAOPin = saoStatus;
863
864 return PADS_WriteReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl);
865 }
866
867 /**
868 * @brief Read the state of the pull-up on the SAO pin
869 * @param[in] sensorInterface Pointer to sensor interface
870 * @param[out] saoPinState The returned SAO pull-up state
871 * @retval Error code
872 */
PADS_isSAOPullUp(WE_sensorInterface_t * sensorInterface,PADS_state_t * saoPinState)873 int8_t PADS_isSAOPullUp(WE_sensorInterface_t* sensorInterface, PADS_state_t *saoPinState)
874 {
875 PADS_interfaceCtrl_t interfaceCtrl;
876
877 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
878 {
879 return WE_FAIL;
880 }
881
882 *saoPinState = (PADS_state_t) interfaceCtrl.pullUpOnSAOPin;
883
884 return WE_SUCCESS;
885 }
886
887 /**
888 * @brief Set internal pull-up on the SDA pin
889 * @param[in] sensorInterface Pointer to sensor interface
890 * @param[in] sdaStatus SDA pull-up state
891 * @retval Error code
892 */
PADS_setSDAPullUp(WE_sensorInterface_t * sensorInterface,PADS_state_t sdaStatus)893 int8_t PADS_setSDAPullUp(WE_sensorInterface_t* sensorInterface, PADS_state_t sdaStatus)
894 {
895 PADS_interfaceCtrl_t interfaceCtrl;
896
897 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
898 {
899 return WE_FAIL;
900 }
901
902 interfaceCtrl.pullUpOnSDAPin = sdaStatus;
903
904 return PADS_WriteReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl);
905 }
906
907 /**
908 * @brief Read the state of the pull-up on the SDA pin
909 * @param[in] sensorInterface Pointer to sensor interface
910 * @param[out] sdaPinState The returned SDA pull-up state
911 * @retval Error code
912 */
PADS_isSDAPullUp(WE_sensorInterface_t * sensorInterface,PADS_state_t * sdaPinState)913 int8_t PADS_isSDAPullUp(WE_sensorInterface_t* sensorInterface, PADS_state_t *sdaPinState)
914 {
915 PADS_interfaceCtrl_t interfaceCtrl;
916
917 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INTERFACE_CTRL_REG, 1, (uint8_t *) &interfaceCtrl))
918 {
919 return WE_FAIL;
920 }
921
922 *sdaPinState = (PADS_state_t) interfaceCtrl.pullUpOnSDAPin;
923
924 return WE_SUCCESS;
925 }
926
927 /**
928 * @brief Set the output data rate of the sensor
929 * @param[in] sensorInterface Pointer to sensor interface
930 * @param[in] odr output data rate
931 * @retval Error code
932 */
PADS_setOutputDataRate(WE_sensorInterface_t * sensorInterface,PADS_outputDataRate_t odr)933 int8_t PADS_setOutputDataRate(WE_sensorInterface_t* sensorInterface, PADS_outputDataRate_t odr)
934 {
935 PADS_ctrl1_t ctrl1;
936
937 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
938 {
939 return WE_FAIL;
940 }
941
942 ctrl1.outputDataRate = odr;
943
944 return PADS_WriteReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
945 }
946
947 /**
948 * @brief Read the output data rate of the sensor
949 * @param[in] sensorInterface Pointer to sensor interface
950 * @param[out] odr The returned output data rate
951 * @retval Error code
952 */
PADS_getOutputDataRate(WE_sensorInterface_t * sensorInterface,PADS_outputDataRate_t * odr)953 int8_t PADS_getOutputDataRate(WE_sensorInterface_t* sensorInterface, PADS_outputDataRate_t* odr)
954 {
955 PADS_ctrl1_t ctrl1;
956
957 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
958 {
959 return WE_FAIL;
960 }
961
962 *odr = (PADS_outputDataRate_t) ctrl1.outputDataRate;
963
964 return WE_SUCCESS;
965 }
966
967 /**
968 * @brief Enable/disable the low pass filter
969 * @param[in] sensorInterface Pointer to sensor interface
970 * @param[in] filterEnabled Filter state (0: disabled, 1: enabled)
971 * @retval Error code
972 */
PADS_enableLowPassFilter(WE_sensorInterface_t * sensorInterface,PADS_state_t filterEnabled)973 int8_t PADS_enableLowPassFilter(WE_sensorInterface_t* sensorInterface, PADS_state_t filterEnabled)
974 {
975 PADS_ctrl1_t ctrl1;
976
977 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
978 {
979 return WE_FAIL;
980 }
981
982 ctrl1.enLowPassFilter = filterEnabled;
983
984 return PADS_WriteReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
985 }
986
987 /**
988 * @brief Check if the low pass filter is enabled
989 * @param[in] sensorInterface Pointer to sensor interface
990 * @param[out] filterEnabled The returned low pass filter enable state
991 * @retval Error code
992 */
PADS_isLowPassFilterEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * filterEnabled)993 int8_t PADS_isLowPassFilterEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *filterEnabled)
994 {
995 PADS_ctrl1_t ctrl1;
996
997 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
998 {
999 return WE_FAIL;
1000 }
1001
1002 *filterEnabled = (PADS_state_t) ctrl1.enLowPassFilter;
1003
1004 return WE_SUCCESS;
1005 }
1006
1007 /**
1008 * @brief Set the low pass filter configuration
1009 * @param[in] sensorInterface Pointer to sensor interface
1010 * @param[in] conf Low pass filter configuration
1011 * @retval Error code
1012 */
PADS_setLowPassFilterConfig(WE_sensorInterface_t * sensorInterface,PADS_filterConf_t conf)1013 int8_t PADS_setLowPassFilterConfig(WE_sensorInterface_t* sensorInterface, PADS_filterConf_t conf)
1014 {
1015 PADS_ctrl1_t ctrl1;
1016
1017 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1018 {
1019 return WE_FAIL;
1020 }
1021
1022 ctrl1.lowPassFilterConfig = conf;
1023
1024 return PADS_WriteReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
1025 }
1026
1027 /**
1028 * @brief Read the low pass filter configuration
1029 * @param[in] sensorInterface Pointer to sensor interface
1030 * @param[out] conf The returned low pass filter configuration
1031 * @retval Error code
1032 */
PADS_getLowPassFilterConfig(WE_sensorInterface_t * sensorInterface,PADS_filterConf_t * conf)1033 int8_t PADS_getLowPassFilterConfig(WE_sensorInterface_t* sensorInterface, PADS_filterConf_t *conf)
1034 {
1035 PADS_ctrl1_t ctrl1;
1036
1037 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1038 {
1039 return WE_FAIL;
1040 }
1041
1042 *conf = (PADS_filterConf_t) ctrl1.lowPassFilterConfig;
1043
1044 return WE_SUCCESS;
1045 }
1046
1047 /**
1048 * @brief Enable/disable block data update
1049 * @param[in] sensorInterface Pointer to sensor interface
1050 * @param[in] bdu Block data update state
1051 * @retval Error code
1052 */
PADS_enableBlockDataUpdate(WE_sensorInterface_t * sensorInterface,PADS_state_t bdu)1053 int8_t PADS_enableBlockDataUpdate(WE_sensorInterface_t* sensorInterface, PADS_state_t bdu)
1054 {
1055 PADS_ctrl1_t ctrl1;
1056
1057 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1058 {
1059 return WE_FAIL;
1060 }
1061
1062 ctrl1.blockDataUpdate = bdu;
1063
1064 return PADS_WriteReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1);
1065 }
1066
1067 /**
1068 * @brief Check if block data update is enabled
1069 * @param[in] sensorInterface Pointer to sensor interface
1070 * @param[out] bdu The returned block data update enable state
1071 * @retval Error code
1072 */
PADS_isBlockDataUpdateEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * bdu)1073 int8_t PADS_isBlockDataUpdateEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *bdu)
1074 {
1075 PADS_ctrl1_t ctrl1;
1076
1077 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_1_REG, 1, (uint8_t *) &ctrl1))
1078 {
1079 return WE_FAIL;
1080 }
1081
1082 *bdu = (PADS_state_t) ctrl1.blockDataUpdate;
1083
1084 return WE_SUCCESS;
1085 }
1086
1087 /**
1088 * @brief (Re)boot the device [enabled, disabled]
1089 * @param[in] sensorInterface Pointer to sensor interface
1090 * @param[in] reboot Reboot state
1091 * @retval Error code
1092 */
PADS_reboot(WE_sensorInterface_t * sensorInterface,PADS_state_t reboot)1093 int8_t PADS_reboot(WE_sensorInterface_t* sensorInterface, PADS_state_t reboot)
1094 {
1095 PADS_ctrl2_t ctrl2;
1096
1097 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1098 {
1099 return WE_FAIL;
1100 }
1101
1102 ctrl2.boot = reboot;
1103
1104 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1105 }
1106
1107 /**
1108 * @brief Read the reboot state
1109 * @param[in] sensorInterface Pointer to sensor interface
1110 * @param[out] rebooting The returned reboot state.
1111 * @retval Error code
1112 */
PADS_isRebooting(WE_sensorInterface_t * sensorInterface,PADS_state_t * reboot)1113 int8_t PADS_isRebooting(WE_sensorInterface_t* sensorInterface, PADS_state_t *reboot)
1114 {
1115 PADS_ctrl2_t ctrl2;
1116
1117 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1118 {
1119 return WE_FAIL;
1120 }
1121 *reboot = (PADS_state_t) ctrl2.boot;
1122
1123 return WE_SUCCESS;
1124 }
1125
1126 /**
1127 * @brief Read the boot state
1128 * @param[in] sensorInterface Pointer to sensor interface
1129 * @param[in] boot The returned Boot state
1130 * @retval Error code
1131 */
PADS_getBootStatus(WE_sensorInterface_t * sensorInterface,PADS_state_t * boot)1132 int8_t PADS_getBootStatus(WE_sensorInterface_t* sensorInterface, PADS_state_t *boot)
1133 {
1134 PADS_intSource_t int_source_reg;
1135
1136 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_INT_SOURCE_REG, 1, (uint8_t *) &int_source_reg))
1137 {
1138 return WE_FAIL;
1139 }
1140
1141 *boot = (PADS_state_t) int_source_reg.bootOn;
1142
1143 return WE_SUCCESS;
1144 }
1145
1146 /**
1147 * @brief Set the interrupt active level [active high/active low]
1148 * @param[in] sensorInterface Pointer to sensor interface
1149 * @param[in] level Interrupt active level
1150 * @retval Error code
1151 */
PADS_setInterruptActiveLevel(WE_sensorInterface_t * sensorInterface,PADS_interruptActiveLevel_t level)1152 int8_t PADS_setInterruptActiveLevel(WE_sensorInterface_t* sensorInterface, PADS_interruptActiveLevel_t level)
1153 {
1154 PADS_ctrl2_t ctrl2;
1155
1156 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1157 {
1158 return WE_FAIL;
1159 }
1160
1161 ctrl2.intActiveLevel = level;
1162
1163 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1164 }
1165
1166 /**
1167 * @brief Read the interrupt active level
1168 * @param[in] sensorInterface Pointer to sensor interface
1169 * @param[out] level The returned interrupt active level
1170 * @retval Error code
1171 */
PADS_getInterruptActiveLevel(WE_sensorInterface_t * sensorInterface,PADS_interruptActiveLevel_t * level)1172 int8_t PADS_getInterruptActiveLevel(WE_sensorInterface_t* sensorInterface, PADS_interruptActiveLevel_t *level)
1173 {
1174 PADS_ctrl2_t ctrl2;
1175
1176 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1177 {
1178 return WE_FAIL;
1179 }
1180
1181 *level = (PADS_interruptActiveLevel_t) ctrl2.intActiveLevel;
1182
1183 return WE_SUCCESS;
1184 }
1185
1186 /**
1187 * @brief Set the interrupt pin type [push-pull/open-drain]
1188 * @param[in] sensorInterface Pointer to sensor interface
1189 * @param[in] pinType Interrupt pin type
1190 * @retval Error code
1191 */
PADS_setInterruptPinType(WE_sensorInterface_t * sensorInterface,PADS_interruptPinConfig_t pinType)1192 int8_t PADS_setInterruptPinType(WE_sensorInterface_t* sensorInterface, PADS_interruptPinConfig_t pinType)
1193 {
1194 PADS_ctrl2_t ctrl2;
1195
1196 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1197 {
1198 return WE_FAIL;
1199 }
1200
1201 ctrl2.openDrainOnINTPin = pinType;
1202
1203 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1204 }
1205
1206 /**
1207 * @brief Read the interrupt pin type [push-pull/open-drain]
1208 * @param[in] sensorInterface Pointer to sensor interface
1209 * @param[out] pinType The returned interrupt pin type.
1210 * @retval Error code
1211 */
PADS_getInterruptPinType(WE_sensorInterface_t * sensorInterface,PADS_interruptPinConfig_t * pinType)1212 int8_t PADS_getInterruptPinType(WE_sensorInterface_t* sensorInterface, PADS_interruptPinConfig_t *pinType)
1213 {
1214 PADS_ctrl2_t ctrl2;
1215
1216 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1217 {
1218 return WE_FAIL;
1219 }
1220
1221 *pinType = (PADS_interruptPinConfig_t) ctrl2.openDrainOnINTPin;
1222
1223 return WE_SUCCESS;
1224 }
1225
1226 /**
1227 * @brief Enable/disable the auto address increment feature
1228 * @param[in] sensorInterface Pointer to sensor interface
1229 * @param[in] autoInc Auto address increment feature enable state
1230 * @retval Error code
1231 */
PADS_enableAutoIncrement(WE_sensorInterface_t * sensorInterface,PADS_state_t autoInc)1232 int8_t PADS_enableAutoIncrement(WE_sensorInterface_t* sensorInterface, PADS_state_t autoInc)
1233 {
1234 PADS_ctrl2_t ctrl2;
1235
1236 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1237 {
1238 return WE_FAIL;
1239 }
1240
1241 ctrl2.autoAddIncr = autoInc;
1242
1243 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1244 }
1245
1246 /**
1247 * @brief Check if the auto address increment feature is enabled
1248 * @param[in] sensorInterface Pointer to sensor interface
1249 * @param[out] inc The returned auto address increment feature enable state
1250 * @retval Error code
1251 */
PADS_isAutoIncrementEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * inc)1252 int8_t PADS_isAutoIncrementEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *inc)
1253 {
1254 PADS_ctrl2_t ctrl2;
1255
1256 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1257 {
1258 return WE_FAIL;
1259 }
1260
1261 *inc = (PADS_state_t)ctrl2.autoAddIncr;
1262
1263 return WE_SUCCESS;
1264 }
1265
1266 /**
1267 * @brief Set software reset [enabled, disabled]
1268 * @param[in] sensorInterface Pointer to sensor interface
1269 * @param[in] swReset Software reset state
1270 * @retval Error code
1271 */
PADS_softReset(WE_sensorInterface_t * sensorInterface,PADS_state_t swReset)1272 int8_t PADS_softReset(WE_sensorInterface_t* sensorInterface, PADS_state_t swReset)
1273 {
1274 PADS_ctrl2_t ctrl2;
1275
1276 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1277 {
1278 return WE_FAIL;
1279 }
1280
1281 ctrl2.softwareReset = swReset;
1282
1283 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1284 }
1285
1286 /**
1287 * @brief Read the software reset state [enabled, disabled]
1288 * @param[in] sensorInterface Pointer to sensor interface
1289 * @param[out] swReset The returned software reset state.
1290 * @retval Error code
1291 */
PADS_getSoftResetState(WE_sensorInterface_t * sensorInterface,PADS_state_t * swReset)1292 int8_t PADS_getSoftResetState(WE_sensorInterface_t* sensorInterface, PADS_state_t *swReset)
1293 {
1294 PADS_ctrl2_t ctrl2;
1295
1296 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1297 {
1298 return WE_FAIL;
1299 }
1300 *swReset = (PADS_state_t) ctrl2.softwareReset;
1301
1302 return WE_SUCCESS;
1303 }
1304
1305 /**
1306 * @brief Set the power mode of the sensor [low noise, low current]
1307 * @param[in] sensorInterface Pointer to sensor interface
1308 * @param[in] mode Power mode
1309 * @retval Error code
1310 */
PADS_setPowerMode(WE_sensorInterface_t * sensorInterface,PADS_powerMode_t mode)1311 int8_t PADS_setPowerMode(WE_sensorInterface_t* sensorInterface, PADS_powerMode_t mode)
1312 {
1313 PADS_ctrl2_t ctrl2;
1314
1315 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1316 {
1317 return WE_FAIL;
1318 }
1319
1320 ctrl2.lowNoiseMode = mode;
1321
1322 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1323 }
1324
1325 /**
1326 * @brief Read the power mode [low noise, low current]
1327 * @param[in] sensorInterface Pointer to sensor interface
1328 * @param[out] mode The returned power mode
1329 * @retval Error code
1330 */
PADS_getPowerMode(WE_sensorInterface_t * sensorInterface,PADS_powerMode_t * mode)1331 int8_t PADS_getPowerMode(WE_sensorInterface_t* sensorInterface, PADS_powerMode_t *mode)
1332 {
1333 PADS_ctrl2_t ctrl2;
1334
1335 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1336 {
1337 return WE_FAIL;
1338 }
1339 *mode = (PADS_powerMode_t) ctrl2.lowNoiseMode;
1340
1341 return WE_SUCCESS;
1342 }
1343
1344 /**
1345 * @brief Enable/disable the one shot mode
1346 * @param[in] sensorInterface Pointer to sensor interface
1347 * @param[in] oneShot One shot bit state
1348 * @retval Error code
1349 */
PADS_enableOneShot(WE_sensorInterface_t * sensorInterface,PADS_state_t oneShot)1350 int8_t PADS_enableOneShot(WE_sensorInterface_t* sensorInterface, PADS_state_t oneShot)
1351 {
1352 PADS_ctrl2_t ctrl2;
1353
1354 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1355 {
1356 return WE_FAIL;
1357 }
1358
1359 ctrl2.oneShotBit = oneShot;
1360
1361 return PADS_WriteReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2);
1362 }
1363
1364 /**
1365 * @brief Check if one shot mode is enabled
1366 * @param[in] sensorInterface Pointer to sensor interface
1367 * @param[out] oneShot The returned one shot bit state
1368 * @retval Error code
1369 */
PADS_isOneShotEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * oneShot)1370 int8_t PADS_isOneShotEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *oneShot)
1371 {
1372 PADS_ctrl2_t ctrl2;
1373
1374 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_CTRL_2_REG, 1, (uint8_t *) &ctrl2))
1375 {
1376 return WE_FAIL;
1377 }
1378
1379 *oneShot = (PADS_state_t)ctrl2.oneShotBit;
1380
1381 return WE_SUCCESS;
1382 }
1383
1384 /**
1385 * @brief Set LSB part of the pressure offset value
1386 * @param[in] sensorInterface Pointer to sensor interface
1387 * @param[in] offset LSB part of the pressure offset value
1388 * @retval Error code
1389 */
PADS_setPressureOffsetLSB(WE_sensorInterface_t * sensorInterface,uint8_t offset)1390 int8_t PADS_setPressureOffsetLSB(WE_sensorInterface_t* sensorInterface, uint8_t offset)
1391 {
1392 return PADS_WriteReg(sensorInterface, PADS_OPC_P_L_REG, 1, &offset);
1393 }
1394
1395 /**
1396 * @brief Read the LSB part of the pressure offset value
1397 * @param[in] sensorInterface Pointer to sensor interface
1398 * @param[out] offset The returned LSB part of the pressure offset value
1399 * @retval Error code
1400 */
PADS_getPressureOffsetLSB(WE_sensorInterface_t * sensorInterface,uint8_t * offset)1401 int8_t PADS_getPressureOffsetLSB(WE_sensorInterface_t* sensorInterface, uint8_t *offset)
1402 {
1403 return PADS_ReadReg(sensorInterface, PADS_OPC_P_L_REG, 1, offset);
1404 }
1405
1406 /**
1407 * @brief Set MSB part of the pressure offset value
1408 * @param[in] sensorInterface Pointer to sensor interface
1409 * @param[in] offset MSB part of the pressure offset value
1410 * @retval Error code
1411 */
PADS_setPressureOffsetMSB(WE_sensorInterface_t * sensorInterface,uint8_t offset)1412 int8_t PADS_setPressureOffsetMSB(WE_sensorInterface_t* sensorInterface, uint8_t offset)
1413 {
1414 return PADS_WriteReg(sensorInterface, PADS_OPC_P_H_REG, 1, &offset);
1415 }
1416
1417 /**
1418 * @brief Read the MSB part of the pressure offset value
1419 * @param[in] sensorInterface Pointer to sensor interface
1420 * @param[out] offset The returned MSB part of the pressure offset value
1421 * @retval Error code
1422 */
PADS_getPressureOffsetMSB(WE_sensorInterface_t * sensorInterface,uint8_t * offset)1423 int8_t PADS_getPressureOffsetMSB(WE_sensorInterface_t* sensorInterface, uint8_t *offset)
1424 {
1425 return PADS_ReadReg(sensorInterface, PADS_OPC_P_H_REG, 1, offset);
1426 }
1427
1428 /**
1429 * @brief Set the FIFO mode
1430 * @param[in] sensorInterface Pointer to sensor interface
1431 * @param[in] fifoMode FIFO mode to be set
1432 * @retval Error code
1433 */
PADS_setFifoMode(WE_sensorInterface_t * sensorInterface,PADS_fifoMode_t fifoMode)1434 int8_t PADS_setFifoMode(WE_sensorInterface_t* sensorInterface, PADS_fifoMode_t fifoMode)
1435 {
1436 PADS_fifoCtrl_t fifoCtrlReg;
1437
1438 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_CTRL_REG, 1, (uint8_t *) &fifoCtrlReg))
1439 {
1440 return WE_FAIL;
1441 }
1442
1443 fifoCtrlReg.fifoMode = fifoMode;
1444
1445 return PADS_WriteReg(sensorInterface, PADS_FIFO_CTRL_REG, 1, (uint8_t *) &fifoCtrlReg);
1446 }
1447
1448 /**
1449 * @brief Read the FIFO mode
1450 * @param[in] sensorInterface Pointer to sensor interface
1451 * @param[out] fifoMode The returned FIFO mode
1452 * @retval Error code
1453 */
PADS_getFifoMode(WE_sensorInterface_t * sensorInterface,PADS_fifoMode_t * fifoMode)1454 int8_t PADS_getFifoMode(WE_sensorInterface_t* sensorInterface, PADS_fifoMode_t *fifoMode)
1455 {
1456 PADS_fifoCtrl_t fifoCtrlReg;
1457
1458 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_CTRL_REG, 1, (uint8_t *) &fifoCtrlReg))
1459 {
1460 return WE_FAIL;
1461 }
1462
1463 *fifoMode = (PADS_fifoMode_t) fifoCtrlReg.fifoMode;
1464
1465 return WE_SUCCESS;
1466 }
1467
1468
1469 /**
1470 * @brief Set stop on user-defined FIFO threshold level
1471 * @param[in] sensorInterface Pointer to sensor interface
1472 * @param[in] state Stop on FIFO threshold state
1473 * @retval Error code
1474 */
PADS_enableStopOnThreshold(WE_sensorInterface_t * sensorInterface,PADS_state_t state)1475 int8_t PADS_enableStopOnThreshold(WE_sensorInterface_t* sensorInterface, PADS_state_t state)
1476 {
1477 PADS_fifoCtrl_t fifoCtrlReg;
1478
1479 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_CTRL_REG, 1, (uint8_t *) &fifoCtrlReg))
1480 {
1481 return WE_FAIL;
1482 }
1483
1484 fifoCtrlReg.stopOnThreshold = state;
1485
1486 return PADS_WriteReg(sensorInterface, PADS_FIFO_CTRL_REG, 1, (uint8_t *) &fifoCtrlReg);
1487 }
1488
1489 /**
1490 * @brief Check if stopping on user-defined threshold level is enabled
1491 * @param[in] sensorInterface Pointer to sensor interface
1492 * @param[out] state Stop on FIFO threshold enable state
1493 * @retval Error code
1494 */
PADS_isStopOnThresholdEnabled(WE_sensorInterface_t * sensorInterface,PADS_state_t * state)1495 int8_t PADS_isStopOnThresholdEnabled(WE_sensorInterface_t* sensorInterface, PADS_state_t *state)
1496 {
1497 PADS_fifoCtrl_t fifoCtrlReg;
1498
1499 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_CTRL_REG, 1, (uint8_t *) &fifoCtrlReg))
1500 {
1501 return WE_FAIL;
1502 }
1503
1504 *state = (PADS_state_t) fifoCtrlReg.stopOnThreshold;
1505
1506 return WE_SUCCESS;
1507 }
1508
1509 /**
1510 * @brief Set the FIFO threshold level
1511 * @param[in] sensorInterface Pointer to sensor interface
1512 * @param[in] fifoThr FIFO threshold level (value between 0 and 127)
1513 * @retval Error code
1514 */
PADS_setFifoThreshold(WE_sensorInterface_t * sensorInterface,uint8_t fifoThr)1515 int8_t PADS_setFifoThreshold(WE_sensorInterface_t* sensorInterface, uint8_t fifoThr)
1516 {
1517 PADS_fifoThreshold_t fifoThresholdReg;
1518
1519 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_WTM_REG, 1, (uint8_t *) &fifoThresholdReg))
1520 {
1521 return WE_FAIL;
1522 }
1523
1524 fifoThresholdReg.fifoThreshold = fifoThr;
1525
1526 return PADS_WriteReg(sensorInterface, PADS_FIFO_WTM_REG, 1, (uint8_t *) &fifoThresholdReg);
1527 }
1528
1529 /**
1530 * @brief Read the FIFO threshold level
1531 * @param[in] sensorInterface Pointer to sensor interface
1532 * @param[out] fifoThr The returned FIFO threshold level
1533 * @retval Error code
1534 */
PADS_getFifoThreshold(WE_sensorInterface_t * sensorInterface,uint8_t * fifoThr)1535 int8_t PADS_getFifoThreshold(WE_sensorInterface_t* sensorInterface, uint8_t *fifoThr)
1536 {
1537 PADS_fifoThreshold_t fifoThresholdReg;
1538
1539 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_WTM_REG, 1, (uint8_t *) &fifoThresholdReg))
1540 {
1541 return WE_FAIL;
1542 }
1543
1544 *fifoThr = (uint8_t) fifoThresholdReg.fifoThreshold;
1545
1546 return WE_SUCCESS;
1547 }
1548
1549 /**
1550 * @brief Read the current FIFO fill level
1551 * @param[in] sensorInterface Pointer to sensor interface
1552 * @param[out] fifoLevel The returned FIFO fill level
1553 * @retval Error code
1554 */
PADS_getFifoFillLevel(WE_sensorInterface_t * sensorInterface,uint8_t * fifoLevel)1555 int8_t PADS_getFifoFillLevel(WE_sensorInterface_t* sensorInterface, uint8_t *fifoLevel)
1556 {
1557 return PADS_ReadReg(sensorInterface, PADS_FIFO_STATUS1_REG, 1, fifoLevel);
1558 }
1559
1560 /**
1561 * @brief Read the reference pressure
1562 *
1563 * Note: The reference pressure is set automatically when enabling AUTOZERO or AUTOREFP.
1564 *
1565 * @param[in] sensorInterface Pointer to sensor interface
1566 * @param[out] referencePressurePa The returned reference pressure in Pa
1567 * @retval Error code
1568 */
PADS_getReferencePressure(WE_sensorInterface_t * sensorInterface,uint32_t * referencePressurePa)1569 int8_t PADS_getReferencePressure(WE_sensorInterface_t* sensorInterface, uint32_t *referencePressurePa)
1570 {
1571 if (WE_FAIL == PADS_getRawReferencePressure(sensorInterface, referencePressurePa))
1572 {
1573 return WE_FAIL;
1574 }
1575 *referencePressurePa = PADS_convertPressure_int(*referencePressurePa);
1576 return WE_SUCCESS;
1577 }
1578
1579 /**
1580 * @brief Read the raw reference pressure
1581 *
1582 * Note: The reference pressure is set automatically when enabling AUTOZERO or AUTOREFP.
1583 *
1584 * @param[in] sensorInterface Pointer to sensor interface
1585 * @param[out] referencePressure The returned raw reference pressure.
1586 * @retval Error code
1587 */
PADS_getRawReferencePressure(WE_sensorInterface_t * sensorInterface,uint32_t * referencePressure)1588 int8_t PADS_getRawReferencePressure(WE_sensorInterface_t* sensorInterface, uint32_t *referencePressure)
1589 {
1590 uint8_t low, high;
1591 if (WE_FAIL == PADS_getReferencePressureLSB(sensorInterface, &low))
1592 {
1593 return WE_FAIL;
1594 }
1595 if (WE_FAIL == PADS_getReferencePressureMSB(sensorInterface, &high))
1596 {
1597 return WE_FAIL;
1598 }
1599 *referencePressure = (((uint32_t) high) << 16) | (((uint32_t) low) << 8);
1600 return WE_SUCCESS;
1601 }
1602
1603 /**
1604 * @brief Read the LSB of the reference pressure
1605 * @param[in] sensorInterface Pointer to sensor interface
1606 * @param[out] lowReferenceValue The returned reference pressure LSB
1607 * @retval Error code
1608 */
PADS_getReferencePressureLSB(WE_sensorInterface_t * sensorInterface,uint8_t * lowReferenceValue)1609 int8_t PADS_getReferencePressureLSB(WE_sensorInterface_t* sensorInterface, uint8_t *lowReferenceValue)
1610 {
1611 return PADS_ReadReg(sensorInterface, PADS_REF_P_L_REG, 1, lowReferenceValue);
1612 }
1613
1614 /**
1615 * @brief Read the MSB of the reference pressure
1616 * @param[in] sensorInterface Pointer to sensor interface
1617 * @param[out] highReferenceValue The returned reference pressure MSB
1618 * @retval Error code
1619 */
PADS_getReferencePressureMSB(WE_sensorInterface_t * sensorInterface,uint8_t * highReferenceValue)1620 int8_t PADS_getReferencePressureMSB(WE_sensorInterface_t* sensorInterface, uint8_t *highReferenceValue)
1621 {
1622 return PADS_ReadReg(sensorInterface, PADS_REF_P_H_REG, 1, highReferenceValue);
1623 }
1624
1625 /**
1626 * @brief Check if the temperature data register has been overwritten
1627 * @param[in] sensorInterface Pointer to sensor interface
1628 * @param[out] state The returned temperature data overwritten state
1629 * @retval Error code
1630 */
PADS_getTemperatureOverrunStatus(WE_sensorInterface_t * sensorInterface,PADS_state_t * state)1631 int8_t PADS_getTemperatureOverrunStatus(WE_sensorInterface_t* sensorInterface, PADS_state_t *state)
1632 {
1633 PADS_status_t statusReg;
1634
1635 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_STATUS_REG, 1, (uint8_t *) &statusReg))
1636 {
1637 return WE_FAIL;
1638 }
1639
1640 *state = (PADS_state_t) statusReg.tempDataOverrun;
1641
1642 return WE_SUCCESS;
1643 }
1644
1645 /**
1646 * @brief Check if the pressure data register has been overwritten
1647 * @param[in] sensorInterface Pointer to sensor interface
1648 * @param[out] state The returned pressure data overwritten state
1649 * @retval Error code
1650 */
PADS_getPressureOverrunStatus(WE_sensorInterface_t * sensorInterface,PADS_state_t * state)1651 int8_t PADS_getPressureOverrunStatus(WE_sensorInterface_t* sensorInterface, PADS_state_t *state)
1652 {
1653 PADS_status_t statusReg;
1654
1655 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_STATUS_REG, 1, (uint8_t *) &statusReg))
1656 {
1657 return WE_FAIL;
1658 }
1659
1660 *state = (PADS_state_t) statusReg.presDataOverrun;
1661
1662 return WE_SUCCESS;
1663 }
1664
1665 /**
1666 * @brief Check if new pressure data is available
1667 * @param[in] sensorInterface Pointer to sensor interface
1668 * @param[out] state The returned pressure data availability state
1669 * @retval Error code
1670 */
PADS_isPressureDataAvailable(WE_sensorInterface_t * sensorInterface,PADS_state_t * state)1671 int8_t PADS_isPressureDataAvailable(WE_sensorInterface_t* sensorInterface, PADS_state_t *state)
1672 {
1673 PADS_status_t statusReg;
1674
1675 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_STATUS_REG, 1, (uint8_t *) &statusReg))
1676 {
1677 return WE_FAIL;
1678 }
1679 *state = (PADS_state_t) statusReg.presDataAvailable;
1680
1681 return WE_SUCCESS;
1682 }
1683
1684 /**
1685 * @brief Check if new temperature data is available
1686 * @param[in] sensorInterface Pointer to sensor interface
1687 * @param[out] state The returned temperature data availability state
1688 * @retval Error code
1689 */
PADS_isTemperatureDataAvailable(WE_sensorInterface_t * sensorInterface,PADS_state_t * state)1690 int8_t PADS_isTemperatureDataAvailable(WE_sensorInterface_t* sensorInterface, PADS_state_t *state)
1691 {
1692 PADS_status_t statusReg;
1693
1694 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_STATUS_REG, 1, (uint8_t *) &statusReg))
1695 {
1696 return WE_FAIL;
1697 }
1698
1699 *state = (PADS_state_t) statusReg.tempDataAvailable;
1700
1701 return WE_SUCCESS;
1702 }
1703
1704 /**
1705 * @brief Check if new temperature and pressure data is available
1706 * @param[in] sensorInterface Pointer to sensor interface
1707 * @param[out] temp_state The returned temperature data availability state
1708 * @param[out] press_state The returned pressure data availability state
1709 * @retval Error code
1710 */
PADS_isDataAvailable(WE_sensorInterface_t * sensorInterface,PADS_state_t * temp_state,PADS_state_t * press_state)1711 int8_t PADS_isDataAvailable(WE_sensorInterface_t* sensorInterface, PADS_state_t *temp_state, PADS_state_t *press_state)
1712 {
1713 PADS_status_t statusReg;
1714
1715 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_STATUS_REG, 1, (uint8_t *) &statusReg))
1716 {
1717 return WE_FAIL;
1718 }
1719
1720 if(temp_state != NULL)
1721 {
1722 *temp_state = (PADS_state_t) statusReg.tempDataAvailable;
1723 }
1724 if(press_state != NULL)
1725 {
1726 *press_state = (PADS_state_t) statusReg.presDataAvailable;
1727 }
1728
1729 return WE_SUCCESS;
1730 }
1731
1732 /**
1733 * @brief Read the raw measured pressure value
1734 * @param[in] sensorInterface Pointer to sensor interface
1735 * @param[out] rawPres The returned raw pressure
1736 * @retval Error code
1737 */
PADS_getRawPressure(WE_sensorInterface_t * sensorInterface,int32_t * rawPres)1738 int8_t PADS_getRawPressure(WE_sensorInterface_t* sensorInterface, int32_t *rawPres)
1739 {
1740 uint8_t tmp[3] = {0};
1741
1742 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_DATA_P_XL_REG, 3, tmp))
1743 {
1744 return WE_FAIL;
1745 }
1746
1747 *rawPres = (int32_t) (tmp[2] << 24);
1748 *rawPres |= (int32_t) (tmp[1] << 16);
1749 *rawPres |= (int32_t) (tmp[0] << 8);
1750 *rawPres /= 256;
1751
1752 return WE_SUCCESS;
1753 }
1754
1755 /**
1756 * @brief Read the raw measured temperature value
1757 * @param[in] sensorInterface Pointer to sensor interface
1758 * @param[out] rawTemp The returned raw temperature
1759 * @retval Error code
1760 */
PADS_getRawTemperature(WE_sensorInterface_t * sensorInterface,int16_t * rawTemp)1761 int8_t PADS_getRawTemperature(WE_sensorInterface_t* sensorInterface, int16_t *rawTemp)
1762 {
1763 uint8_t tmp[2] = {0};
1764
1765 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_DATA_T_L_REG, 2, tmp))
1766 {
1767 return WE_FAIL;
1768 }
1769
1770 *rawTemp = (int16_t) (tmp[1] << 8);
1771 *rawTemp |= (int16_t) tmp[0];
1772
1773 return WE_SUCCESS;
1774 }
1775
1776 /**
1777 * @brief Read one or more raw pressure values from FIFO
1778 * @param[in] sensorInterface Pointer to sensor interface
1779 * @param[in] numSamples Number of samples to read
1780 * @param[out] rawPres The returned FIFO pressure measurement(s)
1781 * @retval Error code
1782 */
PADS_getFifoRawPressure(WE_sensorInterface_t * sensorInterface,uint8_t numSamples,int32_t * rawPres)1783 int8_t PADS_getFifoRawPressure(WE_sensorInterface_t* sensorInterface, uint8_t numSamples, int32_t *rawPres)
1784 {
1785 if (numSamples > PADS_FIFO_BUFFER_SIZE)
1786 {
1787 return WE_FAIL;
1788 }
1789
1790 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_DATA_P_XL_REG, 5 * numSamples, fifoBuffer))
1791 {
1792 return WE_FAIL;
1793 }
1794
1795 uint8_t *bufferPtr = fifoBuffer;
1796 for (uint8_t i = 0; i < numSamples; i++, bufferPtr += 5, rawPres++)
1797 {
1798 *rawPres = (int32_t) (bufferPtr[2] << 24);
1799 *rawPres |= (int32_t) (bufferPtr[1] << 16);
1800 *rawPres |= (int32_t) (bufferPtr[0] << 8);
1801 *rawPres /= 256;
1802 }
1803
1804 return WE_SUCCESS;
1805 }
1806
1807 /**
1808 * @brief Reads one or more raw temperature values from FIFO
1809 * @param[in] sensorInterface Pointer to sensor interface
1810 * @param[in] numSamples Number of samples to read
1811 * @param[out] rawTemp The returned FIFO temperature measurement(s)
1812 * @retval Error code
1813 */
PADS_getFifoRawTemperature(WE_sensorInterface_t * sensorInterface,uint8_t numSamples,int16_t * rawTemp)1814 int8_t PADS_getFifoRawTemperature(WE_sensorInterface_t* sensorInterface, uint8_t numSamples, int16_t *rawTemp)
1815 {
1816 if (numSamples > PADS_FIFO_BUFFER_SIZE)
1817 {
1818 return WE_FAIL;
1819 }
1820
1821 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_DATA_P_XL_REG, 5 * numSamples, fifoBuffer))
1822 {
1823 return WE_FAIL;
1824 }
1825
1826 uint8_t *bufferPtr = fifoBuffer;
1827 for (uint8_t i = 0; i < numSamples; i++, bufferPtr += 5, rawTemp++)
1828 {
1829 *rawTemp = (int16_t) (bufferPtr[4] << 8);
1830 *rawTemp |= (int16_t) bufferPtr[3];
1831 }
1832
1833 return WE_SUCCESS;
1834 }
1835
1836 /**
1837 * @brief Reads one or more raw pressure and temperature values from FIFO
1838 * @param[in] sensorInterface Pointer to sensor interface
1839 * @param[in] numSamples Number of samples to read
1840 * @param[out] rawPres The returned FIFO pressure measurement(s)
1841 * @param[out] rawTemp The returned FIFO temperature measurement(s)
1842 * @retval Error code
1843 */
PADS_getFifoRawValues(WE_sensorInterface_t * sensorInterface,uint8_t numSamples,int32_t * rawPres,int16_t * rawTemp)1844 int8_t PADS_getFifoRawValues(WE_sensorInterface_t* sensorInterface, uint8_t numSamples, int32_t *rawPres, int16_t *rawTemp)
1845 {
1846 if (numSamples > PADS_FIFO_BUFFER_SIZE)
1847 {
1848 return WE_FAIL;
1849 }
1850
1851 if (WE_FAIL == PADS_ReadReg(sensorInterface, PADS_FIFO_DATA_P_XL_REG, 5 * numSamples, fifoBuffer))
1852 {
1853 return WE_FAIL;
1854 }
1855
1856 uint8_t *bufferPtr = fifoBuffer;
1857 for (uint8_t i = 0; i < numSamples; i++, bufferPtr += 5, rawPres++, rawTemp++)
1858 {
1859 *rawPres = (int32_t) (bufferPtr[2] << 24);
1860 *rawPres |= (int32_t) (bufferPtr[1] << 16);
1861 *rawPres |= (int32_t) (bufferPtr[0] << 8);
1862 *rawPres /= 256;
1863
1864 *rawTemp = (int16_t) (bufferPtr[4] << 8);
1865 *rawTemp |= (int16_t) bufferPtr[3];
1866 }
1867
1868 return WE_SUCCESS;
1869 }
1870
1871 /**
1872 * @brief Read the measured pressure value in Pa
1873 *
1874 * Note that, depending on the mode of operation, the sensor's output register
1875 * might contain differential pressure values (e.g. if AUTOZERO is enabled).
1876 * In that case, the function PADS_getDifferentialPressure_int() should be used.
1877 *
1878 * @param[in] sensorInterface Pointer to sensor interface
1879 * @param[out] pressPa The returned pressure measurement
1880 * @retval Error code
1881 */
PADS_getPressure_int(WE_sensorInterface_t * sensorInterface,int32_t * pressPa)1882 int8_t PADS_getPressure_int(WE_sensorInterface_t* sensorInterface, int32_t *pressPa)
1883 {
1884 int32_t rawPressure = 0;
1885 if (PADS_getRawPressure(sensorInterface, &rawPressure) == WE_SUCCESS)
1886 {
1887 *pressPa = PADS_convertPressure_int(rawPressure);
1888 }
1889 else
1890 {
1891 return WE_FAIL;
1892 }
1893 return WE_SUCCESS;
1894 }
1895
1896 /**
1897 * @brief Read the measured differential pressure value in Pa
1898 *
1899 * Use this function if the sensor is configured to write differential pressure
1900 * values to the output register (e.g. if AUTOZERO is enabled).
1901 *
1902 * @param[in] sensorInterface Pointer to sensor interface
1903 * @param[out] pressPa The returned differential pressure measurement
1904 * @retval Error code
1905 */
PADS_getDifferentialPressure_int(WE_sensorInterface_t * sensorInterface,int32_t * pressPa)1906 int8_t PADS_getDifferentialPressure_int(WE_sensorInterface_t* sensorInterface, int32_t *pressPa)
1907 {
1908 int32_t rawPressure = 0;
1909 if (PADS_getRawPressure(sensorInterface, &rawPressure) == WE_SUCCESS)
1910 {
1911 *pressPa = PADS_convertDifferentialPressure_int(rawPressure);
1912 }
1913 else
1914 {
1915 return WE_FAIL;
1916 }
1917 return WE_SUCCESS;
1918 }
1919
1920 /**
1921 * @brief Read the measured temperature value in 0.01 °C
1922 * @param[in] sensorInterface Pointer to sensor interface
1923 * @param[out] temperature The returned temperature measurement
1924 * @retval Error code
1925 */
PADS_getTemperature_int(WE_sensorInterface_t * sensorInterface,int16_t * temperature)1926 int8_t PADS_getTemperature_int(WE_sensorInterface_t* sensorInterface, int16_t *temperature)
1927 {
1928 return PADS_getRawTemperature(sensorInterface, temperature);
1929 }
1930
1931 /**
1932 * @brief Read one or more pressure values from FIFO.
1933 * @param[in] sensorInterface Pointer to sensor interface
1934 * @param[in] numSamples Number of samples to read
1935 * @param[out] pressPa The returned FIFO pressure measurement(s) in Pa
1936 * @retval Error code
1937 */
PADS_getFifoPressure_int(WE_sensorInterface_t * sensorInterface,uint8_t numSamples,int32_t * pressPa)1938 int8_t PADS_getFifoPressure_int(WE_sensorInterface_t* sensorInterface, uint8_t numSamples, int32_t *pressPa)
1939 {
1940 if (WE_FAIL == PADS_getFifoRawPressure(sensorInterface, numSamples, pressPa))
1941 {
1942 return WE_FAIL;
1943 }
1944
1945 for (uint8_t i = 0; i < numSamples; i++)
1946 {
1947 pressPa[i] = PADS_convertPressure_int(pressPa[i]);
1948 }
1949
1950 return WE_SUCCESS;
1951 }
1952
1953 /**
1954 * @brief Read one or more temperature values from FIFO.
1955 * @param[in] sensorInterface Pointer to sensor interface
1956 * @param[in] numSamples Number of samples to read
1957 * @param[out] temperature The returned FIFO temperature measurement(s) in 0.01 °C
1958 * @retval Error code
1959 */
PADS_getFifoTemperature_int(WE_sensorInterface_t * sensorInterface,uint8_t numSamples,int16_t * temperature)1960 int8_t PADS_getFifoTemperature_int(WE_sensorInterface_t* sensorInterface, uint8_t numSamples, int16_t *temperature)
1961 {
1962 return PADS_getFifoRawTemperature(sensorInterface, numSamples, temperature);
1963 }
1964
1965 /**
1966 * @brief Reads one or more pressure and temperature values from FIFO
1967 * @param[in] sensorInterface Pointer to sensor interface
1968 * @param[in] numSamples Number of samples to read
1969 * @param[out] pressPa The returned FIFO pressure measurement(s) in Pa
1970 * @param[out] temperature The returned FIFO temperature measurement(s) in 0.01 °C
1971 * @retval Error code
1972 */
PADS_getFifoValues_int(WE_sensorInterface_t * sensorInterface,uint8_t numSamples,int32_t * pressPa,int16_t * temperature)1973 int8_t PADS_getFifoValues_int(WE_sensorInterface_t* sensorInterface, uint8_t numSamples, int32_t *pressPa, int16_t *temperature)
1974 {
1975 if (WE_FAIL == PADS_getFifoRawValues(sensorInterface, numSamples, pressPa, temperature))
1976 {
1977 return WE_FAIL;
1978 }
1979
1980 for (uint8_t i = 0; i < numSamples; i++)
1981 {
1982 pressPa[i] = PADS_convertPressure_int(pressPa[i]);
1983 }
1984
1985 return WE_SUCCESS;
1986 }
1987
1988 /**
1989 * @brief Converts the supplied raw pressure to [Pa]
1990 *
1991 * Note that, depending on the mode of operation, the sensor's output register
1992 * might contain differential pressure values (e.g. if AUTOZERO is enabled).
1993 * In that case, the function PADS_convertDifferentialPressure_int() should be used.
1994 *
1995 * @retval Pressure in [Pa]
1996 */
PADS_convertPressure_int(int32_t rawPres)1997 int32_t PADS_convertPressure_int(int32_t rawPres)
1998 {
1999 return (rawPres * 100) / 4096;
2000 }
2001
2002 /**
2003 * @brief Converts the supplied raw differential pressure to [Pa]
2004 *
2005 * Use this function if the sensor is configured to write differential pressure
2006 * values to the output register (e.g. if AUTOZERO is enabled).
2007 *
2008 * @retval Differential pressure in [Pa]
2009 */
PADS_convertDifferentialPressure_int(int32_t rawPres)2010 int32_t PADS_convertDifferentialPressure_int(int32_t rawPres)
2011 {
2012 return (rawPres * 25600) / 4096;
2013 }
2014
2015 #ifdef WE_USE_FLOAT
2016
2017 /**
2018 * @brief Read the measured pressure value in kPa
2019 *
2020 * Note that, depending on the mode of operation, the sensor's output register
2021 * might contain differential pressure values (e.g. if AUTOZERO is enabled).
2022 * In that case, the function PADS_getDifferentialPressure_float() should be used.
2023 *
2024 * @param[in] sensorInterface Pointer to sensor interface
2025 * @param[out] presskPa The returned pressure measurement
2026 * @retval Error code
2027 */
PADS_getPressure_float(WE_sensorInterface_t * sensorInterface,float * presskPa)2028 int8_t PADS_getPressure_float(WE_sensorInterface_t* sensorInterface, float *presskPa)
2029 {
2030 int32_t rawPressure = 0;
2031 if (PADS_getRawPressure(sensorInterface, &rawPressure) == WE_SUCCESS)
2032 {
2033 *presskPa = PADS_convertPressure_float(rawPressure);
2034 }
2035 else
2036 {
2037 return WE_FAIL;
2038 }
2039 return WE_SUCCESS;
2040 }
2041
2042 /**
2043 * @brief Read the measured differential pressure value in kPa
2044 *
2045 * Use this function if the sensor is configured to write differential pressure
2046 * values to the output register (e.g. if AUTOZERO is enabled).
2047 *
2048 * @param[in] sensorInterface Pointer to sensor interface
2049 * @param[out] presskPa The returned pressure measurement
2050 * @retval Error code
2051 */
PADS_getDifferentialPressure_float(WE_sensorInterface_t * sensorInterface,float * presskPa)2052 int8_t PADS_getDifferentialPressure_float(WE_sensorInterface_t* sensorInterface, float *presskPa)
2053 {
2054 int32_t rawPressure = 0;
2055 if (PADS_getRawPressure(sensorInterface, &rawPressure) == WE_SUCCESS)
2056 {
2057 *presskPa = PADS_convertDifferentialPressure_float(rawPressure);
2058 }
2059 else
2060 {
2061 return WE_FAIL;
2062 }
2063 return WE_SUCCESS;
2064 }
2065
2066 /**
2067 * @brief Read the measured temperature value in °C
2068 * @param[in] sensorInterface Pointer to sensor interface
2069 * @param[out] tempDegC The returned temperature measurement
2070 * @retval Error code
2071 */
PADS_getTemperature_float(WE_sensorInterface_t * sensorInterface,float * tempDegC)2072 int8_t PADS_getTemperature_float(WE_sensorInterface_t* sensorInterface, float *tempDegC)
2073 {
2074 int16_t rawTemp = 0;
2075 if (PADS_getRawTemperature(sensorInterface, &rawTemp) == WE_SUCCESS)
2076 {
2077 *tempDegC = (float) rawTemp;
2078 *tempDegC = *tempDegC / 100;
2079 }
2080 else
2081 {
2082 return WE_FAIL;
2083 }
2084
2085 return WE_SUCCESS;
2086 }
2087
2088 /**
2089 * @brief Read the pressure value from FIFO in kPa
2090 * @param[in] sensorInterface Pointer to sensor interface
2091 * @param[out] presskPa The returned FIFO pressure measurement
2092 * @retval Error code
2093 */
PADS_getFifoPressure_float(WE_sensorInterface_t * sensorInterface,float * presskPa)2094 int8_t PADS_getFifoPressure_float(WE_sensorInterface_t* sensorInterface, float *presskPa)
2095 {
2096 int32_t rawPressure = 0;
2097 if (PADS_getFifoRawPressure(sensorInterface, 1, &rawPressure) == WE_SUCCESS)
2098 {
2099 *presskPa = PADS_convertPressure_float(rawPressure);
2100 }
2101 else
2102 {
2103 return WE_FAIL;
2104 }
2105 return WE_SUCCESS;
2106 }
2107
2108 /**
2109 * @brief Read the temperature value from FIFO in °C
2110 * @param[in] sensorInterface Pointer to sensor interface
2111 * @param[out] tempDegC The returned FIFO temperature measurement
2112 * @retval Error code
2113 */
PADS_getFifoTemperature_float(WE_sensorInterface_t * sensorInterface,float * tempDegC)2114 int8_t PADS_getFifoTemperature_float(WE_sensorInterface_t* sensorInterface, float *tempDegC)
2115 {
2116 int16_t rawTemp = 0;
2117 if (PADS_getFifoRawTemperature(sensorInterface, 1, &rawTemp) == WE_SUCCESS)
2118 {
2119 *tempDegC = (float) rawTemp;
2120 *tempDegC = *tempDegC / 100;
2121 }
2122 else
2123 {
2124 return WE_FAIL;
2125 }
2126
2127 return WE_SUCCESS;
2128 }
2129
2130 /**
2131 * @brief Converts the supplied raw pressure to [kPa]
2132 *
2133 * Note that, depending on the mode of operation, the sensor's output register
2134 * might contain differential pressure values (e.g. if AUTOZERO is enabled).
2135 * In that case, the function PADS_convertDifferentialPressure_float() should be used.
2136 *
2137 * @retval Pressure in [kPa]
2138 */
PADS_convertPressure_float(int32_t rawPres)2139 float PADS_convertPressure_float(int32_t rawPres)
2140 {
2141 return ((float) rawPres) / 40960;
2142 }
2143
2144 /**
2145 * @brief Converts the supplied raw differential pressure to [kPa]
2146 *
2147 * Use this function if the sensor is configured to write differential pressure
2148 * values to the output register (e.g. if AUTOZERO is enabled).
2149 *
2150 * @retval Differential pressure in [kPa]
2151 */
PADS_convertDifferentialPressure_float(int32_t rawPres)2152 float PADS_convertDifferentialPressure_float(int32_t rawPres)
2153 {
2154 return ((float) rawPres) * 0.00625f;
2155 }
2156
2157 #endif /* WE_USE_FLOAT */
2158