Go to the documentation of this file.
47 #define EX_HTS221_VERSION "1.1.2"
52 #define EX_HTS221_MAJOR 1
57 #define EX_HTS221_MINOR 1
62 #define EX_HTS221_PATCH 2
72 #define HTS221_HYGRO_NUMBER_OF_AXES 1U
74 #define HTS221_HYGRO_SENS 0.00390625f
75 #define HTS221_HYGRO_BIAS 0.0f
85 #define HTS221_THERMO_NUMBER_OF_AXES 1U
87 #define HTS221_THERMO_SENS 0.0015625f
88 #define HTS221_THERMO_BIAS 0.0f
95 #define HTS221_DI_MASK 0xFF
96 #define HTS221_DI(n) (1 << n)
97 #define HTS221_AD_MASK 0x3F
98 #define HTS221_AD(n) (1 << n)
99 #define HTS221_MS (1 << 6)
100 #define HTS221_RW (1 << 7)
102 #define HTS221_SUB_MS (1 << 7)
104 #define HTS221_SAD 0x5F
111 #define HTS221_AD_WHO_AM_I 0x0F
112 #define HTS221_AD_AV_CONF 0x10
113 #define HTS221_AD_CTRL_REG1 0x20
114 #define HTS221_AD_CTRL_REG2 0x21
115 #define HTS221_AD_CTRL_REG3 0x22
116 #define HTS221_AD_STATUS_REG 0x27
117 #define HTS221_AD_HUMIDITY_OUT_L 0x28
118 #define HTS221_AD_HUMIDITY_OUT_H 0x29
119 #define HTS221_AD_TEMP_OUT_L 0x2A
120 #define HTS221_AD_TEMP_OUT_H 0x2B
121 #define HTS221_AD_CALIB_0 0x30
122 #define HTS221_AD_CALIB_1 0x31
123 #define HTS221_AD_CALIB_2 0x32
124 #define HTS221_AD_CALIB_3 0x33
125 #define HTS221_AD_CALIB_4 0x34
126 #define HTS221_AD_CALIB_5 0x35
127 #define HTS221_AD_CALIB_6 0x36
128 #define HTS221_AD_CALIB_7 0x37
129 #define HTS221_AD_CALIB_8 0x38
130 #define HTS221_AD_CALIB_9 0x39
131 #define HTS221_AD_CALIB_A 0x3A
132 #define HTS221_AD_CALIB_B 0x3B
133 #define HTS221_AD_CALIB_C 0x3C
134 #define HTS221_AD_CALIB_D 0x3D
135 #define HTS221_AD_CALIB_E 0x3E
136 #define HTS221_AD_CALIB_F 0x3F
143 #define HTS221_CTRL_REG1_MASK 0x87
144 #define HTS221_CTRL_REG1_ODR0 (1 << 0)
145 #define HTS221_CTRL_REG1_ODR1 (1 << 1)
146 #define HTS221_CTRL_REG1_BDU (1 << 2)
147 #define HTS221_CTRL_REG1_PD (1 << 7)
154 #define HTS221_CTRL_REG2_MASK 0x83
155 #define HTS221_CTRL_REG2_ONE_SHOT (1 << 0)
156 #define HTS221_CTRL_REG2_HEATER (1 << 1)
157 #define HTS221_CTRL_REG2_BOOT (1 << 7)
164 #define HTS221_CTRL_REG3_MASK 0xC4
165 #define HTS221_CTRL_REG3_DRDY (1 << 2)
166 #define HTS221_CTRL_REG3_PP_OD (1 << 6)
167 #define HTS221_CTRL_REG3_INT_H_L (1 << 7)
183 #if !defined(HTS221_USE_SPI) || defined(__DOXYGEN__)
184 #define HTS221_USE_SPI FALSE
193 #if !defined(HTS221_SHARED_SPI) || defined(__DOXYGEN__)
194 #define HTS221_SHARED_SPI FALSE
202 #if !defined(HTS221_USE_I2C) || defined(__DOXYGEN__)
203 #define HTS221_USE_I2C TRUE
212 #if !defined(HTS221_SHARED_I2C) || defined(__DOXYGEN__)
213 #define HTS221_SHARED_I2C FALSE
221 #if !defined(HTS221_USE_ADVANCED) || defined(__DOXYGEN__)
222 #define HTS221_USE_ADVANCED FALSE
230 #if !(HTS221_USE_SPI ^ HTS221_USE_I2C)
231 #error "HTS221_USE_SPI and HTS221_USE_I2C cannot be both true or both false"
234 #if HTS221_USE_SPI && !HAL_USE_SPI
235 #error "HTS221_USE_SPI requires HAL_USE_SPI"
238 #if HTS221_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
239 #error "HTS221_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
242 #if HTS221_USE_I2C && !HAL_USE_I2C
243 #error "HTS221_USE_I2C requires HAL_USE_I2C"
246 #if HTS221_SHARED_I2C && !I2C_USE_MUTUAL_EXCLUSION
247 #error "HTS221_SHARED_I2C requires I2C_USE_MUTUAL_EXCLUSION"
254 #error "HTS221 over SPI still not supported."
330 #if HTS221_USE_SPI || defined(__DOXYGEN__)
340 #if HTS221_USE_I2C || defined(__DOXYGEN__)
370 #if HTS221_USE_ADVANCED || defined(__DOXYGEN__)
390 #define _hts221_methods_alone
395 #define _hts221_methods \
396 _base_object_methods \
397 _hts221_methods_alone
411 #define _hts221_data \
413 hts221_state_t state; \
415 const HTS221Config *config; \
419 float hygrosensitivity; \
423 float hygrofactorysensitivity; \
425 float hygrofactorybias; \
429 float thermosensitivity; \
433 float thermofactorysensitivity; \
435 float thermofactorybias;
464 #define hts221HygrometerGetAxesNumber(devp) \
465 hygrometerGetAxesNumber(&((devp)->hygro_if))
485 #define hts221HygrometerReadRaw(devp, axes) \
486 hygrometerReadRaw(&((devp)->hygro_if), axes)
507 #define hts221HygrometerReadCooked(devp, axes) \
508 hygrometerReadCooked(&((devp)->hygro_if), axes)
524 #define hts221HygrometerSetBias(devp, bp) \
525 hygrometerSetBias(&((devp)->hygro_if), bp)
539 #define hts221HygrometerResetBias(devp) \
540 hygrometerResetBias(&((devp)->hygro_if))
556 #define hts221HygrometerSetSensitivity(devp, sp) \
557 hygrometerSetSensitivity(&((devp)->hygro_if), sp)
570 #define hts221HygrometerResetSensitivity(devp) \
571 hygrometerResetSensitivity(&((devp)->hygro_if))
582 #define hts221ThermometerGetAxesNumber(devp) \
583 thermometerGetAxesNumber(&((devp)->thermo_if))
603 #define hts221ThermometerReadRaw(devp, axes) \
604 thermometerReadRaw(&((devp)->thermo_if), axes)
625 #define hts221ThermometerReadCooked(devp, axes) \
626 thermometerReadCooked(&((devp)->thermo_if), axes)
642 #define hts221ThermometerSetBias(devp, bp) \
643 thermometerSetBias(&((devp)->thermo_if), bp)
657 #define hts221ThermometerResetBias(devp) \
658 thermometerResetBias(&((devp)->thermo_if))
674 #define hts221ThermometerSetSensitivity(devp, sp) \
675 thermometerSetSensitivity(&((devp)->thermo_if), sp)
688 #define hts221ThermometerResetSensitivity(devp) \
689 thermometerResetSensitivity(&((devp)->thermo_if))
Generic hygrometer interface header.
Structure representing an I2C driver.
hts221_state_t
Driver state machine possible states.
void hts221Stop(HTS221Driver *devp)
Deactivates the HTS221 Complex Driver peripheral.
hts221_odr_t
HTS221 output data rate and bandwidth.
Driver configuration structure.
hts221_avgt_t
HTS221 temperature resolution.
Structure representing an SPI driver.
hts221_avgt_t thermoresolution
HTS221 thermometer subsystem resolution.
#define _hts221_methods
HTS221 specific methods with inherited ones.
float * hygrosensitivity
HTS221 hygrometer subsystem initial sensitivity.
BaseThermometer thermo_if
Base thermometer interface.
const struct HTS221VMT * vmt
Virtual Methods Table.
hts221_odr_t outputdatarate
HTS221 output data rate selection.
float * thermosensitivity
HTS221 thermometer subsystem initial sensitivity.
BaseHygrometer hygro_if
Base hygrometer interface.
HTS221 configuration structure.
void hts221Start(HTS221Driver *devp, const HTS221Config *config)
Configures and activates HTS221 Complex Driver peripheral.
SPIDriver * spip
SPI driver associated to this HTS221.
float * thermobias
HTS221 thermometer subsystem initial bias.
hts221_avgh_t
HTS221 humidity resolution.
const SPIConfig * spicfg
SPI configuration associated to this HTS221.
hts221_bdu_t blockdataupdate
HTS221 block data update.
void hts221ObjectInit(HTS221Driver *devp)
Initializes an instance.
I2CDriver * i2cp
I2C driver associated to this HTS221.
Generic thermometer interface header.
hts221_bdu_t
HTS221 block data update.
float * hygrobias
HTS221 hygrometer subsystem initial bias.
const I2CConfig * i2ccfg
I2C configuration associated to this HTS221.
HTS221 virtual methods table.
HTS221 2-axis hygrometer/thermometer class.
Type of I2C driver configuration structure.
hts221_avgh_t hygroresolution
HTS221 hygrometer subsystem resolution.
#define _hts221_data
HTS221Driver specific data.