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 
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_analog_in.h"
48 #include "drv_i2c_master.h"
49 
75 #define IRSENSE5_ROOM_TEMP_IN_K 298.15f
76 #define IRSENSE5_THERMISOR_BETA 3960.00f
77 #define IRSENSE5_INVERTED_VALUE 1.0f
78 #define IRSENSE5_TEMP_K_TO_C 273.15f
79 #define IRSENSE5_VREF_GAIN_X10 10.0f
80 #define IRSENSE5_LIN_FUN_MULT 10.121f
81 #define IRSENSE5_LIN_FUN_ADD 18.818f
82 
87 #define IRSENSE5_ADC_RESOLUTION 0x0FFF
88 #define IRSENSE5_VREF_3V3 3.3
89 #define IRSENSE5_VREF_5V 5.0
90 
96 #define IRSENSE5_SET_DEV_ADDR 0x4D
97  // irsense5_set
99 
114 #define IRSENSE5_MAP_MIKROBUS( cfg, mikrobus ) \
115  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
116  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
117  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
118  // irsense5_map // irsense5
121 
126 typedef struct
127 {
128 
129  analog_in_t adc;
130  i2c_master_t i2c;
132  uint8_t slave_address;
133  float vref;
135 } irsense5_t;
136 
141 typedef struct
142 {
143  pin_name_t an;
144  pin_name_t scl;
145  pin_name_t sda;
147  analog_in_resolution_t resolution;
148  float vref;
150  uint32_t i2c_speed;
151  uint8_t i2c_address;
154 
159 typedef enum
160 {
162  IRSENSE5_ERROR = -1
163 
165 
182 
197 
209 err_t irsense5_read_raw_adc_thermopile ( irsense5_t *ctx, uint16_t *raw_adc );
210 
222 err_t irsense5_read_raw_adc_thermistor ( irsense5_t *ctx, uint16_t *raw_adc );
223 
235 err_t irsense5_read_vtg_thp ( irsense5_t *ctx, float *voltage );
236 
248 err_t irsense5_read_vtg_thm ( irsense5_t *ctx, float *voltage );
249 
261 err_t irsense5_set_vref ( irsense5_t *ctx, float vref );
262 
274 err_t irsense5_get_amb_temp ( irsense5_t *ctx, float *amb_temp );
275 
287 err_t irsense5_get_obj_temp ( irsense5_t *ctx, float *obj_temp );
288 
289 #ifdef __cplusplus
290 }
291 #endif
292 #endif // IRSENSE5_H
293  // irsense5
295 
296 // ------------------------------------------------------------------------ END
irsense5_cfg_t::scl
pin_name_t scl
Definition: irsense5.h:144
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:162
irsense5_cfg_t::an
pin_name_t an
Definition: irsense5.h:143
irsense5_cfg_t
IR Sense 5 Click configuration object.
Definition: irsense5.h:142
irsense5_return_value_t
irsense5_return_value_t
IR Sense 5 Click return value data.
Definition: irsense5.h:160
irsense5_t
IR Sense 5 Click context object.
Definition: irsense5.h:127
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:129
irsense5_t::i2c
i2c_master_t i2c
Definition: irsense5.h:130
irsense5_cfg_t::sda
pin_name_t sda
Definition: irsense5.h:145
irsense5_read_raw_adc_thermistor
err_t irsense5_read_raw_adc_thermistor(irsense5_t *ctx, uint16_t *raw_adc)
IR Sense 5 read thermistor raw ADC value function.
irsense5_t::vref
float vref
Definition: irsense5.h:133
irsense5_cfg_t::vref
float vref
Definition: irsense5.h:148
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:150
irsense5_cfg_setup
void irsense5_cfg_setup(irsense5_cfg_t *cfg)
IR Sense 5 configuration object setup function.
irsense5_read_raw_adc_thermopile
err_t irsense5_read_raw_adc_thermopile(irsense5_t *ctx, uint16_t *raw_adc)
IR Sense 5 read thermopile raw ADC value function.
irsense5_t::slave_address
uint8_t slave_address
Definition: irsense5.h:132
IRSENSE5_OK
@ IRSENSE5_OK
Definition: irsense5.h:161
irsense5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: irsense5.h:147
irsense5_cfg_t::i2c_address
uint8_t i2c_address
Definition: irsense5.h:151
irsense5_set_vref
err_t irsense5_set_vref(irsense5_t *ctx, float vref)
IR Sense 5 set vref function.