grideye2  2.1.0.0
grideye2.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 GRIDEYE2_H
29 #define GRIDEYE2_H
30 
31 #ifdef __cplusplus
32 extern "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 GRIDEYE2_REG_PCLT 0x00
74 #define GRIDEYE2_REG_RST 0x01
75 #define GRIDEYE2_REG_FPSC 0x02
76 #define GRIDEYE2_REG_INTC 0x03
77 #define GRIDEYE2_REG_STAT 0x04
78 #define GRIDEYE2_REG_SCLR 0x05
79 #define GRIDEYE2_REG_AVE 0x07
80 #define GRIDEYE2_REG_INTHL 0x08
81 #define GRIDEYE2_REG_INTHH 0x09
82 #define GRIDEYE2_REG_INTLL 0x0A
83 #define GRIDEYE2_REG_INTLH 0x0B
84 #define GRIDEYE2_REG_IHYSL 0x0C
85 #define GRIDEYE2_REG_IHYSH 0x0D
86 #define GRIDEYE2_REG_TTHL 0x0E
87 #define GRIDEYE2_REG_TTHH 0x0F
88 #define GRIDEYE2_REG_INT0 0x10
89 #define GRIDEYE2_REG_INT1 0x11
90 #define GRIDEYE2_REG_INT2 0x12
91 #define GRIDEYE2_REG_INT3 0x13
92 #define GRIDEYE2_REG_INT4 0x14
93 #define GRIDEYE2_REG_INT5 0x15
94 #define GRIDEYE2_REG_INT6 0x16
95 #define GRIDEYE2_REG_INT7 0x17
96 #define GRIDEYE2_REG_AVE_SET 0x1F
97 #define GRIDEYE2_REG_TO1L 0x80
98 #define GRIDEYE2_REG_TO1H 0x81
99  // grideye2_reg
101 
116 #define GRIDEYE2_PCLT_NORMAL_MODE 0x00
117 #define GRIDEYE2_PCLT_SLEEP_MODE 0x10
118 
123 #define GRIDEYE2_RST_FLAG 0x30
124 #define GRIDEYE2_RST_INITIAL 0x3F
125 
130 #define GRIDEYE2_FPSC_10FPS 0x00
131 #define GRIDEYE2_FPSC_1FPS 0x01
132 
137 #define GRIDEYE2_INTC_INTMOD_DIFF 0x00
138 #define GRIDEYE2_INTC_INTMOD_ABS 0x02
139 #define GRIDEYE2_INTC_INTMOD_MASK 0x02
140 #define GRIDEYE2_INTC_INTEN_INACTIVE 0x00
141 #define GRIDEYE2_INTC_INTEN_ACTIVE 0x01
142 #define GRIDEYE2_INTC_INTEN_MASK 0x01
143 
148 #define GRIDEYE2_STAT_OVF_IRS 0x04
149 #define GRIDEYE2_STAT_INTF 0x02
150 
157 #define GRIDEYE2_AVE_MAMOD_OFF 0x00
158 #define GRIDEYE2_AVE_MAMOD_ON 0x20
159 #define GRIDEYE2_AVE_SET_0 0x50
160 #define GRIDEYE2_AVE_SET_1 0x45
161 #define GRIDEYE2_AVE_SET_2 0x57
162 #define GRIDEYE2_AVE_SET_3 0x00
163 
168 #define GRIDEYE2_DATA_SIGN_BIT 0x0800
169 #define GRIDEYE2_DATA_FILL_SIGN 0xF000
170 #define GRIDEYE2_DATA_LSB 0.25f
171 #define GRIDEYE2_NUM_PIXELS 64
172 
178 #define GRIDEYE2_DEVICE_ADDRESS_0 0x68
179 #define GRIDEYE2_DEVICE_ADDRESS_1 0x69
180  // grideye2_set
182 
197 #define GRIDEYE2_MAP_MIKROBUS( cfg, mikrobus ) \
198  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
199  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
200  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
201  // grideye2_map // grideye2
204 
209 typedef struct
210 {
211  // Input pins
212  digital_in_t int_pin;
214  // Modules
215  i2c_master_t i2c;
217  // I2C slave address
218  uint8_t slave_address;
220  float grid_temp[ GRIDEYE2_NUM_PIXELS ];
222 } grideye2_t;
223 
228 typedef struct
229 {
230  pin_name_t scl;
231  pin_name_t sda;
233  pin_name_t int_pin;
235  uint32_t i2c_speed;
236  uint8_t i2c_address;
239 
244 typedef enum
245 {
247  GRIDEYE2_ERROR = -1
248 
250 
267 
282 
296 
311 err_t grideye2_write_reg_bytes ( grideye2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
312 
325 err_t grideye2_write_reg_byte ( grideye2_t *ctx, uint8_t reg, uint8_t data_in );
326 
340 err_t grideye2_write_reg_word ( grideye2_t *ctx, uint8_t reg, uint16_t data_in );
341 
356 err_t grideye2_read_reg_bytes ( grideye2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
357 
370 err_t grideye2_read_reg_byte ( grideye2_t *ctx, uint8_t reg, uint8_t *data_out );
371 
385 err_t grideye2_read_reg_word ( grideye2_t *ctx, uint8_t reg, uint16_t *data_out );
386 
396 
409 
421 
422 #ifdef __cplusplus
423 }
424 #endif
425 #endif // GRIDEYE2_H
426  // grideye2
428 
429 // ------------------------------------------------------------------------ END
grideye2_t::int_pin
digital_in_t int_pin
Definition: grideye2.h:212
grideye2_clear_status
err_t grideye2_clear_status(grideye2_t *ctx)
Grid-EYE 2 clear status function.
grideye2_read_grid
err_t grideye2_read_grid(grideye2_t *ctx)
Grid-EYE 2 read grid function.
grideye2_cfg_t::sda
pin_name_t sda
Definition: grideye2.h:231
grideye2_init
err_t grideye2_init(grideye2_t *ctx, grideye2_cfg_t *cfg)
Grid-EYE 2 initialization function.
grideye2_get_int_pin
uint8_t grideye2_get_int_pin(grideye2_t *ctx)
Grid-EYE 2 get INT pin function.
grideye2_write_reg_byte
err_t grideye2_write_reg_byte(grideye2_t *ctx, uint8_t reg, uint8_t data_in)
Grid-EYE 2 write reg byte function.
grideye2_cfg_t
Grid-EYE 2 Click configuration object.
Definition: grideye2.h:229
grideye2_t::slave_address
uint8_t slave_address
Definition: grideye2.h:218
grideye2_cfg_t::int_pin
pin_name_t int_pin
Definition: grideye2.h:233
GRIDEYE2_ERROR
@ GRIDEYE2_ERROR
Definition: grideye2.h:247
grideye2_default_cfg
err_t grideye2_default_cfg(grideye2_t *ctx)
Grid-EYE 2 default configuration function.
grideye2_read_reg_bytes
err_t grideye2_read_reg_bytes(grideye2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Grid-EYE 2 read reg bytes function.
GRIDEYE2_NUM_PIXELS
#define GRIDEYE2_NUM_PIXELS
Definition: grideye2.h:171
GRIDEYE2_OK
@ GRIDEYE2_OK
Definition: grideye2.h:246
grideye2_t
Grid-EYE 2 Click context object.
Definition: grideye2.h:210
grideye2_read_reg_word
err_t grideye2_read_reg_word(grideye2_t *ctx, uint8_t reg, uint16_t *data_out)
Grid-EYE 2 read reg word function.
grideye2_write_reg_word
err_t grideye2_write_reg_word(grideye2_t *ctx, uint8_t reg, uint16_t data_in)
Grid-EYE 2 write reg word function.
grideye2_write_reg_bytes
err_t grideye2_write_reg_bytes(grideye2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Grid-EYE 2 write reg bytes function.
grideye2_read_reg_byte
err_t grideye2_read_reg_byte(grideye2_t *ctx, uint8_t reg, uint8_t *data_out)
Grid-EYE 2 read reg byte function.
grideye2_return_value_t
grideye2_return_value_t
Grid-EYE 2 Click return value data.
Definition: grideye2.h:245
grideye2_cfg_t::i2c_address
uint8_t i2c_address
Definition: grideye2.h:236
grideye2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: grideye2.h:235
grideye2_cfg_setup
void grideye2_cfg_setup(grideye2_cfg_t *cfg)
Grid-EYE 2 configuration object setup function.
grideye2_t::i2c
i2c_master_t i2c
Definition: grideye2.h:215
grideye2_cfg_t::scl
pin_name_t scl
Definition: grideye2.h:230