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 "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define THERMO24_CMD_MEASURE_HIGH_PRECISION 0xFD
70 #define THERMO24_CMD_MEASURE_MEDIUM_PRECISION 0xF6
71 #define THERMO24_CMD_MEASURE_LOWEST_PRECISION 0xE0
72 #define THERMO24_CMD_READ_SERIAL 0x89
73 #define THERMO24_CMD_SOFT_RESET 0x94
74  // thermo24_cmd
76 
91 #define THERMO24_MEASURE_PRECISION_LOW 0x00
92 #define THERMO24_MEASURE_PRECISION_MEDIUM 0x01
93 #define THERMO24_MEASURE_PRECISION_HIGH 0x02
94 
99 #define THERMO24_TEMP_RESOLUTION 0xFFFF
100 #define THERMO24_TEMP_MULTIPLIER_CELSIUS 175.0
101 #define THERMO24_TEMP_OFFSET 45.0
102 
108 #define THERMO24_SET_DEVICE_ADDRESS 0x44
109  // thermo24_set
111 
126 #define THERMO24_MAP_MIKROBUS( cfg, mikrobus ) \
127  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
128  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
129  // thermo24_map // thermo24
132 
137 typedef struct
138 {
139  // Modules
140  i2c_master_t i2c;
142  // I2C slave address
143  uint8_t slave_address;
145 } thermo24_t;
146 
151 typedef struct
152 {
153  pin_name_t scl;
154  pin_name_t sda;
156  uint32_t i2c_speed;
157  uint8_t i2c_address;
160 
165 typedef enum
166 {
168  THERMO24_ERROR = -1
169 
171 
188 
203 
216 
228 err_t thermo24_read_serial ( thermo24_t *ctx, uint32_t *serial_num );
229 
245 err_t thermo24_read_temperature ( thermo24_t *ctx, uint8_t precision, float *temperature );
246 
247 #ifdef __cplusplus
248 }
249 #endif
250 #endif // THERMO24_H
251  // thermo24
253 
254 // ------------------------------------------------------------------------ END
thermo24_return_value_t
thermo24_return_value_t
Thermo 24 Click return value data.
Definition: thermo24.h:166
THERMO24_OK
@ THERMO24_OK
Definition: thermo24.h:167
thermo24_t::slave_address
uint8_t slave_address
Definition: thermo24.h:143
THERMO24_ERROR
@ THERMO24_ERROR
Definition: thermo24.h:168
thermo24_cfg_t::i2c_address
uint8_t i2c_address
Definition: thermo24.h:157
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:152
thermo24_t::i2c
i2c_master_t i2c
Definition: thermo24.h:140
thermo24_cfg_t::scl
pin_name_t scl
Definition: thermo24.h:153
thermo24_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: thermo24.h:156
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:154
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:138