hts221.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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 hts221.h
  17. * @brief HTS221 MEMS interface module header.
  18. *
  19. *
  20. * @addtogroup HTS221
  21. * @ingroup EX_ST
  22. * @{
  23. */
  24. #ifndef _HTS221_H_
  25. #define _HTS221_H_
  26. #include "hal_hygrometer.h"
  27. #include "hal_thermometer.h"
  28. /*===========================================================================*/
  29. /* Driver constants. */
  30. /*===========================================================================*/
  31. /**
  32. * @name Version identification
  33. * @{
  34. */
  35. /**
  36. * @brief HTS221 driver version string.
  37. */
  38. #define EX_HTS221_VERSION "1.1.2"
  39. /**
  40. * @brief HTS221 driver version major number.
  41. */
  42. #define EX_HTS221_MAJOR 1
  43. /**
  44. * @brief HTS221 driver version minor number.
  45. */
  46. #define EX_HTS221_MINOR 1
  47. /**
  48. * @brief HTS221 driver version patch number.
  49. */
  50. #define EX_HTS221_PATCH 2
  51. /** @} */
  52. /**
  53. * @brief HTS221 hygrometer subsystem characteristics.
  54. * @note Sensitivity is expressed as %rH/LSB whereas %rH stand for percentage
  55. * of relative humidity.
  56. * @note Bias is expressed as %rH.
  57. * @{
  58. */
  59. #define HTS221_HYGRO_NUMBER_OF_AXES 1U
  60. #define HTS221_HYGRO_SENS 0.00390625f
  61. #define HTS221_HYGRO_BIAS 0.0f
  62. /** @} */
  63. /**
  64. * @brief HTS221 thermometer subsystem characteristics.
  65. * @note Sensitivity is expressed as °C/LSB.
  66. * @note Bias is expressed as °C.
  67. *
  68. * @{
  69. */
  70. #define HTS221_THERMO_NUMBER_OF_AXES 1U
  71. #define HTS221_THERMO_SENS 0.0015625f
  72. #define HTS221_THERMO_BIAS 0.0f
  73. /** @} */
  74. /**
  75. * @name HTS221 communication interfaces related bit masks
  76. * @{
  77. */
  78. #define HTS221_DI_MASK 0xFF
  79. #define HTS221_DI(n) (1 << n)
  80. #define HTS221_AD_MASK 0x3F
  81. #define HTS221_AD(n) (1 << n)
  82. #define HTS221_MS (1 << 6)
  83. #define HTS221_RW (1 << 7)
  84. #define HTS221_SUB_MS (1 << 7)
  85. #define HTS221_SAD 0x5F
  86. /** @} */
  87. /**
  88. * @name HTS221 register addresses
  89. * @{
  90. */
  91. #define HTS221_AD_WHO_AM_I 0x0F
  92. #define HTS221_AD_AV_CONF 0x10
  93. #define HTS221_AD_CTRL_REG1 0x20
  94. #define HTS221_AD_CTRL_REG2 0x21
  95. #define HTS221_AD_CTRL_REG3 0x22
  96. #define HTS221_AD_STATUS_REG 0x27
  97. #define HTS221_AD_HUMIDITY_OUT_L 0x28
  98. #define HTS221_AD_HUMIDITY_OUT_H 0x29
  99. #define HTS221_AD_TEMP_OUT_L 0x2A
  100. #define HTS221_AD_TEMP_OUT_H 0x2B
  101. #define HTS221_AD_CALIB_0 0x30
  102. #define HTS221_AD_CALIB_1 0x31
  103. #define HTS221_AD_CALIB_2 0x32
  104. #define HTS221_AD_CALIB_3 0x33
  105. #define HTS221_AD_CALIB_4 0x34
  106. #define HTS221_AD_CALIB_5 0x35
  107. #define HTS221_AD_CALIB_6 0x36
  108. #define HTS221_AD_CALIB_7 0x37
  109. #define HTS221_AD_CALIB_8 0x38
  110. #define HTS221_AD_CALIB_9 0x39
  111. #define HTS221_AD_CALIB_A 0x3A
  112. #define HTS221_AD_CALIB_B 0x3B
  113. #define HTS221_AD_CALIB_C 0x3C
  114. #define HTS221_AD_CALIB_D 0x3D
  115. #define HTS221_AD_CALIB_E 0x3E
  116. #define HTS221_AD_CALIB_F 0x3F
  117. /** @} */
  118. /**
  119. * @name HTS221_CTRL_REG1 register bits definitions
  120. * @{
  121. */
  122. #define HTS221_CTRL_REG1_MASK 0x87
  123. #define HTS221_CTRL_REG1_ODR0 (1 << 0)
  124. #define HTS221_CTRL_REG1_ODR1 (1 << 1)
  125. #define HTS221_CTRL_REG1_BDU (1 << 2)
  126. #define HTS221_CTRL_REG1_PD (1 << 7)
  127. /** @} */
  128. /**
  129. * @name HTS221_CTRL_REG2 register bits definitions
  130. * @{
  131. */
  132. #define HTS221_CTRL_REG2_MASK 0x83
  133. #define HTS221_CTRL_REG2_ONE_SHOT (1 << 0)
  134. #define HTS221_CTRL_REG2_HEATER (1 << 1)
  135. #define HTS221_CTRL_REG2_BOOT (1 << 7)
  136. /** @} */
  137. /**
  138. * @name HTS221_CTRL_REG3 register bits definitions
  139. * @{
  140. */
  141. #define HTS221_CTRL_REG3_MASK 0xC4
  142. #define HTS221_CTRL_REG3_DRDY (1 << 2)
  143. #define HTS221_CTRL_REG3_PP_OD (1 << 6)
  144. #define HTS221_CTRL_REG3_INT_H_L (1 << 7)
  145. /** @} */
  146. /*===========================================================================*/
  147. /* Driver pre-compile time settings. */
  148. /*===========================================================================*/
  149. /**
  150. * @name Configuration options
  151. * @{
  152. */
  153. /**
  154. * @brief HTS221 SPI interface switch.
  155. * @details If set to @p TRUE the support for SPI is included.
  156. * @note The default is @p FALSE.
  157. */
  158. #if !defined(HTS221_USE_SPI) || defined(__DOXYGEN__)
  159. #define HTS221_USE_SPI FALSE
  160. #endif
  161. /**
  162. * @brief HTS221 shared SPI switch.
  163. * @details If set to @p TRUE the device acquires SPI bus ownership
  164. * on each transaction.
  165. * @note The default is @p FALSE. Requires SPI_USE_MUTUAL_EXCLUSION
  166. */
  167. #if !defined(HTS221_SHARED_SPI) || defined(__DOXYGEN__)
  168. #define HTS221_SHARED_SPI FALSE
  169. #endif
  170. /**
  171. * @brief HTS221 I2C interface switch.
  172. * @details If set to @p TRUE the support for I2C is included.
  173. * @note The default is @p TRUE.
  174. */
  175. #if !defined(HTS221_USE_I2C) || defined(__DOXYGEN__)
  176. #define HTS221_USE_I2C TRUE
  177. #endif
  178. /**
  179. * @brief HTS221 shared I2C switch.
  180. * @details If set to @p TRUE the device acquires I2C bus ownership
  181. * on each transaction.
  182. * @note The default is @p FALSE. Requires I2C_USE_MUTUAL_EXCLUSION
  183. */
  184. #if !defined(HTS221_SHARED_I2C) || defined(__DOXYGEN__)
  185. #define HTS221_SHARED_I2C FALSE
  186. #endif
  187. /**
  188. * @brief HTS221 advanced configurations switch.
  189. * @details If set to @p TRUE more configurations are available.
  190. * @note The default is @p FALSE.
  191. */
  192. #if !defined(HTS221_USE_ADVANCED) || defined(__DOXYGEN__)
  193. #define HTS221_USE_ADVANCED FALSE
  194. #endif
  195. /** @} */
  196. /*===========================================================================*/
  197. /* Derived constants and error checks. */
  198. /*===========================================================================*/
  199. #if !(HTS221_USE_SPI ^ HTS221_USE_I2C)
  200. #error "HTS221_USE_SPI and HTS221_USE_I2C cannot be both true or both false"
  201. #endif
  202. #if HTS221_USE_SPI && !HAL_USE_SPI
  203. #error "HTS221_USE_SPI requires HAL_USE_SPI"
  204. #endif
  205. #if HTS221_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
  206. #error "HTS221_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
  207. #endif
  208. #if HTS221_USE_I2C && !HAL_USE_I2C
  209. #error "HTS221_USE_I2C requires HAL_USE_I2C"
  210. #endif
  211. #if HTS221_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
  212. #error "HTS221_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
  213. #endif
  214. /**
  215. * @todo Add support for HTS221 over SPI.
  216. */
  217. #if HTS221_USE_SPI
  218. #error "HTS221 over SPI still not supported."
  219. #endif
  220. /*===========================================================================*/
  221. /* Driver data structures and types. */
  222. /*===========================================================================*/
  223. /**
  224. * @name HTS221 data structures and types.
  225. * @{
  226. */
  227. /**
  228. * @brief Structure representing a HTS221 driver.
  229. */
  230. typedef struct HTS221Driver HTS221Driver;
  231. /**
  232. * @brief HTS221 output data rate and bandwidth.
  233. */
  234. typedef enum {
  235. HTS221_ODR_ONE_SHOT = 0x00, /**< One shot. */
  236. HTS221_ODR_1HZ = 0x01, /**< Output data rate 1 Hz. */
  237. HTS221_ODR_7HZ = 0x02, /**< Output data rate 7 Hz. */
  238. HTS221_ODR_12P5HZ = 0x03, /**< Output data rate 12.5 Hz. */
  239. }hts221_odr_t;
  240. /**
  241. * @brief HTS221 humidity resolution.
  242. */
  243. typedef enum {
  244. HTS221_AVGH_4 = 0x00, /**< Number of internal average is 4. */
  245. HTS221_AVGH_8 = 0x01, /**< Number of internal average is 8. */
  246. HTS221_AVGH_16 = 0x02, /**< Number of internal average is 16. */
  247. HTS221_AVGH_32 = 0x03, /**< Number of internal average is 32. */
  248. HTS221_AVGH_64 = 0x04, /**< Number of internal average is 64. */
  249. HTS221_AVGH_128 = 0x05, /**< Number of internal average is 128. */
  250. HTS221_AVGH_256 = 0x06, /**< Number of internal average is 256. */
  251. HTS221_AVGH_512 = 0x07 /**< Number of internal average is 512. */
  252. }hts221_avgh_t;
  253. /**
  254. * @brief HTS221 temperature resolution.
  255. */
  256. typedef enum {
  257. HTS221_AVGT_2 = 0x00, /**< Number of internal average is 2. */
  258. HTS221_AVGT_4 = 0x08, /**< Number of internal average is 4. */
  259. HTS221_AVGT_8 = 0x10, /**< Number of internal average is 8. */
  260. HTS221_AVGT_16 = 0x18, /**< Number of internal average is 16. */
  261. HTS221_AVGT_32 = 0x20, /**< Number of internal average is 32. */
  262. HTS221_AVGT_64 = 0x28, /**< Number of internal average is 64. */
  263. HTS221_AVGT_128 = 0x30, /**< Number of internal average is 128. */
  264. HTS221_AVGT_256 = 0x38, /**< Number of internal average is 256. */
  265. }hts221_avgt_t;
  266. /**
  267. * @brief HTS221 block data update.
  268. */
  269. typedef enum {
  270. HTS221_BDU_CONTINUOUS = 0x00, /**< Block data continuously updated. */
  271. HTS221_BDU_BLOCKED = 0x40 /**< Block data updated after reading. */
  272. }hts221_bdu_t;
  273. /**
  274. * @brief Driver state machine possible states.
  275. */
  276. typedef enum {
  277. HTS221_UNINIT = 0, /**< Not initialized. */
  278. HTS221_STOP = 1, /**< Stopped. */
  279. HTS221_READY = 2, /**< Ready. */
  280. } hts221_state_t;
  281. /**
  282. * @brief HTS221 configuration structure.
  283. */
  284. typedef struct {
  285. #if HTS221_USE_SPI || defined(__DOXYGEN__)
  286. /**
  287. * @brief SPI driver associated to this HTS221.
  288. */
  289. SPIDriver *spip;
  290. /**
  291. * @brief SPI configuration associated to this HTS221.
  292. */
  293. const SPIConfig *spicfg;
  294. #endif /* HTS221_USE_SPI */
  295. #if HTS221_USE_I2C || defined(__DOXYGEN__)
  296. /**
  297. * @brief I2C driver associated to this HTS221.
  298. */
  299. I2CDriver *i2cp;
  300. /**
  301. * @brief I2C configuration associated to this HTS221.
  302. */
  303. const I2CConfig *i2ccfg;
  304. #endif /* HTS221_USE_I2C */
  305. /**
  306. * @brief HTS221 hygrometer subsystem initial sensitivity.
  307. */
  308. float *hygrosensitivity;
  309. /**
  310. * @brief HTS221 hygrometer subsystem initial bias.
  311. */
  312. float *hygrobias;
  313. /**
  314. * @brief HTS221 thermometer subsystem initial sensitivity.
  315. */
  316. float *thermosensitivity;
  317. /**
  318. * @brief HTS221 thermometer subsystem initial bias.
  319. */
  320. float *thermobias;
  321. /**
  322. * @brief HTS221 output data rate selection.
  323. */
  324. hts221_odr_t outputdatarate;
  325. #if HTS221_USE_ADVANCED || defined(__DOXYGEN__)
  326. /**
  327. * @brief HTS221 block data update.
  328. */
  329. hts221_bdu_t blockdataupdate;
  330. /**
  331. * @brief HTS221 hygrometer subsystem resolution.
  332. */
  333. hts221_avgh_t hygroresolution;
  334. /**
  335. * @brief HTS221 thermometer subsystem resolution.
  336. */
  337. hts221_avgt_t thermoresolution;
  338. #endif
  339. } HTS221Config;
  340. /**
  341. * @brief @p HTS221 specific methods.
  342. * @note No methods so far, just a common ancestor interface.
  343. */
  344. #define _hts221_methods_alone
  345. /**
  346. * @brief @p HTS221 specific methods with inherited ones.
  347. */
  348. #define _hts221_methods \
  349. _base_object_methods \
  350. _hts221_methods_alone
  351. /**
  352. * @extends BaseObjectVMT
  353. *
  354. * @brief @p HTS221 virtual methods table.
  355. */
  356. struct HTS221VMT {
  357. _hts221_methods
  358. };
  359. /**
  360. * @brief @p HTS221Driver specific data.
  361. */
  362. #define _hts221_data \
  363. /* Driver state.*/ \
  364. hts221_state_t state; \
  365. /* Current configuration data.*/ \
  366. const HTS221Config *config; \
  367. /* Hygrometer subsystem axes number.*/ \
  368. size_t hygroaxes; \
  369. /* Hygrometer subsystem current sensitivity.*/ \
  370. float hygrosensitivity; \
  371. /* Hygrometer subsystem current bias .*/ \
  372. float hygrobias; \
  373. /* Hygrometer subsystem factory sensitivity.*/ \
  374. float hygrofactorysensitivity; \
  375. /* Hygrometer subsystem factory bias .*/ \
  376. float hygrofactorybias; \
  377. /* Thermometer subsystem axes number.*/ \
  378. size_t thermoaxes; \
  379. /* Thermometer subsystem current sensitivity.*/ \
  380. float thermosensitivity; \
  381. /* Thermometer subsystem current bias.*/ \
  382. float thermobias; \
  383. /* Thermometer subsystem factory sensitivity.*/ \
  384. float thermofactorysensitivity; \
  385. /* Thermometer subsystem factory bias.*/ \
  386. float thermofactorybias;
  387. /**
  388. * @brief HTS221 2-axis hygrometer/thermometer class.
  389. */
  390. struct HTS221Driver {
  391. /** @brief Virtual Methods Table.*/
  392. const struct HTS221VMT *vmt;
  393. /** @brief Base hygrometer interface.*/
  394. BaseHygrometer hygro_if;
  395. /** @brief Base thermometer interface.*/
  396. BaseThermometer thermo_if;
  397. _hts221_data
  398. };
  399. /** @} */
  400. /*===========================================================================*/
  401. /* Driver macros. */
  402. /*===========================================================================*/
  403. /**
  404. * @brief Return the number of axes of the BaseHygrometer.
  405. *
  406. * @param[in] devp pointer to @p HTS221Driver.
  407. *
  408. * @return the number of axes.
  409. *
  410. * @api
  411. */
  412. #define hts221HygrometerGetAxesNumber(devp) \
  413. hygrometerGetAxesNumber(&((devp)->hygro_if))
  414. /**
  415. * @brief Retrieves raw data from the BaseHygrometer.
  416. * @note This data is retrieved from MEMS register without any algebraical
  417. * manipulation.
  418. * @note The axes array must be at least the same size of the
  419. * BaseHygrometer axes number.
  420. *
  421. * @param[in] devp pointer to @p HTS221Driver.
  422. * @param[out] axes a buffer which would be filled with raw data.
  423. *
  424. * @return The operation status.
  425. * @retval MSG_OK if the function succeeded.
  426. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  427. * be retrieved using @p i2cGetErrors().
  428. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  429. *
  430. * @api
  431. */
  432. #define hts221HygrometerReadRaw(devp, axes) \
  433. hygrometerReadRaw(&((devp)->hygro_if), axes)
  434. /**
  435. * @brief Retrieves cooked data from the BaseHygrometer.
  436. * @note This data is manipulated according to the formula
  437. * cooked = (raw * sensitivity) - bias.
  438. * @note Final data is expressed as %rH.
  439. * @note The axes array must be at least the same size of the
  440. * BaseHygrometer axes number.
  441. *
  442. * @param[in] devp pointer to @p HTS221Driver.
  443. * @param[out] axes a buffer which would be filled with cooked data.
  444. *
  445. * @return The operation status.
  446. * @retval MSG_OK if the function succeeded.
  447. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  448. * be retrieved using @p i2cGetErrors().
  449. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  450. *
  451. * @api
  452. */
  453. #define hts221HygrometerReadCooked(devp, axes) \
  454. hygrometerReadCooked(&((devp)->hygro_if), axes)
  455. /**
  456. * @brief Set bias values for the BaseHygrometer.
  457. * @note Bias must be expressed as %rH.
  458. * @note The bias buffer must be at least the same size of the
  459. * BaseHygrometer axes number.
  460. *
  461. * @param[in] devp pointer to @p HTS221Driver.
  462. * @param[in] bp a buffer which contains biases.
  463. *
  464. * @return The operation status.
  465. * @retval MSG_OK if the function succeeded.
  466. *
  467. * @api
  468. */
  469. #define hts221HygrometerSetBias(devp, bp) \
  470. hygrometerSetBias(&((devp)->hygro_if), bp)
  471. /**
  472. * @brief Reset bias values for the BaseHygrometer.
  473. * @note Default biases value are obtained from device datasheet when
  474. * available otherwise they are considered zero.
  475. *
  476. * @param[in] devp pointer to @p HTS221Driver.
  477. *
  478. * @return The operation status.
  479. * @retval MSG_OK if the function succeeded.
  480. *
  481. * @api
  482. */
  483. #define hts221HygrometerResetBias(devp) \
  484. hygrometerResetBias(&((devp)->hygro_if))
  485. /**
  486. * @brief Set sensitivity values for the BaseHygrometer.
  487. * @note Sensitivity must be expressed as %rH/LSB.
  488. * @note The sensitivity buffer must be at least the same size of the
  489. * BaseHygrometer axes number.
  490. *
  491. * @param[in] devp pointer to @p HTS221Driver.
  492. * @param[in] sp a buffer which contains sensitivities.
  493. *
  494. * @return The operation status.
  495. * @retval MSG_OK if the function succeeded.
  496. *
  497. * @api
  498. */
  499. #define hts221HygrometerSetSensitivity(devp, sp) \
  500. hygrometerSetSensitivity(&((devp)->hygro_if), sp)
  501. /**
  502. * @brief Reset sensitivity values for the BaseHygrometer.
  503. * @note Default sensitivities value are obtained from device datasheet.
  504. *
  505. * @param[in] devp pointer to @p HTS221Driver.
  506. *
  507. * @return The operation status.
  508. * @retval MSG_OK if the function succeeded.
  509. *
  510. * @api
  511. */
  512. #define hts221HygrometerResetSensitivity(devp) \
  513. hygrometerResetSensitivity(&((devp)->hygro_if))
  514. /**
  515. * @brief Return the number of axes of the BaseThermometer.
  516. *
  517. * @param[in] devp pointer to @p HTS221Driver.
  518. *
  519. * @return the number of axes.
  520. *
  521. * @api
  522. */
  523. #define hts221ThermometerGetAxesNumber(devp) \
  524. thermometerGetAxesNumber(&((devp)->thermo_if))
  525. /**
  526. * @brief Retrieves raw data from the BaseThermometer.
  527. * @note This data is retrieved from MEMS register without any algebraical
  528. * manipulation.
  529. * @note The axes array must be at least the same size of the
  530. * BaseThermometer axes number.
  531. *
  532. * @param[in] devp pointer to @p HTS221Driver.
  533. * @param[out] axes a buffer which would be filled with raw data.
  534. *
  535. * @return The operation status.
  536. * @retval MSG_OK if the function succeeded.
  537. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  538. * be retrieved using @p i2cGetErrors().
  539. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  540. *
  541. * @api
  542. */
  543. #define hts221ThermometerReadRaw(devp, axes) \
  544. thermometerReadRaw(&((devp)->thermo_if), axes)
  545. /**
  546. * @brief Retrieves cooked data from the BaseThermometer.
  547. * @note This data is manipulated according to the formula
  548. * cooked = (raw * sensitivity) - bias.
  549. * @note Final data is expressed as °C.
  550. * @note The axes array must be at least the same size of the
  551. * BaseThermometer axes number.
  552. *
  553. * @param[in] devp pointer to @p HTS221Driver.
  554. * @param[out] axes a buffer which would be filled with cooked data.
  555. *
  556. * @return The operation status.
  557. * @retval MSG_OK if the function succeeded.
  558. * @retval MSG_RESET if one or more I2C errors occurred, the errors can
  559. * be retrieved using @p i2cGetErrors().
  560. * @retval MSG_TIMEOUT if a timeout occurred before operation end.
  561. *
  562. * @api
  563. */
  564. #define hts221ThermometerReadCooked(devp, axes) \
  565. thermometerReadCooked(&((devp)->thermo_if), axes)
  566. /**
  567. * @brief Set bias values for the BaseThermometer.
  568. * @note Bias must be expressed as °C.
  569. * @note The bias buffer must be at least the same size of the
  570. * BaseThermometer axes number.
  571. *
  572. * @param[in] devp pointer to @p HTS221Driver.
  573. * @param[in] bp a buffer which contains biases.
  574. *
  575. * @return The operation status.
  576. * @retval MSG_OK if the function succeeded.
  577. *
  578. * @api
  579. */
  580. #define hts221ThermometerSetBias(devp, bp) \
  581. thermometerSetBias(&((devp)->thermo_if), bp)
  582. /**
  583. * @brief Reset bias values for the BaseThermometer.
  584. * @note Default biases value are obtained from device datasheet when
  585. * available otherwise they are considered zero.
  586. *
  587. * @param[in] devp pointer to @p HTS221Driver.
  588. *
  589. * @return The operation status.
  590. * @retval MSG_OK if the function succeeded.
  591. *
  592. * @api
  593. */
  594. #define hts221ThermometerResetBias(devp) \
  595. thermometerResetBias(&((devp)->thermo_if))
  596. /**
  597. * @brief Set sensitivity values for the BaseThermometer.
  598. * @note Sensitivity must be expressed as °C/LSB.
  599. * @note The sensitivity buffer must be at least the same size of the
  600. * BaseThermometer axes number.
  601. *
  602. * @param[in] devp pointer to @p HTS221Driver.
  603. * @param[in] sp a buffer which contains sensitivities.
  604. *
  605. * @return The operation status.
  606. * @retval MSG_OK if the function succeeded.
  607. *
  608. * @api
  609. */
  610. #define hts221ThermometerSetSensitivity(devp, sp) \
  611. thermometerSetSensitivity(&((devp)->thermo_if), sp)
  612. /**
  613. * @brief Reset sensitivity values for the BaseThermometer.
  614. * @note Default sensitivities value are obtained from device datasheet.
  615. *
  616. * @param[in] devp pointer to @p HTS221Driver.
  617. *
  618. * @return The operation status.
  619. * @retval MSG_OK if the function succeeded.
  620. *
  621. * @api
  622. */
  623. #define hts221ThermometerResetSensitivity(devp) \
  624. thermometerResetSensitivity(&((devp)->thermo_if))
  625. /*===========================================================================*/
  626. /* External declarations. */
  627. /*===========================================================================*/
  628. #ifdef __cplusplus
  629. extern "C" {
  630. #endif
  631. void hts221ObjectInit(HTS221Driver *devp);
  632. void hts221Start(HTS221Driver *devp, const HTS221Config *config);
  633. void hts221Stop(HTS221Driver *devp);
  634. #ifdef __cplusplus
  635. }
  636. #endif
  637. #endif /* _HTS221_H_ */
  638. /** @} */