irsense5  2.1.0.0
irsense5.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 IRSENSE5_H
29 #define IRSENSE5_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_analog_in.h"
52 #include "drv_i2c_master.h"
53 
79 #define IRSENSE5_ROOM_TEMP_IN_K 298.15f
80 #define IRSENSE5_THERMISOR_BETA 3960.00f
81 #define IRSENSE5_INVERTED_VALUE 1.0f
82 #define IRSENSE5_TEMP_K_TO_C 273.15f
83 #define IRSENSE5_VREF_GAIN_X10 10.0f
84 #define IRSENSE5_LIN_FUN_MULT 10.121f
85 #define IRSENSE5_LIN_FUN_ADD 18.818f
86 
91 #define IRSENSE5_ADC_RESOLUTION 0x0FFF
92 #define IRSENSE5_VREF_3V3 3.3
93 #define IRSENSE5_VREF_5V 5.0
94 
100 #define IRSENSE5_SET_DEV_ADDR 0x4D
101  // irsense5_set
103 
118 #define IRSENSE5_MAP_MIKROBUS( cfg, mikrobus ) \
119  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
120  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
121  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
122  // irsense5_map // irsense5
125 
130 typedef struct
131 {
132 
133  analog_in_t adc;
134  i2c_master_t i2c;
136  uint8_t slave_address;
137  float vref;
139 } irsense5_t;
140 
145 typedef struct
146 {
147  pin_name_t an;
148  pin_name_t scl;
149  pin_name_t sda;
151  analog_in_resolution_t resolution;
152  float vref;
154  uint32_t i2c_speed;
155  uint8_t i2c_address;
158 
163 typedef enum
164 {
166  IRSENSE5_ERROR = -1
167 
169 
186 
201 
213 err_t irsense5_read_raw_adc_thp ( irsense5_t *ctx, uint16_t *raw_adc );
214 
226 err_t irsense5_read_raw_adc_thm ( irsense5_t *ctx, uint16_t *raw_adc );
227 
239 err_t irsense5_read_vtg_thp ( irsense5_t *ctx, float *voltage );
240 
252 err_t irsense5_read_vtg_thm ( irsense5_t *ctx, float *voltage );
253 
265 err_t irsense5_set_vref ( irsense5_t *ctx, float vref );
266 
278 err_t irsense5_get_amb_temp ( irsense5_t *ctx, float *amb_temp );
279 
291 err_t irsense5_get_obj_temp ( irsense5_t *ctx, float *obj_temp );
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 #endif // IRSENSE5_H
297  // irsense5
299 
300 // ------------------------------------------------------------------------ END
irsense5_cfg_t::scl
pin_name_t scl
Definition: irsense5.h:148
irsense5_read_vtg_thp
err_t irsense5_read_vtg_thp(irsense5_t *ctx, float *voltage)
IR Sense 5 read thermopile voltage level function.
IRSENSE5_ERROR
@ IRSENSE5_ERROR
Definition: irsense5.h:166
irsense5_cfg_t::an
pin_name_t an
Definition: irsense5.h:147
irsense5_cfg_t
IR Sense 5 Click configuration object.
Definition: irsense5.h:146
irsense5_return_value_t
irsense5_return_value_t
IR Sense 5 Click return value data.
Definition: irsense5.h:164
irsense5_t
IR Sense 5 Click context object.
Definition: irsense5.h:131
irsense5_init
err_t irsense5_init(irsense5_t *ctx, irsense5_cfg_t *cfg)
IR Sense 5 initialization function.
irsense5_get_obj_temp
err_t irsense5_get_obj_temp(irsense5_t *ctx, float *obj_temp)
IR Sense 5 get object temperature function.
irsense5_get_amb_temp
err_t irsense5_get_amb_temp(irsense5_t *ctx, float *amb_temp)
IR Sense 5 get ambient temperature function.
irsense5_t::adc
analog_in_t adc
Definition: irsense5.h:133
irsense5_t::i2c
i2c_master_t i2c
Definition: irsense5.h:134
irsense5_read_raw_adc_thm
err_t irsense5_read_raw_adc_thm(irsense5_t *ctx, uint16_t *raw_adc)
IR Sense 5 read thermistor raw ADC value function.
irsense5_cfg_t::sda
pin_name_t sda
Definition: irsense5.h:149
irsense5_t::vref
float vref
Definition: irsense5.h:137
irsense5_read_raw_adc_thp
err_t irsense5_read_raw_adc_thp(irsense5_t *ctx, uint16_t *raw_adc)
IR Sense 5 read thermopile raw ADC value function.
irsense5_cfg_t::vref
float vref
Definition: irsense5.h:152
irsense5_read_vtg_thm
err_t irsense5_read_vtg_thm(irsense5_t *ctx, float *voltage)
IR Sense 5 read thermistor voltage level function.
irsense5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: irsense5.h:154
irsense5_cfg_setup
void irsense5_cfg_setup(irsense5_cfg_t *cfg)
IR Sense 5 configuration object setup function.
irsense5_t::slave_address
uint8_t slave_address
Definition: irsense5.h:136
IRSENSE5_OK
@ IRSENSE5_OK
Definition: irsense5.h:165
irsense5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: irsense5.h:151
irsense5_cfg_t::i2c_address
uint8_t i2c_address
Definition: irsense5.h:155
irsense5_set_vref
err_t irsense5_set_vref(irsense5_t *ctx, float vref)
IR Sense 5 set vref function.