ChibiOS  21.6.0
lps25h.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2016..2019 Rocco Marco Guglielmi
3 
4  This file is part of ChibiOS.
5 
6  ChibiOS is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  ChibiOS is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 */
20 
21 /**
22  * @file lps25h.h
23  * @brief LPS25H MEMS interface module header.
24  *
25  * @addtogroup LPS25H
26  * @ingroup EX_ST
27  * @{
28  */
29 #ifndef _LPS25H_H_
30 #define _LPS25H_H_
31 
32 #include "ex_barometer.h"
33 #include "ex_thermometer.h"
34 
35 /*===========================================================================*/
36 /* Driver constants. */
37 /*===========================================================================*/
38 
39 /**
40  * @name Version identification
41  * @{
42  */
43 /**
44  * @brief LPS25H driver version string.
45  */
46 #define EX_LPS25H_VERSION "1.1.2"
47 
48 /**
49  * @brief LPS25H driver version major number.
50  */
51 #define EX_LPS25H_MAJOR 1
52 
53 /**
54  * @brief LPS25H driver version minor number.
55  */
56 #define EX_LPS25H_MINOR 1
57 
58 /**
59  * @brief LPS25H driver version patch number.
60  */
61 #define EX_LPS25H_PATCH 2
62 /** @} */
63 
64 /**
65  * @brief LPS25H barometer subsystem characteristics.
66  * @note Sensitivity is expressed as hPa/LSB whereas hPa stand for
67  * hectopascal.
68  * @note Bias is expressed as hPa.
69  *
70  * @{
71  */
72 #define LPS25H_BARO_NUMBER_OF_AXES 1U
73 
74 #define LPS25H_BARO_SENS 0.00024414f
75 #define LPS25H_BARO_BIAS 0.0f
76 /** @} */
77 
78 /**
79  * @brief LPS25H thermometer subsystem characteristics.
80  * @note Sensitivity is expressed as �C/LSB.
81  * @note Bias is expressed as �C.
82  *
83  * @{
84  */
85 #define LPS25H_THERMO_NUMBER_OF_AXES 1U
86 
87 #define LPS25H_THERMO_SENS 0.00208333f
88 #define LPS25H_THERMO_BIAS -42.5f
89 /** @} */
90 
91 /**
92  * @name LPS25H communication interfaces related bit masks
93  * @{
94  */
95 #define LPS25H_DI_MASK 0xFF
96 #define LPS25H_DI(n) (1 << n)
97 #define LPS25H_AD_MASK 0x3F
98 #define LPS25H_AD(n) (1 << n)
99 #define LPS25H_MS (1 << 6)
100 #define LPS25H_RW (1 << 7)
101 
102 #define LPS25H_SUB_MS (1 << 7)
103 /** @} */
104 
105 /**
106  * @name LPS25H register addresses
107  * @{
108  */
109 #define LPS25H_AD_REF_P_XL 0x08
110 #define LPS25H_AD_REF_P_L 0x09
111 #define LPS25H_AD_REF_P_H 0x0A
112 #define LPS25H_AD_WHO_AM_I 0x0F
113 #define LPS25H_AD_RES_CONF 0x10
114 #define LPS25H_AD_CTRL_REG1 0x20
115 #define LPS25H_AD_CTRL_REG2 0x21
116 #define LPS25H_AD_CTRL_REG3 0x22
117 #define LPS25H_AD_CTRL_REG4 0x23
118 #define LPS25H_AD_INT_CFG 0x24
119 #define LPS25H_AD_INT_SRC 0x25
120 #define LPS25H_AD_STATUS_REG 0x27
121 #define LPS25H_AD_PRESS_OUT_XL 0x28
122 #define LPS25H_AD_PRESS_OUT_L 0x29
123 #define LPS25H_AD_PRESS_OUT_H 0x2A
124 #define LPS25H_AD_TEMP_OUT_L 0x2B
125 #define LPS25H_AD_TEMP_OUT_H 0x2C
126 #define LPS25H_AD_FIFO_CTRL 0x2E
127 #define LPS25H_AD_FIFO_SRC 0x2F
128 #define LPS25H_AD_THS_P_L 0x30
129 #define LPS25H_AD_THS_P_H 0x31
130 #define LPS25H_AD_RPDS_L 0x39
131 #define LPS25H_AD_RPDS_H 0x3A
132 /** @} */
133 
134 /**
135  * @name LPS25H_CTRL_REG1 register bits definitions
136  * @{
137  */
138 #define LPS25H_CTRL_REG1_MASK 0xFF
139 #define LPS25H_CTRL_REG1_SIM (1 << 0)
140 #define LPS25H_CTRL_REG1_RESET_AZ (1 << 1)
141 #define LPS25H_CTRL_REG1_BDU (1 << 2)
142 #define LPS25H_CTRL_REG1_DIFF_EN (1 << 3)
143 #define LPS25H_CTRL_REG1_ODR0 (1 << 4)
144 #define LPS25H_CTRL_REG1_ODR1 (1 << 5)
145 #define LPS25H_CTRL_REG1_ODR2 (1 << 6)
146 #define LPS25H_CTRL_REG1_PD (1 << 7)
147 /** @} */
148 
149 /**
150  * @name LPS25H_CTRL_REG2 register bits definitions
151  * @{
152  */
153 #define LPS25H_CTRL_REG2_MASK 0xF3
154 #define LPS25H_CTRL_REG2_ONE_SHOT (1 << 0)
155 #define LPS25H_CTRL_REG2_AUTO_ZERO (1 << 1)
156 #define LPS25H_CTRL_REG2_SWRESET (1 << 2)
157 #define LPS25H_CTRL_REG2_FIFO_MEAN_DEC (1 << 4)
158 #define LPS25H_CTRL_REG2_WTM_EN (1 << 5)
159 #define LPS25H_CTRL_REG2_FIFO_EN (1 << 6)
160 #define LPS25H_CTRL_REG2_BOOT (1 << 7)
161 /** @} */
162 
163 /**
164  * @name LPS25H_CTRL_REG3 register bits definitions
165  * @{
166  */
167 #define LPS25H_CTRL_REG3_MASK 0xC3
168 #define LPS25H_CTRL_REG3_INT_S1 (1 << 0)
169 #define LPS25H_CTRL_REG3_INT_S2 (1 << 1)
170 #define LPS25H_CTRL_REG3_PP_OD (1 << 6)
171 #define LPS25H_CTRL_REG3_INT_H_L (1 << 7)
172 /** @} */
173 
174 /**
175  * @name LPS25H_CTRL_REG4 register bits definitions
176  * @{
177  */
178 #define LPS25H_CTRL_REG4_MASK 0x0F
179 #define LPS25H_CTRL_REG4_P1_DRDY (1 << 0)
180 #define LPS25H_CTRL_REG4_P1_OVERRUN (1 << 1)
181 #define LPS25H_CTRL_REG4_P1_WTM (1 << 2)
182 #define LPS25H_CTRL_REG4_P1_EMPTY (1 << 3)
183 /** @} */
184 
185 /**
186  * @name LPS25H_INT1_CFG register bits definitions
187  * @{
188  */
189 #define LPS25H_INT1_CFG_MASK 0x07
190 #define LPS25H_INT1_CFG_PH_E (1 << 0)
191 #define LPS25H_INT1_CFG_PL_E (1 << 1)
192 #define LPS25H_INT1_CFG_LIR (1 << 2)
193 /** @} */
194 
195 /**
196  * @name LPS25H_INT1_SRC register bits definitions
197  * @{
198  */
199 #define LPS25H_INT1_SRC_MASK 0x07
200 #define LPS25H_INT1_SRC_PH (1 << 0)
201 #define LPS25H_INT1_SRC_PL (1 << 1)
202 #define LPS25H_INT1_SRC_IA (1 << 2)
203 /** @} */
204 
205 /*===========================================================================*/
206 /* Driver pre-compile time settings. */
207 /*===========================================================================*/
208 
209 /**
210  * @name Configuration options
211  * @{
212  */
213 /**
214  * @brief LPS25H SPI interface switch.
215  * @details If set to @p TRUE the support for SPI is included.
216  * @note The default is @p FALSE.
217  */
218 #if !defined(LPS25H_USE_SPI) || defined(__DOXYGEN__)
219 #define LPS25H_USE_SPI FALSE
220 #endif
221 
222 /**
223  * @brief LPS25H shared SPI switch.
224  * @details If set to @p TRUE the device acquires SPI bus ownership
225  * on each transaction.
226  * @note The default is @p FALSE. Requires SPI_USE_MUTUAL_EXCLUSION.
227  */
228 #if !defined(LPS25H_SHARED_SPI) || defined(__DOXYGEN__)
229 #define LPS25H_SHARED_SPI FALSE
230 #endif
231 
232 /**
233  * @brief LPS25H I2C interface switch.
234  * @details If set to @p TRUE the support for I2C is included.
235  * @note The default is @p TRUE.
236  */
237 #if !defined(LPS25H_USE_I2C) || defined(__DOXYGEN__)
238 #define LPS25H_USE_I2C TRUE
239 #endif
240 
241 /**
242  * @brief LPS25H shared I2C switch.
243  * @details If set to @p TRUE the device acquires I2C bus ownership
244  * on each transaction.
245  * @note The default is @p FALSE. Requires I2C_USE_MUTUAL_EXCLUSION.
246  */
247 #if !defined(LPS25H_SHARED_I2C) || defined(__DOXYGEN__)
248 #define LPS25H_SHARED_I2C FALSE
249 #endif
250 
251 /**
252  * @brief LPS25H advanced configurations switch.
253  * @details If set to @p TRUE more configurations are available.
254  * @note The default is @p FALSE.
255  */
256 #if !defined(LPS25H_USE_ADVANCED) || defined(__DOXYGEN__)
257 #define LPS25H_USE_ADVANCED FALSE
258 #endif
259 /** @} */
260 
261 /*===========================================================================*/
262 /* Derived constants and error checks. */
263 /*===========================================================================*/
264 
265 #if !(LPS25H_USE_SPI ^ LPS25H_USE_I2C)
266 #error "LPS25H_USE_SPI and LPS25H_USE_I2C cannot be both true or both false"
267 #endif
268 
269 #if LPS25H_USE_SPI && !HAL_USE_SPI
270 #error "LPS25H_USE_SPI requires HAL_USE_SPI"
271 #endif
272 
273 #if LPS25H_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
274 #error "LPS25H_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
275 #endif
276 
277 #if LPS25H_USE_I2C && !HAL_USE_I2C
278 #error "LPS25H_USE_I2C requires HAL_USE_I2C"
279 #endif
280 
281 #if LPS25H_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
282 #error "LPS25H_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
283 #endif
284 
285 /*
286  * CHTODO: Add support for LPS25H over SPI.
287  */
288 #if LPS25H_USE_SPI
289 #error "LPS25H over SPI still not supported"
290 #endif
291 
292 /*===========================================================================*/
293 /* Driver data structures and types. */
294 /*===========================================================================*/
295 
296 /**
297  * @name LPS25H data structures and types.
298  * @{
299  */
300 /**
301  * @brief Structure representing a LPS25H driver.
302  */
303 typedef struct LPS25HDriver LPS25HDriver;
304 
305 /**
306  * @brief LPS25H slave address
307  */
308 typedef enum {
309  LPS25H_SAD_GND = 0x5C, /**< Slave Address when SA0 is to GND */
310  LPS25H_SAD_VCC = 0x5D /**< Slave Address when SA0 is to VCC */
311 }lps25h_sad_t;
312 
313 /**
314  * @brief LPS25H output data rate and bandwidth.
315  */
316 typedef enum {
317  LPS25H_ODR_ONE_SHOT = 0x00, /**< One shot. */
318  LPS25H_ODR_1HZ = 0x10, /**< Output data rate 1 Hz. */
319  LPS25H_ODR_7HZ = 0x20, /**< Output data rate 7 Hz. */
320  LPS25H_ODR_12P5HZ = 0x30, /**< Output data rate 12.5 Hz. */
321  LPS25H_ODR_25HZ = 0x40 /**< Output data rate 25 Hz. */
322 }lps25h_odr_t;
323 
324 /**
325  * @brief LPS25H pressure resolution.
326  */
327 typedef enum {
328  LPS25H_AVGP_8 = 0x00, /**< Number of internal average is 8. */
329  LPS25H_AVGP_32 = 0x01, /**< Number of internal average is 32. */
330  LPS25H_AVGP_128 = 0x02, /**< Number of internal average is 128. */
331  LPS25H_AVGP_512 = 0x03, /**< Number of internal average is 512. */
333 
334 /**
335  * @brief LPS25H temperature resolution.
336  */
337 typedef enum {
338  LPS25H_AVGT_8 = 0x00, /**< Number of internal average is 8. */
339  LPS25H_AVGT_32 = 0x04, /**< Number of internal average is 32. */
340  LPS25H_AVGT_128 = 0x08, /**< Number of internal average is 128. */
341  LPS25H_AVGT_512 = 0x0C, /**< Number of internal average is 512. */
343 
344 /**
345  * @brief LPS25H block data update.
346  */
347 typedef enum {
348  LPS25H_BDU_CONTINUOUS = 0x00, /**< Block data continuously updated. */
349  LPS25H_BDU_BLOCKED = 0x40 /**< Block data updated after reading. */
350 }lps25h_bdu_t;
351 
352 /**
353  * @brief Driver state machine possible states.
354  */
355 typedef enum {
356  LPS25H_UNINIT = 0, /**< Not initialized. */
357  LPS25H_STOP = 1, /**< Stopped. */
358  LPS25H_READY = 2, /**< Ready. */
360 
361 /**
362  * @brief LPS25H configuration structure.
363  */
364 typedef struct {
365 
366 #if LPS25H_USE_SPI || defined(__DOXYGEN__)
367  /**
368  * @brief SPI driver associated to this LPS25H.
369  */
371  /**
372  * @brief SPI configuration associated to this LPS25H.
373  */
375 #endif /* LPS25H_USE_SPI */
376 #if LPS25H_USE_I2C || defined(__DOXYGEN__)
377  /**
378  * @brief I2C driver associated to this LPS25H.
379  */
381  /**
382  * @brief I2C configuration associated to this LPS25H.
383  */
385  /**
386  * @brief LPS25H slave address
387  */
389 #endif /* LPS25H_USE_I2C */
390  /**
391  * @brief LPS25H barometer subsystem initial sensitivity.
392  */
394  /**
395  * @brief LPS25H barometer subsystem initial bias.
396  */
397  float *barobias;
398  /**
399  * @brief LPS25H thermometer subsystem initial sensitivity.
400  */
402  /**
403  * @brief LPS25H thermometer subsystem initial bias.
404  */
405  float *thermobias;
406  /**
407  * @brief LPS25H output data rate selection.
408  */
410 #if LPS25H_USE_ADVANCED || defined(__DOXYGEN__)
411  /**
412  * @brief LPS25H block data update.
413  */
415  /**
416  * @brief LPS25H barometer subsystem resolution.
417  */
419  /**
420  * @brief LPS25H thermometer subsystem resolution.
421  */
423 #endif
424 } LPS25HConfig;
425 
426 /**
427  * @brief @p LPS25H specific methods.
428  * @note No methods so far, just a common ancestor interface.
429  */
430 #define _lps25h_methods_alone
431 
432 /**
433  * @brief @p LPS25H specific methods with inherited ones.
434  */
435 #define _lps25h_methods \
436  _base_object_methods \
437  _lps25h_methods_alone
438 
439 /**
440  * @extends BaseObjectVMT
441  *
442  * @brief @p LPS25H virtual methods table.
443  */
444 struct LPS25HVMT {
446 };
447 
448 /**
449  * @brief @p LPS25HDriver specific data.
450  */
451 #define _lps25h_data \
452  /* Driver state.*/ \
453  lps25h_state_t state; \
454  /* Current configuration data.*/ \
455  const LPS25HConfig *config; \
456  /* Barometer subsystem axes number.*/ \
457  size_t baroaxes; \
458  /* Barometer subsystem current sensitivity.*/ \
459  float barosensitivity; \
460  /* Barometer subsystem current bias .*/ \
461  float barobias; \
462  /* Thermometer subsystem axes number.*/ \
463  size_t thermoaxes; \
464  /* Thermometer subsystem current sensitivity.*/ \
465  float thermosensitivity; \
466  /* Thermometer subsystem current bias.*/ \
467  float thermobias;
468 
469 /**
470  * @brief LPS25H 2-axis barometer/thermometer class.
471  */
472 struct LPS25HDriver {
473  /** @brief Virtual Methods Table.*/
474  const struct LPS25HVMT *vmt;
475  /** @brief Base barometer interface.*/
477  /** @brief Base thermometer interface.*/
480 };
481 /** @} */
482 
483 /*===========================================================================*/
484 /* Driver macros. */
485 /*===========================================================================*/
486 
487 /**
488  * @brief Return the number of axes of the BaseBarometer.
489  *
490  * @param[in] devp pointer to @p LPS25HDriver.
491  *
492  * @return the number of axes.
493  *
494  * @api
495  */
496 #define lps25hBarometerGetAxesNumber(devp) \
497  barometerGetAxesNumber(&((devp)->baro_if))
498 
499 /**
500  * @brief Retrieves raw data from the BaseBarometer.
501  * @note This data is retrieved from MEMS register without any algebraical
502  * manipulation.
503  * @note The axes array must be at least the same size of the
504  * BaseBarometer axes number.
505  *
506  * @param[in] devp pointer to @p LPS25HDriver.
507  * @param[out] axes a buffer which would be filled with raw data.
508  *
509  * @return The operation status.
510  * @retval MSG_OK if the function succeeded.
511  * @retval MSG_RESET if one or more I2C errors occurred, the errors can
512  * be retrieved using @p i2cGetErrors().
513  * @retval MSG_TIMEOUT if a timeout occurred before operation end.
514  *
515  * @api
516  */
517 #define lps25hBarometerReadRaw(devp, axes) \
518  barometerReadRaw(&((devp)->baro_if), axes)
519 
520 /**
521  * @brief Retrieves cooked data from the BaseBarometer.
522  * @note This data is manipulated according to the formula
523  * cooked = (raw * sensitivity) - bias.
524  * @note Final data is expressed as hPa.
525  * @note The axes array must be at least the same size of the
526  * BaseBarometer axes number.
527  *
528  * @param[in] devp pointer to @p LPS25HDriver.
529  * @param[out] axes a buffer which would be filled with cooked data.
530  *
531  * @return The operation status.
532  * @retval MSG_OK if the function succeeded.
533  * @retval MSG_RESET if one or more I2C errors occurred, the errors can
534  * be retrieved using @p i2cGetErrors().
535  * @retval MSG_TIMEOUT if a timeout occurred before operation end.
536  *
537  * @api
538  */
539 #define lps25hBarometerReadCooked(devp, axes) \
540  barometerReadCooked(&((devp)->baro_if), axes)
541 
542 /**
543  * @brief Set bias values for the BaseBarometer.
544  * @note Bias must be expressed as hPa.
545  * @note The bias buffer must be at least the same size of the
546  * BaseBarometer axes number.
547  *
548  * @param[in] devp pointer to @p LPS25HDriver.
549  * @param[in] bp a buffer which contains biases.
550  *
551  * @return The operation status.
552  * @retval MSG_OK if the function succeeded.
553  *
554  * @api
555  */
556 #define lps25hBarometerSetBias(devp, bp) \
557  barometerSetBias(&((devp)->baro_if), bp)
558 
559 /**
560  * @brief Reset bias values for the BaseBarometer.
561  * @note Default biases value are obtained from device datasheet when
562  * available otherwise they are considered zero.
563  *
564  * @param[in] devp pointer to @p LPS25HDriver.
565  *
566  * @return The operation status.
567  * @retval MSG_OK if the function succeeded.
568  *
569  * @api
570  */
571 #define lps25hBarometerResetBias(devp) \
572  barometerResetBias(&((devp)->baro_if))
573 
574 /**
575  * @brief Set sensitivity values for the BaseBarometer.
576  * @note Sensitivity must be expressed as hPa/LSB.
577  * @note The sensitivity buffer must be at least the same size of the
578  * BaseBarometer axes number.
579  *
580  * @param[in] devp pointer to @p LPS25HDriver.
581  * @param[in] sp a buffer which contains sensitivities.
582  *
583  * @return The operation status.
584  * @retval MSG_OK if the function succeeded.
585  *
586  * @api
587  */
588 #define lps25hBarometerSetSensitivity(devp, sp) \
589  barometerSetSensitivity(&((devp)->baro_if), sp)
590 
591 /**
592  * @brief Reset sensitivity values for the BaseBarometer.
593  * @note Default sensitivities value are obtained from device datasheet.
594  *
595  * @param[in] devp pointer to @p LPS25HDriver.
596  *
597  * @return The operation status.
598  * @retval MSG_OK if the function succeeded.
599  *
600  * @api
601  */
602 #define lps25hBarometerResetSensitivity(devp) \
603  barometerResetSensitivity(&((devp)->baro_if))
604 
605 /**
606  * @brief Return the number of axes of the BaseThermometer.
607  *
608  * @param[in] devp pointer to @p LPS25HDriver.
609  *
610  * @return the number of axes.
611  *
612  * @api
613  */
614 #define lps25hThermometerGetAxesNumber(devp) \
615  thermometerGetAxesNumber(&((devp)->thermo_if))
616 
617 /**
618  * @brief Retrieves raw data from the BaseThermometer.
619  * @note This data is retrieved from MEMS register without any algebraical
620  * manipulation.
621  * @note The axes array must be at least the same size of the
622  * BaseThermometer axes number.
623  *
624  * @param[in] devp pointer to @p LPS25HDriver.
625  * @param[out] axes a buffer which would be filled with raw data.
626  *
627  * @return The operation status.
628  * @retval MSG_OK if the function succeeded.
629  * @retval MSG_RESET if one or more I2C errors occurred, the errors can
630  * be retrieved using @p i2cGetErrors().
631  * @retval MSG_TIMEOUT if a timeout occurred before operation end.
632  *
633  * @api
634  */
635 #define lps25hThermometerReadRaw(devp, axes) \
636  thermometerReadRaw(&((devp)->thermo_if), axes)
637 
638 /**
639  * @brief Retrieves cooked data from the BaseThermometer.
640  * @note This data is manipulated according to the formula
641  * cooked = (raw * sensitivity) - bias.
642  * @note Final data is expressed as °C.
643  * @note The axes array must be at least the same size of the
644  * BaseThermometer axes number.
645  *
646  * @param[in] devp pointer to @p LPS25HDriver.
647  * @param[out] axes a buffer which would be filled with cooked data.
648  *
649  * @return The operation status.
650  * @retval MSG_OK if the function succeeded.
651  * @retval MSG_RESET if one or more I2C errors occurred, the errors can
652  * be retrieved using @p i2cGetErrors().
653  * @retval MSG_TIMEOUT if a timeout occurred before operation end.
654  *
655  * @api
656  */
657 #define lps25hThermometerReadCooked(devp, axes) \
658  thermometerReadCooked(&((devp)->thermo_if), axes)
659 
660 /**
661  * @brief Set bias values for the BaseThermometer.
662  * @note Bias must be expressed as °C.
663  * @note The bias buffer must be at least the same size of the
664  * BaseThermometer axes number.
665  *
666  * @param[in] devp pointer to @p LPS25HDriver.
667  * @param[in] bp a buffer which contains biases.
668  *
669  * @return The operation status.
670  * @retval MSG_OK if the function succeeded.
671  *
672  * @api
673  */
674 #define lps25hThermometerSetBias(devp, bp) \
675  thermometerSetBias(&((devp)->thermo_if), bp)
676 
677 /**
678  * @brief Reset bias values for the BaseThermometer.
679  * @note Default biases value are obtained from device datasheet when
680  * available otherwise they are considered zero.
681  *
682  * @param[in] devp pointer to @p LPS25HDriver.
683  *
684  * @return The operation status.
685  * @retval MSG_OK if the function succeeded.
686  *
687  * @api
688  */
689 #define lps25hThermometerResetBias(devp) \
690  thermometerResetBias(&((devp)->thermo_if))
691 
692 /**
693  * @brief Set sensitivity values for the BaseThermometer.
694  * @note Sensitivity must be expressed as °C/LSB.
695  * @note The sensitivity buffer must be at least the same size of the
696  * BaseThermometer axes number.
697  *
698  * @param[in] devp pointer to @p LPS25HDriver.
699  * @param[in] sp a buffer which contains sensitivities.
700  *
701  * @return The operation status.
702  * @retval MSG_OK if the function succeeded.
703  *
704  * @api
705  */
706 #define lps25hThermometerSetSensitivity(devp, sp) \
707  thermometerSetSensitivity(&((devp)->thermo_if), sp)
708 
709 /**
710  * @brief Reset sensitivity values for the BaseThermometer.
711  * @note Default sensitivities value are obtained from device datasheet.
712  *
713  * @param[in] devp pointer to @p LPS25HDriver.
714  *
715  * @return The operation status.
716  * @retval MSG_OK if the function succeeded.
717  *
718  * @api
719  */
720 #define lps25hThermometerResetSensitivity(devp) \
721  thermometerResetSensitivity(&((devp)->thermo_if))
722 
723 /*===========================================================================*/
724 /* External declarations. */
725 /*===========================================================================*/
726 
727 #ifdef __cplusplus
728 extern "C" {
729 #endif
730  void lps25hObjectInit(LPS25HDriver *devp);
731  void lps25hStart(LPS25HDriver *devp, const LPS25HConfig *config);
732  void lps25hStop(LPS25HDriver *devp);
733 #ifdef __cplusplus
734 }
735 #endif
736 
737 #endif /* _LPS25H_H_ */
738 
739 /** @} */
740 
LPS25HConfig::spicfg
const SPIConfig * spicfg
SPI configuration associated to this LPS25H.
Definition: lps25h.h:374
I2CDriver
Structure representing an I2C driver.
Definition: hal_i2c_lld.h:88
LPS25HDriver::vmt
const struct LPS25HVMT * vmt
Virtual Methods Table.
Definition: lps25h.h:474
LPS25H_AVGT_128
@ LPS25H_AVGT_128
Definition: lps25h.h:340
LPS25HConfig::thermoresolution
lps25h_avgt_t thermoresolution
LPS25H thermometer subsystem resolution.
Definition: lps25h.h:422
BaseThermometer
Base thermometer class.
Definition: ex_thermometer.h:86
LPS25HConfig::i2ccfg
const I2CConfig * i2ccfg
I2C configuration associated to this LPS25H.
Definition: lps25h.h:384
ex_barometer.h
Generic barometer interface header.
LPS25H_ODR_ONE_SHOT
@ LPS25H_ODR_ONE_SHOT
Definition: lps25h.h:317
hal_spi_config
Driver configuration structure.
Definition: hal_spi.h:146
lps25hStop
void lps25hStop(LPS25HDriver *devp)
Deactivates the LPS25H Complex Driver peripheral.
Definition: lps25h.c:669
LPS25H_BDU_BLOCKED
@ LPS25H_BDU_BLOCKED
Definition: lps25h.h:349
hal_spi_driver
Structure representing an SPI driver.
Definition: hal_spi.h:190
LPS25HConfig
LPS25H configuration structure.
Definition: lps25h.h:364
lps25h_avgp_t
lps25h_avgp_t
LPS25H pressure resolution.
Definition: lps25h.h:327
LPS25H_AVGT_32
@ LPS25H_AVGT_32
Definition: lps25h.h:339
LPS25HDriver::baro_if
BaseBarometer baro_if
Base barometer interface.
Definition: lps25h.h:476
LPS25H_AVGP_8
@ LPS25H_AVGP_8
Definition: lps25h.h:328
LPS25H_BDU_CONTINUOUS
@ LPS25H_BDU_CONTINUOUS
Definition: lps25h.h:348
LPS25HConfig::baroresolution
lps25h_avgp_t baroresolution
LPS25H barometer subsystem resolution.
Definition: lps25h.h:418
LPS25H_ODR_1HZ
@ LPS25H_ODR_1HZ
Definition: lps25h.h:318
LPS25HConfig::barosensitivity
float * barosensitivity
LPS25H barometer subsystem initial sensitivity.
Definition: lps25h.h:393
LPS25H_AVGP_128
@ LPS25H_AVGP_128
Definition: lps25h.h:330
LPS25HVMT
LPS25H virtual methods table.
Definition: lps25h.h:444
LPS25HConfig::spip
SPIDriver * spip
SPI driver associated to this LPS25H.
Definition: lps25h.h:370
_lps25h_data
#define _lps25h_data
LPS25HDriver specific data.
Definition: lps25h.h:451
lps25h_odr_t
lps25h_odr_t
LPS25H output data rate and bandwidth.
Definition: lps25h.h:316
LPS25H_ODR_12P5HZ
@ LPS25H_ODR_12P5HZ
Definition: lps25h.h:320
LPS25H_UNINIT
@ LPS25H_UNINIT
Definition: lps25h.h:356
LPS25H_SAD_VCC
@ LPS25H_SAD_VCC
Definition: lps25h.h:310
BaseBarometer
Base barometer class.
Definition: ex_barometer.h:86
LPS25H_ODR_25HZ
@ LPS25H_ODR_25HZ
Definition: lps25h.h:321
LPS25HConfig::i2cp
I2CDriver * i2cp
I2C driver associated to this LPS25H.
Definition: lps25h.h:380
LPS25HConfig::blockdataupdate
lps25h_bdu_t blockdataupdate
LPS25H block data update.
Definition: lps25h.h:414
LPS25H_AVGP_512
@ LPS25H_AVGP_512
Definition: lps25h.h:331
LPS25HDriver::thermo_if
BaseThermometer thermo_if
Base thermometer interface.
Definition: lps25h.h:478
LPS25H_STOP
@ LPS25H_STOP
Definition: lps25h.h:357
lps25h_bdu_t
lps25h_bdu_t
LPS25H block data update.
Definition: lps25h.h:347
LPS25H_READY
@ LPS25H_READY
Definition: lps25h.h:358
LPS25HConfig::slaveaddress
lps25h_sad_t slaveaddress
LPS25H slave address.
Definition: lps25h.h:388
LPS25H_SAD_GND
@ LPS25H_SAD_GND
Definition: lps25h.h:309
LPS25HConfig::outputdatarate
lps25h_odr_t outputdatarate
LPS25H output data rate selection.
Definition: lps25h.h:409
LPS25H_AVGP_32
@ LPS25H_AVGP_32
Definition: lps25h.h:329
ex_thermometer.h
Generic thermometer interface header.
LPS25HConfig::thermobias
float * thermobias
LPS25H thermometer subsystem initial bias.
Definition: lps25h.h:405
LPS25HConfig::thermosensitivity
float * thermosensitivity
LPS25H thermometer subsystem initial sensitivity.
Definition: lps25h.h:401
LPS25H_AVGT_8
@ LPS25H_AVGT_8
Definition: lps25h.h:338
lps25h_sad_t
lps25h_sad_t
LPS25H slave address.
Definition: lps25h.h:308
lps25hStart
void lps25hStart(LPS25HDriver *devp, const LPS25HConfig *config)
Configures and activates LPS25H Complex Driver peripheral.
Definition: lps25h.c:572
lps25h_state_t
lps25h_state_t
Driver state machine possible states.
Definition: lps25h.h:355
lps25h_avgt_t
lps25h_avgt_t
LPS25H temperature resolution.
Definition: lps25h.h:337
LPS25HConfig::barobias
float * barobias
LPS25H barometer subsystem initial bias.
Definition: lps25h.h:397
_lps25h_methods
#define _lps25h_methods
LPS25H specific methods with inherited ones.
Definition: lps25h.h:435
I2CConfig
Type of I2C driver configuration structure.
Definition: hal_i2c_lld.h:75
LPS25HDriver
LPS25H 2-axis barometer/thermometer class.
Definition: lps25h.h:472
LPS25H_AVGT_512
@ LPS25H_AVGT_512
Definition: lps25h.h:341
lps25hObjectInit
void lps25hObjectInit(LPS25HDriver *devp)
Initializes an instance.
Definition: lps25h.c:550
LPS25H_ODR_7HZ
@ LPS25H_ODR_7HZ
Definition: lps25h.h:319