thermo24  2.0.0.0
thermo24.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 THERMO24_H
29 #define THERMO24_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 THERMO24_CMD_MEASURE_HIGH_PRECISION 0xFD
60 #define THERMO24_CMD_MEASURE_MEDIUM_PRECISION 0xF6
61 #define THERMO24_CMD_MEASURE_LOWEST_PRECISION 0xE0
62 #define THERMO24_CMD_READ_SERIAL 0x89
63 #define THERMO24_CMD_SOFT_RESET 0x94
64  // thermo24_cmd
66 
81 #define THERMO24_MEASURE_PRECISION_LOW 0x00
82 #define THERMO24_MEASURE_PRECISION_MEDIUM 0x01
83 #define THERMO24_MEASURE_PRECISION_HIGH 0x02
84 
89 #define THERMO24_TEMP_RESOLUTION 0xFFFF
90 #define THERMO24_TEMP_MULTIPLIER_CELSIUS 175.0
91 #define THERMO24_TEMP_OFFSET 45.0
92 
98 #define THERMO24_SET_DEVICE_ADDRESS 0x44
99  // thermo24_set
101 
116 #define THERMO24_MAP_MIKROBUS( cfg, mikrobus ) \
117  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
118  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
119  // thermo24_map // thermo24
122 
127 typedef struct
128 {
129  // Modules
130  i2c_master_t i2c;
132  // I2C slave address
133  uint8_t slave_address;
135 } thermo24_t;
136 
141 typedef struct
142 {
143  pin_name_t scl;
144  pin_name_t sda;
146  uint32_t i2c_speed;
147  uint8_t i2c_address;
150 
155 typedef enum
156 {
158  THERMO24_ERROR = -1
159 
161 
178 
193 
206 
218 err_t thermo24_read_serial ( thermo24_t *ctx, uint32_t *serial_num );
219 
235 err_t thermo24_read_temperature ( thermo24_t *ctx, uint8_t precision, float *temperature );
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 #endif // THERMO24_H
241  // thermo24
243 
244 // ------------------------------------------------------------------------ END
thermo24_return_value_t
thermo24_return_value_t
Thermo 24 Click return value data.
Definition: thermo24.h:156
THERMO24_OK
@ THERMO24_OK
Definition: thermo24.h:157
thermo24_t::slave_address
uint8_t slave_address
Definition: thermo24.h:133
THERMO24_ERROR
@ THERMO24_ERROR
Definition: thermo24.h:158
thermo24_cfg_t::i2c_address
uint8_t i2c_address
Definition: thermo24.h:147
thermo24_soft_reset
err_t thermo24_soft_reset(thermo24_t *ctx)
Thermo 24 soft reset function.
thermo24_cfg_t
Thermo 24 Click configuration object.
Definition: thermo24.h:142
thermo24_t::i2c
i2c_master_t i2c
Definition: thermo24.h:130
thermo24_cfg_t::scl
pin_name_t scl
Definition: thermo24.h:143
thermo24_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: thermo24.h:146
thermo24_cfg_setup
void thermo24_cfg_setup(thermo24_cfg_t *cfg)
Thermo 24 configuration object setup function.
thermo24_read_serial
err_t thermo24_read_serial(thermo24_t *ctx, uint32_t *serial_num)
Thermo 24 read serial function.
thermo24_cfg_t::sda
pin_name_t sda
Definition: thermo24.h:144
thermo24_read_temperature
err_t thermo24_read_temperature(thermo24_t *ctx, uint8_t precision, float *temperature)
Thermo 24 read temperature function.
thermo24_init
err_t thermo24_init(thermo24_t *ctx, thermo24_cfg_t *cfg)
Thermo 24 initialization function.
thermo24_t
Thermo 24 Click context object.
Definition: thermo24.h:128