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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define IRGRID_CAL_ACOMMON_L 0xD0
60 #define IRGRID_CAL_ACOMMON_H 0xD1
61 #define IRGRID_CAL_ACP_L 0xD3
62 #define IRGRID_CAL_ACP_H 0xD4
63 #define IRGRID_CAL_BCP 0xD5
64 #define IRGRID_CAL_ALPHA_CP_L 0xD6
65 #define IRGRID_CAL_ALPHA_CP_H 0xD7
66 #define IRGRID_CAL_TGC 0xD8
67 #define IRGRID_CAL_AI_SCALE 0xD9
68 #define IRGRID_CAL_BI_SCALE 0xD9
69 #define IRGRID_VTH_L 0xDA
70 #define IRGRID_VTH_H 0xDB
71 #define IRGRID_KT1_L 0xDC
72 #define IRGRID_KT1_H 0xDD
73 #define IRGRID_KT2_L 0xDE
74 #define IRGRID_KT2_H 0xDF
75 #define IRGRID_KT_SCALE 0xD2
76 #define IRGRID_CAL_A0_L 0xE0
77 #define IRGRID_CAL_A0_H 0xE1
78 #define IRGRID_CAL_A0_SCALE 0xE2
79 #define IRGRID_CAL_DELTA_A_SCALE 0xE3
80 #define IRGRID_CAL_EMIS_L 0xE4
81 #define IRGRID_CAL_EMIS_H 0xE5
82 #define IRGRID_OSC_TRIM_VALUE 0xF7
83  // irgrid_reg
85 
105 #define IRGRID_MAP_MIKROBUS( cfg, mikrobus ) \
106  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
107  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
108  // irgrid_map // irgrid
111 
116 typedef struct
117 {
118  // Modules
119  i2c_master_t i2c;
121  // I2C slave address
122  uint8_t slave_ram_address;
123  uint8_t slave_eeprom_address;
124 
125  // static variable
126  uint8_t refresh_rate;
127  float temperature_amb;
128  int16_t resolution;
129  int16_t cpix;
130  int16_t ptat;
131 
132 } irgrid_t;
133 
138 typedef struct
139 {
140  pin_name_t scl;
141  pin_name_t sda;
143  uint32_t i2c_speed;
144  uint8_t i2c_ram_address;
145  uint8_t i2c_eeprom_address;
147 } irgrid_cfg_t;
148 
152 typedef struct
153 {
154  // Static variable
155 
156  uint8_t eeprom_data[ 256 ];
157  int16_t ir_data[ 64 ];
158  float temperature_data[ 64 ];
159  float a_data[ 64 ];
160  float b_data[ 64 ];
161  float alpha_a_data[ 64 ];
162 
163 } irgrid_data_t;
164 
169 typedef enum
170 {
172  IRGRID_ERROR = -1
173 
175 
191 void irgrid_cfg_setup ( irgrid_cfg_t *cfg );
192 
207 err_t irgrid_init ( irgrid_t *ctx, irgrid_cfg_t *cfg );
208 
220 uint8_t irgrid_device_init ( irgrid_t *ctx, irgrid_data_t *data_str, uint8_t refrate );
221 
231 void irgrid_write_ram( irgrid_t *ctx, uint8_t *data_buf, uint8_t len );
232 
243 void irgrid_read_ram ( irgrid_t *ctx, uint8_t *reg, uint8_t *data_buf, uint8_t len );
244 
255 void irgrid_write_eeprom ( irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
256 
267 void irgrid_read_eeprom ( irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
268 
279 uint8_t irgrid_measure ( irgrid_t *ctx, irgrid_data_t *data_str );
280 
289 void irgrid_get_ir_raw ( irgrid_data_t *data_str, int16_t *buffer );
290 
299 void irgrid_get_temperature ( irgrid_data_t *data_str, float *buffer );
300 
310 float irgrid_get_amb_temperature ( irgrid_t *ctx );
311 
312 #ifdef __cplusplus
313 }
314 #endif
315 #endif // IRGRID_H
316  // irgrid
318 
319 // ------------------------------------------------------------------------ END
irgrid_get_amb_temperature
float irgrid_get_amb_temperature(irgrid_t *ctx)
Read Ambient Temperature.
irgrid_get_ir_raw
void irgrid_get_ir_raw(irgrid_data_t *data_str, int16_t *buffer)
Read Raw Temperature buffer.
IRGRID_ERROR
Definition: irgrid.h:171
irgrid_write_eeprom
void irgrid_write_eeprom(irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Write function using EEPROM slave adress.
irgrid_data_t
Click data object definition.
Definition: irgrid.h:151
irgrid_write_ram
void irgrid_write_ram(irgrid_t *ctx, uint8_t *data_buf, uint8_t len)
Write function using RAM slave adress.
irgrid_read_ram
void irgrid_read_ram(irgrid_t *ctx, uint8_t *reg, uint8_t *data_buf, uint8_t len)
Read function using RAM slave adress.
irgrid_read_eeprom
void irgrid_read_eeprom(irgrid_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Read function using EEPROM slave adress.
irgrid_cfg_t
IR Grid Click configuration object.
Definition: irgrid.h:137
irgrid_get_temperature
void irgrid_get_temperature(irgrid_data_t *data_str, float *buffer)
Read Calculated Temperature buffer.
irgrid_measure
uint8_t irgrid_measure(irgrid_t *ctx, irgrid_data_t *data_str)
Measurement.
irgrid_cfg_setup
void irgrid_cfg_setup(irgrid_cfg_t *cfg)
IR Grid configuration object setup function.
irgrid_return_value_t
irgrid_return_value_t
IR Grid Click return value data.
Definition: irgrid.h:168
irgrid_t
IR Grid Click context object.
Definition: irgrid.h:115
IRGRID_OK
Definition: irgrid.h:170
irgrid_init
err_t irgrid_init(irgrid_t *ctx, irgrid_cfg_t *cfg)
IR Grid initialization function.
irgrid_device_init
uint8_t irgrid_device_init(irgrid_t *ctx, irgrid_data_t *data_str, uint8_t refrate)
Device Initialization.