irgrid2 2.0.0.0
irgrid2.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 IRGRID2_H
29#define IRGRID2_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_i2c_master.h"
51
78#define IRGRID2_SET_DEV_ADDR 0x33
79
80 // irgrid2_set
81
96#define IRGRID2_MAP_MIKROBUS( cfg, mikrobus ) \
97 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
98 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
99
100 // irgrid2_map
101 // irgrid2
102
107typedef struct
108{
109 int16_t k_vdd;
110 int16_t vdd_25;
111 float kv_ptat;
112 float kt_ptat;
113 uint16_t v_ptat_25;
115 int16_t gain_eeprom;
116 float tgc;
117 float cp_kv;
118 float cp_kta;
121 float ks_ta;
122 float ks_to[ 4 ];
123 int16_t ct[ 4 ];
124 float alpha[ 768 ];
125 int16_t offset[ 768 ];
126 float kta[ 768 ];
127 float kv[ 768 ];
128 float cp_alpha[ 2 ];
129 int16_t cp_offset[ 2 ];
130 float il_chess_c[ 3 ];
131 uint16_t broken_pixels[ 5 ];
132 uint16_t outlier_pixels[ 5 ];
134
139typedef struct
140{
141 // Modules
142 i2c_master_t i2c;
144 // I2C slave address
147
148} irgrid2_t;
149
154typedef struct
155{
156 pin_name_t scl;
157 pin_name_t sda;
159 uint32_t i2c_speed;
160 uint8_t i2c_address;
163
182
200
217
232
248void irgrid2_generic_write ( irgrid2_t *ctx, uint16_t reg, uint8_t *data_buf, uint16_t len );
249
266void irgrid2_generic_read ( irgrid2_t *ctx, uint16_t reg, uint8_t *rx_buf, uint16_t rx_len );
267
277void irgrid2_read_eeprom ( irgrid2_t *ctx, uint16_t *eeprom_data );
278
288uint8_t irgrid2_extract_parameters ( irgrid2_t *ctx, uint16_t *eeprom_data );
289
299void irgrid2_set_refresh_rate ( irgrid2_t *ctx, uint8_t refresh_rate );
300
310uint16_t irgrid2_get_frame_data ( irgrid2_t *ctx, uint16_t *frame_data );
311
321void irgrid2_set_resolution ( irgrid2_t *ctx, uint8_t resolution );
322
331
340
350
360
370
381void irgrid2_get_pixel_temperature ( irgrid2_t *ctx, float *temp_ambient, float *pixel_temp );
382
392float irgrid2_get_temp_ambient ( irgrid2_t *ctx, uint16_t *frame_data );
393
403uint16_t irgrid2_get_subpage_number ( uint16_t *frame_data );
404
412float irgrid2_get_vdd ( irgrid2_t *ctx, uint16_t *frame_data );
413
425void irgrid2_calculate_temp_obj ( irgrid2_t *ctx, uint16_t *frame_data, float tr_data, float *px_matrix );
426
437void irgrid2_get_image ( irgrid2_t *ctx, uint16_t *frame_data, float *px_matrix );
438#ifdef __cplusplus
439}
440#endif
441#endif // IRGRID2_H
442
443 // irgrid2
444
445// ------------------------------------------------------------------------ END
uint8_t irgrid2_extract_parameters(irgrid2_t *ctx, uint16_t *eeprom_data)
Parameters storage function.
void irgrid2_set_chess_mode(irgrid2_t *ctx)
Function for setting chess mode.
uint16_t irgrid2_get_refresh_rate(irgrid2_t *ctx)
Function for getting current refresh Rate.
void irgrid2_get_pixel_temperature(irgrid2_t *ctx, float *temp_ambient, float *pixel_temp)
Function for getting pixels temperature.
void irgrid2_get_image(irgrid2_t *ctx, uint16_t *frame_data, float *px_matrix)
Function for getting Image.
void irgrid2_set_interleaved_mode(irgrid2_t *ctx)
Function for setting interleaved mode.
err_t irgrid2_init(irgrid2_t *ctx, irgrid2_cfg_t *cfg)
IR Grid 2 initialization function.
float irgrid2_get_temp_ambient(irgrid2_t *ctx, uint16_t *frame_data)
Function for getting Ambient temperature.
void irgrid2_set_refresh_rate(irgrid2_t *ctx, uint8_t refresh_rate)
Function for setting refresh rate.
void irgrid2_default_cfg(irgrid2_t *ctx)
IR Grid 2 default configuration function.
void irgrid2_set_resolution(irgrid2_t *ctx, uint8_t resolution)
Function for setting resolution.
void irgrid2_calculate_temp_obj(irgrid2_t *ctx, uint16_t *frame_data, float tr_data, float *px_matrix)
Function for calculating temperature objects.
float irgrid2_get_vdd(irgrid2_t *ctx, uint16_t *frame_data)
Function for getting Vdd.
void irgrid2_generic_read(irgrid2_t *ctx, uint16_t reg, uint8_t *rx_buf, uint16_t rx_len)
IR Grid 2 I2C reading function.
void irgrid2_cfg_setup(irgrid2_cfg_t *cfg)
IR Grid 2 configuration object setup function.
uint16_t irgrid2_get_frame_data(irgrid2_t *ctx, uint16_t *frame_data)
Function for getting frame data.
uint16_t irgrid2_get_current_mode(irgrid2_t *ctx)
Function for getting current mode.
uint16_t irgrid2_get_current_res(irgrid2_t *ctx)
Function for getting current resolution.
void irgrid2_generic_write(irgrid2_t *ctx, uint16_t reg, uint8_t *data_buf, uint16_t len)
IR Grid 2 I2C writing function.
void irgrid2_read_eeprom(irgrid2_t *ctx, uint16_t *eeprom_data)
Function for reading EEPROM.
uint16_t irgrid2_get_subpage_number(uint16_t *frame_data)
Function for getting sub page number.
irgrid2_return_value_t
IR Grid 2 Click return value data.
Definition irgrid2.h:169
@ IRGRID2_OUTLIER_PIX_ERROR
Definition irgrid2.h:178
@ IRGRID2_2_PIX_ERROR
Definition irgrid2.h:179
@ IRGRID2_INIT_ERROR
Definition irgrid2.h:172
@ IRGRID2_ADJ_PIXELS_ERROR
Definition irgrid2.h:175
@ IRGRID2_ERROR
Definition irgrid2.h:171
@ IRGRID2_EEPROM_OK
Definition irgrid2.h:173
@ IRGRID2_ADJ_PIXELS_OK
Definition irgrid2.h:176
@ IRGRID2_OK
Definition irgrid2.h:170
@ IRGRID2_EEPROM_ERROR
Definition irgrid2.h:174
@ IRGRID2_BROKEN_PIX_ERROR
Definition irgrid2.h:177
IR Grid 2 Click configuration object.
Definition irgrid2.h:155
uint32_t i2c_speed
Definition irgrid2.h:159
pin_name_t scl
Definition irgrid2.h:156
pin_name_t sda
Definition irgrid2.h:157
uint8_t i2c_address
Definition irgrid2.h:160
IR Grid 2 Click params definition.
Definition irgrid2.h:108
int16_t k_vdd
Definition irgrid2.h:109
float ks_ta
Definition irgrid2.h:121
float kt_ptat
Definition irgrid2.h:112
uint8_t calibration_mode_eeprom
Definition irgrid2.h:120
float cp_kv
Definition irgrid2.h:117
float alpha_ptat
Definition irgrid2.h:114
int16_t vdd_25
Definition irgrid2.h:110
float kv_ptat
Definition irgrid2.h:111
float cp_kta
Definition irgrid2.h:118
uint8_t resolution_eeprom
Definition irgrid2.h:119
uint16_t v_ptat_25
Definition irgrid2.h:113
int16_t gain_eeprom
Definition irgrid2.h:115
float tgc
Definition irgrid2.h:116
IR Grid 2 Click context object.
Definition irgrid2.h:140
irgrid2_params_t params
Definition irgrid2.h:146
i2c_master_t i2c
Definition irgrid2.h:142
uint8_t slave_address
Definition irgrid2.h:145