irsense5 2.2.0
Loading...
Searching...
No Matches
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
27
28#ifndef IRSENSE5_H
29#define IRSENSE5_H
30
31#ifdef __cplusplus
32extern "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
59
64
69
74
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
108
113
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
130typedef struct
131{
132
133 analog_in_t adc;
134 i2c_master_t i2c;
135
137 float vref;
138
139} irsense5_t;
140
145typedef struct
146{
147 pin_name_t an;
148 pin_name_t scl;
149 pin_name_t sda;
150
151 analog_in_resolution_t resolution;
152 float vref;
153
154 uint32_t i2c_speed;
155 uint8_t i2c_address;
156
158
163typedef enum
164{
167
169
175
186
201
213err_t irsense5_read_raw_adc_thp ( irsense5_t *ctx, uint16_t *raw_adc );
214
226err_t irsense5_read_raw_adc_thm ( irsense5_t *ctx, uint16_t *raw_adc );
227
239err_t irsense5_read_vtg_thp ( irsense5_t *ctx, float *voltage );
240
252err_t irsense5_read_vtg_thm ( irsense5_t *ctx, float *voltage );
253
265err_t irsense5_set_vref ( irsense5_t *ctx, float vref );
266
278err_t irsense5_get_amb_temp ( irsense5_t *ctx, float *amb_temp );
279
291err_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
err_t irsense5_read_vtg_thp(irsense5_t *ctx, float *voltage)
IR Sense 5 read thermopile voltage level function.
err_t irsense5_read_raw_adc_thm(irsense5_t *ctx, uint16_t *raw_adc)
IR Sense 5 read thermistor raw ADC value function.
err_t irsense5_set_vref(irsense5_t *ctx, float vref)
IR Sense 5 set vref function.
err_t irsense5_read_raw_adc_thp(irsense5_t *ctx, uint16_t *raw_adc)
IR Sense 5 read thermopile raw ADC value function.
err_t irsense5_get_amb_temp(irsense5_t *ctx, float *amb_temp)
IR Sense 5 get ambient temperature function.
err_t irsense5_init(irsense5_t *ctx, irsense5_cfg_t *cfg)
IR Sense 5 initialization function.
err_t irsense5_get_obj_temp(irsense5_t *ctx, float *obj_temp)
IR Sense 5 get object temperature function.
err_t irsense5_read_vtg_thm(irsense5_t *ctx, float *voltage)
IR Sense 5 read thermistor voltage level function.
void irsense5_cfg_setup(irsense5_cfg_t *cfg)
IR Sense 5 configuration object setup function.
irsense5_return_value_t
IR Sense 5 Click return value data.
Definition irsense5.h:164
@ IRSENSE5_ERROR
Definition irsense5.h:166
@ IRSENSE5_OK
Definition irsense5.h:165
IR Sense 5 Click configuration object.
Definition irsense5.h:146
analog_in_resolution_t resolution
Definition irsense5.h:151
float vref
Definition irsense5.h:152
uint32_t i2c_speed
Definition irsense5.h:154
pin_name_t scl
Definition irsense5.h:148
pin_name_t sda
Definition irsense5.h:149
pin_name_t an
Definition irsense5.h:147
uint8_t i2c_address
Definition irsense5.h:155
IR Sense 5 Click context object.
Definition irsense5.h:131
float vref
Definition irsense5.h:137
i2c_master_t i2c
Definition irsense5.h:134
uint8_t slave_address
Definition irsense5.h:136
analog_in_t adc
Definition irsense5.h:133