Example of wake up detection for LSM6DSL in X-NUCLEO-IKS01A2

Dependencies:   X_NUCLEO_IKS01A2 mbed

Fork of WakeUp_IKS01A2 by ST Expansion SW Team

Wake up Demo Application based on sensor expansion board X-NUCLEO-IKS01A2

Main function is to show how to detect the wake up event using the sensor expansion board and send a notification using UART to a connected PC or Desktop and display it on terminal applications like TeraTerm.
After connection has been established:
- the user can try to shake the board and then view the notification using an hyper terminal. When the wake up event is detected, the LED is switched on for a while.
- the user button can be used to enable/disable the wake up detection feature.

Committer:
cparata
Date:
Fri Aug 19 12:35:45 2016 +0000
Revision:
2:7ad7571557a5
Parent:
0:e7e920b85676
Add interfaces to all components

Who changed what in which revision?

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