lps22hb.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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 lps22hb.h
  17. * @brief LPS22HB MEMS interface module header.
  18. *
  19. * @addtogroup LPS22HB
  20. * @ingroup EX_ST
  21. * @{
  22. */
  23. #ifndef _LPS22HB_H_
  24. #define _LPS22HB_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 LPS22HB driver version string.
  36. */
  37. #define EX_LPS22HB_VERSION "1.0.2"
  38. /**
  39. * @brief LPS22HB driver version major number.
  40. */
  41. #define EX_LPS22HB_MAJOR 1
  42. /**
  43. * @brief LPS22HB driver version minor number.
  44. */
  45. #define EX_LPS22HB_MINOR 0
  46. /**
  47. * @brief LPS22HB driver version patch number.
  48. */
  49. #define EX_LPS22HB_PATCH 2
  50. /** @} */
  51. /**
  52. * @brief LPS22HB 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 LPS22HB_BARO_NUMBER_OF_AXES 1U
  60. #define LPS22HB_BARO_SENS 0.00024414f
  61. #define LPS22HB_BARO_BIAS 0.0f
  62. /** @} */
  63. /**
  64. * @brief LPS22HB thermometer subsystem characteristics.
  65. * @note Sensitivity is expressed as °C/LSB.
  66. * @note Bias is expressed as °C.
  67. *
  68. * @{
  69. */
  70. #define LPS22HB_THERMO_NUMBER_OF_AXES 1U
  71. #define LPS22HB_THERMO_SENS 0.01f
  72. #define LPS22HB_THERMO_BIAS 0.0f
  73. /** @} */
  74. /**
  75. * @name LPS22HB communication interfaces related bit masks
  76. * @{
  77. */
  78. #define LPS22HB_DI_MASK 0xFF
  79. #define LPS22HB_DI(n) (1 << n)
  80. #define LPS22HB_AD_MASK 0x3F
  81. #define LPS22HB_AD(n) (1 << n)
  82. #define LPS22HB_MS (1 << 6)
  83. #define LPS22HB_RW (1 << 7)
  84. #define LPS22HB_SUB_MS (1 << 7)
  85. /** @} */
  86. /**
  87. * @name LPS22HB register addresses
  88. * @{
  89. */
  90. #define LPS22HB_AD_INT_CFG 0x0B
  91. #define LPS22HB_AD_THS_P_L 0x0C
  92. #define LPS22HB_AD_THS_P_H 0x0D
  93. #define LPS22HB_AD_WHO_AM_I 0x0F
  94. #define LPS22HB_AD_CTRL_REG1 0x10
  95. #define LPS22HB_AD_CTRL_REG2 0x11
  96. #define LPS22HB_AD_CTRL_REG3 0x12
  97. #define LPS22HB_AD_FIFO_CTRL 0x14
  98. #define LPS22HB_AD_REF_P_XL 0x15
  99. #define LPS22HB_AD_REF_P_L 0x16
  100. #define LPS22HB_AD_REF_P_H 0x17
  101. #define LPS22HB_AD_RPDS_L 0x18
  102. #define LPS22HB_AD_RPDS_H 0x19
  103. #define LPS22HB_AD_RES_CONF 0x1A
  104. #define LPS22HB_AD_INT_SRC 0x25
  105. #define LPS22HB_AD_FIFO_SRC 0x26
  106. #define LPS22HB_AD_STATUS_REG 0x27
  107. #define LPS22HB_AD_PRESS_OUT_XL 0x28
  108. #define LPS22HB_AD_PRESS_OUT_L 0x29
  109. #define LPS22HB_AD_PRESS_OUT_H 0x2A
  110. #define LPS22HB_AD_TEMP_OUT_L 0x2B
  111. #define LPS22HB_AD_TEMP_OUT_H 0x2C
  112. #define LPS22HB_AD_LPFP_RES 0x33
  113. /** @} */
  114. /**
  115. * @name LPS22HB_INT_CFG register bits definitions
  116. * @{
  117. */
  118. #define LPS22HB_INT_CFG_MASK 0xFF
  119. #define LPS22HB_INT_CFG_PHE (1 << 0)
  120. #define LPS22HB_INT_CFG_PLE (1 << 1)
  121. #define LPS22HB_INT_CFG_LIR (1 << 2)
  122. #define LPS22HB_INT_CFG_DIFF_EN (1 << 3)
  123. #define LPS22HB_INT_CFG_RESET_AZ (1 << 4)
  124. #define LPS22HB_INT_CFG_AUTOZERO (1 << 5)
  125. #define LPS22HB_INT_CFG_RESET_ARP (1 << 6)
  126. #define LPS22HB_INT_CFG_AUTORIFP (1 << 7)
  127. /** @} */
  128. /**
  129. * @name LPS22HB_CTRL_REG1 register bits definitions
  130. * @{
  131. */
  132. #define LPS22HB_CTRL_REG1_MASK 0x7F
  133. #define LPS22HB_CTRL_REG1_SIM (1 << 0)
  134. #define LPS22HB_CTRL_REG1_BDU (1 << 1)
  135. #define LPS22HB_CTRL_REG1_LPFP_CFG (1 << 2)
  136. #define LPS22HB_CTRL_REG1_LPFP_EN (1 << 3)
  137. #define LPS22HB_CTRL_REG1_ODR0 (1 << 4)
  138. #define LPS22HB_CTRL_REG1_ODR1 (1 << 5)
  139. #define LPS22HB_CTRL_REG1_ODR2 (1 << 6)
  140. /** @} */
  141. /**
  142. * @name LPS22HB_CTRL_REG2 register bits definitions
  143. * @{
  144. */
  145. #define LPS22HB_CTRL_REG2_MASK 0xFD
  146. #define LPS22HB_CTRL_REG2_ONE_SHOT (1 << 0)
  147. #define LPS22HB_CTRL_REG2_SWRESET (1 << 2)
  148. #define LPS22HB_CTRL_REG2_I2C_DIS (1 << 3)
  149. #define LPS22HB_CTRL_REG2_IF_ADD_INC (1 << 4)
  150. #define LPS22HB_CTRL_REG2_STOP_ON_FTH (1 << 5)
  151. #define LPS22HB_CTRL_REG2_FIFO_EN (1 << 6)
  152. #define LPS22HB_CTRL_REG2_BOOT (1 << 7)
  153. /** @} */
  154. /**
  155. * @name LPS22HB_CTRL_REG3 register bits definitions
  156. * @{
  157. */
  158. #define LPS22HB_CTRL_REG3_MASK 0xFF
  159. #define LPS22HB_CTRL_REG3_INT_S1 (1 << 0)
  160. #define LPS22HB_CTRL_REG3_INT_S2 (1 << 1)
  161. #define LPS22HB_CTRL_REG3_DRDY (1 << 2)
  162. #define LPS22HB_CTRL_REG3_F_OVR (1 << 3)
  163. #define LPS22HB_CTRL_REG3_F_FTH (1 << 4)
  164. #define LPS22HB_CTRL_REG3_F_FSS5 (1 << 5)
  165. #define LPS22HB_CTRL_REG3_PP_OD (1 << 6)
  166. #define LPS22HB_CTRL_REG3_INT_H_L (1 << 7)
  167. /** @} */
  168. /**
  169. * @name LPS22HB_INT_SRC register bits definitions
  170. * @{
  171. */
  172. #define LPS22HB_INT_SRC_MASK 0x87
  173. #define LPS22HB_INT_SRC_PH (1 << 0)
  174. #define LPS22HB_INT_SRC_PL (1 << 1)
  175. #define LPS22HB_INT_SRC_IA (1 << 2)
  176. #define LPS22HB_INT_SRC_BOOT_STATUS (1 << 8)
  177. /** @} */
  178. /*===========================================================================*/
  179. /* Driver pre-compile time settings. */
  180. /*===========================================================================*/
  181. /**
  182. * @name Configuration options
  183. * @{
  184. */
  185. /**
  186. * @brief LPS22HB SPI interface switch.
  187. * @details If set to @p TRUE the support for SPI is included.
  188. * @note The default is @p FALSE.
  189. */
  190. #if !defined(LPS22HB_USE_SPI) || defined(__DOXYGEN__)
  191. #define LPS22HB_USE_SPI FALSE
  192. #endif
  193. /**
  194. * @brief LPS22HB shared SPI switch.
  195. * @details If set to @p TRUE the device acquires SPI bus ownership
  196. * on each transaction.
  197. * @note The default is @p FALSE. Requires SPI_USE_MUTUAL_EXCLUSION.
  198. */
  199. #if !defined(LPS22HB_SHARED_SPI) || defined(__DOXYGEN__)
  200. #define LPS22HB_SHARED_SPI FALSE
  201. #endif
  202. /**
  203. * @brief LPS22HB I2C interface switch.
  204. * @details If set to @p TRUE the support for I2C is included.
  205. * @note The default is @p TRUE.
  206. */
  207. #if !defined(LPS22HB_USE_I2C) || defined(__DOXYGEN__)
  208. #define LPS22HB_USE_I2C TRUE
  209. #endif
  210. /**
  211. * @brief LPS22HB shared I2C switch.
  212. * @details If set to @p TRUE the device acquires I2C bus ownership
  213. * on each transaction.
  214. * @note The default is @p FALSE. Requires I2C_USE_MUTUAL_EXCLUSION.
  215. */
  216. #if !defined(LPS22HB_SHARED_I2C) || defined(__DOXYGEN__)
  217. #define LPS22HB_SHARED_I2C FALSE
  218. #endif
  219. /**
  220. * @brief LPS22HB advanced configurations switch.
  221. * @details If set to @p TRUE more configurations are available.
  222. * @note The default is @p FALSE.
  223. */
  224. #if !defined(LPS22HB_USE_ADVANCED) || defined(__DOXYGEN__)
  225. #define LPS22HB_USE_ADVANCED FALSE
  226. #endif
  227. /** @} */
  228. /*===========================================================================*/
  229. /* Derived constants and error checks. */
  230. /*===========================================================================*/
  231. #if !(LPS22HB_USE_SPI ^ LPS22HB_USE_I2C)
  232. #error "LPS22HB_USE_SPI and LPS22HB_USE_I2C cannot be both true or both false"
  233. #endif
  234. #if LPS22HB_USE_SPI && !HAL_USE_SPI
  235. #error "LPS22HB_USE_SPI requires HAL_USE_SPI"
  236. #endif
  237. #if LPS22HB_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
  238. #error "LPS22HB_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
  239. #endif
  240. #if LPS22HB_USE_I2C && !HAL_USE_I2C
  241. #error "LPS22HB_USE_I2C requires HAL_USE_I2C"
  242. #endif
  243. #if LPS22HB_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
  244. #error "LPS22HB_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
  245. #endif
  246. /**
  247. * @todo Add support for LPS22HB over SPI.
  248. */
  249. #if LPS22HB_USE_SPI
  250. #error "LPS22HB over SPI still not supported"
  251. #endif
  252. /*===========================================================================*/
  253. /* Driver data structures and types. */
  254. /*===========================================================================*/
  255. /**
  256. * @name LPS22HB data structures and types.
  257. * @{
  258. */
  259. /**
  260. * @brief Structure representing a LPS22HB driver.
  261. */
  262. typedef struct LPS22HBDriver LPS22HBDriver;
  263. /**
  264. * @brief LPS22HB slave address
  265. */
  266. typedef enum {
  267. LPS22HB_SAD_GND = 0x5C, /**< Slave Address when SA0 is to GND */
  268. LPS22HB_SAD_VCC = 0x5D /**< Slave Address when SA0 is to VCC */
  269. }lps22hb_sad_t;
  270. /**
  271. * @brief LPS22HB output data rate and bandwidth.
  272. */
  273. typedef enum {
  274. LPS22HB_ODR_PD = 0x00, /**< Power down. */
  275. LPS22HB_ODR_1HZ = 0x10, /**< Output data rate 1 Hz. */
  276. LPS22HB_ODR_10HZ = 0x20, /**< Output data rate 10 Hz. */
  277. LPS22HB_ODR_25HZ = 0x30, /**< Output data rate 25 Hz. */
  278. LPS22HB_ODR_50HZ = 0x40, /**< Output data rate 50 Hz. */
  279. LPS22HB_ODR_75HZ = 0x50 /**< Output data rate 75 Hz. */
  280. }lps22hb_odr_t;
  281. /**
  282. * @brief LPS22HB pressure resolution.
  283. */
  284. typedef enum {
  285. LPS22HB_LP_DISABLED = 0x00, /**< LP Filter disabled. */
  286. LPS22HB_LP_ODR_9 = 0x08, /**< LP Filter enabled. Cut-off ORD/9. */
  287. LPS22HB_LP_ODR_20 = 0x0C /**< LP Filter enabled. Cut-off ORD/20. */
  288. }lps22hb_lp_t;
  289. /**
  290. * @brief LPS22HB block data update.
  291. */
  292. typedef enum {
  293. LPS22HB_BDU_CONTINUOUS = 0x00, /**< Block data continuously updated. */
  294. LPS22HB_BDU_BLOCKED = 0x40 /**< Block data updated after reading. */
  295. }lps22hb_bdu_t;
  296. /**
  297. * @brief Driver state machine possible states.
  298. */
  299. typedef enum {
  300. LPS22HB_UNINIT = 0, /**< Not initialized. */
  301. LPS22HB_STOP = 1, /**< Stopped. */
  302. LPS22HB_READY = 2, /**< Ready. */
  303. } lps22hb_state_t;
  304. /**
  305. * @brief LPS22HB configuration structure.
  306. */
  307. typedef struct {
  308. #if LPS22HB_USE_SPI || defined(__DOXYGEN__)
  309. /**
  310. * @brief SPI driver associated to this LPS22HB.
  311. */
  312. SPIDriver *spip;
  313. /**
  314. * @brief SPI configuration associated to this LPS22HB.
  315. */
  316. const SPIConfig *spicfg;
  317. #endif /* LPS22HB_USE_SPI */
  318. #if LPS22HB_USE_I2C || defined(__DOXYGEN__)
  319. /**
  320. * @brief I2C driver associated to this LPS22HB.
  321. */
  322. I2CDriver *i2cp;
  323. /**
  324. * @brief I2C configuration associated to this LPS22HB.
  325. */
  326. const I2CConfig *i2ccfg;
  327. /**
  328. * @brief LPS22HB slave address
  329. */
  330. lps22hb_sad_t slaveaddress;
  331. #endif /* LPS22HB_USE_I2C */
  332. /**
  333. * @brief LPS22HB barometer subsystem initial sensitivity.
  334. */
  335. float *barosensitivity;
  336. /**
  337. * @brief LPS22HB barometer subsystem initial bias.
  338. */
  339. float *barobias;
  340. /**
  341. * @brief LPS22HB thermometer subsystem initial sensitivity.
  342. */
  343. float *thermosensitivity;
  344. /**
  345. * @brief LPS22HB thermometer subsystem initial bias.
  346. */
  347. float *thermobias;
  348. /**
  349. * @brief LPS22HB output data rate selection.
  350. */
  351. lps22hb_odr_t outputdatarate;
  352. #if LPS22HB_USE_ADVANCED || defined(__DOXYGEN__)
  353. /**
  354. * @brief LPS22HB block data update.
  355. */
  356. lps22hb_bdu_t blockdataupdate;
  357. /**
  358. * @brief LPS22HB barometer subsystem resolution.
  359. */
  360. lps22hb_lp_t lowpass_filter;
  361. #endif
  362. } LPS22HBConfig;
  363. /**
  364. * @brief @p LPS22HB specific methods.
  365. * @note No methods so far, just a common ancestor interface.
  366. */
  367. #define _lps22hb_methods_alone
  368. /**
  369. * @brief @p LPS22HB specific methods with inherited ones.
  370. */
  371. #define _lps22hb_methods \
  372. _base_object_methods \
  373. _lps22hb_methods_alone
  374. /**
  375. * @extends BaseObjectVMT
  376. *
  377. * @brief @p LPS22HB virtual methods table.
  378. */
  379. struct LPS22HBVMT {
  380. _lps22hb_methods
  381. };
  382. /**
  383. * @brief @p LPS22HBDriver specific data.
  384. */
  385. #define _lps22hb_data \
  386. /* Driver state.*/ \
  387. lps22hb_state_t state; \
  388. /* Current configuration data.*/ \
  389. const LPS22HBConfig *config; \
  390. /* Barometer subsystem axes number.*/ \
  391. size_t baroaxes; \
  392. /* Barometer subsystem current sensitivity.*/ \
  393. float barosensitivity; \
  394. /* Barometer subsystem current bias .*/ \
  395. float barobias; \
  396. /* Thermometer subsystem axes number.*/ \
  397. size_t thermoaxes; \
  398. /* Thermometer subsystem current sensitivity.*/ \
  399. float thermosensitivity; \
  400. /* Thermometer subsystem current bias.*/ \
  401. float thermobias;
  402. /**
  403. * @brief LPS22HB 2-axis barometer/thermometer class.
  404. */
  405. struct LPS22HBDriver {
  406. /** @brief Virtual Methods Table.*/
  407. const struct LPS22HBVMT *vmt;
  408. /** @brief Base barometer interface.*/
  409. BaseBarometer baro_if;
  410. /** @brief Base thermometer interface.*/
  411. BaseThermometer thermo_if;
  412. _lps22hb_data
  413. };
  414. /** @} */
  415. /*===========================================================================*/
  416. /* Driver macros. */
  417. /*===========================================================================*/
  418. /**
  419. * @brief Return the number of axes of the BaseBarometer.
  420. *
  421. * @param[in] devp pointer to @p LPS22HBDriver.
  422. *
  423. * @return the number of axes.
  424. *
  425. * @api
  426. */
  427. #define lps22hbBarometerGetAxesNumber(devp) \
  428. barometerGetAxesNumber(&((devp)->baro_if))
  429. /**
  430. * @brief Retrieves raw data from the BaseBarometer.
  431. * @note This data is retrieved from MEMS register without any algebraical
  432. * manipulation.
  433. * @note The axes array must be at least the same size of the
  434. * BaseBarometer axes number.
  435. *
  436. * @param[in] devp pointer to @p LPS22HBDriver.
  437. * @param[out] axes a buffer which would be filled with raw data.
  438. *
  439. * @return The operation status.
  440. * @retval MSG_OK if the function succeeded.
  441. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  442. * be retrieved using @p i2cGetErrors().
  443. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  444. *
  445. * @api
  446. */
  447. #define lps22hbBarometerReadRaw(devp, axes) \
  448. barometerReadRaw(&((devp)->baro_if), axes)
  449. /**
  450. * @brief Retrieves cooked data from the BaseBarometer.
  451. * @note This data is manipulated according to the formula
  452. * cooked = (raw * sensitivity) - bias.
  453. * @note Final data is expressed as hPa.
  454. * @note The axes array must be at least the same size of the
  455. * BaseBarometer axes number.
  456. *
  457. * @param[in] devp pointer to @p LPS22HBDriver.
  458. * @param[out] axes a buffer which would be filled with cooked data.
  459. *
  460. * @return The operation status.
  461. * @retval MSG_OK if the function succeeded.
  462. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  463. * be retrieved using @p i2cGetErrors().
  464. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  465. *
  466. * @api
  467. */
  468. #define lps22hbBarometerReadCooked(devp, axes) \
  469. barometerReadCooked(&((devp)->baro_if), axes)
  470. /**
  471. * @brief Set bias values for the BaseBarometer.
  472. * @note Bias must be expressed as hPa.
  473. * @note The bias buffer must be at least the same size of the
  474. * BaseBarometer axes number.
  475. *
  476. * @param[in] devp pointer to @p LPS22HBDriver.
  477. * @param[in] bp a buffer which contains biases.
  478. *
  479. * @return The operation status.
  480. * @retval MSG_OK if the function succeeded.
  481. *
  482. * @api
  483. */
  484. #define lps22hbBarometerSetBias(devp, bp) \
  485. barometerSetBias(&((devp)->baro_if), bp)
  486. /**
  487. * @brief Reset bias values for the BaseBarometer.
  488. * @note Default biases value are obtained from device datasheet when
  489. * available otherwise they are considered zero.
  490. *
  491. * @param[in] devp pointer to @p LPS22HBDriver.
  492. *
  493. * @return The operation status.
  494. * @retval MSG_OK if the function succeeded.
  495. *
  496. * @api
  497. */
  498. #define lps22hbBarometerResetBias(devp) \
  499. barometerResetBias(&((devp)->baro_if))
  500. /**
  501. * @brief Set sensitivity values for the BaseBarometer.
  502. * @note Sensitivity must be expressed as hPa/LSB.
  503. * @note The sensitivity buffer must be at least the same size of the
  504. * BaseBarometer axes number.
  505. *
  506. * @param[in] devp pointer to @p LPS22HBDriver.
  507. * @param[in] sp a buffer which contains sensitivities.
  508. *
  509. * @return The operation status.
  510. * @retval MSG_OK if the function succeeded.
  511. *
  512. * @api
  513. */
  514. #define lps22hbBarometerSetSensitivity(devp, sp) \
  515. barometerSetSensitivity(&((devp)->baro_if), sp)
  516. /**
  517. * @brief Reset sensitivity values for the BaseBarometer.
  518. * @note Default sensitivities value are obtained from device datasheet.
  519. *
  520. * @param[in] devp pointer to @p LPS22HBDriver.
  521. *
  522. * @return The operation status.
  523. * @retval MSG_OK if the function succeeded.
  524. *
  525. * @api
  526. */
  527. #define lps22hbBarometerResetSensitivity(devp) \
  528. barometerResetSensitivity(&((devp)->baro_if))
  529. /**
  530. * @brief Return the number of axes of the BaseThermometer.
  531. *
  532. * @param[in] devp pointer to @p LPS22HBDriver.
  533. *
  534. * @return the number of axes.
  535. *
  536. * @api
  537. */
  538. #define lps22hbThermometerGetAxesNumber(devp) \
  539. thermometerGetAxesNumber(&((devp)->thermo_if))
  540. /**
  541. * @brief Retrieves raw data from the BaseThermometer.
  542. * @note This data is retrieved from MEMS register without any algebraical
  543. * manipulation.
  544. * @note The axes array must be at least the same size of the
  545. * BaseThermometer axes number.
  546. *
  547. * @param[in] devp pointer to @p LPS22HBDriver.
  548. * @param[out] axes a buffer which would be filled with raw data.
  549. *
  550. * @return The operation status.
  551. * @retval MSG_OK if the function succeeded.
  552. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  553. * be retrieved using @p i2cGetErrors().
  554. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  555. *
  556. * @api
  557. */
  558. #define lps22hbThermometerReadRaw(devp, axes) \
  559. thermometerReadRaw(&((devp)->thermo_if), axes)
  560. /**
  561. * @brief Retrieves cooked data from the BaseThermometer.
  562. * @note This data is manipulated according to the formula
  563. * cooked = (raw * sensitivity) - bias.
  564. * @note Final data is expressed as °C.
  565. * @note The axes array must be at least the same size of the
  566. * BaseThermometer axes number.
  567. *
  568. * @param[in] devp pointer to @p LPS22HBDriver.
  569. * @param[out] axes a buffer which would be filled with cooked data.
  570. *
  571. * @return The operation status.
  572. * @retval MSG_OK if the function succeeded.
  573. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  574. * be retrieved using @p i2cGetErrors().
  575. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  576. *
  577. * @api
  578. */
  579. #define lps22hbThermometerReadCooked(devp, axes) \
  580. thermometerReadCooked(&((devp)->thermo_if), axes)
  581. /**
  582. * @brief Set bias values for the BaseThermometer.
  583. * @note Bias must be expressed as °C.
  584. * @note The bias buffer must be at least the same size of the
  585. * BaseThermometer axes number.
  586. *
  587. * @param[in] devp pointer to @p LPS22HBDriver.
  588. * @param[in] bp a buffer which contains biases.
  589. *
  590. * @return The operation status.
  591. * @retval MSG_OK if the function succeeded.
  592. *
  593. * @api
  594. */
  595. #define lps22hbThermometerSetBias(devp, bp) \
  596. thermometerSetBias(&((devp)->thermo_if), bp)
  597. /**
  598. * @brief Reset bias values for the BaseThermometer.
  599. * @note Default biases value are obtained from device datasheet when
  600. * available otherwise they are considered zero.
  601. *
  602. * @param[in] devp pointer to @p LPS22HBDriver.
  603. *
  604. * @return The operation status.
  605. * @retval MSG_OK if the function succeeded.
  606. *
  607. * @api
  608. */
  609. #define lps22hbThermometerResetBias(devp) \
  610. thermometerResetBias(&((devp)->thermo_if))
  611. /**
  612. * @brief Set sensitivity values for the BaseThermometer.
  613. * @note Sensitivity must be expressed as °C/LSB.
  614. * @note The sensitivity buffer must be at least the same size of the
  615. * BaseThermometer axes number.
  616. *
  617. * @param[in] devp pointer to @p LPS22HBDriver.
  618. * @param[in] sp a buffer which contains sensitivities.
  619. *
  620. * @return The operation status.
  621. * @retval MSG_OK if the function succeeded.
  622. *
  623. * @api
  624. */
  625. #define lps22hbThermometerSetSensitivity(devp, sp) \
  626. thermometerSetSensitivity(&((devp)->thermo_if), sp)
  627. /**
  628. * @brief Reset sensitivity values for the BaseThermometer.
  629. * @note Default sensitivities value are obtained from device datasheet.
  630. *
  631. * @param[in] devp pointer to @p LPS22HBDriver.
  632. *
  633. * @return The operation status.
  634. * @retval MSG_OK if the function succeeded.
  635. *
  636. * @api
  637. */
  638. #define lps22hbThermometerResetSensitivity(devp) \
  639. thermometerResetSensitivity(&((devp)->thermo_if))
  640. /*===========================================================================*/
  641. /* External declarations. */
  642. /*===========================================================================*/
  643. #ifdef __cplusplus
  644. extern "C" {
  645. #endif
  646. void lps22hbObjectInit(LPS22HBDriver *devp);
  647. void lps22hbStart(LPS22HBDriver *devp, const LPS22HBConfig *config);
  648. void lps22hbStop(LPS22HBDriver *devp);
  649. #ifdef __cplusplus
  650. }
  651. #endif
  652. #endif /* _LPS22HB_H_ */
  653. /** @} */