lps25h.h 24 KB

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