temphum23  2.1.0.0
temphum23.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef TEMPHUM23_H
29 #define TEMPHUM23_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define TEMPHUM23_CMD_MEAS_TH_HIGH_PREC 0xFD
60 #define TEMPHUM23_CMD_MEAS_TH_MED_PREC 0xF6
61 #define TEMPHUM23_CMD_MEAS_TH_LOW_PREC 0xE0
62 #define TEMPHUM23_CMD_READ_SERIAL_NUM 0x89
63 #define TEMPHUM23_CMD_SOFT_RESET 0x94
64 #define TEMPHUM23_CMD_ACT_HEATER_200mW_1S 0x39
65 #define TEMPHUM23_CMD_ACT_HEATER_200mW_0p1S 0x32
66 #define TEMPHUM23_CMD_ACT_HEATER_110mW_1S 0x2F
67 #define TEMPHUM23_CMD_ACT_HEATER_110mW_0p1S 0x24
68 #define TEMPHUM23_CMD_ACT_HEATER_20mW_1S 0x1E
69 #define TEMPHUM23_CMD_ACT_HEATER_20mW_0p1S 0x15
70  // temphum23_reg
72 
87 #define TEMPHUM23_MAX_RH 100.0
88 #define TEMPHUM23_MIN_RH 0.0
89 #define TEMPHUM23_DATA_RESOLUTION 65535.0
90 #define TEMPHUM23_ABS_MIN_TEMP ( -45.0 )
91 #define TEMPHUM23_ABS_MAX_TEMP ( 130.0 )
92 #define TEMPHUM23_ABS_MIN_HUM ( -6.0 )
93 #define TEMPHUM23_ABS_MAX_HUM ( 119.0 )
94 
100 #define TEMPHUM23_DEVICE_ADDRESS 0x44
101  // temphum23_set
103 
118 #define TEMPHUM23_MAP_MIKROBUS( cfg, mikrobus ) \
119  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
120  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
121  // temphum23_map // temphum23
124 
129 typedef struct
130 {
131  // Modules
132  i2c_master_t i2c;
134  // I2C slave address
135  uint8_t slave_address;
137 } temphum23_t;
138 
143 typedef struct
144 {
145  pin_name_t scl;
146  pin_name_t sda;
148  uint32_t i2c_speed;
149  uint8_t i2c_address;
152 
157 typedef enum
158 {
160  TEMPHUM23_ERROR = -1
161 
163 
180 
195 
207 err_t temphum23_send_cmd ( temphum23_t *ctx, uint8_t cmd );
208 
221 err_t temphum23_read_response ( temphum23_t *ctx, uint8_t *data_out );
222 
234 
246 err_t temphum23_read_serial_num ( temphum23_t *ctx, uint32_t *serial_num );
247 
260 err_t temphum23_read_measurement_high_precision ( temphum23_t *ctx, float *temp, float *hum );
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 #endif // TEMPHUM23_H
266  // temphum23
268 
269 // ------------------------------------------------------------------------ END
temphum23_t::slave_address
uint8_t slave_address
Definition: temphum23.h:135
temphum23_t
TempHum 23 Click context object.
Definition: temphum23.h:130
temphum23_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: temphum23.h:148
temphum23_cfg_t
TempHum 23 Click configuration object.
Definition: temphum23.h:144
temphum23_cfg_setup
void temphum23_cfg_setup(temphum23_cfg_t *cfg)
TempHum 23 configuration object setup function.
temphum23_cfg_t::i2c_address
uint8_t i2c_address
Definition: temphum23.h:149
temphum23_soft_reset
err_t temphum23_soft_reset(temphum23_t *ctx)
TempHum 23 soft reset function.
temphum23_read_response
err_t temphum23_read_response(temphum23_t *ctx, uint8_t *data_out)
TempHum 23 read response function.
temphum23_t::i2c
i2c_master_t i2c
Definition: temphum23.h:132
temphum23_return_value_t
temphum23_return_value_t
TempHum 23 Click return value data.
Definition: temphum23.h:158
temphum23_read_measurement_high_precision
err_t temphum23_read_measurement_high_precision(temphum23_t *ctx, float *temp, float *hum)
TempHum 23 read measurement high precision function.
temphum23_cfg_t::scl
pin_name_t scl
Definition: temphum23.h:145
temphum23_read_serial_num
err_t temphum23_read_serial_num(temphum23_t *ctx, uint32_t *serial_num)
TempHum 23 read serial num function.
TEMPHUM23_OK
@ TEMPHUM23_OK
Definition: temphum23.h:159
temphum23_cfg_t::sda
pin_name_t sda
Definition: temphum23.h:146
TEMPHUM23_ERROR
@ TEMPHUM23_ERROR
Definition: temphum23.h:160
temphum23_init
err_t temphum23_init(temphum23_t *ctx, temphum23_cfg_t *cfg)
TempHum 23 initialization function.
temphum23_send_cmd
err_t temphum23_send_cmd(temphum23_t *ctx, uint8_t cmd)
TempHum 23 send cmd function.