grideye 2.0.0.0
grideye.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef GRIDEYE_H
36#define GRIDEYE_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define GRIDEYE_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
75#define GRIDEYE_RETVAL int8_t
76
77#define GRIDEYE_OK 0
78#define GRIDEYE_INIT_ERROR (-1)
85#define GRIDEYE_I2C_ADDR 0x68
92#define GRIDEYE_PCLT 0x00
93#define GRIDEYE_RST 0x01
94#define GRIDEYE_FPSC 0x02
95#define GRIDEYE_INTC 0x03
96#define GRIDEYE_STAT 0x04
97#define GRIDEYE_SCLR 0x05
98#define GRIDEYE_AVE 0x07
99
100#define GRIDEYE_INTHL 0x08
101#define GRIDEYE_INTHH 0x09
102#define GRIDEYE_INTLL 0x0A
103#define GRIDEYE_INTLH 0x0B
104#define GRIDEYE_IHYSL 0x0C
105#define GRIDEYE_IHYSH 0x0D
106#define GRIDEYE_TTHL 0x0E
107#define GRIDEYE_TTHH 0x0F
114#define GRIDEYE_INT0 0x10
115#define GRIDEYE_INT1 0x11
116#define GRIDEYE_INT2 0x12
117#define GRIDEYE_INT3 0x13
118#define GRIDEYE_INT4 0x14
119#define GRIDEYE_INT5 0x15
120#define GRIDEYE_INT6 0x16
121#define GRIDEYE_INT7 0x17
128#define GRIDEYE_PCLT_NORMAL 0x00
129#define GRIDEYE_PCLT_SLEEP 0x10
130#define GRIDEYE_PCLT_STANDBY_60 0x20
131#define GRIDEYE_PCLT_STANDBY_10 0x21
138#define GRIDEYE_RST_FLAG 0x30
139#define GRIDEYE_RST_INIT 0x3F
146#define GRIDEYE_FPSC_1FPS 0x01
147#define GRIDEYE_FPSC_10FPS 0x00
154#define GRIDEYE_INTC_INTEN_ACTIVE 0x01
155#define GRIDEYE_INTC_INTEN_INACTIVE 0x00
156#define GRIDEYE_INTC_INTMOD_ABSO 0x10
157#define GRIDEYE_INTC_INTMOD_DIFE 0x00
164#define GRIDEYE_SCLR_INTCLR 0x02
165#define GRIDEYE_SCLR_OVS_CLR 0x04
166#define GRIDEYE_SCLR_OVT_CLR 0x08
173#define GRIDEYE_AVE_MAMOD_ACTIVE 0x20
174#define GRIDEYE_AVE_MAMOD_INACTIVE 0x00
181#define GRIDEYE_PIXELS 0x80
184 // End group macro
185// --------------------------------------------------------------- PUBLIC TYPES
194typedef struct
195{
196 // Input pins
197
198 digital_in_t int_pin;
199
200 // Modules
201
202 i2c_master_t i2c;
203
204 // ctx variable
205
207
208} grideye_t;
209
213typedef struct
214{
215 // Communication gpio pins
216
217 pin_name_t scl;
218 pin_name_t sda;
219
220 // Additional gpio pins
221
222 pin_name_t int_pin;
223
224 // static variable
225
226 uint32_t i2c_speed;
227 uint8_t i2c_address;
228
230
231 // End types group
232// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
233
239#ifdef __cplusplus
240extern "C"{
241#endif
242
252
261
270
280void grideye_generic_write ( grideye_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
281
293void grideye_generic_read ( grideye_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
294
306void grideye_write_data ( grideye_t *ctx, uint8_t wr_addr, uint16_t wr_data );
307
318uint16_t grideye_read_data ( grideye_t *ctx, uint8_t rd_addr );
319
328void grideye_read_grid ( grideye_t *ctx, int16_t *buffer );
329
342
352void grideye_set_power_control ( grideye_t *ctx, uint8_t pow_cnt );
353
365
375
385
394
403
416
426void grideye_set_int_ctl_reg ( grideye_t *ctx, uint8_t int_cnt );
427
439
451
461void grideye_set_stat_clr_reg ( grideye_t *ctx, uint8_t int_cnt );
462
473void grideye_set_ave_reg ( grideye_t *ctx, uint8_t mamod );
474
486
495void grideye_write_int_lvl_high ( grideye_t *ctx, uint16_t wr_data );
496
504void grideye_write_int_lvl_low( grideye_t *ctx, uint16_t wr_data );
505
516
527
536void grideye_write_int_hyst_lvl ( grideye_t *ctx, uint16_t wr_data );
537
548
559
570
591
602
613
624
635
646
647#ifdef __cplusplus
648}
649#endif
650#endif // GRIDEYE_H
651
652 // End public_function group
653 // End click Driver group
654
655// ------------------------------------------------------------------------ END
#define GRIDEYE_RETVAL
Definition grideye.h:75
void grideye_default_cfg(grideye_t *ctx)
Click Default Configuration function.
uint8_t grideye_read_int2(grideye_t *ctx)
Read Interrupt Table Register 2 function.
uint16_t grideye_read_int_hyst_lvl(grideye_t *ctx)
Read interrupt hysteresis level function.
uint8_t grideye_read_int4(grideye_t *ctx)
Read Interrupt Table Register 4 function.
uint8_t grideye_check_interrupt(grideye_t *ctx)
Get Interrupt state function.
void grideye_write_int_lvl_high(grideye_t *ctx, uint16_t wr_data)
Set interrupt level high function.
void grideye_write_data(grideye_t *ctx, uint8_t wr_addr, uint16_t wr_data)
Write data function.
uint16_t grideye_read_data(grideye_t *ctx, uint8_t rd_addr)
Data read function.
void grideye_set_ave_reg(grideye_t *ctx, uint8_t mamod)
Set Average Register function.
void grideye_initial_reset(grideye_t *ctx)
Initial reset function.
uint8_t grideye_read_int3(grideye_t *ctx)
Read Interrupt Table Register 3 function.
void grideye_set_fps1(grideye_t *ctx)
Set FPS 1 function.
void grideye_flag_reset(grideye_t *ctx)
Flag reset function.
uint8_t grideye_read_int6(grideye_t *ctx)
Read Interrupt Table Register 6 function.
uint8_t grideye_read_int7(grideye_t *ctx)
Read Interrupt Table Register 7 function.
void grideye_generic_write(grideye_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void grideye_set_stat_clr_reg(grideye_t *ctx, uint8_t int_cnt)
Set Status Clear Register function.
void grideye_write_int_hyst_lvl(grideye_t *ctx, uint16_t wr_data)
Set interrupt hysteresis level function.
uint8_t grideye_read_power_control(grideye_t *ctx)
Read Power Control function.
void grideye_set_fps10(grideye_t *ctx)
Set FPS 10 function.
uint8_t grideye_read_int1(grideye_t *ctx)
Read Interrupt Table Register 1 function.
uint8_t grideye_read_int5(grideye_t *ctx)
Read Interrupt Table Register 5 function.
uint8_t grideye_read_ave_reg(grideye_t *ctx)
Read Average Register function.
float grideye_read_therm_temp_reg(grideye_t *ctx)
Read Thermistor Temperature Register function.
uint8_t grideye_read_int0(grideye_t *ctx)
Read Interrupt Table Register 0 function.
void grideye_cfg_setup(grideye_cfg_t *cfg)
Config Object Initialization function.
void grideye_generic_read(grideye_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void grideye_set_int_ctl_reg(grideye_t *ctx, uint8_t int_cnt)
Set Interrupt Control Register function.
GRIDEYE_RETVAL grideye_init(grideye_t *ctx, grideye_cfg_t *cfg)
Initialization function.
uint16_t grideye_read_int_lvl_high(grideye_t *ctx)
Read interrupt level high function.
void grideye_write_int_lvl_low(grideye_t *ctx, uint16_t wr_data)
Set interrupt level low function.
uint16_t grideye_read_int_lvl_low(grideye_t *ctx)
Read interrupt level low function.
void grideye_read_grid(grideye_t *ctx, int16_t *buffer)
Read whole grid function.
uint8_t grideye_check_fps(grideye_t *ctx)
Check FPS function.
uint8_t grideye_read_stat_reg(grideye_t *ctx)
Read Status Register function.
void grideye_set_power_control(grideye_t *ctx, uint8_t pow_cnt)
Set Power Control function.
uint8_t grideye_read_int_ctl_reg(grideye_t *ctx)
Read Interrupt Control Register function.
Click configuration structure definition.
Definition grideye.h:214
uint32_t i2c_speed
Definition grideye.h:226
pin_name_t scl
Definition grideye.h:217
pin_name_t int_pin
Definition grideye.h:222
pin_name_t sda
Definition grideye.h:218
uint8_t i2c_address
Definition grideye.h:227
Click ctx object definition.
Definition grideye.h:195
digital_in_t int_pin
Definition grideye.h:198
i2c_master_t i2c
Definition grideye.h:202
uint8_t slave_address
Definition grideye.h:206