irthermo3 2.0.0.0
irthermo3.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 IRTHERMO3_H
36#define IRTHERMO3_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_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define IRTHERMO3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define IRTHERMO3_OK 0x00
76#define IRTHERMO3_ERROR 0xFF
83#define IRTHERMO3_DEV_ADR_GND 0x3A
84#define IRTHERMO3_DEV_ADR_VCC 0x3B
91#define IRTHERMO3_EEPROM_VERSION 0x240B
98#define IRTHERMO3_EEPROM_CAL_CONST_P_R_LSW 0x240C
99#define IRTHERMO3_EEPROM_CAL_CONST_P_R_MSW 0x240D
100#define IRTHERMO3_EEPROM_CAL_CONST_P_G_LSW 0x240E
101#define IRTHERMO3_EEPROM_CAL_CONST_P_G_MSW 0x240F
102#define IRTHERMO3_EEPROM_CAL_CONST_P_T_LSW 0x2410
103#define IRTHERMO3_EEPROM_CAL_CONST_P_T_MSW 0x2411
104#define IRTHERMO3_EEPROM_CAL_CONST_P_O_LSW 0x2412
105#define IRTHERMO3_EEPROM_CAL_CONST_P_O_MSW 0x2413
106#define IRTHERMO3_EEPROM_CAL_CONST_AA_LSW 0x2414
107#define IRTHERMO3_EEPROM_CAL_CONST_AA_MSW 0x2415
108#define IRTHERMO3_EEPROM_CAL_CONST_AB_LSW 0x2416
109#define IRTHERMO3_EEPROM_CAL_CONST_AB_MSW 0x2417
110#define IRTHERMO3_EEPROM_CAL_CONST_BA_LSW 0x2418
111#define IRTHERMO3_EEPROM_CAL_CONST_BA_MSW 0x2419
112#define IRTHERMO3_EEPROM_CAL_CONST_BB_LSW 0x241A
113#define IRTHERMO3_EEPROM_CAL_CONST_BB_MSW 0x241B
114#define IRTHERMO3_EEPROM_CAL_CONST_CA_LSW 0x241C
115#define IRTHERMO3_EEPROM_CAL_CONST_CA_MSW 0x241D
116#define IRTHERMO3_EEPROM_CAL_CONST_CB_LSW 0x241E
117#define IRTHERMO3_EEPROM_CAL_CONST_CB_MSW 0x241F
118#define IRTHERMO3_EEPROM_CAL_CONST_DA_LSW 0x2420
119#define IRTHERMO3_EEPROM_CAL_CONST_DA_MSW 0x2421
120#define IRTHERMO3_EEPROM_CAL_CONST_DB_LSW 0x2422
121#define IRTHERMO3_EEPROM_CAL_CONST_DB_MSW 0x2423
122#define IRTHERMO3_EEPROM_CAL_CONST_EA_LSW 0x2424
123#define IRTHERMO3_EEPROM_CAL_CONST_EA_MSW 0x2425
124#define IRTHERMO3_EEPROM_CAL_CONST_EB_LSW 0x2426
125#define IRTHERMO3_EEPROM_CAL_CONST_EB_MSW 0x2427
126#define IRTHERMO3_EEPROM_CAL_CONST_FA_LSW 0x2428
127#define IRTHERMO3_EEPROM_CAL_CONST_FA_MSW 0x2429
128#define IRTHERMO3_EEPROM_CAL_CONST_FB_LSW 0x242A
129#define IRTHERMO3_EEPROM_CAL_CONST_FB_MSW 0x242B
130#define IRTHERMO3_EEPROM_CAL_CONST_GA_LSW 0x242C
131#define IRTHERMO3_EEPROM_CAL_CONST_GA_MSW 0x242D
132#define IRTHERMO3_EEPROM_CAL_CONST_GB 0x242E
133#define IRTHERMO3_EEPROM_CAL_CONST_KA 0x242E
134#define IRTHERMO3_EEPROM_CAL_CONST_KB 0x242E
135#define IRTHERMO3_EEPROM_CAL_CONST_HA_COSTUMER 0x2481
136#define IRTHERMO3_EEPROM_CAL_CONST_HB_COSTUMER 0x2482
143#define IRTHERMO3_EEPROM_CTRL_REG 0x24D4
144#define IRTHERMO3_EEPROM_I2C_ADDRESS 0x24D5
145#define IRTHERMO3_REG_I2C_ADDRESS 0x3000
146#define IRTHERMO3_REG_CONTROL 0x3001
147#define IRTHERMO3_REG_RESET 0x3005
148#define IRTHERMO3_REG_STATUS 0x3FFF
155#define IRTHERMO3_RAW_DATA_1 0x4000
156#define IRTHERMO3_RAW_DATA_2 0x4001
157#define IRTHERMO3_RAW_DATA_3 0x4002
158#define IRTHERMO3_RAW_DATA_4 0x4003
159#define IRTHERMO3_RAW_DATA_5 0x4004
160#define IRTHERMO3_RAW_DATA_6 0x4005
161#define IRTHERMO3_RAW_DATA_7 0x4006
162#define IRTHERMO3_RAW_DATA_8 0x4007
163#define IRTHERMO3_RAW_DATA_9 0x4008
170#define IRTHERMO3_MODE_SLEEP 0x02
171#define IRTHERMO3_MODE_STEPIN 0x04
172#define IRTHERMO3_MODE_CONTINOUS 0x06
175 // End group macro
176// --------------------------------------------------------------- PUBLIC TYPES
185typedef struct
186{
187 float p_r;
188 float p_g;
189 float p_t;
190 float p_o;
191 float ea;
192 float eb;
193 float fa;
194 float fb;
195 float ga;
196 float gb;
197 float ka;
198 float ha;
199 float hb;
200
202
206typedef struct
207{
208 // Modules
209 i2c_master_t i2c;
210
211 // ctx variable
213
214 // Calculation coefficients
216
218
222typedef struct
223{
224 // Communication gpio pins
225 pin_name_t scl;
226 pin_name_t sda;
227
228 // static variable
229 uint32_t i2c_speed;
230 uint8_t i2c_address;
231
233
234 // End types group
235// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
236
242#ifdef __cplusplus
243extern "C"{
244#endif
245
255
265
276void irthermo3_generic_write ( irthermo3_t *ctx, uint16_t reg, uint8_t *data_buf, uint8_t len );
277
288void irthermo3_generic_read ( irthermo3_t *ctx, uint16_t reg, uint8_t *data_buf, uint8_t len );
289
299void irthermo3_write_u16 ( irthermo3_t *ctx, uint16_t reg, uint16_t wr_data );
300
311int16_t irthermo3_read_i16( irthermo3_t *ctx, uint16_t reg );
312
323int32_t irthermo3_read_i32 ( irthermo3_t *ctx, uint16_t reg );
324
333void irthermo3_set_mode( irthermo3_t *ctx, uint8_t mode );
334
344
353
362
363#ifdef __cplusplus
364}
365#endif
366#endif // _IRTHERMO3_H_
367
368 // End public_function group
370
371// ------------------------------------------------------------------------- END
float irthermo3_get_ambient_temp(irthermo3_t *ctx)
Read Ambient Temperature function.
void irthermo3_cfg_setup(irthermo3_cfg_t *cfg)
Config Object Initialization function.
void irthermo3_generic_read(irthermo3_t *ctx, uint16_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void irthermo3_generic_write(irthermo3_t *ctx, uint16_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
int16_t irthermo3_read_i16(irthermo3_t *ctx, uint16_t reg)
Read i16 dat function.
void irthermo3_cal(irthermo3_t *ctx)
Calibration function.
int32_t irthermo3_read_i32(irthermo3_t *ctx, uint16_t reg)
Read i32 dat function.
void irthermo3_set_mode(irthermo3_t *ctx, uint8_t mode)
Set device mode function.
void irthermo3_write_u16(irthermo3_t *ctx, uint16_t reg, uint16_t wr_data)
Write u16 data function.
err_t irthermo3_init(irthermo3_t *ctx, irthermo3_cfg_t *cfg)
Initialization function.
float irthermo3_get_object_temp(irthermo3_t *ctx)
Read Object Temperature function.
Calculation coefficients.
Definition irthermo3.h:186
float ka
Definition irthermo3.h:197
float p_g
Definition irthermo3.h:188
float ga
Definition irthermo3.h:195
float eb
Definition irthermo3.h:192
float ea
Definition irthermo3.h:191
float p_t
Definition irthermo3.h:189
float gb
Definition irthermo3.h:196
float ha
Definition irthermo3.h:198
float hb
Definition irthermo3.h:199
float fb
Definition irthermo3.h:194
float fa
Definition irthermo3.h:193
float p_r
Definition irthermo3.h:187
float p_o
Definition irthermo3.h:190
Click configuration structure definition.
Definition irthermo3.h:223
uint32_t i2c_speed
Definition irthermo3.h:229
pin_name_t scl
Definition irthermo3.h:225
pin_name_t sda
Definition irthermo3.h:226
uint8_t i2c_address
Definition irthermo3.h:230
Click ctx object definition.
Definition irthermo3.h:207
i2c_master_t i2c
Definition irthermo3.h:209
irthermo3_cal_coef_t cal_coef
Definition irthermo3.h:215
uint8_t slave_address
Definition irthermo3.h:212