Beta

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_IKS01A2 by ST

Committer:
nikapov
Date:
Mon Nov 28 13:16:22 2016 +0000
Revision:
0:cad5dab2b21d
Child:
6:671fd10a51b7
X_NUCLEO_IKS01A2 lib created.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nikapov 0:cad5dab2b21d 1 /**
nikapov 0:cad5dab2b21d 2 ******************************************************************************
nikapov 0:cad5dab2b21d 3 * @file HTS221_Driver.h
nikapov 0:cad5dab2b21d 4 * @author HESA Application Team
nikapov 0:cad5dab2b21d 5 * @version V1.1
nikapov 0:cad5dab2b21d 6 * @date 10-August-2016
nikapov 0:cad5dab2b21d 7 * @brief HTS221 driver header file
nikapov 0:cad5dab2b21d 8 ******************************************************************************
nikapov 0:cad5dab2b21d 9 * @attention
nikapov 0:cad5dab2b21d 10 *
nikapov 0:cad5dab2b21d 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
nikapov 0:cad5dab2b21d 12 *
nikapov 0:cad5dab2b21d 13 * Redistribution and use in source and binary forms, with or without modification,
nikapov 0:cad5dab2b21d 14 * are permitted provided that the following conditions are met:
nikapov 0:cad5dab2b21d 15 * 1. Redistributions of source code must retain the above copyright notice,
nikapov 0:cad5dab2b21d 16 * this list of conditions and the following disclaimer.
nikapov 0:cad5dab2b21d 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
nikapov 0:cad5dab2b21d 18 * this list of conditions and the following disclaimer in the documentation
nikapov 0:cad5dab2b21d 19 * and/or other materials provided with the distribution.
nikapov 0:cad5dab2b21d 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
nikapov 0:cad5dab2b21d 21 * may be used to endorse or promote products derived from this software
nikapov 0:cad5dab2b21d 22 * without specific prior written permission.
nikapov 0:cad5dab2b21d 23 *
nikapov 0:cad5dab2b21d 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
nikapov 0:cad5dab2b21d 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
nikapov 0:cad5dab2b21d 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
nikapov 0:cad5dab2b21d 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
nikapov 0:cad5dab2b21d 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
nikapov 0:cad5dab2b21d 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
nikapov 0:cad5dab2b21d 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
nikapov 0:cad5dab2b21d 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
nikapov 0:cad5dab2b21d 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
nikapov 0:cad5dab2b21d 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
nikapov 0:cad5dab2b21d 34 *
nikapov 0:cad5dab2b21d 35 ******************************************************************************
nikapov 0:cad5dab2b21d 36 */
nikapov 0:cad5dab2b21d 37
nikapov 0:cad5dab2b21d 38 /* Define to prevent recursive inclusion -------------------------------------*/
nikapov 0:cad5dab2b21d 39 #ifndef __HTS221_DRIVER__H
nikapov 0:cad5dab2b21d 40 #define __HTS221_DRIVER__H
nikapov 0:cad5dab2b21d 41
nikapov 0:cad5dab2b21d 42 #include <stdint.h>
nikapov 0:cad5dab2b21d 43
nikapov 0:cad5dab2b21d 44 #ifdef __cplusplus
nikapov 0:cad5dab2b21d 45 extern "C" {
nikapov 0:cad5dab2b21d 46 #endif
nikapov 0:cad5dab2b21d 47
nikapov 0:cad5dab2b21d 48 /* Uncomment the line below to expanse the "assert_param" macro in the drivers code */
nikapov 0:cad5dab2b21d 49 #define USE_FULL_ASSERT_HTS221
nikapov 0:cad5dab2b21d 50
nikapov 0:cad5dab2b21d 51 /* Exported macro ------------------------------------------------------------*/
nikapov 0:cad5dab2b21d 52 #ifdef USE_FULL_ASSERT_HTS221
nikapov 0:cad5dab2b21d 53
nikapov 0:cad5dab2b21d 54 /**
nikapov 0:cad5dab2b21d 55 * @brief The assert_param macro is used for function's parameters check.
nikapov 0:cad5dab2b21d 56 * @param expr: If expr is false, it calls assert_failed function which reports
nikapov 0:cad5dab2b21d 57 * the name of the source file and the source line number of the call
nikapov 0:cad5dab2b21d 58 * that failed. If expr is true, it returns no value.
nikapov 0:cad5dab2b21d 59 * @retval None
nikapov 0:cad5dab2b21d 60 */
nikapov 0:cad5dab2b21d 61 #define HTS221_assert_param(expr) ((expr) ? (void)0 : HTS221_assert_failed((uint8_t *)__FILE__, __LINE__))
nikapov 0:cad5dab2b21d 62 /* Exported functions ------------------------------------------------------- */
nikapov 0:cad5dab2b21d 63 void HTS221_assert_failed(uint8_t* file, uint32_t line);
nikapov 0:cad5dab2b21d 64 #else
nikapov 0:cad5dab2b21d 65 #define HTS221_assert_param(expr) ((void)0)
nikapov 0:cad5dab2b21d 66 #endif /* USE_FULL_ASSERT_HTS221 */
nikapov 0:cad5dab2b21d 67
nikapov 0:cad5dab2b21d 68 /** @addtogroup Environmental_Sensor
nikapov 0:cad5dab2b21d 69 * @{
nikapov 0:cad5dab2b21d 70 */
nikapov 0:cad5dab2b21d 71
nikapov 0:cad5dab2b21d 72 /** @addtogroup HTS221_DRIVER
nikapov 0:cad5dab2b21d 73 * @{
nikapov 0:cad5dab2b21d 74 */
nikapov 0:cad5dab2b21d 75
nikapov 0:cad5dab2b21d 76 /* Exported Types -------------------------------------------------------------*/
nikapov 0:cad5dab2b21d 77 /** @defgroup HTS221_Exported_Types
nikapov 0:cad5dab2b21d 78 * @{
nikapov 0:cad5dab2b21d 79 */
nikapov 0:cad5dab2b21d 80
nikapov 0:cad5dab2b21d 81
nikapov 0:cad5dab2b21d 82 /**
nikapov 0:cad5dab2b21d 83 * @brief Error code type.
nikapov 0:cad5dab2b21d 84 */
nikapov 0:cad5dab2b21d 85 typedef enum {HTS221_OK = (uint8_t)0, HTS221_ERROR = !HTS221_OK} HTS221_Error_et;
nikapov 0:cad5dab2b21d 86
nikapov 0:cad5dab2b21d 87 /**
nikapov 0:cad5dab2b21d 88 * @brief State type.
nikapov 0:cad5dab2b21d 89 */
nikapov 0:cad5dab2b21d 90 typedef enum {HTS221_DISABLE = (uint8_t)0, HTS221_ENABLE = !HTS221_DISABLE} HTS221_State_et;
nikapov 0:cad5dab2b21d 91 #define IS_HTS221_State(MODE) ((MODE == HTS221_ENABLE) || (MODE == HTS221_DISABLE))
nikapov 0:cad5dab2b21d 92
nikapov 0:cad5dab2b21d 93 /**
nikapov 0:cad5dab2b21d 94 * @brief Bit status type.
nikapov 0:cad5dab2b21d 95 */
nikapov 0:cad5dab2b21d 96 typedef enum {HTS221_RESET = (uint8_t)0, HTS221_SET = !HTS221_RESET} HTS221_BitStatus_et;
nikapov 0:cad5dab2b21d 97 #define IS_HTS221_BitStatus(MODE) ((MODE == HTS221_RESET) || (MODE == HTS221_SET))
nikapov 0:cad5dab2b21d 98
nikapov 0:cad5dab2b21d 99 /**
nikapov 0:cad5dab2b21d 100 * @brief Humidity average.
nikapov 0:cad5dab2b21d 101 */
nikapov 0:cad5dab2b21d 102 typedef enum
nikapov 0:cad5dab2b21d 103 {
nikapov 0:cad5dab2b21d 104 HTS221_AVGH_4 = (uint8_t)0x00, /*!< Internal average on 4 samples */
nikapov 0:cad5dab2b21d 105 HTS221_AVGH_8 = (uint8_t)0x01, /*!< Internal average on 8 samples */
nikapov 0:cad5dab2b21d 106 HTS221_AVGH_16 = (uint8_t)0x02, /*!< Internal average on 16 samples */
nikapov 0:cad5dab2b21d 107 HTS221_AVGH_32 = (uint8_t)0x03, /*!< Internal average on 32 samples */
nikapov 0:cad5dab2b21d 108 HTS221_AVGH_64 = (uint8_t)0x04, /*!< Internal average on 64 samples */
nikapov 0:cad5dab2b21d 109 HTS221_AVGH_128 = (uint8_t)0x05, /*!< Internal average on 128 samples */
nikapov 0:cad5dab2b21d 110 HTS221_AVGH_256 = (uint8_t)0x06, /*!< Internal average on 256 samples */
nikapov 0:cad5dab2b21d 111 HTS221_AVGH_512 = (uint8_t)0x07 /*!< Internal average on 512 samples */
nikapov 0:cad5dab2b21d 112 } HTS221_Avgh_et;
nikapov 0:cad5dab2b21d 113 #define IS_HTS221_AVGH(AVGH) ((AVGH == HTS221_AVGH_4) || (AVGH == HTS221_AVGH_8) || \
nikapov 0:cad5dab2b21d 114 (AVGH == HTS221_AVGH_16) || (AVGH == HTS221_AVGH_32) || \
nikapov 0:cad5dab2b21d 115 (AVGH == HTS221_AVGH_64) || (AVGH == HTS221_AVGH_128) || \
nikapov 0:cad5dab2b21d 116 (AVGH == HTS221_AVGH_256) || (AVGH == HTS221_AVGH_512))
nikapov 0:cad5dab2b21d 117
nikapov 0:cad5dab2b21d 118 /**
nikapov 0:cad5dab2b21d 119 * @brief Temperature average.
nikapov 0:cad5dab2b21d 120 */
nikapov 0:cad5dab2b21d 121 typedef enum
nikapov 0:cad5dab2b21d 122 {
nikapov 0:cad5dab2b21d 123 HTS221_AVGT_2 = (uint8_t)0x00, /*!< Internal average on 2 samples */
nikapov 0:cad5dab2b21d 124 HTS221_AVGT_4 = (uint8_t)0x08, /*!< Internal average on 4 samples */
nikapov 0:cad5dab2b21d 125 HTS221_AVGT_8 = (uint8_t)0x10, /*!< Internal average on 8 samples */
nikapov 0:cad5dab2b21d 126 HTS221_AVGT_16 = (uint8_t)0x18, /*!< Internal average on 16 samples */
nikapov 0:cad5dab2b21d 127 HTS221_AVGT_32 = (uint8_t)0x20, /*!< Internal average on 32 samples */
nikapov 0:cad5dab2b21d 128 HTS221_AVGT_64 = (uint8_t)0x28, /*!< Internal average on 64 samples */
nikapov 0:cad5dab2b21d 129 HTS221_AVGT_128 = (uint8_t)0x30, /*!< Internal average on 128 samples */
nikapov 0:cad5dab2b21d 130 HTS221_AVGT_256 = (uint8_t)0x38 /*!< Internal average on 256 samples */
nikapov 0:cad5dab2b21d 131 } HTS221_Avgt_et;
nikapov 0:cad5dab2b21d 132 #define IS_HTS221_AVGT(AVGT) ((AVGT == HTS221_AVGT_2) || (AVGT == HTS221_AVGT_4) || \
nikapov 0:cad5dab2b21d 133 (AVGT == HTS221_AVGT_8) || (AVGT == HTS221_AVGT_16) || \
nikapov 0:cad5dab2b21d 134 (AVGT == HTS221_AVGT_32) || (AVGT == HTS221_AVGT_64) || \
nikapov 0:cad5dab2b21d 135 (AVGT == HTS221_AVGT_128) || (AVGT == HTS221_AVGT_256))
nikapov 0:cad5dab2b21d 136
nikapov 0:cad5dab2b21d 137 /**
nikapov 0:cad5dab2b21d 138 * @brief Output data rate configuration.
nikapov 0:cad5dab2b21d 139 */
nikapov 0:cad5dab2b21d 140 typedef enum
nikapov 0:cad5dab2b21d 141 {
nikapov 0:cad5dab2b21d 142 HTS221_ODR_ONE_SHOT = (uint8_t)0x00, /*!< Output Data Rate: one shot */
nikapov 0:cad5dab2b21d 143 HTS221_ODR_1HZ = (uint8_t)0x01, /*!< Output Data Rate: 1Hz */
nikapov 0:cad5dab2b21d 144 HTS221_ODR_7HZ = (uint8_t)0x02, /*!< Output Data Rate: 7Hz */
nikapov 0:cad5dab2b21d 145 HTS221_ODR_12_5HZ = (uint8_t)0x03, /*!< Output Data Rate: 12.5Hz */
nikapov 0:cad5dab2b21d 146 } HTS221_Odr_et;
nikapov 0:cad5dab2b21d 147 #define IS_HTS221_ODR(ODR) ((ODR == HTS221_ODR_ONE_SHOT) || (ODR == HTS221_ODR_1HZ) || \
nikapov 0:cad5dab2b21d 148 (ODR == HTS221_ODR_7HZ) || (ODR == HTS221_ODR_12_5HZ))
nikapov 0:cad5dab2b21d 149
nikapov 0:cad5dab2b21d 150
nikapov 0:cad5dab2b21d 151 /**
nikapov 0:cad5dab2b21d 152 * @brief Push-pull/Open Drain selection on DRDY pin.
nikapov 0:cad5dab2b21d 153 */
nikapov 0:cad5dab2b21d 154 typedef enum
nikapov 0:cad5dab2b21d 155 {
nikapov 0:cad5dab2b21d 156 HTS221_PUSHPULL = (uint8_t)0x00, /*!< DRDY pin in push pull */
nikapov 0:cad5dab2b21d 157 HTS221_OPENDRAIN = (uint8_t)0x40 /*!< DRDY pin in open drain */
nikapov 0:cad5dab2b21d 158 } HTS221_OutputType_et;
nikapov 0:cad5dab2b21d 159 #define IS_HTS221_OutputType(MODE) ((MODE == HTS221_PUSHPULL) || (MODE == HTS221_OPENDRAIN))
nikapov 0:cad5dab2b21d 160
nikapov 0:cad5dab2b21d 161 /**
nikapov 0:cad5dab2b21d 162 * @brief Active level of DRDY pin.
nikapov 0:cad5dab2b21d 163 */
nikapov 0:cad5dab2b21d 164 typedef enum
nikapov 0:cad5dab2b21d 165 {
nikapov 0:cad5dab2b21d 166 HTS221_HIGH_LVL = (uint8_t)0x00, /*!< HIGH state level for DRDY pin */
nikapov 0:cad5dab2b21d 167 HTS221_LOW_LVL = (uint8_t)0x80 /*!< LOW state level for DRDY pin */
nikapov 0:cad5dab2b21d 168 } HTS221_DrdyLevel_et;
nikapov 0:cad5dab2b21d 169 #define IS_HTS221_DrdyLevelType(MODE) ((MODE == HTS221_HIGH_LVL) || (MODE == HTS221_LOW_LVL))
nikapov 0:cad5dab2b21d 170
nikapov 0:cad5dab2b21d 171 /**
nikapov 0:cad5dab2b21d 172 * @brief Driver Version Info structure definition.
nikapov 0:cad5dab2b21d 173 */
nikapov 0:cad5dab2b21d 174 typedef struct
nikapov 0:cad5dab2b21d 175 {
nikapov 0:cad5dab2b21d 176 uint8_t Major;
nikapov 0:cad5dab2b21d 177 uint8_t Minor;
nikapov 0:cad5dab2b21d 178 uint8_t Point;
nikapov 0:cad5dab2b21d 179 } HTS221_DriverVersion_st;
nikapov 0:cad5dab2b21d 180
nikapov 0:cad5dab2b21d 181
nikapov 0:cad5dab2b21d 182 /**
nikapov 0:cad5dab2b21d 183 * @brief HTS221 Init structure definition.
nikapov 0:cad5dab2b21d 184 */
nikapov 0:cad5dab2b21d 185 typedef struct
nikapov 0:cad5dab2b21d 186 {
nikapov 0:cad5dab2b21d 187 HTS221_Avgh_et avg_h; /*!< Humidity average */
nikapov 0:cad5dab2b21d 188 HTS221_Avgt_et avg_t; /*!< Temperature average */
nikapov 0:cad5dab2b21d 189 HTS221_Odr_et odr; /*!< Output data rate */
nikapov 0:cad5dab2b21d 190 HTS221_State_et bdu_status; /*!< HTS221_ENABLE/HTS221_DISABLE the block data update */
nikapov 0:cad5dab2b21d 191 HTS221_State_et heater_status; /*!< HTS221_ENABLE/HTS221_DISABLE the internal heater */
nikapov 0:cad5dab2b21d 192
nikapov 0:cad5dab2b21d 193 HTS221_DrdyLevel_et irq_level; /*!< HTS221_HIGH_LVL/HTS221_LOW_LVL the level for DRDY pin */
nikapov 0:cad5dab2b21d 194 HTS221_OutputType_et irq_output_type; /*!< Output configuration for DRDY pin */
nikapov 0:cad5dab2b21d 195 HTS221_State_et irq_enable; /*!< HTS221_ENABLE/HTS221_DISABLE interrupt on DRDY pin */
nikapov 0:cad5dab2b21d 196 } HTS221_Init_st;
nikapov 0:cad5dab2b21d 197
nikapov 0:cad5dab2b21d 198 /**
nikapov 0:cad5dab2b21d 199 * @}
nikapov 0:cad5dab2b21d 200 */
nikapov 0:cad5dab2b21d 201
nikapov 0:cad5dab2b21d 202
nikapov 0:cad5dab2b21d 203 /* Exported Constants ---------------------------------------------------------*/
nikapov 0:cad5dab2b21d 204 /** @defgroup HTS221_Exported_Constants
nikapov 0:cad5dab2b21d 205 * @{
nikapov 0:cad5dab2b21d 206 */
nikapov 0:cad5dab2b21d 207
nikapov 0:cad5dab2b21d 208 /**
nikapov 0:cad5dab2b21d 209 * @brief Bitfield positioning.
nikapov 0:cad5dab2b21d 210 */
nikapov 0:cad5dab2b21d 211 #define HTS221_BIT(x) ((uint8_t)x)
nikapov 0:cad5dab2b21d 212
nikapov 0:cad5dab2b21d 213 /**
nikapov 0:cad5dab2b21d 214 * @brief I2C address.
nikapov 0:cad5dab2b21d 215 */
nikapov 0:cad5dab2b21d 216 #define HTS221_I2C_ADDRESS (uint8_t)0xBE
nikapov 0:cad5dab2b21d 217
nikapov 0:cad5dab2b21d 218 /**
nikapov 0:cad5dab2b21d 219 * @brief Driver version.
nikapov 0:cad5dab2b21d 220 */
nikapov 0:cad5dab2b21d 221 #define HTS221_DRIVER_VERSION_MAJOR (uint8_t)1
nikapov 0:cad5dab2b21d 222 #define HTS221_DRIVER_VERSION_MINOR (uint8_t)1
nikapov 0:cad5dab2b21d 223 #define HTS221_DRIVER_VERSION_POINT (uint8_t)0
nikapov 0:cad5dab2b21d 224
nikapov 0:cad5dab2b21d 225 /**
nikapov 0:cad5dab2b21d 226 * @addtogroup HTS221_Registers
nikapov 0:cad5dab2b21d 227 * @{
nikapov 0:cad5dab2b21d 228 */
nikapov 0:cad5dab2b21d 229
nikapov 0:cad5dab2b21d 230
nikapov 0:cad5dab2b21d 231 /**
nikapov 0:cad5dab2b21d 232 * @brief Device Identification register.
nikapov 0:cad5dab2b21d 233 * \code
nikapov 0:cad5dab2b21d 234 * Read
nikapov 0:cad5dab2b21d 235 * Default value: 0xBC
nikapov 0:cad5dab2b21d 236 * 7:0 This read-only register contains the device identifier for HTS221.
nikapov 0:cad5dab2b21d 237 * \endcode
nikapov 0:cad5dab2b21d 238 */
nikapov 0:cad5dab2b21d 239 #define HTS221_WHO_AM_I_REG (uint8_t)0x0F
nikapov 0:cad5dab2b21d 240
nikapov 0:cad5dab2b21d 241 /**
nikapov 0:cad5dab2b21d 242 * @brief Device Identification value.
nikapov 0:cad5dab2b21d 243 */
nikapov 0:cad5dab2b21d 244 #define HTS221_WHO_AM_I_VAL (uint8_t)0xBC
nikapov 0:cad5dab2b21d 245
nikapov 0:cad5dab2b21d 246
nikapov 0:cad5dab2b21d 247 /**
nikapov 0:cad5dab2b21d 248 * @brief Humidity and temperature average mode register.
nikapov 0:cad5dab2b21d 249 * \code
nikapov 0:cad5dab2b21d 250 * Read/write
nikapov 0:cad5dab2b21d 251 * Default value: 0x1B
nikapov 0:cad5dab2b21d 252 * 7:6 Reserved.
nikapov 0:cad5dab2b21d 253 * 5:3 AVGT2-AVGT1-AVGT0: Select the temperature internal average.
nikapov 0:cad5dab2b21d 254 *
nikapov 0:cad5dab2b21d 255 * AVGT2 | AVGT1 | AVGT0 | Nr. Internal Average
nikapov 0:cad5dab2b21d 256 * ----------------------------------------------------
nikapov 0:cad5dab2b21d 257 * 0 | 0 | 0 | 2
nikapov 0:cad5dab2b21d 258 * 0 | 0 | 1 | 4
nikapov 0:cad5dab2b21d 259 * 0 | 1 | 0 | 8
nikapov 0:cad5dab2b21d 260 * 0 | 1 | 1 | 16
nikapov 0:cad5dab2b21d 261 * 1 | 0 | 0 | 32
nikapov 0:cad5dab2b21d 262 * 1 | 0 | 1 | 64
nikapov 0:cad5dab2b21d 263 * 1 | 1 | 0 | 128
nikapov 0:cad5dab2b21d 264 * 1 | 1 | 1 | 256
nikapov 0:cad5dab2b21d 265 *
nikapov 0:cad5dab2b21d 266 * 2:0 AVGH2-AVGH1-AVGH0: Select humidity internal average.
nikapov 0:cad5dab2b21d 267 * AVGH2 | AVGH1 | AVGH0 | Nr. Internal Average
nikapov 0:cad5dab2b21d 268 * ------------------------------------------------------
nikapov 0:cad5dab2b21d 269 * 0 | 0 | 0 | 4
nikapov 0:cad5dab2b21d 270 * 0 | 0 | 1 | 8
nikapov 0:cad5dab2b21d 271 * 0 | 1 | 0 | 16
nikapov 0:cad5dab2b21d 272 * 0 | 1 | 1 | 32
nikapov 0:cad5dab2b21d 273 * 1 | 0 | 0 | 64
nikapov 0:cad5dab2b21d 274 * 1 | 0 | 1 | 128
nikapov 0:cad5dab2b21d 275 * 1 | 1 | 0 | 256
nikapov 0:cad5dab2b21d 276 * 1 | 1 | 1 | 512
nikapov 0:cad5dab2b21d 277 *
nikapov 0:cad5dab2b21d 278 * \endcode
nikapov 0:cad5dab2b21d 279 */
nikapov 0:cad5dab2b21d 280 #define HTS221_AV_CONF_REG (uint8_t)0x10
nikapov 0:cad5dab2b21d 281
nikapov 0:cad5dab2b21d 282 #define HTS221_AVGT_BIT HTS221_BIT(3)
nikapov 0:cad5dab2b21d 283 #define HTS221_AVGH_BIT HTS221_BIT(0)
nikapov 0:cad5dab2b21d 284
nikapov 0:cad5dab2b21d 285 #define HTS221_AVGH_MASK (uint8_t)0x07
nikapov 0:cad5dab2b21d 286 #define HTS221_AVGT_MASK (uint8_t)0x38
nikapov 0:cad5dab2b21d 287
nikapov 0:cad5dab2b21d 288 /**
nikapov 0:cad5dab2b21d 289 * @brief Control register 1.
nikapov 0:cad5dab2b21d 290 * \code
nikapov 0:cad5dab2b21d 291 * Read/write
nikapov 0:cad5dab2b21d 292 * Default value: 0x00
nikapov 0:cad5dab2b21d 293 * 7 PD: power down control. 0 - power down mode; 1 - active mode.
nikapov 0:cad5dab2b21d 294 * 6:3 Reserved.
nikapov 0:cad5dab2b21d 295 * 2 BDU: block data update. 0 - continuous update; 1 - output registers not updated until MSB and LSB reading.
nikapov 0:cad5dab2b21d 296 * 1:0 ODR1, ODR0: output data rate selection.
nikapov 0:cad5dab2b21d 297 *
nikapov 0:cad5dab2b21d 298 * ODR1 | ODR0 | Humidity output data-rate(Hz) | Pressure output data-rate(Hz)
nikapov 0:cad5dab2b21d 299 * ----------------------------------------------------------------------------------
nikapov 0:cad5dab2b21d 300 * 0 | 0 | one shot | one shot
nikapov 0:cad5dab2b21d 301 * 0 | 1 | 1 | 1
nikapov 0:cad5dab2b21d 302 * 1 | 0 | 7 | 7
nikapov 0:cad5dab2b21d 303 * 1 | 1 | 12.5 | 12.5
nikapov 0:cad5dab2b21d 304 *
nikapov 0:cad5dab2b21d 305 * \endcode
nikapov 0:cad5dab2b21d 306 */
nikapov 0:cad5dab2b21d 307 #define HTS221_CTRL_REG1 (uint8_t)0x20
nikapov 0:cad5dab2b21d 308
nikapov 0:cad5dab2b21d 309 #define HTS221_PD_BIT HTS221_BIT(7)
nikapov 0:cad5dab2b21d 310 #define HTS221_BDU_BIT HTS221_BIT(2)
nikapov 0:cad5dab2b21d 311 #define HTS221_ODR_BIT HTS221_BIT(0)
nikapov 0:cad5dab2b21d 312
nikapov 0:cad5dab2b21d 313 #define HTS221_PD_MASK (uint8_t)0x80
nikapov 0:cad5dab2b21d 314 #define HTS221_BDU_MASK (uint8_t)0x04
nikapov 0:cad5dab2b21d 315 #define HTS221_ODR_MASK (uint8_t)0x03
nikapov 0:cad5dab2b21d 316
nikapov 0:cad5dab2b21d 317 /**
nikapov 0:cad5dab2b21d 318 * @brief Control register 2.
nikapov 0:cad5dab2b21d 319 * \code
nikapov 0:cad5dab2b21d 320 * Read/write
nikapov 0:cad5dab2b21d 321 * Default value: 0x00
nikapov 0:cad5dab2b21d 322 * 7 BOOT: Reboot memory content. 0: normal mode; 1: reboot memory content. Self-cleared upon completation.
nikapov 0:cad5dab2b21d 323 * 6:2 Reserved.
nikapov 0:cad5dab2b21d 324 * 1 HEATHER: 0: heater enable; 1: heater disable.
nikapov 0:cad5dab2b21d 325 * 0 ONE_SHOT: 0: waiting for start of conversion; 1: start for a new dataset. Self-cleared upon completation.
nikapov 0:cad5dab2b21d 326 * \endcode
nikapov 0:cad5dab2b21d 327 */
nikapov 0:cad5dab2b21d 328 #define HTS221_CTRL_REG2 (uint8_t)0x21
nikapov 0:cad5dab2b21d 329
nikapov 0:cad5dab2b21d 330 #define HTS221_BOOT_BIT HTS221_BIT(7)
nikapov 0:cad5dab2b21d 331 #define HTS221_HEATHER_BIT HTS221_BIT(1)
nikapov 0:cad5dab2b21d 332 #define HTS221_ONESHOT_BIT HTS221_BIT(0)
nikapov 0:cad5dab2b21d 333
nikapov 0:cad5dab2b21d 334 #define HTS221_BOOT_MASK (uint8_t)0x80
nikapov 0:cad5dab2b21d 335 #define HTS221_HEATHER_MASK (uint8_t)0x02
nikapov 0:cad5dab2b21d 336 #define HTS221_ONE_SHOT_MASK (uint8_t)0x01
nikapov 0:cad5dab2b21d 337
nikapov 0:cad5dab2b21d 338 /**
nikapov 0:cad5dab2b21d 339 * @brief Control register 3.
nikapov 0:cad5dab2b21d 340 * \code
nikapov 0:cad5dab2b21d 341 * Read/write
nikapov 0:cad5dab2b21d 342 * Default value: 0x00
nikapov 0:cad5dab2b21d 343 * 7 DRDY_H_L: Interrupt edge. 0: active high, 1: active low.
nikapov 0:cad5dab2b21d 344 * 6 PP_OD: Push-Pull/OpenDrain selection on interrupt pads. 0: push-pull; 1: open drain.
nikapov 0:cad5dab2b21d 345 * 5:3 Reserved.
nikapov 0:cad5dab2b21d 346 * 2 DRDY: interrupt config. 0: disable, 1: enable.
nikapov 0:cad5dab2b21d 347 * \endcode
nikapov 0:cad5dab2b21d 348 */
nikapov 0:cad5dab2b21d 349 #define HTS221_CTRL_REG3 (uint8_t)0x22
nikapov 0:cad5dab2b21d 350
nikapov 0:cad5dab2b21d 351 #define HTS221_DRDY_H_L_BIT HTS221_BIT(7)
nikapov 0:cad5dab2b21d 352 #define HTS221_PP_OD_BIT HTS221_BIT(6)
nikapov 0:cad5dab2b21d 353 #define HTS221_DRDY_BIT HTS221_BIT(2)
nikapov 0:cad5dab2b21d 354
nikapov 0:cad5dab2b21d 355 #define HTS221_DRDY_H_L_MASK (uint8_t)0x80
nikapov 0:cad5dab2b21d 356 #define HTS221_PP_OD_MASK (uint8_t)0x40
nikapov 0:cad5dab2b21d 357 #define HTS221_DRDY_MASK (uint8_t)0x04
nikapov 0:cad5dab2b21d 358
nikapov 0:cad5dab2b21d 359 /**
nikapov 0:cad5dab2b21d 360 * @brief Status register.
nikapov 0:cad5dab2b21d 361 * \code
nikapov 0:cad5dab2b21d 362 * Read
nikapov 0:cad5dab2b21d 363 * Default value: 0x00
nikapov 0:cad5dab2b21d 364 * 7:2 Reserved.
nikapov 0:cad5dab2b21d 365 * 1 H_DA: Humidity data available. 0: new data for humidity is not yet available; 1: new data for humidity is available.
nikapov 0:cad5dab2b21d 366 * 0 T_DA: Temperature data available. 0: new data for temperature is not yet available; 1: new data for temperature is available.
nikapov 0:cad5dab2b21d 367 * \endcode
nikapov 0:cad5dab2b21d 368 */
nikapov 0:cad5dab2b21d 369 #define HTS221_STATUS_REG (uint8_t)0x27
nikapov 0:cad5dab2b21d 370
nikapov 0:cad5dab2b21d 371 #define HTS221_H_DA_BIT HTS221_BIT(1)
nikapov 0:cad5dab2b21d 372 #define HTS221_T_DA_BIT HTS221_BIT(0)
nikapov 0:cad5dab2b21d 373
nikapov 0:cad5dab2b21d 374 #define HTS221_HDA_MASK (uint8_t)0x02
nikapov 0:cad5dab2b21d 375 #define HTS221_TDA_MASK (uint8_t)0x01
nikapov 0:cad5dab2b21d 376
nikapov 0:cad5dab2b21d 377 /**
nikapov 0:cad5dab2b21d 378 * @brief Humidity data (LSB).
nikapov 0:cad5dab2b21d 379 * \code
nikapov 0:cad5dab2b21d 380 * Read
nikapov 0:cad5dab2b21d 381 * Default value: 0x00.
nikapov 0:cad5dab2b21d 382 * HOUT7 - HOUT0: Humidity data LSB (2's complement).
nikapov 0:cad5dab2b21d 383 * \endcode
nikapov 0:cad5dab2b21d 384 */
nikapov 0:cad5dab2b21d 385 #define HTS221_HR_OUT_L_REG (uint8_t)0x28
nikapov 0:cad5dab2b21d 386
nikapov 0:cad5dab2b21d 387 /**
nikapov 0:cad5dab2b21d 388 * @brief Humidity data (MSB).
nikapov 0:cad5dab2b21d 389 * \code
nikapov 0:cad5dab2b21d 390 * Read
nikapov 0:cad5dab2b21d 391 * Default value: 0x00.
nikapov 0:cad5dab2b21d 392 * HOUT15 - HOUT8: Humidity data MSB (2's complement).
nikapov 0:cad5dab2b21d 393 * \endcode
nikapov 0:cad5dab2b21d 394 */
nikapov 0:cad5dab2b21d 395 #define HTS221_HR_OUT_H_REG (uint8_t)0x29
nikapov 0:cad5dab2b21d 396
nikapov 0:cad5dab2b21d 397
nikapov 0:cad5dab2b21d 398 /**
nikapov 0:cad5dab2b21d 399 * @brief Temperature data (LSB).
nikapov 0:cad5dab2b21d 400 * \code
nikapov 0:cad5dab2b21d 401 * Read
nikapov 0:cad5dab2b21d 402 * Default value: 0x00.
nikapov 0:cad5dab2b21d 403 * TOUT7 - TOUT0: temperature data LSB.
nikapov 0:cad5dab2b21d 404 * \endcode
nikapov 0:cad5dab2b21d 405 */
nikapov 0:cad5dab2b21d 406 #define HTS221_TEMP_OUT_L_REG (uint8_t)0x2A
nikapov 0:cad5dab2b21d 407
nikapov 0:cad5dab2b21d 408 /**
nikapov 0:cad5dab2b21d 409 * @brief Temperature data (MSB).
nikapov 0:cad5dab2b21d 410 * \code
nikapov 0:cad5dab2b21d 411 * Read
nikapov 0:cad5dab2b21d 412 * Default value: 0x00.
nikapov 0:cad5dab2b21d 413 * TOUT15 - TOUT8: temperature data MSB.
nikapov 0:cad5dab2b21d 414 * \endcode
nikapov 0:cad5dab2b21d 415 */
nikapov 0:cad5dab2b21d 416 #define HTS221_TEMP_OUT_H_REG (uint8_t)0x2B
nikapov 0:cad5dab2b21d 417
nikapov 0:cad5dab2b21d 418 /**
nikapov 0:cad5dab2b21d 419 * @brief Calibration registers.
nikapov 0:cad5dab2b21d 420 * \code
nikapov 0:cad5dab2b21d 421 * Read
nikapov 0:cad5dab2b21d 422 * \endcode
nikapov 0:cad5dab2b21d 423 */
nikapov 0:cad5dab2b21d 424 #define HTS221_H0_RH_X2 (uint8_t)0x30
nikapov 0:cad5dab2b21d 425 #define HTS221_H1_RH_X2 (uint8_t)0x31
nikapov 0:cad5dab2b21d 426 #define HTS221_T0_DEGC_X8 (uint8_t)0x32
nikapov 0:cad5dab2b21d 427 #define HTS221_T1_DEGC_X8 (uint8_t)0x33
nikapov 0:cad5dab2b21d 428 #define HTS221_T0_T1_DEGC_H2 (uint8_t)0x35
nikapov 0:cad5dab2b21d 429 #define HTS221_H0_T0_OUT_L (uint8_t)0x36
nikapov 0:cad5dab2b21d 430 #define HTS221_H0_T0_OUT_H (uint8_t)0x37
nikapov 0:cad5dab2b21d 431 #define HTS221_H1_T0_OUT_L (uint8_t)0x3A
nikapov 0:cad5dab2b21d 432 #define HTS221_H1_T0_OUT_H (uint8_t)0x3B
nikapov 0:cad5dab2b21d 433 #define HTS221_T0_OUT_L (uint8_t)0x3C
nikapov 0:cad5dab2b21d 434 #define HTS221_T0_OUT_H (uint8_t)0x3D
nikapov 0:cad5dab2b21d 435 #define HTS221_T1_OUT_L (uint8_t)0x3E
nikapov 0:cad5dab2b21d 436 #define HTS221_T1_OUT_H (uint8_t)0x3F
nikapov 0:cad5dab2b21d 437
nikapov 0:cad5dab2b21d 438
nikapov 0:cad5dab2b21d 439 /**
nikapov 0:cad5dab2b21d 440 * @}
nikapov 0:cad5dab2b21d 441 */
nikapov 0:cad5dab2b21d 442
nikapov 0:cad5dab2b21d 443
nikapov 0:cad5dab2b21d 444 /**
nikapov 0:cad5dab2b21d 445 * @}
nikapov 0:cad5dab2b21d 446 */
nikapov 0:cad5dab2b21d 447
nikapov 0:cad5dab2b21d 448
nikapov 0:cad5dab2b21d 449 /* Exported Functions -------------------------------------------------------------*/
nikapov 0:cad5dab2b21d 450 /** @defgroup HTS221_Exported_Functions
nikapov 0:cad5dab2b21d 451 * @{
nikapov 0:cad5dab2b21d 452 */
nikapov 0:cad5dab2b21d 453
nikapov 0:cad5dab2b21d 454 HTS221_Error_et HTS221_ReadReg( void *handle, uint8_t RegAddr, uint16_t NumByteToRead, uint8_t *Data );
nikapov 0:cad5dab2b21d 455 HTS221_Error_et HTS221_WriteReg( void *handle, uint8_t RegAddr, uint16_t NumByteToWrite, uint8_t *Data );
nikapov 0:cad5dab2b21d 456
nikapov 0:cad5dab2b21d 457 HTS221_Error_et HTS221_Get_DriverVersion(HTS221_DriverVersion_st* version);
nikapov 0:cad5dab2b21d 458 HTS221_Error_et HTS221_Get_DeviceID(void *handle, uint8_t* deviceid);
nikapov 0:cad5dab2b21d 459
nikapov 0:cad5dab2b21d 460 HTS221_Error_et HTS221_Set_InitConfig(void *handle, HTS221_Init_st* pxInit);
nikapov 0:cad5dab2b21d 461 HTS221_Error_et HTS221_Get_InitConfig(void *handle, HTS221_Init_st* pxInit);
nikapov 0:cad5dab2b21d 462 HTS221_Error_et HTS221_DeInit(void *handle);
nikapov 0:cad5dab2b21d 463 HTS221_Error_et HTS221_IsMeasurementCompleted(void *handle, HTS221_BitStatus_et* Is_Measurement_Completed);
nikapov 0:cad5dab2b21d 464
nikapov 0:cad5dab2b21d 465 HTS221_Error_et HTS221_Get_Measurement(void *handle, uint16_t* humidity, int16_t* temperature);
nikapov 0:cad5dab2b21d 466 HTS221_Error_et HTS221_Get_RawMeasurement(void *handle, int16_t* humidity, int16_t* temperature);
nikapov 0:cad5dab2b21d 467 HTS221_Error_et HTS221_Get_Humidity(void *handle, uint16_t* value);
nikapov 0:cad5dab2b21d 468 HTS221_Error_et HTS221_Get_HumidityRaw(void *handle, int16_t* value);
nikapov 0:cad5dab2b21d 469 HTS221_Error_et HTS221_Get_TemperatureRaw(void *handle, int16_t* value);
nikapov 0:cad5dab2b21d 470 HTS221_Error_et HTS221_Get_Temperature(void *handle, int16_t* value);
nikapov 0:cad5dab2b21d 471 HTS221_Error_et HTS221_Get_DataStatus(void *handle, HTS221_BitStatus_et* humidity, HTS221_BitStatus_et* temperature);
nikapov 0:cad5dab2b21d 472 HTS221_Error_et HTS221_Activate(void *handle);
nikapov 0:cad5dab2b21d 473 HTS221_Error_et HTS221_DeActivate(void *handle);
nikapov 0:cad5dab2b21d 474
nikapov 0:cad5dab2b21d 475 HTS221_Error_et HTS221_Set_AvgHT(void *handle, HTS221_Avgh_et avgh, HTS221_Avgt_et avgt);
nikapov 0:cad5dab2b21d 476 HTS221_Error_et HTS221_Set_AvgH(void *handle, HTS221_Avgh_et avgh);
nikapov 0:cad5dab2b21d 477 HTS221_Error_et HTS221_Set_AvgT(void *handle, HTS221_Avgt_et avgt);
nikapov 0:cad5dab2b21d 478 HTS221_Error_et HTS221_Get_AvgHT(void *handle, HTS221_Avgh_et* avgh, HTS221_Avgt_et* avgt);
nikapov 0:cad5dab2b21d 479 HTS221_Error_et HTS221_Set_BduMode(void *handle, HTS221_State_et status);
nikapov 0:cad5dab2b21d 480 HTS221_Error_et HTS221_Get_BduMode(void *handle, HTS221_State_et* status);
nikapov 0:cad5dab2b21d 481 HTS221_Error_et HTS221_Set_PowerDownMode(void *handle, HTS221_BitStatus_et status);
nikapov 0:cad5dab2b21d 482 HTS221_Error_et HTS221_Get_PowerDownMode(void *handle, HTS221_BitStatus_et* status);
nikapov 0:cad5dab2b21d 483 HTS221_Error_et HTS221_Set_Odr(void *handle, HTS221_Odr_et odr);
nikapov 0:cad5dab2b21d 484 HTS221_Error_et HTS221_Get_Odr(void *handle, HTS221_Odr_et* odr);
nikapov 0:cad5dab2b21d 485 HTS221_Error_et HTS221_MemoryBoot(void *handle);
nikapov 0:cad5dab2b21d 486 HTS221_Error_et HTS221_Set_HeaterState(void *handle, HTS221_State_et status);
nikapov 0:cad5dab2b21d 487 HTS221_Error_et HTS221_Get_HeaterState(void *handle, HTS221_State_et* status);
nikapov 0:cad5dab2b21d 488 HTS221_Error_et HTS221_StartOneShotMeasurement(void *handle);
nikapov 0:cad5dab2b21d 489 HTS221_Error_et HTS221_Set_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et status);
nikapov 0:cad5dab2b21d 490 HTS221_Error_et HTS221_Get_IrqActiveLevel(void *handle, HTS221_DrdyLevel_et* status);
nikapov 0:cad5dab2b21d 491 HTS221_Error_et HTS221_Set_IrqOutputType(void *handle, HTS221_OutputType_et value);
nikapov 0:cad5dab2b21d 492 HTS221_Error_et HTS221_Get_IrqOutputType(void *handle, HTS221_OutputType_et* value);
nikapov 0:cad5dab2b21d 493 HTS221_Error_et HTS221_Set_IrqEnable(void *handle, HTS221_State_et status);
nikapov 0:cad5dab2b21d 494 HTS221_Error_et HTS221_Get_IrqEnable(void *handle, HTS221_State_et* status);
nikapov 0:cad5dab2b21d 495
nikapov 0:cad5dab2b21d 496 /**
nikapov 0:cad5dab2b21d 497 * @}
nikapov 0:cad5dab2b21d 498 */
nikapov 0:cad5dab2b21d 499
nikapov 0:cad5dab2b21d 500 /**
nikapov 0:cad5dab2b21d 501 * @}
nikapov 0:cad5dab2b21d 502 */
nikapov 0:cad5dab2b21d 503
nikapov 0:cad5dab2b21d 504 /**
nikapov 0:cad5dab2b21d 505 * @}
nikapov 0:cad5dab2b21d 506 */
nikapov 0:cad5dab2b21d 507
nikapov 0:cad5dab2b21d 508 #ifdef __cplusplus
nikapov 0:cad5dab2b21d 509 }
nikapov 0:cad5dab2b21d 510 #endif
nikapov 0:cad5dab2b21d 511
nikapov 0:cad5dab2b21d 512 #endif /* __HTS221_DRIVER__H */
nikapov 0:cad5dab2b21d 513
nikapov 0:cad5dab2b21d 514 /******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/