thermo17 2.0.0.0
thermo17.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef THERMO17_H
36#define THERMO17_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
54
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define THERMO17_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define THERMO17_SLAVE_ADDRESS 0x4C
84#define THERMO17_REG_R_LOCAL_TEMP_HB 0x00
85#define THERMO17_REG_R_REMOTE_TEMP_HB 0x01
86#define THERMO17_REG_R_STATUS 0x02
87#define THERMO17_REG_R_CFG 0x03
88#define THERMO17_REG_R_CONVERSION_RATE 0x04
89#define THERMO17_REG_R_LOCAL_TEMP_LIMIT_H 0x05
90#define THERMO17_REG_R_LOCAL_TEMP_LIMIT_L 0x06
91#define THERMO17_REG_R_REMOTE_TEMP_LIMIT_H_HB 0x07
92#define THERMO17_REG_R_REMOTE_TEMP_LIMIT_L_HB 0x08
93#define THERMO17_REG_R_REMOTE_TEMP_LB 0x10
94#define THERMO17_REG_RW_REMOTE_TEMP_OFFSET_HB 0x11
95#define THERMO17_REG_RW_REMOTE_TEMP_OFFSET_LB 0x12
96#define THERMO17_REG_RW_REMOTE_TEMP_LIMIT_H_LB 0x13
97#define THERMO17_REG_RW_REMOTE_TEMP_LIMIT_L_LB 0x14
98#define THERMO17_REG_R_LOCAL_TEMP_LB 0x15
99#define THERMO17_REG_RW_REMOTE_TEMP_THERM_LIMIT 0x19
100#define THERMO17_REG_RW_LOCAL_TEMP_THERM_LIMIT 0x20
101#define THERMO17_REG_RW_THERMO_HYSTERESIS 0x21
102#define THERMO17_REG_RW_CONSECUTIVE_ALERT 0x22
103#define THERMO17_REG_RW_M_FACTOR_CORRECTION 0x23
104#define THERMO17_REG_RW_DIGITAL_FILTER_CTRL 0x24
105#define THERMO17_REG_R_ID 0xFE
106#define THERMO17_REG_W_CFG 0x09
107#define THERMO17_REG_W_CONVERSION_RATE 0x0A
108#define THERMO17_REG_W_LOCAL_TEMP_LIMIT_H 0x0B
109#define THERMO17_REG_W_LOCAL_TEMP_LIMIT_L 0x0C
110#define THERMO17_REG_W_REMOTE_TEMP_LIMIT_H_HB 0x0D
111#define THERMO17_REG_W_REMOTE_TEMP_LIMIT_L_HB 0x0E
112#define THERMO17_REG_W_ONE_SHOT 0x0F
119#define THERMO17_TEMPERATURE_LOCAL 0xAA
120#define THERMO17_TEMPERATURE_REMOTE 0xBB
121#define THERMO17_ERROR 0x00
128#define THERMO17_DEV_ID 0x55
135#define THERMO17_STATUS_BUSY 0x80
136#define THERMO17_STATUS_LOCAL_HIGH_TEMP 0x40
137#define THERMO17_STATUS_LOCAL_LOW_TEMP 0x20
138#define THERMO17_STATUS_REMOTE_HIGH_TEMP 0x10
139#define THERMO17_STATUS_REMOTE_LOW_TEMP 0x08
140#define THERMO17_STATUS_REMOTE_SENS_OPEN_CIRCUIT 0x04
141#define THERMO17_STATUS_REMOTE_THERM_TIPPED 0x02
142#define THERMO17_STATUS_LOCAL_THERM_TIPPED 0x01
149#define THERMO17_RETVAL uint8_t
150
151#define THERMO17_OK 0x00
152#define THERMO17_INIT_ERROR 0xFF
157 // End group macro
158// --------------------------------------------------------------- PUBLIC TYPES
167typedef struct
168{
169 // Input pins
170
171 digital_in_t an;
172 digital_in_t int_pin;
173
174 // Modules
175
176 i2c_master_t i2c;
177
178 // ctx variable
179
181
182} thermo17_t;
183
187typedef struct
188{
189 // Communication gpio pins
190
191 pin_name_t scl;
192 pin_name_t sda;
193
194 // Additional gpio pins
195
196 pin_name_t an;
197 pin_name_t int_pin;
198
199 // static variable
200
201 uint32_t i2c_speed;
202 uint8_t i2c_address;
203
205
206 // End variable group
207// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
208
214#ifdef __cplusplus
215extern "C"{
216#endif
217
227
237
247void thermo17_generic_write ( thermo17_t *ctx, uint8_t reg_adr, uint8_t write_data );
248
259uint8_t thermo17_generic_read ( thermo17_t *ctx, uint8_t reg_adr );
260
272float thermo17_read_temp ( thermo17_t *ctx, uint8_t temp_macro );
273
284
295
296#ifdef __cplusplus
297}
298#endif
299#endif // _THERMO17_H_
300
301 // End public_function group
303
304// ------------------------------------------------------------------------- END
#define THERMO17_RETVAL
Definition thermo17.h:149
uint8_t thermo17_generic_read(thermo17_t *ctx, uint8_t reg_adr)
Generic read function.
uint8_t thermo17_get_an_status(thermo17_t *ctx)
Checks status of an pin.
float thermo17_read_temp(thermo17_t *ctx, uint8_t temp_macro)
Function for reading temperature.
THERMO17_RETVAL thermo17_init(thermo17_t *ctx, thermo17_cfg_t *cfg)
Initialization function.
uint8_t thermo17_get_int_status(thermo17_t *ctx)
Checks status of int pin.
void thermo17_generic_write(thermo17_t *ctx, uint8_t reg_adr, uint8_t write_data)
Generic write function.
void thermo17_cfg_setup(thermo17_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition thermo17.h:188
uint32_t i2c_speed
Definition thermo17.h:201
pin_name_t scl
Definition thermo17.h:191
pin_name_t int_pin
Definition thermo17.h:197
pin_name_t sda
Definition thermo17.h:192
pin_name_t an
Definition thermo17.h:196
uint8_t i2c_address
Definition thermo17.h:202
Click ctx object definition.
Definition thermo17.h:168
digital_in_t int_pin
Definition thermo17.h:172
i2c_master_t i2c
Definition thermo17.h:176
digital_in_t an
Definition thermo17.h:171
uint8_t slave_address
Definition thermo17.h:180