Library for supporting the Nucleo Sensor Shield.
Dependents: Nucleo_Sensors_Demo m2x-temp_ethernet_demo m2x-MEMS_ACKme_Wifi_demo m2x_MEMS_Ublox_Cellular_demo ... more
Fork of Nucleo_Sensor_Shield by
hts221_platform.h
00001 /** 00002 ****************************************************************************** 00003 * @file hts221.h 00004 * @author MEMS Application Team 00005 * @version V1.0.0 00006 * @date 30-July-2014 00007 * @brief This file contains definitions for the hts221.c 00008 * firmware driver. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 00040 /* Define to prevent recursive inclusion -------------------------------------*/ 00041 #ifndef __HTS221_PLATFORM_H 00042 #define __HTS221_PLATFORM_H 00043 00044 /** @addtogroup HTS221 00045 * @{ 00046 */ 00047 00048 /** @defgroup HTS221_Exported_Constants 00049 * @{ 00050 */ 00051 00052 /** 00053 * @brief Device Address 00054 */ 00055 #define HTS221_ADDRESS 0xBE 00056 00057 /******************************************************************************/ 00058 /*************************** START REGISTER MAPPING **************************/ 00059 /******************************************************************************/ 00060 00061 00062 /** 00063 * @brief Device identification register. 00064 * \code 00065 * Read 00066 * Default value: 0xBC 00067 * 7:0 This read-only register contains the device identifier that, for HTS221, is set to BCh. 00068 * \endcode 00069 */ 00070 #define HTS221_WHO_AM_I_ADDR 0x0F 00071 00072 00073 /** 00074 * @brief Humidity resolution Register 00075 * \code 00076 * Read/write 00077 * Default value: 0x1B 00078 * 7:6 RFU 00079 * 5:3 AVGT2-AVGT0: Temperature internal average. 00080 * AVGT2 | AVGT1 | AVGT0 | Nr. Internal Average 00081 * ------------------------------------------------------ 00082 * 0 | 0 | 0 | 2 00083 * 0 | 0 | 1 | 4 00084 * 0 | 1 | 0 | 8 00085 * 0 | 1 | 1 | 16 00086 * 1 | 0 | 0 | 32 00087 * 1 | 0 | 1 | 64 00088 * 1 | 1 | 0 | 128 00089 * 1 | 1 | 1 | 256 00090 * 00091 * 2:0 AVGH2-AVGH0: Humidity internal average. 00092 * AVGH2 | AVGH1 | AVGH0 | Nr. Internal Average 00093 * ------------------------------------------------------ 00094 * 0 | 0 | 0 | 4 00095 * 0 | 0 | 1 | 8 00096 * 0 | 1 | 0 | 16 00097 * 0 | 1 | 1 | 32 00098 * 1 | 0 | 0 | 64 00099 * 1 | 0 | 1 | 128 00100 * 1 | 1 | 0 | 256 00101 * 1 | 1 | 1 | 512 00102 * 00103 * \endcode 00104 */ 00105 #define HTS221_RES_CONF_ADDR 0x10 00106 00107 00108 /** 00109 * @brief INFO Register (LSB data) 00110 * \code 00111 * Read/write 00112 * Default value: 0x00 00113 * 7:0 INFO7-INFO0: Lower part of the INFO reference 00114 * used for traceability of the sample. 00115 * \endcode 00116 */ 00117 #define HTS221_INFO_L_ADDR 0x1E 00118 00119 00120 /** 00121 * @brief INFO & Calibration Version Register (LSB data) 00122 * \code 00123 * Read/write 00124 * Default value: 0x00 00125 * 7:6 CALVER1:CALVER0 00126 * 5:0 INFO13-INFO8: Higher part of the INFO reference 00127 * used for traceability of the sample. 00128 * \endcode 00129 */ 00130 #define HTS221_INFO_H_ADDR 0x1F 00131 00132 00133 /** 00134 * @brief Humidity sensor control register 1 00135 * \code 00136 * Read/write 00137 * Default value: 0x00 00138 * 7 PD: power down control. 0 - disable; 1 - enable 00139 * 6:3 RFU 00140 * 2 BDU: block data update. 0 - disable; 1 - enable 00141 * 1:0 RFU 00142 * \endcode 00143 */ 00144 00145 #define HTS221_CTRL_REG1_ADDR 0x20 00146 00147 00148 /** 00149 * @brief Humidity sensor control register 2 00150 * \code 00151 * Read/write 00152 * Default value: 0x00 00153 * 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content 00154 * 6:3 Reserved. 00155 * 2 Reserved. 00156 * 1 Reserved. 00157 * 0 ONE_SHOT: One shot enable. 0: waiting for start of conversion; 1: start for a new dataset 00158 * \endcode 00159 */ 00160 #define HTS221_CTRL_REG2_ADDR 0x21 00161 00162 00163 /** 00164 * @brief Humidity sensor control register 3 00165 * \code 00166 * Read/write 00167 * Default value: 0x00 00168 * [7] DRDY_H_L: Data Ready output signal active high, low (0: active high -default;1: active low) 00169 * [6] PP_OD: Push-pull / Open Drain selection on pin 3 (DRDY) (0: push-pull - default; 1: open drain) 00170 * [5:3] Reserved 00171 * [2] DRDY_EN: Data Ready enable (0: Data Ready disabled - default;1: Data Ready signal available on pin 3) 00172 * [1:0] Reserved 00173 * \endcode 00174 */ 00175 #define HTS221_CTRL_REG3_ADDR 0x22 00176 00177 00178 /** 00179 * @brief Status Register 00180 * \code 00181 * Read 00182 * Default value: 0x00 00183 * 7:2 RFU 00184 * 1 H_DA: Humidity data available. 0: new data for Humidity is not yet available; 1: new data for Humidity is available. 00185 * 0 T_DA: Temperature data available. 0: new data for temperature is not yet available; 1: new data for temperature is available. 00186 * \endcode 00187 */ 00188 #define HTS221_STATUS_REG_ADDR 0x27 00189 00190 00191 /** 00192 * @brief Humidity data (LSB). 00193 * \code 00194 * Read 00195 * Default value: 0x00. 00196 * POUT7 - POUT0: Humidity data LSB (2's complement) => signed 16 bits 00197 * RAW Humidity output data: Hout(%)=(HUMIDITY_OUT_H & HUMIDITY_OUT_L). 00198 * \endcode 00199 */ 00200 #define HTS221_HUMIDITY_OUT_L_ADDR 0x28 00201 00202 00203 /** 00204 * @brief Humidity data (MSB). 00205 * \code 00206 * Read 00207 * Default value: 0x00. 00208 * POUT7 - POUT0: Humidity data LSB (2's complement) => signed 16 bits 00209 * RAW Humidity output data: Hout(%)=(HUMIDITY_OUT_H & HUMIDITY_OUT_L). 00210 * \endcode 00211 */ 00212 #define HTS221_HUMIDITY_OUT_H_ADDR 0x29 00213 00214 00215 /** 00216 * @brief Temperature data (LSB). 00217 * \code 00218 * Read 00219 * Default value: 0x00. 00220 * TOUT7 - TOUT0: temperature data LSB (2's complement) => signed 16 bits 00221 * RAW Temperature output data: Tout (LSB)=(TEMP_OUT_H & TEMP_OUT_L). 00222 * \endcode 00223 */ 00224 #define HTS221_TEMP_OUT_L_ADDR 0x2A 00225 00226 00227 /** 00228 * @brief Temperature data (MSB). 00229 * \code 00230 * Read 00231 * Default value: 0x00. 00232 * TOUT15 - TOUT8: temperature data MSB (2's complement) => signed 16 bits 00233 * RAW Temperature output data: Tout (LSB)=(TEMP_OUT_H & TEMP_OUT_L). 00234 * \endcode 00235 */ 00236 #define HTS221_TEMP_OUT_H_ADDR 0x2B 00237 00238 00239 /* 00240 *@brief Humidity 0 Register in %RH with sensitivity=2 00241 *\code 00242 * Read 00243 * Value: (Unsigned 8 Bit)/2 00244 *\endcode 00245 */ 00246 #define HTS221_H0_RH_X2_ADDR 0x30 00247 00248 00249 /* 00250 *@brief Humidity 1 Register in %RH with sensitivity=2 00251 *\code 00252 * Read 00253 * Value: (Unsigned 8 Bit)/2 00254 *\endcode 00255 */ 00256 #define HTS221_H1_RH_X2_ADDR 0x31 00257 00258 00259 /* 00260 *@brief Temperature 0 Register in deg with sensitivity=8 00261 *\code 00262 * Read 00263 * Value: (Unsigned 16 Bit)/2 00264 *\endcode 00265 */ 00266 #define HTS221_T0_degC_X8_ADDR 0x32 00267 00268 00269 /* 00270 *@brief Temperature 1 Register in deg with sensitivity=8 00271 *\code 00272 * Read 00273 * Value: (Unsigned 16 Bit)/2 00274 *\endcode 00275 */ 00276 #define HTS221_T1_degC_X8_ADDR 0x33 00277 00278 00279 /* 00280 *@brief Temperature 1/0 MSB Register in deg with sensitivity=8 00281 *\code 00282 * Read 00283 * Value: (Unsigned 16 Bit)/2 00284 * 3:2 T1(9):T1(8) MSB T1_degC_X8 bits 00285 * 1:0 T0(9):T0(8) MSB T0_degC_X8 bits 00286 *\endcode 00287 */ 00288 #define HTS221_T1_T0_MSB_X8_ADDR 0x35 00289 00290 00291 /* 00292 *@brief Humidity LOW CALIBRATION Register 00293 *\code 00294 * Read 00295 * Default value: 0x00. 00296 * H0_T0_TOUT7 - H0_T0_TOUT0: HUMIDITY data lSB (2's complement) => signed 16 bits 00297 *\endcode 00298 */ 00299 #define HTS221_H0_T0_OUT_L_ADDR 0x36 00300 00301 00302 /* 00303 *@brief Humidity LOW CALIBRATION Register 00304 *\code 00305 * Read 00306 * Default value: 0x00. 00307 * H0_T0_TOUT15 - H0_T0_TOUT8: HUMIDITY data mSB (2's complement) => signed 16 bits 00308 *\endcode 00309 */ 00310 #define HTS221_H0_T0_OUT_H_ADDR 0x37 00311 00312 00313 /* 00314 *@brief Humidity HIGH CALIBRATION Register 00315 *\code 00316 * Read 00317 * Default value: 0x00. 00318 * H1_T0_TOUT7 - H1_T0_TOUT0: HUMIDITY data lSB (2's complement) => signed 16 bits 00319 *\endcode 00320 */ 00321 #define HTS221_H1_T0_OUT_L_ADDR 0x3A 00322 00323 00324 /* 00325 *@brief Humidity HIGH CALIBRATION Register 00326 *\code 00327 * Read 00328 * Default value: 0x00. 00329 * H1_T0_TOUT15 - H1_T0_TOUT8: HUMIDITY data mSB (2's complement) => signed 16 bits 00330 *\endcode 00331 */ 00332 #define HTS221_H1_T0_OUT_H_ADDR 0x3B 00333 00334 00335 /** 00336 * @brief Low Calibration Temperature Register (LSB). 00337 * \code 00338 * Read 00339 * Default value: 0x00. 00340 * T0_OUT7 - T0_OUT0: temperature data LSB (2's complement) => signed 16 bits 00341 * RAW LOW Calibration data: T0_OUT (LSB)=(T0_OUT_H & T0_OUT_L). 00342 * \endcode 00343 */ 00344 #define HTS221_T0_OUT_L_ADDR 0x3C 00345 00346 00347 /** 00348 * @brief Low Calibration Temperature Register (MSB) 00349 * \code 00350 * Read 00351 * Default value: 0x00. 00352 * T0_OUT15 - T0_OUT8: temperature data MSB (2's complement) => signed 16 bits 00353 * RAW LOW Calibration data: T0_OUT (LSB)=(T0_OUT_H & T0_OUT_L). 00354 * \endcode 00355 */ 00356 #define HTS221_T0_OUT_H_ADDR 0x3D 00357 00358 00359 /** 00360 * @brief Low Calibration Temperature Register (LSB). 00361 * \code 00362 * Read 00363 * Default value: 0x00. 00364 * T1_OUT7 - T1_OUT0: temperature data LSB (2's complement) => signed 16 bits 00365 * RAW LOW Calibration data: T1_OUT (LSB)=(T1_OUT_H & T1_OUT_L). 00366 * \endcode 00367 */ 00368 #define HTS221_T1_OUT_L_ADDR 0x3E 00369 00370 00371 /** 00372 * @brief Low Calibration Temperature Register (MSB) 00373 * \code 00374 * Read 00375 * Default value: 0x00. 00376 * T1_OUT15 - T1_OUT8: temperature data MSB (2's complement) => signed 16 bits 00377 * RAW LOW Calibration data: T1_OUT (LSB)=(T1_OUT_H & T1_OUT_L). 00378 * \endcode 00379 */ 00380 #define HTS221_T1_OUT_H_ADDR 0x3F 00381 00382 00383 /******************************************************************************/ 00384 /**************************** END REGISTER MAPPING ***************************/ 00385 /******************************************************************************/ 00386 00387 00388 /** 00389 * @brief Device Identifier. Default value of the WHO_AM_I register. 00390 */ 00391 #define I_AM_HTS221 ((uint8_t)0xBC) 00392 00393 00394 /** @defgroup HTS221 Power Mode selection - CTRL_REG1 00395 * @{ 00396 */ 00397 #define HTS221_MODE_POWERDOWN ((uint8_t)0x00) 00398 #define HTS221_MODE_ACTIVE ((uint8_t)0x80) 00399 00400 #define HTS221_MODE_MASK ((uint8_t)0x80) 00401 /** 00402 * @} 00403 */ 00404 00405 00406 /** @defgroup HTS221 Block Data Update Mode selection - CTRL_REG1 00407 * @{ 00408 */ 00409 #define HTS221_BDU_CONTINUOUS ((uint8_t)0x00) 00410 #define HTS221_BDU_NOT_UNTIL_READING ((uint8_t)0x04) 00411 00412 #define HTS221_BDU_MASK ((uint8_t)0x04) 00413 /** 00414 * @} 00415 */ 00416 00417 /** @defgroup HTS221 Output Data Rate selection - CTRL_REG1 00418 * @{ 00419 */ 00420 #define HTS221_ODR_ONE_SHOT ((uint8_t)0x00) /*!< Output Data Rate: H - one shot, T - one shot */ 00421 #define HTS221_ODR_1Hz ((uint8_t)0x01) /*!< Output Data Rate: H - 1Hz, T - 1Hz */ 00422 #define HTS221_ODR_7Hz ((uint8_t)0x02) /*!< Output Data Rate: H - 7Hz, T - 7Hz */ 00423 #define HTS221_ODR_12_5Hz ((uint8_t)0x03) /*!< Output Data Rate: H - 12.5Hz, T - 12.5Hz */ 00424 00425 #define HTS221_ODR_MASK ((uint8_t)0x03) 00426 /** 00427 * @} 00428 */ 00429 00430 00431 /** @defgroup HTS221 Boot Mode selection - CTRL_REG2 00432 * @{ 00433 */ 00434 #define HTS221_BOOT_NORMALMODE ((uint8_t)0x00) 00435 #define HTS221_BOOT_REBOOTMEMORY ((uint8_t)0x80) 00436 00437 #define HTS221_BOOT_MASK ((uint8_t)0x80) 00438 /** 00439 * @} 00440 */ 00441 00442 00443 /** @defgroup HTS221 One Shot selection - CTRL_REG2 00444 * @{ 00445 */ 00446 #define HTS221_ONE_SHOT_START ((uint8_t)0x01) 00447 00448 #define HTS221_ONE_SHOT_MASK ((uint8_t)0x01) 00449 /** 00450 * @} 00451 */ 00452 00453 00454 /** @defgroup HTS221 Boot Mode selection - CTRL_REG2 00455 * @{ 00456 */ 00457 #define HTS221_BOOT_NORMALMODE ((uint8_t)0x00) 00458 #define HTS221_BOOT_REBOOTMEMORY ((uint8_t)0x80) 00459 00460 #define HTS221_BOOT_MASK ((uint8_t)0x80) 00461 /** 00462 * @} 00463 */ 00464 00465 00466 /** @defgroup HTS221 PushPull_OpenDrain selection - CTRL_REG3 00467 * @{ 00468 */ 00469 #define HTS221_PP_OD_PUSH_PULL ((uint8_t)0x00) 00470 #define HTS221_PP_OD_OPEN_DRAIN ((uint8_t)0x40) 00471 00472 #define HTS221_PP_OD_MASK ((uint8_t)0x40) 00473 /** 00474 * @} 00475 */ 00476 00477 00478 /** @defgroup HTS221 Data ready selection - CTRL_REG3 00479 * @{ 00480 */ 00481 #define HTS221_DRDY_DISABLE ((uint8_t)0x00) 00482 #define HTS221_DRDY_AVAILABLE ((uint8_t)0x40) 00483 00484 #define HTS221_DRDY_MASK ((uint8_t)0x40) 00485 /** 00486 * @} 00487 */ 00488 00489 00490 /** @defgroup HTS221 Humidity resolution selection - RES_CONF 00491 * @{ 00492 */ 00493 #define HTS221_H_RES_AVG_4 ((uint8_t)0x00) 00494 #define HTS221_H_RES_AVG_8 ((uint8_t)0x01) 00495 #define HTS221_H_RES_AVG_16 ((uint8_t)0x02) 00496 #define HTS221_H_RES_AVG_32 ((uint8_t)0x03) 00497 #define HTS221_H_RES_AVG_64 ((uint8_t)0x04) 00498 #define HTS221_H_RES_AVG_128 ((uint8_t)0x05) 00499 00500 #define HTS221_H_RES_MASK ((uint8_t)0x07) 00501 /** 00502 * @} 00503 */ 00504 00505 00506 /** @defgroup HTS221 Temperature resolution - RES_CONF 00507 * @{ 00508 */ 00509 #define HTS221_T_RES_AVG_2 ((uint8_t)0x00) 00510 #define HTS221_T_RES_AVG_4 ((uint8_t)0x08) 00511 #define HTS221_T_RES_AVG_8 ((uint8_t)0x10) 00512 #define HTS221_T_RES_AVG_16 ((uint8_t)0x18) 00513 #define HTS221_T_RES_AVG_32 ((uint8_t)0x20) 00514 #define HTS221_T_RES_AVG_64 ((uint8_t)0x28) 00515 00516 #define HTS221_T_RES_MASK ((uint8_t)0x38) 00517 /** 00518 * @} 00519 */ 00520 00521 00522 /** @defgroup HTS221 Temperature Humidity data available - STATUS_REG 00523 * @{ 00524 */ 00525 #define HTS221_H_DATA_AVAILABLE_MASK ((uint8_t)0x02) 00526 #define HTS221_T_DATA_AVAILABLE_MASK ((uint8_t)0x01) 00527 /** 00528 * @} 00529 */ 00530 00531 00532 00533 /* Data resolution */ 00534 #define HUM_DECIMAL_DIGITS (2) 00535 #define TEMP_DECIMAL_DIGITS (2) 00536 00537 00538 #endif /* __HTS221_PLATFORM_H */ 00539 00540 00541 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 14:47:53 by 1.7.2