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 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
52 
73 #define THERMO24_CMD_MEASURE_HIGH_PRECISION 0xFD
74 #define THERMO24_CMD_MEASURE_MEDIUM_PRECISION 0xF6
75 #define THERMO24_CMD_MEASURE_LOWEST_PRECISION 0xE0
76 #define THERMO24_CMD_READ_SERIAL 0x89
77 #define THERMO24_CMD_SOFT_RESET 0x94
78  // thermo24_cmd
80 
95 #define THERMO24_MEASURE_PRECISION_LOW 0x00
96 #define THERMO24_MEASURE_PRECISION_MEDIUM 0x01
97 #define THERMO24_MEASURE_PRECISION_HIGH 0x02
98 
103 #define THERMO24_TEMP_RESOLUTION 0xFFFF
104 #define THERMO24_TEMP_MULTIPLIER_CELSIUS 175.0
105 #define THERMO24_TEMP_OFFSET 45.0
106 
112 #define THERMO24_SET_DEVICE_ADDRESS 0x44
113  // thermo24_set
115 
130 #define THERMO24_MAP_MIKROBUS( cfg, mikrobus ) \
131  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
132  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
133  // thermo24_map // thermo24
136 
141 typedef struct
142 {
143  // Modules
144  i2c_master_t i2c;
146  // I2C slave address
147  uint8_t slave_address;
149 } thermo24_t;
150 
155 typedef struct
156 {
157  pin_name_t scl;
158  pin_name_t sda;
160  uint32_t i2c_speed;
161  uint8_t i2c_address;
164 
169 typedef enum
170 {
172  THERMO24_ERROR = -1
173 
175 
192 
207 
220 
232 err_t thermo24_read_serial ( thermo24_t *ctx, uint32_t *serial_num );
233 
249 err_t thermo24_read_temperature ( thermo24_t *ctx, uint8_t precision, float *temperature );
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 #endif // THERMO24_H
255  // thermo24
257 
258 // ------------------------------------------------------------------------ END
thermo24_return_value_t
thermo24_return_value_t
Thermo 24 Click return value data.
Definition: thermo24.h:170
THERMO24_OK
@ THERMO24_OK
Definition: thermo24.h:171
thermo24_t::slave_address
uint8_t slave_address
Definition: thermo24.h:147
THERMO24_ERROR
@ THERMO24_ERROR
Definition: thermo24.h:172
thermo24_cfg_t::i2c_address
uint8_t i2c_address
Definition: thermo24.h:161
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:156
thermo24_t::i2c
i2c_master_t i2c
Definition: thermo24.h:144
thermo24_cfg_t::scl
pin_name_t scl
Definition: thermo24.h:157
thermo24_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: thermo24.h:160
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:158
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:142