lps25hb.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  1. /**
  2. ******************************************************************************
  3. * @file LPS25HB_Driver.h
  4. * @author HESA Application Team
  5. @version 1.0.0
  6. * @date 07/04/2014
  7. * @brief LPS25HB driver header file
  8. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  10. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  11. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  12. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  13. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  14. *
  15. * THIS SOURCE CODE IS PROTECTED BY A LICENSE.
  16. * FOR MORE INFORMATION PLEASE CAREFULLY READ THE LICENSE AGREEMENT FILE LOCATED
  17. * IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.
  18. *
  19. * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
  20. ******************************************************************************
  21. */
  22. /* Define to prevent recursive inclusion -------------------------------------*/
  23. #ifndef __LPS25HB_DRIVER__H
  24. #define __LPS25HB_DRIVER__H
  25. #include "esp_common.h"
  26. //include <stdint.h>
  27. // the user must include the proper file where HAL_ReadReg and HAL_WriteReg are implemented
  28. //#include "HAL_EnvSensors.h"
  29. /* Uncomment the line below to expanse the "assert_param" macro in the drivers code */
  30. //#define USE_FULL_ASSERT_LPS25HB
  31. /* Exported macro ------------------------------------------------------------*/
  32. #ifdef USE_FULL_ASSERT_LPS25HB
  33. /**
  34. * @brief The assert_param macro is used for function's parameters check.
  35. * @param expr: If expr is false, it calls assert_failed function which reports
  36. * the name of the source file and the source line number of the call
  37. * that failed. If expr is true, it returns no value.
  38. * @retval None
  39. */
  40. #define LPS25HB_assert_param(expr) ((expr) ? (void)0 : LPS25HB_assert_failed((uint8_t *)__FILE__, __LINE__))
  41. /* Exported functions ------------------------------------------------------- */
  42. void LPS25HB_assert_failed(uint8_t* file, uint32_t line);
  43. #else
  44. #define LPS25HB_assert_param(expr) ((void)0)
  45. #endif /* USE_FULL_ASSERT_LPS25HB */
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. /** @addtogroup Environmental_Sensor
  50. * @{
  51. */
  52. /** @addtogroup LPS25HB_DRIVER
  53. * @{
  54. */
  55. /* Exported Types -------------------------------------------------------------*/
  56. /** @defgroup LPS25HB_Exported_Types
  57. * @{
  58. */
  59. /**
  60. * @brief Error type.
  61. */
  62. typedef enum {LPS25HB_OK = (uint8_t)0, LPS25HB_ERROR = !LPS25HB_OK} LPS25HB_Error_et;
  63. /**
  64. * @brief Enable/Disable type.
  65. */
  66. typedef enum {LPS25HB_DISABLE = (uint8_t)0, LPS25HB_ENABLE = !LPS25HB_DISABLE} LPS25HB_State_et;
  67. #define IS_LPS25HB_State(MODE) ((MODE == LPS25HB_ENABLE) || (MODE == LPS25HB_DISABLE) )
  68. /**
  69. * @brief Bit status type.
  70. */
  71. typedef enum {LPS25HB_RESET = (uint8_t)0, LPS25HB_SET = !LPS25HB_RESET} LPS25HB_BitStatus_et;
  72. #define IS_LPS25HB_BitStatus(MODE) ((MODE == LPS25HB_RESET) || (MODE == LPS25HB_SET))
  73. /**
  74. * @brief Pressure average.
  75. */
  76. typedef enum {
  77. LPS25HB_AVGP_8 = (uint8_t)0x00, /*!< Internal average on 8 samples */
  78. LPS25HB_AVGP_32 = (uint8_t)0x01, /*!< Internal average on 32 samples */
  79. LPS25HB_AVGP_128 = (uint8_t)0x02, /*!< Internal average on 128 samples */
  80. LPS25HB_AVGP_512 = (uint8_t)0x03 /*!< Internal average on 512 sample */
  81. }LPS25HB_Avgp_et;
  82. #define IS_LPS25HB_AVGP(AVGP) ((AVGP == LPS25HB_AVGP_8) || (AVGP == LPS25HB_AVGP_32) || \
  83. (AVGP == LPS25HB_AVGP_128) || (AVGP == LPS25HB_AVGP_512))
  84. /**
  85. * @brief Temperature average.
  86. */
  87. typedef enum {
  88. LPS25HB_AVGT_8 = (uint8_t)0x00, /*!< Internal average on 8 samples */
  89. LPS25HB_AVGT_16 = (uint8_t)0x04, /*!< Internal average on 16 samples */
  90. LPS25HB_AVGT_32 = (uint8_t)0x08, /*!< Internal average on 32 samples */
  91. LPS25HB_AVGT_64 = (uint8_t)0x0C /*!< Internal average on 64 samples */
  92. }LPS25HB_Avgt_et;
  93. #define IS_LPS25HB_AVGT(AVGT) ((AVGT == LPS25HB_AVGT_8) || (AVGT == LPS25HB_AVGT_16) || \
  94. (AVGT == LPS25HB_AVGT_32) || (AVGT == LPS25HB_AVGT_64))
  95. /**
  96. * @brief Output data rate configuration.
  97. */
  98. typedef enum {
  99. LPS25HB_ODR_ONE_SHOT = (uint8_t)0x00, /*!< Output Data Rate: one shot */
  100. LPS25HB_ODR_1HZ = (uint8_t)0x10, /*!< Output Data Rate: 1Hz */
  101. LPS25HB_ODR_7HZ = (uint8_t)0x20, /*!< Output Data Rate: 7Hz */
  102. LPS25HB_ODR_12_5HZ = (uint8_t)0x30, /*!< Output Data Rate: 12.5Hz */
  103. LPS25HB_ODR_25HZ = (uint8_t)0x40 /*!< Output Data Rate: 25Hz */
  104. } LPS25HB_Odr_et;
  105. #define IS_LPS25HB_ODR(ODR) ((ODR == LPS25HB_ODR_ONE_SHOT) || (ODR == LPS25HB_ODR_1HZ) || \
  106. (ODR == LPS25HB_ODR_7HZ) || (ODR == LPS25HB_ODR_12_5HZ)|| (ODR == LPS25HB_ODR_25HZ))
  107. /**
  108. * @brief LPS25HB Spi Mode configuration.
  109. */
  110. typedef enum {
  111. LPS25HB_SPI_4_WIRE = (uint8_t)0x00,
  112. LPS25HB_SPI_3_WIRE = (uint8_t)0x01
  113. } LPS25HB_SPIMode_et;
  114. #define IS_LPS25HB_SPIMode(MODE) ((MODE == LPS25HB_SPI_4_WIRE) || (MODE == LPS25HB_SPI_3_WIRE))
  115. /**
  116. * @brief Block data update.
  117. */
  118. typedef enum {
  119. LPS25HB_BDU_CONTINUOUS_UPDATE = (uint8_t)0x00, /*!< Data updated continuously */
  120. LPS25HB_BDU_NO_UPDATE = (uint8_t)0x04 /*!< Data updated after a read operation */
  121. } LPS25HB_Bdu_et;
  122. #define IS_LPS25HB_BDUMode(MODE) ((MODE == LPS25HB_BDU_CONTINUOUS_UPDATE) || (MODE == LPS25HB_BDU_NO_UPDATE))
  123. /**
  124. * @brief Data Signal on INT1 pad control bits.
  125. */
  126. typedef enum
  127. {
  128. LPS25HB_DATA = (uint8_t)0x00,
  129. LPS25HB_P_HIGH = (uint8_t)0x01,
  130. LPS25HB_P_LOW = (uint8_t)0x02,
  131. LPS25HB_P_LOW_HIGH = (uint8_t)0x03
  132. }LPS25HB_OutputSignalConfig_et;
  133. #define IS_LPS25HB_OutputSignal(MODE) ((MODE == LPS25HB_DATA) || (MODE == LPS25HB_P_HIGH)||\
  134. (MODE == LPS25HB_P_LOW) || (MODE == LPS25HB_P_LOW_HIGH))
  135. /**
  136. * @brief LPS25HB INT1 Interrupt pins configuration.
  137. */
  138. typedef enum
  139. {
  140. LPS25HB_DISABLE_DATA_INT = (uint8_t)0x00,
  141. LPS25HB_DATA_READY = (uint8_t)0x01,
  142. LPS25HB_OVR = (uint8_t)0x02,
  143. LPS25HB_WTM = (uint8_t)0x04,
  144. LPS25HB_EMPTY = (uint8_t)0x08
  145. }LPS25HB_DataSignalType_et;
  146. #define IS_LPS25HB_DataSignal(MODE) ((MODE == LPS25HB_DISABLE_DATA_INT) ||(MODE == LPS25HB_EMPTY) || (MODE ==LPS25HB_WTM)||\
  147. (MODE == LPS25HB_OVR) || (MODE == LPS25HB_DATA_READY))
  148. /**
  149. * @brief LPS25HB Push-pull/Open Drain selection on Interrupt pads.
  150. */
  151. typedef enum
  152. {
  153. LPS25HB_PushPull = (uint8_t)0x00,
  154. LPS25HB_OpenDrain = (uint8_t)0x40
  155. }LPS25HB_OutputType_et;
  156. #define IS_LPS25HB_OutputType(MODE) ((MODE == LPS25HB_PushPull) || (MODE == LPS25HB_OpenDrain))
  157. /**
  158. * @brief LPS25HB Interrupt Differential Configuration.
  159. */
  160. typedef enum
  161. {
  162. LPS25HB_DISABLE_INT = (uint8_t)0x00,
  163. LPS25HB_PHE = (uint8_t)0x01,
  164. LPS25HB_PLE = (uint8_t)0x02,
  165. LPS25HB_PLE_PHE = (uint8_t)0x03
  166. }LPS25HB_InterruptDiffConfig_et;
  167. #define IS_LPS25HB_InterruptDiff(MODE) ((MODE == LPS25HB_DISABLE_INT) || (MODE ==LPS25HB_PHE)||\
  168. (MODE == LPS25HB_PLE) || (MODE == LPS25HB_PLE_PHE))
  169. /**
  170. * @brief LPS25HB Interrupt Differential Status.
  171. */
  172. typedef struct
  173. {
  174. uint8_t PH; /*!< High Differential Pressure event occured */
  175. uint8_t PL; /*!< Low Differential Pressure event occured */
  176. uint8_t IA; /*!< One or more interrupt events have been generated.Interrupt Active */
  177. }LPS25HB_InterruptDiffStatus_st;
  178. /**
  179. * @brief LPS25HB Pressure and Temperature data status.
  180. */
  181. typedef struct
  182. {
  183. uint8_t TempDataAvailable; /*!< Temperature data available bit */
  184. uint8_t PressDataAvailable; /*!< Pressure data available bit */
  185. uint8_t TempDataOverrun; /*!< Temperature data over-run bit */
  186. uint8_t PressDataOverrun; /*!< Pressure data over-run bit */
  187. }LPS25HB_DataStatus_st;
  188. /**
  189. * @brief LPS25HB Fifo Mode.
  190. */
  191. typedef enum {
  192. LPS25HB_FIFO_BYPASS_MODE = (uint8_t)0x00, /*!< The FIFO is disabled and empty. The pressure is read directly*/
  193. LPS25HB_FIFO_MODE = (uint8_t)0x20, /*!< Stops collecting data when full */
  194. LPS25HB_FIFO_STREAM_MODE = (uint8_t)0x40, /*!< Keep the newest measurements in the FIFO*/
  195. LPS25HB_FIFO_TRIGGER_STREAMTOFIFO_MODE = (uint8_t)0x60, /*!< STREAM MODE until trigger deasserted, then change to FIFO MODE*/
  196. LPS25HB_FIFO_TRIGGER_BYPASSTOSTREAM_MODE = (uint8_t)0x80, /*!< BYPASS MODE until trigger deasserted, then STREAM MODE*/
  197. LPS25HB_FIFO_MEAN_MODE = (uint8_t)0xC0, /*!< FIFO is used to generate a running average filtered pressure */
  198. LPS25HB_FIFO_TRIGGER_BYPASSTOFIFO_MODE = (uint8_t)0xE0 /*!< BYPASS mode until trigger deasserted, then FIFO MODE*/
  199. } LPS25HB_FifoMode_et;
  200. #define IS_LPS25HB_FifoMode(MODE) ((MODE == LPS25HB_FIFO_BYPASS_MODE) || (MODE ==LPS25HB_FIFO_MODE)||\
  201. (MODE == LPS25HB_FIFO_STREAM_MODE) || (MODE == LPS25HB_FIFO_TRIGGER_STREAMTOFIFO_MODE)||\
  202. (MODE == LPS25HB_FIFO_TRIGGER_BYPASSTOSTREAM_MODE) || (MODE == LPS25HB_FIFO_MEAN_MODE)||\
  203. (MODE == LPS25HB_FIFO_TRIGGER_BYPASSTOFIFO_MODE))
  204. /**
  205. * @brief LPS25HB Fifo Mean Mode Sample Size.
  206. */
  207. typedef enum {
  208. LPS25HB_FIFO_SAMPLE_2 = (uint8_t)0x01, /*!< 2 Fifo Mean Mode samples */
  209. LPS25HB_FIFO_SAMPLE_4 = (uint8_t)0x03, /*!< 4 Fifo Mean Mode samples */
  210. LPS25HB_FIFO_SAMPLE_8 = (uint8_t)0x07, /*!< 8 Fifo Mean Mode samples */
  211. LPS25HB_FIFO_SAMPLE_16 = (uint8_t)0x0F, /*!< 16 Fifo Mean Mode samples */
  212. LPS25HB_FIFO_SAMPLE_32 = (uint8_t)0x1F /*!< 32 Fifo Mean Mode samples */
  213. } LPS25HB_FifoMeanModeSample_et;
  214. #define IS_LPS25HB_FifoMeanModeSample(MODE) ((MODE == LPS25HB_FIFO_SAMPLE_2) || (MODE ==LPS25HB_FIFO_SAMPLE_4)||\
  215. (MODE == LPS25HB_FIFO_SAMPLE_8) || (MODE == LPS25HB_FIFO_SAMPLE_16)||\
  216. (MODE == LPS25HB_FIFO_SAMPLE_32))
  217. /**
  218. * @brief LPS25HB Fifo Satus.
  219. */
  220. typedef struct {
  221. uint8_t FIFO_LEVEL; /*!< FIFO Stored data level t */
  222. uint8_t FIFO_EMPTY; /*!< Empy FIFO bit.1 FIFO is empty */
  223. uint8_t FIFO_FULL; /*!< Overrun bit status. 1 FIFO is full */
  224. uint8_t FIFO_WTM; /*!< Watermark Status. 1 FIFO is equal or higher then wtm level.*/
  225. }LPS25HB_FifoStatus_st;
  226. /**
  227. * @brief LPS25HB Configuration structure definition.
  228. */
  229. typedef struct
  230. {
  231. LPS25HB_Avgp_et PressResolution; /*!< Pressure sensor resolution */
  232. LPS25HB_Avgt_et TempResolution; /*!< Temperature sensor resolution */
  233. LPS25HB_Odr_et OutputDataRate; /*!< Output Data Rate */
  234. LPS25HB_Bdu_et BDU; /*!< Enable to inhibit the output registers update between the reading of upper and lower register parts.*/
  235. LPS25HB_State_et AutoZero; /*! < Auto zero feature enabled.the actual pressure output is copied in the REF_P*/
  236. LPS25HB_State_et Reset_AZ; /*!< Reset the Auto ZeroFunc. The daefualt RPDS value is copied in REF_P */
  237. LPS25HB_SPIMode_et Sim; /*!< SPI Serial Interface Mode selection */
  238. }LPS25HB_ConfigTypeDef_st;
  239. /**
  240. * @brief LPS25HB Interrupt structure definition .
  241. */
  242. typedef struct {
  243. LPS25HB_State_et INT_H_L; /*!< Interrupt active high, low. Default value: 0 */
  244. LPS25HB_OutputType_et PP_OD; /*!< Push-pull/open drain selection on interrupt pads. Default value: 0 */
  245. LPS25HB_OutputSignalConfig_et OutputSignal_INT1; /*!< Data signal on INT1 Pad: Data,Pressure High, Preessure Low,P High or Low*/
  246. LPS25HB_DataSignalType_et DataInterrupt_INT1; /*!< Interrupt Pin Config:DRDY, WTM, OVERRUN, EMPTY*/
  247. LPS25HB_InterruptDiffConfig_et PressureInterrupt; /*!< Interrupt differential Configuration: PL_E and/or PH_E*/
  248. LPS25HB_State_et LatchIRQ; /*!< Latch Interrupt request in to INT_SOURCE reg*/
  249. int16_t fP_threshold; /*!< Threshold value for pressure interrupt generation*/
  250. }LPS25HB_InterruptTypeDef_st;
  251. /**
  252. * @brief LPS25HB FIFO structure definition.
  253. */
  254. typedef struct {
  255. LPS25HB_FifoMode_et FIFO_MODE; /*!< Fifo Mode Selection */
  256. LPS25HB_State_et WTM_INT; /*!< Enable/Disable the watermark interrupt*/
  257. LPS25HB_State_et FIFO_MEAN_DEC; /*!< Enable/Disable 1 Hz ODR decimation */
  258. LPS25HB_FifoMeanModeSample_et MEAN_MODE_SAMPLE; /*!< FIFO Mean Mode Sample Size*/
  259. uint8_t WTM_LEVEL; /*!< FIFO threshold.Watermark level setting*/
  260. }LPS25HB_FIFOTypeDef_st;
  261. #define IS_LPS25HB_WtmLevel(LEVEL) ((LEVEL > 0) && (LEVEL <=31))
  262. /**
  263. * @brief LPS25HB Measure Type definition.
  264. */
  265. typedef struct {
  266. int16_t Tout;
  267. int32_t Pout;
  268. }LPS25HB_MeasureTypeDef_st;
  269. /**
  270. * @brief LPS25HB Driver Version Info structure definition.
  271. */
  272. typedef struct {
  273. uint8_t Major;
  274. uint8_t Minor;
  275. uint8_t Point;
  276. }LPS25HB_DriverVersion_st;
  277. /**
  278. * @brief Bitfield positioning.
  279. */
  280. #define LPS25HB_BIT(x) ((uint8_t)x)
  281. /**
  282. * @brief I2C address.
  283. */
  284. /*SDO/SA0 (pin5) is connected to the GND*/
  285. #define LPS25HB_ADDRESS (uint8_t)0xB8
  286. /* SD0/SA0(pin 5) is connected to the voltage supply*/
  287. //#define LPS25HB_ADDRESS (uint8_t)0xBA //SA0=1
  288. /**
  289. * @brief Set the LPS25HB driver version.
  290. */
  291. #define LPS25HB_DriverVersion_Major (uint8_t)1
  292. #define LPS25HB_DriverVersion_Minor (uint8_t)0
  293. #define LPS25HB_DriverVersion_Point (uint8_t)0
  294. /**
  295. * @}
  296. */
  297. /* Exported Constants ---------------------------------------------------------*/
  298. /** @defgroup LPS25HB_Exported_Constants
  299. * @{
  300. */
  301. /**
  302. * @addtogroup LPS25HB_Register
  303. * @{
  304. */
  305. /**
  306. * @brief Device Identification register.
  307. * \code
  308. * Read
  309. * Default value: 0xBD
  310. * 7:0 This read-only register contains the device identifier that, for LPS25HB, is set to BDh.
  311. * \endcode
  312. */
  313. #define LPS25HB_WHO_AM_I_REG (uint8_t)0x0F
  314. /**
  315. * @brief Device Identification value.
  316. */
  317. #define LPS25HB_WHO_AM_I_VAL (uint8_t)0xBD
  318. /**
  319. * @brief Reference Pressure Register(LSB data)
  320. * \code
  321. * Read/write
  322. * Default value: 0x00
  323. * 7:0 REFL7-0: Lower part of the reference pressure value that
  324. * is sum to the sensor output pressure.
  325. * \endcode
  326. */
  327. #define LPS25HB_REF_P_XL_REG (uint8_t)0x08
  328. /**
  329. * @brief Reference Pressure Register (Middle data)
  330. * \code
  331. * Read/write
  332. * Default value: 0x00
  333. * 7:0 REFL15-8: Middle part of the reference pressure value that
  334. * is sum to the sensor output pressure.
  335. * \endcode
  336. */
  337. #define LPS25HB_REF_P_L_REG (uint8_t)0x09
  338. /**
  339. * @brief Reference Pressure Register (MSB data)
  340. * \code
  341. * Read/write
  342. * Default value: 0x00
  343. * 7:0 REFL23-16 Higest part of the reference pressure value that
  344. * is sum to the sensor output pressure.
  345. * \endcode
  346. */
  347. #define LPS25HB_REF_P_H_REG (uint8_t)0x0A
  348. /**
  349. * @brief Pressure and temperature resolution mode Register
  350. * \code
  351. * Read/write
  352. * Default value: 0x05
  353. * 7:4 RFU
  354. * 3:2 AVGT1-AVGT0: Select the temperature internal average.
  355. * AVGT1 | AVGT0 | Nr. Internal Average
  356. * ------------------------------------------------------
  357. * 0 | 0 | 8
  358. * 0 | 1 | 16
  359. * 1 | 0 | 32
  360. * 1 | 1 | 64
  361. *
  362. * 1:0 AVGP1-AVGP0: Select pressure internal average.
  363. * AVGP1 | AVGP0 | Nr. Internal Average
  364. * ------------------------------------------------------
  365. * 0 | 0 | 8
  366. * 0 | 1 | 32
  367. * 1 | 0 | 128
  368. * 1 | 1 | 512
  369. * \endcode
  370. */
  371. #define LPS25HB_RES_CONF_REG (uint8_t)0x10
  372. #define LPS25HB_AVGT_BIT LPS25HB_BIT(2)
  373. #define LPS25HB_AVGP_BIT LPS25HB_BIT(0)
  374. #define LPS25HB_AVGT_MASK (uint8_t)0x0C
  375. #define LPS25HB_AVGP_MASK (uint8_t)0x03
  376. /**
  377. * @brief Control Register 1
  378. * \code
  379. * Read/write
  380. * Default value: 0x00
  381. * 7 PD: power down control. 0 - power down mode; 1 - active mode
  382. * 6:4 ODR2, ODR1, ODR0: output data rate selection.
  383. * ODR2 | ODR1 | ODR0 | Pressure output data-rate(Hz) | Pressure output data-rate(Hz)
  384. * ----------------------------------------------------------------------------------
  385. * 0 | 0 | 0 | one shot | one shot
  386. * 0 | 0 | 1 | 1 | 1
  387. * 0 | 1 | 0 | 7 | 7
  388. * 0 | 1 | 1 | 12.5 | 12.5
  389. * 1 | 0 | 0 | 25 | 25
  390. * 1 | 0 | 1 | Reserved | Reserved
  391. * 1 | 1 | 0 | Reserved | Reserved
  392. * 1 | 1 | 1 | Reserved | Reserved
  393. *
  394. * 3 DIFF_EN: Interrupt circuit Enable. 0 - interrupt generation disable; 1 - interrupt generation enable
  395. * 2 BDU: block data update. 0 - continuous update; 1 - output registers not updated until MSB and LSB reading.
  396. * 1 RESET_AZ: Reset AutoZero Function. Reset Ref_P reg, set pressure to default value in RDPS reg. 0 - disable;1 - Reset
  397. * 0 SIM: SPI Serial Interface Mode selection. 0 - SPI 4-wire; 1 - SPI 3-wire
  398. * \endcode
  399. */
  400. #define LPS25HB_CTRL_REG1 (uint8_t)0x20
  401. #define LPS25HB_PD_BIT LPS25HB_BIT(7)
  402. #define LPS25HB_ODR_BIT LPS25HB_BIT(4)
  403. #define LPS25HB_DIFF_EN_BIT LPS25HB_BIT(3)
  404. #define LPS25HB_BDU_BIT LPS25HB_BIT(2)
  405. #define LPS25HB_RESET_AZ_BIT LPS25HB_BIT(1)
  406. #define LPS25HB_SIM_BIT LPS25HB_BIT(0)
  407. #define LPS25HB_PD_MASK (uint8_t)0x80
  408. #define LPS25HB_ODR_MASK (uint8_t)0x70
  409. #define LPS25HB_DIFF_EN_MASK (uint8_t)0x08
  410. #define LPS25HB_BDU_MASK (uint8_t)0x04
  411. #define LPS25HB_RESET_AZ_MASK (uint8_t)0x02
  412. #define LPS25HB_SIM_MASK (uint8_t)0x01
  413. /**
  414. * @brief Control Register 2
  415. * \code
  416. * Read/write
  417. * Default value: 0x00
  418. * 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content. Self-clearing upon completation
  419. * 6 FIFO_EN: FIFO Enable. 0: disable; 1: enable
  420. * 5 WTM_EN: FIFO Watermark level use. 0: disable; 1: enable
  421. * 4 FIFO_MEAN_DEC: Enable 1 HZ decimation 0: enable; 1: disable
  422. * 3 I2C Enable: 0: I2C Enable; 1: SPI disable
  423. * 2 SWRESET: Software reset. 0: normal mode; 1: SW reset. Self-clearing upon completation
  424. * 1 AUTO_ZERO: Autozero enable. 0: normal mode; 1: autozero enable.
  425. * 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset
  426. * \endcode
  427. */
  428. #define LPS25HB_CTRL_REG2 (uint8_t)0x21
  429. #define LPS25HB_BOOT_BIT LPS25HB_BIT(7)
  430. #define LPS25HB_FIFO_EN_BIT LPS25HB_BIT(6)
  431. #define LPS25HB_WTM_EN_BIT LPS25HB_BIT(5)
  432. #define LPS25HB_FIFO_MEAN_BIT LPS25HB_BIT(4)
  433. #define LPS25HB_I2C_BIT LPS25HB_BIT(3)
  434. #define LPS25HB_SW_RESET_BIT LPS25HB_BIT(2)
  435. #define LPS25HB_AUTO_ZERO_BIT LPS25HB_BIT(1)
  436. #define LPS25HB_ONE_SHOT_BIT LPS25HB_BIT(0)
  437. #define LPS25HB_BOOT_MASK (uint8_t)0x80
  438. #define LPS25HB_FIFO_EN_MASK (uint8_t)0x40
  439. #define LPS25HB_WTM_EN_MASK (uint8_t)0x20
  440. #define LPS25HB_FIFO_MEAN_MASK (uint8_t)0x10
  441. #define LPS25HB_I2C_MASK (uint8_t)0x08
  442. #define LPS25HB_SW_RESET_MASK (uint8_t)0x04
  443. #define LPS25HB_AUTO_ZERO_MASK (uint8_t)0x02
  444. #define LPS25HB_ONE_SHOT_MASK (uint8_t)0x01
  445. /**
  446. * @brief CTRL Reg3 Interrupt Control Register
  447. * \code
  448. * Read/write
  449. * Default value: 0x00
  450. * 7 INT_H_L: Interrupt active high, low. 0:active high; 1: active low.
  451. * 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: Push-pull; 1: open drain.
  452. * 5:2 Reserved
  453. * 1:0 INT1_S2, INT1_S1: data signal on INT1 pad control bits.
  454. * INT1_S2 | INT1_S1 | INT1 pin
  455. * ------------------------------------------------------
  456. * 0 | 0 | Data signal
  457. * 0 | 1 | Pressure high (P_high)
  458. * 1 | 0 | Pressure low (P_low)
  459. * 1 | 1 | P_low OR P_high
  460. * \endcode
  461. */
  462. #define LPS25HB_CTRL_REG3 (uint8_t)0x22
  463. #define LPS25HB_INT_H_L_BIT LPS25HB_BIT(7)
  464. #define LPS25HB_PP_OD_BIT LPS25HB_BIT(6)
  465. #define LPS25HB_INT1_S2_BIT LPS25HB_BIT(1)
  466. #define LPS25HB_INT1_S1_BIT LPS25HB_BIT(0)
  467. #define LPS25HB_INT_H_L_MASK (uint8_t)0x80
  468. #define LPS25HB_PP_OD_MASK (uint8_t)0x40
  469. #define LPS25HB_INT1_S2_MASK (uint8_t)0x02
  470. #define LPS25HB_INT1_S1_MASK (uint8_t)0x01
  471. /**
  472. * @brief CTRL Reg4 Interrupt Configuration Register
  473. * \code
  474. * Read/write
  475. * Default value: 0x00
  476. * 7:4 Reserved: Keep these bits at 0
  477. * 3 P1_EMPTY: Empty Signal on INT1 pin.
  478. * 2 P1_WTM: Watermark Signal on INT1 pin.
  479. * 1 P1_Overrunn:Overrun Signal on INT1 pin.
  480. * 0 P1_DRDY: Data Ready Signal on INT1 pin.
  481. * \endcode
  482. */
  483. #define LPS25HB_CTRL_REG4 (uint8_t)0x23
  484. #define LPS25HB_P1_EMPTY_BIT LPS25HB_BIT(3)
  485. #define LPS25HB_P1_WTM_BIT LPS25HB_BIT(2)
  486. #define LPS25HB_P1_OVERRUN_BIT LPS25HB_BIT(1)
  487. #define LPS25HB_P1_DRDY_BIT LPS25HB_BIT(0)
  488. #define LPS25HB_P1_EMPTY_MASK (uint8_t)0x08
  489. #define LPS25HB_P1_WTM_MASK (uint8_t)0x04
  490. #define LPS25HB_P1_OVERRUN_MASK (uint8_t)0x02
  491. #define LPS25HB_P1_DRDY_MASK (uint8_t)0x01
  492. /**
  493. * @brief Interrupt Differential configuration Register
  494. * \code
  495. * Read/write
  496. * Default value: 0x00.
  497. * 7:3 Reserved.
  498. * 2 LIR: Latch Interrupt request into INT_SOURCE register. 0 - interrupt request not latched; 1 - interrupt request latched
  499. * 1 PL_E: Enable interrupt generation on differential pressure low event. 0 - disable; 1 - enable
  500. * 0 PH_E: Enable interrupt generation on differential pressure high event. 0 - disable; 1 - enable
  501. * \endcode
  502. */
  503. #define LPS25HB_INTERRUPT_CFG_REG (uint8_t)0x24
  504. #define LPS25HB_LIR_BIT LPS25HB_BIT(2)
  505. #define LPS25HB_PL_E_BIT LPS25HB_BIT(1)
  506. #define LPS25HB_PH_E_BIT LPS25HB_BIT(0)
  507. #define LPS25HB_LIR_MASK (uint8_t)0x04
  508. #define LPS25HB_PL_E_MASK (uint8_t)0x02
  509. #define LPS25HB_PH_E_MASK (uint8_t)0x01
  510. #define LPS25HB_PE_MASK (uint8_t)0x03
  511. /**
  512. * @brief Interrupt source Register (It is cleared by reading it)
  513. * \code
  514. * Read
  515. * Default value: 0x00.
  516. * 7:3 Reserved: Keep these bits at 0
  517. * 2 IA: Interrupt Active.0: no interrupt has been generated; 1: one or more interrupt events have been generated.
  518. * 1 PL: Differential pressure Low. 0: no interrupt has been generated; 1: Low differential pressure event has occurred.
  519. * 0 PH: Differential pressure High. 0: no interrupt has been generated; 1: High differential pressure event has occurred.
  520. * \endcode
  521. */
  522. #define LPS25HB_INTERRUPT_SOURCE_REG (uint8_t)0x25
  523. #define LPS25HB_IA_BIT LPS25HB_BIT(2)
  524. #define LPS25HB_PL_BIT LPS25HB_BIT(1)
  525. #define LPS25HB_PH_BIT LPS25HB_BIT(0)
  526. #define LPS25HB_IA_MASK (uint8_t)0x04
  527. #define LPS25HB_PL_MASK (uint8_t)0x02
  528. #define LPS25HB_PH_MASK (uint8_t)0x01
  529. /**
  530. * @brief Status Register
  531. * \code
  532. * Read
  533. * Default value: 0x00
  534. * 7:6 Reserved: 0
  535. * 5 P_OR: Pressure data overrun. 0: no overrun has occurred; 1: new data for pressure has overwritten the previous one.
  536. * 4 T_OR: Temperature data overrun. 0: no overrun has occurred; 1: a new data for temperature has overwritten the previous one.
  537. * 3:2 Reserved: 0
  538. * 1 P_DA: Pressure data available. 0: new data for pressure is not yet available; 1: new data for pressure is available.
  539. * 0 T_DA: Temperature data available. 0: new data for temperature is not yet available; 1: new data for temperature is available.
  540. * \endcode
  541. */
  542. #define LPS25HB_STATUS_REG (uint8_t)0x27
  543. #define LPS25HB_POR_BIT LPS25HB_BIT(5)
  544. #define LPS25HB_TOR_BIT LPS25HB_BIT(4)
  545. #define LPS25HB_PDA_BIT LPS25HB_BIT(1)
  546. #define LPS25HB_TDA_BIT LPS25HB_BIT(0)
  547. #define LPS25HB_POR_MASK (uint8_t)0x20
  548. #define LPS25HB_TOR_MASK (uint8_t)0x10
  549. #define LPS25HB_PDA_MASK (uint8_t)0x02
  550. #define LPS25HB_TDA_MASK (uint8_t)0x01
  551. /**
  552. * @brief Pressure data (LSB) register.
  553. * \code
  554. * Read
  555. * Default value: 0x00.(To be verified)
  556. * POUT7 - POUT0: Pressure data LSB (2's complement).
  557. * Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
  558. * PRESS_OUT_XL)[dec]/4096.
  559. * \endcode
  560. */
  561. #define LPS25HB_PRESS_OUT_XL_REG (uint8_t)0x28
  562. /**
  563. * @brief Pressure data (Middle part) register.
  564. * \code
  565. * Read
  566. * Default value: 0x80.
  567. * POUT15 - POUT8: Pressure data middle part (2's complement).
  568. * Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
  569. * PRESS_OUT_XL)[dec]/4096.
  570. * \endcode
  571. */
  572. #define LPS25HB_PRESS_OUT_L_REG (uint8_t)0x29
  573. /**
  574. * @brief Pressure data (MSB) register.
  575. * \code
  576. * Read
  577. * Default value: 0x2F.
  578. * POUT23 - POUT16: Pressure data MSB (2's complement).
  579. * Pressure output data: Pout(hPA)=(PRESS_OUT_H & PRESS_OUT_L &
  580. * PRESS_OUT_XL)[dec]/4096.
  581. * \endcode
  582. */
  583. #define LPS25HB_PRESS_OUT_H_REG (uint8_t)0x2A
  584. /**
  585. * @brief Temperature data (LSB) register.
  586. * \code
  587. * Read
  588. * Default value: 0x00.
  589. * TOUT7 - TOUT0: temperature data LSB.
  590. * T(degC) = 42.5 + (Temp_OUTH & TEMP_OUT_L)[dec]/480.
  591. * \endcode
  592. */
  593. #define LPS25HB_TEMP_OUT_L_REG (uint8_t)0x2B
  594. /**
  595. * @brief Temperature data (MSB) register.
  596. * \code
  597. * Read
  598. * Default value: 0x00.
  599. * TOUT15 - TOUT8: temperature data MSB.
  600. * T(degC) = 42.5 + (Temp_OUTH & TEMP_OUT_L)[dec]/480.
  601. * \endcode
  602. */
  603. #define LPS25HB_TEMP_OUT_H_REG (uint8_t)0x2C
  604. /**
  605. * @brief Threshold pressure (LSB) register.
  606. * \code
  607. * Read/write
  608. * Default value: 0x00.
  609. * 7:0 THS7-THS0: LSB Threshold pressure Low part of threshold value for pressure interrupt
  610. * generation. The complete threshold value is given by THS_P_H & THS_P_L and is
  611. * expressed as unsigned number. P_ths(hPA)=(THS_P_H & THS_P_L)[dec]/16.
  612. * \endcode
  613. */
  614. #define LPS25HB_THS_P_LOW_REG (uint8_t)0x30
  615. /**
  616. * @brief Threshold pressure (MSB)
  617. * \code
  618. * Read/write
  619. * Default value: 0x00.
  620. * 7:0 THS15-THS8: MSB Threshold pressure. High part of threshold value for pressure interrupt
  621. * generation. The complete threshold value is given by THS_P_H & THS_P_L and is
  622. * expressed as unsigned number. P_ths(mbar)=(THS_P_H & THS_P_L)[dec]/16.
  623. * \endcode
  624. */
  625. #define LPS25HB_THS_P_HIGH_REG (uint8_t)0x31
  626. /**
  627. * @brief FIFO control register
  628. * \code
  629. * Read/write
  630. * Default value: 0x00
  631. * 7:5 F_MODE2, F_MODE1, F_MODE0: FIFO mode selection.
  632. * FM2 | FM1 | FM0 | FIFO MODE
  633. * ---------------------------------------------------
  634. * 0 | 0 | 0 | BYPASS MODE
  635. * 0 | 0 | 1 | FIFO MODE. Stops collecting data when full
  636. * 0 | 1 | 0 | STREAM MODE: Keep the newest measurements in the FIFO
  637. * 0 | 1 | 1 | STREAM MODE until trigger deasserted, then change to FIFO MODE
  638. * 1 | 0 | 0 | BYPASS MODE until trigger deasserted, then STREAM MODE
  639. * 1 | 0 | 1 | Reserved for future use
  640. * 1 | 1 | 0 | FIFO_MEAN MODE: Fifo is used to generate a running average filtered pressure
  641. * 1 | 1 | 1 | BYPASS mode until trigger deasserted, then FIFO MODE
  642. *
  643. * 4:0 WTM_POINT4-0 : FIFO threshold.Watermark level setting (0-31)
  644. * 4:0 WTM_POINT4-0 is FIFO Mean Mode Sample size if FIFO_MEAN MODE is used
  645. * WTM_POINT4 | WTM_POINT4 | WTM_POINT4 | WTM_POINT4 | WTM_POINT4 | Sample Size
  646. * ----------------------------------------------------------------------------------
  647. * 0 | 0 | 0 | 0 | 1 | 2
  648. * 0 | 0 | 0 | 1 | 1 | 4
  649. * 0 | 0 | 1 | 1 | 1 | 8
  650. * 0 | 1 | 1 | 1 | 1 | 16
  651. * 1 | 1 | 1 | 1 | 1 | 32
  652. * other values operation not guaranteed
  653. * \endcode
  654. */
  655. #define LPS25HB_CTRL_FIFO_REG (uint8_t)0x2E
  656. #define LPS25HB_FMODE_BIT LPS25HB_BIT(5)
  657. #define LPS25HB_WTM_POINT_BIT LPS25HB_BIT(0)
  658. #define LPS25HB_FMODE_MASK (uint8_t)0xE0
  659. #define LPS25HB_WTM_POINT_MASK (uint8_t)0x1F
  660. /**
  661. * @brief FIFO Status register
  662. * \code
  663. * Read
  664. * Default value: 0x00
  665. * 7 WTM_FIFO: Watermark status. 0:FIFO filling is lower than watermark level; 1: FIFO is equal or higher than watermark level.
  666. * 6 FULL_FIFO: Overrun bit status. 0 - FIFO not full; 1 -FIFO is full.
  667. * 5 EMPTY_FIFO: Empty FIFO bit. 0 - FIFO not empty; 1 -FIFO is empty.
  668. * 4:0 DIFF_POINT4-0: FIFOsStored data level.
  669. * \endcode
  670. */
  671. #define LPS25HB_STATUS_FIFO_REG (uint8_t)0x2F
  672. #define LPS25HB_WTM_FIFO_BIT LPS25HB_BIT(7)
  673. #define LPS25HB_FULL_FIFO_BIT LPS25HB_BIT(6)
  674. #define LPS25HB_EMPTY_FIFO_BIT LPS25HB_BIT(5)
  675. #define LPS25HB_DIFF_POINT_BIT LPS25HB_BIT(0)
  676. #define LPS25HB_WTM_FIFO_MASK (uint8_t)0x80
  677. #define LPS25HB_FULL_FIFO_MASK (uint8_t)0x40
  678. #define LPS25HB_EMPTY_FIFO_MASK (uint8_t)0x20
  679. #define LPS25HB_DIFF_POINT_MASK (uint8_t)0x1F
  680. /**
  681. * @brief Pressure offset register (LSB)
  682. * \code
  683. * Read/write
  684. * Default value: 0x00
  685. * 7:0 RPDS7-0:Pressure Offset for 1 point calibration after soldering.
  686. * This register contains the low part of the pressure offset value after soldering,for
  687. * differential pressure computing. The complete value is given by RPDS_L & RPDS_H
  688. * and is expressed as signed 2 complement value.
  689. * \endcode
  690. */
  691. #define LPS25HB_RPDS_L_REG (uint8_t)0x39
  692. /**
  693. * @brief Pressure offset register (MSB)
  694. * \code
  695. * Read/write
  696. * Default value: 0x00
  697. * 7:0 RPDS15-8:Pressure Offset for 1 point calibration after soldering.
  698. * This register contains the high part of the pressure offset value after soldering (see description RPDS_L)
  699. * \endcode
  700. */
  701. #define LPS25HB_RPDS_H_REG (uint8_t)0x3A
  702. /**
  703. * @}
  704. */
  705. /**
  706. * @}
  707. */
  708. /* Exported Functions -------------------------------------------------------------*/
  709. /** @defgroup LPS25HB_Exported_Functions
  710. * @{
  711. */
  712. /**
  713. * @brief Init the HAL layer.
  714. * @param None
  715. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  716. */
  717. #define LPS25HB_HalInit HAL_Init_I2C
  718. /**
  719. * @brief DeInit the HAL layer.
  720. * @param None
  721. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  722. */
  723. #define LPS25HB_HalDeInit HAL_DeInit_I2C
  724. /**
  725. * @brief Read LPS25HB Registers
  726. * @param uint32_t RegAddr: address of the first register to read
  727. * @param uint32_t NumByteToRead: number of registers to read
  728. * @param uint8_t *Data: pointer to the destination data buffer
  729. * @retval LPS25HB_ERROR or LPS25HB_OK
  730. */
  731. // the user must redefine the proper LPS25HB_ReadReg
  732. #define LPS25HB_ReadReg(RegAddr, NumByteToRead, Data) Sensor_IO_Read(RegAddr, NumByteToRead, Data)
  733. /**
  734. * @brief Write LPS25HB Registers
  735. * @param uint32_t RegAddr: address of the register to write
  736. * @param uint8_t *Data: pointer to the source data buffer
  737. * @param uint32_t NumByteToWrite: Number of bytes to write
  738. * @retval LPS25HB_ERROR or LPS25HB_OK
  739. */
  740. // the user must redefine the proper LPS25HB_WriteReg
  741. #define LPS25HB_WriteReg(RegAddr, NumByteToWrite, Data) Sensor_IO_Write(RegAddr, NumByteToWrite, Data)
  742. /**
  743. * @brief Get the LPS25HB driver version.
  744. * @param None
  745. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  746. */
  747. LPS25HB_Error_et LPS25HB_Get_DriverVersion(LPS25HB_DriverVersion_st *Version);
  748. /**
  749. * @brief DeInit the LPS25HB driver.
  750. * @param None
  751. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  752. */
  753. LPS25HB_Error_et LPS25HB_DeInit(void);
  754. /**
  755. * @brief Exit the shutdown mode for LPS25HB.
  756. * @param None
  757. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  758. */
  759. LPS25HB_Error_et LPS25HB_Activate(void);
  760. /**
  761. * @brief Enter the shutdown mode for LPS25HB.
  762. * @param None
  763. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  764. */
  765. LPS25HB_Error_et LPS25HB_DeActivate(void);
  766. /**
  767. * @brief Check if the single measurement has completed.
  768. * @param value is set to 1, when the measure is completed
  769. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  770. */
  771. LPS25HB_Error_et LPS25HB_IsMeasurementCompleted(uint8_t *Is_Measurement_Completed);
  772. /**
  773. * @brief Get the values of the last single measurement.
  774. * @param Pressure and temperature value
  775. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  776. */
  777. LPS25HB_Error_et LPS25HB_Get_Measurement(LPS25HB_MeasureTypeDef_st *Measurement_Value);
  778. /**
  779. * @brief Get the Reference Pressure value that is sum to the sensor output pressure
  780. * @param buffer to empty with reference pressure value
  781. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  782. */
  783. LPS25HB_Error_et LPS25HB_Get_ReferencePressure(int32_t *RefP);
  784. /*Sensor Configuration Functions*/
  785. /*CTRL_REG1*/
  786. /**
  787. * @brief Set LPS25HB Power Down Mode
  788. * @param BSET/BRESET bit in order to SET/RESET LPS25HB Power Down Mode bit
  789. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  790. */
  791. LPS25HB_Error_et LPS25HB_Set_PowerDownMode(LPS25HB_BitStatus_et powerdown);
  792. /**
  793. * @brief Sets LPS25HB Pressure and Temperature Resolution Mode
  794. * @param Pressure and Temperature Resolution Congiguration
  795. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  796. */
  797. LPS25HB_Error_et LPS25HB_Set_Avg(LPS25HB_Avgp_et avgp,LPS25HB_Avgt_et avgt);
  798. /**
  799. * @brief Sets LPS25HB Pressure Resolution Mode
  800. * @param Pressure Resolution Congiguration
  801. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  802. */
  803. LPS25HB_Error_et LPS25HB_Set_AvgP(LPS25HB_Avgp_et avgp);
  804. /**
  805. * @brief Sets LPS25HB Temperature Resolution Mode
  806. * @param Temperature Resolution Congiguration
  807. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  808. */
  809. LPS25HB_Error_et LPS25HB_Set_AvgT(LPS25HB_Avgt_et avgt);
  810. /**
  811. * @brief Gets LPS25HB Pressure Resolution Mode
  812. * @param value to empty
  813. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  814. */
  815. LPS25HB_Error_et LPS25HB_Get_AvgP(LPS25HB_Avgp_et* avgpress);
  816. /**
  817. * @brief Gets LPS25HB Temperature Resolution Mode
  818. * @param value to empty
  819. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  820. */
  821. LPS25HB_Error_et LPS25HB_Get_AvgT(LPS25HB_Avgt_et* avgtemp);
  822. /**
  823. * @brief Set the Output Data Rate
  824. * @param Output Data Rate Value
  825. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  826. */
  827. LPS25HB_Error_et LPS25HB_Set_Odr(LPS25HB_Odr_et odr);
  828. /**
  829. * @brief Get the Output Data Rate
  830. * @param Output Data Rate Value
  831. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  832. */
  833. LPS25HB_Error_et LPS25HB_Get_Odr(LPS25HB_Odr_et* odr);
  834. /**
  835. * @brief Enable/ Disable the Interrupt Circuit
  836. * @param LPS25HB_ENABLE,LPS25HB_DISABLE
  837. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  838. */
  839. LPS25HB_Error_et LPS25HB_Set_InterruptCircuitEnable(LPS25HB_State_et diff_en) ;
  840. /**
  841. * @brief Get the DIFF_EN bit value
  842. * @param buffer
  843. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  844. */
  845. LPS25HB_Error_et LPS25HB_Get_InterruptCircuitEnable(LPS25HB_State_et* diff_en);
  846. /**
  847. * @brief Set Block Data Update mode
  848. * @param LPS25HB_BDU_CONTINUOS_UPDATE/ LPS25HB_BDU_NO_UPDATE
  849. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  850. */
  851. LPS25HB_Error_et LPS25HB_Set_BDU(LPS25HB_Bdu_et bdu);
  852. /**
  853. * @brief Get Block Data Update mode
  854. * @param
  855. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  856. */
  857. LPS25HB_Error_et LPS25HB_Get_BDU(LPS25HB_Bdu_et* bdu);
  858. /**
  859. * @brief Reset the Auto ZeroFunc. The defualt RPDS value is copied in REF_P
  860. * @param void
  861. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  862. */
  863. LPS25HB_Error_et LPS25HB_ResetAZ(void);
  864. /**
  865. * @brief Set SPI mode: 3 Wire Interface OR 4 Wire Interface
  866. * @param LPS25HB_SPI_4_WIRE/LPS25HB_SPI_3_WIRE
  867. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  868. */
  869. LPS25HB_Error_et LPS25HB_Set_SpiInterface(LPS25HB_SPIMode_et spimode);
  870. /**
  871. * @brief Get SPI mode: 3 Wire Interface OR 4 Wire Interface
  872. * @param buffer to empty with SPI mode
  873. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  874. */
  875. LPS25HB_Error_et LPS25HB_Get_SpiInterface(LPS25HB_SPIMode_et* spimode);
  876. /**
  877. * @brief Enable/Disable I2C
  878. * @param State. Enable (reset bit)/ Disable (set bit)
  879. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  880. */
  881. LPS25HB_Error_et LPS25HB_Set_I2C(LPS25HB_State_et i2cstate);
  882. /**
  883. * @brief Set One Shot bit to start a new conversion (ODR mode has to be 000)
  884. * @param void
  885. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  886. */
  887. LPS25HB_Error_et LPS25HB_StartOneShotMeasurement(void);
  888. /**
  889. * @brief Set AutoZero Function bit
  890. * @param Bit action: LPS25HB_BitRESET/LPS25HB_BitSET
  891. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  892. */
  893. LPS25HB_Error_et LPS25HB_Set_AutoZeroFunction(LPS25HB_BitStatus_et autozero);
  894. /**
  895. * @brief Software Reset
  896. * @param void
  897. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  898. */
  899. LPS25HB_Error_et LPS25HB_SwReset(void);
  900. /**
  901. * @brief Reboot Memory Content.
  902. * @param void
  903. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  904. */
  905. LPS25HB_Error_et LPS25HB_MemoryBoot(void);
  906. /**
  907. * @brief Software Reset ann BOOT
  908. * @param void
  909. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  910. */
  911. LPS25HB_Error_et LPS25HB_SwResetAndMemoryBoot(void);
  912. /**
  913. * @brief Enable or Disable FIFO
  914. * @param LPS25HB_ENABLE/LPS25HB_DISABLE
  915. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  916. */
  917. LPS25HB_Error_et LPS25HB_Set_FifoModeUse(LPS25HB_State_et status);
  918. /**
  919. * @brief Enable or Disable FIFO Watermark level use
  920. * @param LPS25HB_ENABLE/LPS25HB_DISABLE
  921. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  922. */
  923. LPS25HB_Error_et LPS25HB_Set_FifoWatermarkLevelUse(LPS25HB_State_et status);
  924. /**
  925. * @brief Enable or Disable 1 HZ ODR Decimation
  926. * @param LPS25HB_ENABLE/LPS25HB_DISABLE
  927. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  928. */
  929. LPS25HB_Error_et LPS25HB_Set_FifoMeanDecUse(LPS25HB_State_et status);
  930. /*CTRL_REG3 Interrupt Control*/
  931. /**
  932. * @brief Set Interrupt Active on High or Low Level
  933. * @param LPS25HB_ENABLE/LPS25HB_DISABLE
  934. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  935. */
  936. LPS25HB_Error_et LPS25HB_Set_InterruptActiveLevel(LPS25HB_State_et status);
  937. /**
  938. * @brief Set Push-pull/open drain selection on interrupt pads.
  939. * @param LPS25HB_PushPull/LPS25HB_OpenDrain
  940. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  941. */
  942. LPS25HB_Error_et LPS25HB_Set_InterruptOutputType(LPS25HB_OutputType_et output);
  943. /**
  944. * @brief Set Data signal on INT1 pad control bits.
  945. * @param LPS25HB_DATA,LPS25HB_P_HIGH_LPS25HB_P_LOW,LPS25HB_P_LOW_HIGH
  946. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  947. */
  948. LPS25HB_Error_et LPS25HB_Set_InterruptControlConfig(LPS25HB_OutputSignalConfig_et config);
  949. /**
  950. * @brief Set INT1 interrupt pins configuration.
  951. * @param LPS25HB_EMPTY,LPS25HB_WTM,LPS25HB_OVR,LPS25HB_DATA_READY
  952. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  953. */
  954. LPS25HB_Error_et LPS25HB_Set_InterruptDataConfig(LPS25HB_DataSignalType_et signal);
  955. /**
  956. * @brief Enable\Disable Interrupt Generation on differential pressure low and/or high event
  957. * @param LPS25HB_DISABLE_INT, LPS25HB_PHE,LPS25HB_PLE,LPS25HB_PLE_PHE
  958. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  959. */
  960. LPS25HB_Error_et LPS25HB_Set_InterruptDifferentialConfig(LPS25HB_InterruptDiffConfig_et config);
  961. /**
  962. * @brief Latch Interrupt request into INT_SOURCE register.
  963. * @param LPS25HB_ENABLE/LPS25HB_DISABLE
  964. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  965. */
  966. LPS25HB_Error_et LPS25HB_LatchInterruptRequest(LPS25HB_State_et status);
  967. /**
  968. * @brief Get the Status of low-high differential pressure event
  969. * @param Status Event Flag: PH,PL,IA
  970. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  971. */
  972. LPS25HB_Error_et LPS25HB_Get_InterruptDifferentialEventStatus(LPS25HB_InterruptDiffStatus_st* interruptsource);
  973. /**
  974. * @brief Get the status of Pressure and Temperature data
  975. * @param Data Status Flag: TempDataAvailable, TempDataOverrun, PressDataAvailable, PressDataOverrun
  976. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  977. */
  978. LPS25HB_Error_et LPS25HB_Get_DataStatus(LPS25HB_DataStatus_st* datastatus);
  979. /**
  980. * @brief Read LPS25HB output register, and calculate the raw pressure
  981. * @param The buffer to empty with the pressure raw value
  982. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  983. */
  984. LPS25HB_Error_et LPS25HB_Get_RawPressure(int32_t *raw_press);
  985. /**
  986. * @brief Read the Pressure value in mbar.
  987. * @param The buffer to empty with the pressure value that must be divided by 100 to get the value in hPA
  988. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  989. */
  990. LPS25HB_Error_et LPS25HB_Get_Pressure(int32_t* Pout);
  991. /**
  992. * @brief Read LPS25HB output register, and calculate the raw temperature.
  993. * @param The buffer to empty with the temperature raw value
  994. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  995. */
  996. LPS25HB_Error_et LPS25HB_Get_RawTemperature(int16_t *raw_data);
  997. /**
  998. * @brief Read the Temperature value in �C.
  999. * @param The buffer to empty with the temperature value that must be divided by 10 to get the value in ['C]
  1000. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1001. */
  1002. LPS25HB_Error_et LPS25HB_Get_Temperature(int16_t* Tout);
  1003. /**
  1004. * @brief Get the threshold value used for pressure interrupt generation.
  1005. * @param The buffer to empty with the temperature value
  1006. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1007. */
  1008. LPS25HB_Error_et LPS25HB_Get_PressureThreshold(int16_t *P_ths);
  1009. /**
  1010. * @brief Set the threshold value used for pressure interrupt generation.
  1011. * @param The buffer to empty with the temperature value
  1012. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1013. */
  1014. LPS25HB_Error_et LPS25HB_Set_PressureThreshold(int16_t P_ths);
  1015. /**
  1016. * @brief Set Fifo Mode.
  1017. * @param FifoModee struct
  1018. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1019. */
  1020. LPS25HB_Error_et LPS25HB_Set_FifoMode(LPS25HB_FifoMode_et fifomode);
  1021. /**
  1022. * @brief Get Fifo Mode.
  1023. * @param Buffer to empty with fifo mode value
  1024. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1025. */
  1026. LPS25HB_Error_et LPS25HB_Get_FifoMode(LPS25HB_FifoMode_et* fifomode);
  1027. /**
  1028. * @brief Get Fifo Status.
  1029. * @param Buffer to empty with fifo mode value
  1030. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1031. */
  1032. LPS25HB_Error_et LPS25HB_Get_FifoStatus(LPS25HB_FifoStatus_st* status);
  1033. /**
  1034. * @brief Set Fifo Watermark Level.
  1035. * @param Wtm level value [0 31]
  1036. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1037. */
  1038. LPS25HB_Error_et LPS25HB_Set_FifoWatermarkLevel(uint8_t wtmlevel);
  1039. /**
  1040. * @brief Get Fifo Watermark Level
  1041. * @param Buffer to empty with wtm value
  1042. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1043. */
  1044. LPS25HB_Error_et LPS25HB_Get_FifoWatermarkLevel(uint8_t *wtmlevel);
  1045. /**
  1046. * @brief Set the number of sample to perform moving average when FIFO_MEAN_MODE is used
  1047. * @param 2,4,8,16 32 samples moving average value
  1048. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1049. */
  1050. LPS25HB_Error_et LPS25HB_Set_FifoSampleSize(LPS25HB_FifoMeanModeSample_et samplesize);
  1051. /**
  1052. * @brief Get FiFo Sample size
  1053. * @param 2,4,8,16 32 samples moving average value
  1054. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1055. */
  1056. LPS25HB_Error_et LPS25HB_Get_FifoSampleSize(LPS25HB_FifoMeanModeSample_et* samplesize);
  1057. /**
  1058. * @brief Get Device ID
  1059. * @param value to empty with Identification Device
  1060. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1061. */
  1062. LPS25HB_Error_et LPS25HB_Get_DeviceID(uint8_t* deviceid);
  1063. /**
  1064. * @brief Get the reference pressure after soldering for computing differential pressure
  1065. * @param buffer to empty with pressure value
  1066. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1067. */
  1068. LPS25HB_Error_et LPS25HB_Get_PressureOffsetValue(int16_t *pressoffset);
  1069. /**
  1070. * @brief Set Generic configuration
  1071. * @param Struct holding the configuration values
  1072. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1073. */
  1074. LPS25HB_Error_et LPS25HB_Set_GenericConfig(LPS25HB_ConfigTypeDef_st* pxLPS25HBInit);
  1075. /**
  1076. * @brief Get Generic configuration
  1077. * @param Struct to empty with configuration values
  1078. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1079. */
  1080. LPS25HB_Error_et LPS25HB_Get_GenericConfig(LPS25HB_ConfigTypeDef_st* pxLPS25HBInit);
  1081. /**
  1082. * @brief Set Interrupt configuration
  1083. * @param Struct holding the configuration values
  1084. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1085. */
  1086. LPS25HB_Error_et LPS25HB_Set_InterruptConfig(LPS25HB_InterruptTypeDef_st* pLPS25HBInt);
  1087. /**
  1088. * @brief LPS25HB_Get_InterruptConfig
  1089. * @param Struct to empty with configuration values
  1090. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1091. */
  1092. LPS25HB_Error_et LPS25HB_Get_InterruptConfig(LPS25HB_InterruptTypeDef_st* pLPS25HBInt);
  1093. /**
  1094. * @brief Set Fifo configuration
  1095. * @param Struct holding the configuration values
  1096. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1097. */
  1098. LPS25HB_Error_et LPS25HB_Set_FifoConfig(LPS25HB_FIFOTypeDef_st* pLPS25HBFIFO);
  1099. /**
  1100. * @brief Get Fifo configuration
  1101. * @param Struct to empty with the configuration values
  1102. * @retval Status [LPS25HB_ERROR, LPS25HB_OK]
  1103. */
  1104. LPS25HB_Error_et LPS25HB_Get_FifoConfig(LPS25HB_FIFOTypeDef_st* pLPS25HBFIFO);
  1105. #ifdef __cplusplus
  1106. }
  1107. #endif
  1108. /**
  1109. * @}
  1110. */
  1111. /**
  1112. * @}
  1113. */
  1114. /**
  1115. * @}
  1116. */
  1117. #endif /* __LPS25HB_DRIVER__H */
  1118. /******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/