irgrid 2.0.0.0
irgrid.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 IRGRID_H
29#define IRGRID_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_i2c_master.h"
52
73#define IRGRID_CAL_ACOMMON_L 0xD0
74#define IRGRID_CAL_ACOMMON_H 0xD1
75#define IRGRID_CAL_ACP_L 0xD3
76#define IRGRID_CAL_ACP_H 0xD4
77#define IRGRID_CAL_BCP 0xD5
78#define IRGRID_CAL_ALPHA_CP_L 0xD6
79#define IRGRID_CAL_ALPHA_CP_H 0xD7
80#define IRGRID_CAL_TGC 0xD8
81#define IRGRID_CAL_AI_SCALE 0xD9
82#define IRGRID_CAL_BI_SCALE 0xD9
83#define IRGRID_VTH_L 0xDA
84#define IRGRID_VTH_H 0xDB
85#define IRGRID_KT1_L 0xDC
86#define IRGRID_KT1_H 0xDD
87#define IRGRID_KT2_L 0xDE
88#define IRGRID_KT2_H 0xDF
89#define IRGRID_KT_SCALE 0xD2
90#define IRGRID_CAL_A0_L 0xE0
91#define IRGRID_CAL_A0_H 0xE1
92#define IRGRID_CAL_A0_SCALE 0xE2
93#define IRGRID_CAL_DELTA_A_SCALE 0xE3
94#define IRGRID_CAL_EMIS_L 0xE4
95#define IRGRID_CAL_EMIS_H 0xE5
96#define IRGRID_OSC_TRIM_VALUE 0xF7
97
98 // irgrid_reg
99
119#define IRGRID_MAP_MIKROBUS( cfg, mikrobus ) \
120 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
121 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
122
123 // irgrid_map
124 // irgrid
125
130typedef struct
131{
132 // Modules
133 i2c_master_t i2c;
135 // I2C slave address
138
139 // static variable
142 int16_t resolution;
143 int16_t cpix;
144 int16_t ptat;
145
146} irgrid_t;
147
152typedef struct
153{
154 pin_name_t scl;
155 pin_name_t sda;
157 uint32_t i2c_speed;
162
166typedef struct
167{
168 // Static variable
169
170 uint8_t eeprom_data[ 256 ];
171 int16_t ir_data[ 64 ];
172 float temperature_data[ 64 ];
173 float a_data[ 64 ];
174 float b_data[ 64 ];
175 float alpha_a_data[ 64 ];
176
178
183typedef enum
184{
186 IRGRID_ERROR = -1
187
189
206
221err_t irgrid_init ( irgrid_t *ctx, irgrid_cfg_t *cfg );
222
234uint8_t irgrid_device_init ( irgrid_t *ctx, irgrid_data_t *data_str, uint8_t refrate );
235
245void irgrid_write_ram( irgrid_t *ctx, uint8_t *data_buf, uint8_t len );
246
257void irgrid_read_ram ( irgrid_t *ctx, uint8_t *reg, uint8_t *data_buf, uint8_t len );
258
269void irgrid_write_eeprom ( irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
270
281void irgrid_read_eeprom ( irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
282
293uint8_t irgrid_measure ( irgrid_t *ctx, irgrid_data_t *data_str );
294
303void irgrid_get_ir_raw ( irgrid_data_t *data_str, int16_t *buffer );
304
313void irgrid_get_temperature ( irgrid_data_t *data_str, float *buffer );
314
325
326#ifdef __cplusplus
327}
328#endif
329#endif // IRGRID_H
330
331 // irgrid
332
333// ------------------------------------------------------------------------ END
void irgrid_read_ram(irgrid_t *ctx, uint8_t *reg, uint8_t *data_buf, uint8_t len)
Read function using RAM slave adress.
void irgrid_write_eeprom(irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Write function using EEPROM slave adress.
void irgrid_get_temperature(irgrid_data_t *data_str, float *buffer)
Read Calculated Temperature buffer.
void irgrid_read_eeprom(irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Read function using EEPROM slave adress.
float irgrid_get_amb_temperature(irgrid_t *ctx)
Read Ambient Temperature.
void irgrid_get_ir_raw(irgrid_data_t *data_str, int16_t *buffer)
Read Raw Temperature buffer.
uint8_t irgrid_measure(irgrid_t *ctx, irgrid_data_t *data_str)
Measurement.
void irgrid_cfg_setup(irgrid_cfg_t *cfg)
IR Grid configuration object setup function.
uint8_t irgrid_device_init(irgrid_t *ctx, irgrid_data_t *data_str, uint8_t refrate)
Device Initialization.
err_t irgrid_init(irgrid_t *ctx, irgrid_cfg_t *cfg)
IR Grid initialization function.
void irgrid_write_ram(irgrid_t *ctx, uint8_t *data_buf, uint8_t len)
Write function using RAM slave adress.
irgrid_return_value_t
IR Grid Click return value data.
Definition irgrid.h:184
@ IRGRID_OK
Definition irgrid.h:185
@ IRGRID_ERROR
Definition irgrid.h:186
IR Grid Click configuration object.
Definition irgrid.h:153
uint8_t i2c_ram_address
Definition irgrid.h:158
uint32_t i2c_speed
Definition irgrid.h:157
pin_name_t scl
Definition irgrid.h:154
uint8_t i2c_eeprom_address
Definition irgrid.h:159
pin_name_t sda
Definition irgrid.h:155
Click data object definition.
Definition irgrid.h:167
IR Grid Click context object.
Definition irgrid.h:131
uint8_t slave_eeprom_address
Definition irgrid.h:137
uint8_t refresh_rate
Definition irgrid.h:140
uint8_t slave_ram_address
Definition irgrid.h:136
int16_t cpix
Definition irgrid.h:143
float temperature_amb
Definition irgrid.h:141
int16_t ptat
Definition irgrid.h:144
i2c_master_t i2c
Definition irgrid.h:133
int16_t resolution
Definition irgrid.h:142