39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define IRGESTURE2_REG_INT_STATUS 0x00
75#define IRGESTURE2_REG_MAIN_CONFIG_1 0x01
76#define IRGESTURE2_REG_MAIN_CONFIG_2 0x02
77#define IRGESTURE2_REG_SEQ_CONFIG_1 0x03
78#define IRGESTURE2_REG_SEQ_CONFIG_2 0x04
79#define IRGESTURE2_REG_AFE_CONFIG 0x05
80#define IRGESTURE2_REG_LED_CONFIG 0x06
81#define IRGESTURE2_REG_ADC00H 0x10
82#define IRGESTURE2_REG_ADC00L 0x11
83#define IRGESTURE2_REG_ADC01H 0x12
84#define IRGESTURE2_REG_ADC01L 0x13
85#define IRGESTURE2_REG_ADC02H 0x14
86#define IRGESTURE2_REG_ADC02L 0x15
87#define IRGESTURE2_REG_ADC03H 0x16
88#define IRGESTURE2_REG_ADC03L 0x17
89#define IRGESTURE2_REG_ADC04H 0x18
90#define IRGESTURE2_REG_ADC04L 0x19
91#define IRGESTURE2_REG_ADC05H 0x1A
92#define IRGESTURE2_REG_ADC05L 0x1B
93#define IRGESTURE2_REG_ADC06H 0x1C
94#define IRGESTURE2_REG_ADC06L 0x1D
95#define IRGESTURE2_REG_ADC07H 0x1E
96#define IRGESTURE2_REG_ADC07L 0x1F
97#define IRGESTURE2_REG_ADC08H 0x20
98#define IRGESTURE2_REG_ADC08L 0x21
99#define IRGESTURE2_REG_ADC09H 0x22
100#define IRGESTURE2_REG_ADC09L 0x23
101#define IRGESTURE2_REG_ADC10H 0x24
102#define IRGESTURE2_REG_ADC10L 0x25
103#define IRGESTURE2_REG_ADC11H 0x26
104#define IRGESTURE2_REG_ADC11L 0x27
105#define IRGESTURE2_REG_ADC12H 0x28
106#define IRGESTURE2_REG_ADC12L 0x29
107#define IRGESTURE2_REG_ADC13H 0x2A
108#define IRGESTURE2_REG_ADC13L 0x2B
109#define IRGESTURE2_REG_ADC14H 0x2C
110#define IRGESTURE2_REG_ADC14L 0x2D
111#define IRGESTURE2_REG_ADC15H 0x2E
112#define IRGESTURE2_REG_ADC15L 0x2F
113#define IRGESTURE2_REG_ADC16H 0x30
114#define IRGESTURE2_REG_ADC16L 0x31
115#define IRGESTURE2_REG_ADC17H 0x32
116#define IRGESTURE2_REG_ADC17L 0x33
117#define IRGESTURE2_REG_ADC18H 0x34
118#define IRGESTURE2_REG_ADC18L 0x35
119#define IRGESTURE2_REG_ADC19H 0x36
120#define IRGESTURE2_REG_ADC19L 0x37
121#define IRGESTURE2_REG_ADC20H 0x38
122#define IRGESTURE2_REG_ADC20L 0x39
123#define IRGESTURE2_REG_ADC21H 0x3A
124#define IRGESTURE2_REG_ADC21L 0x3B
125#define IRGESTURE2_REG_ADC22H 0x3C
126#define IRGESTURE2_REG_ADC22L 0x3D
127#define IRGESTURE2_REG_ADC23H 0x3E
128#define IRGESTURE2_REG_ADC23L 0x3F
129#define IRGESTURE2_REG_ADC24H 0x40
130#define IRGESTURE2_REG_ADC24L 0x41
131#define IRGESTURE2_REG_ADC25H 0x42
132#define IRGESTURE2_REG_ADC25L 0x43
133#define IRGESTURE2_REG_ADC26H 0x44
134#define IRGESTURE2_REG_ADC26L 0x45
135#define IRGESTURE2_REG_ADC27H 0x46
136#define IRGESTURE2_REG_ADC27L 0x47
137#define IRGESTURE2_REG_ADC28H 0x48
138#define IRGESTURE2_REG_ADC28L 0x49
139#define IRGESTURE2_REG_ADC29H 0x4A
140#define IRGESTURE2_REG_ADC29L 0x4B
141#define IRGESTURE2_REG_ADC30H 0x4C
142#define IRGESTURE2_REG_ADC30L 0x4D
143#define IRGESTURE2_REG_ADC31H 0x4E
144#define IRGESTURE2_REG_ADC31L 0x4F
145#define IRGESTURE2_REG_ADC32H 0x50
146#define IRGESTURE2_REG_ADC32L 0x51
147#define IRGESTURE2_REG_ADC33H 0x52
148#define IRGESTURE2_REG_ADC33L 0x53
149#define IRGESTURE2_REG_ADC34H 0x54
150#define IRGESTURE2_REG_ADC34L 0x55
151#define IRGESTURE2_REG_ADC35H 0x56
152#define IRGESTURE2_REG_ADC35L 0x57
153#define IRGESTURE2_REG_ADC36H 0x58
154#define IRGESTURE2_REG_ADC36L 0x59
155#define IRGESTURE2_REG_ADC37H 0x5A
156#define IRGESTURE2_REG_ADC37L 0x5B
157#define IRGESTURE2_REG_ADC38H 0x5C
158#define IRGESTURE2_REG_ADC38L 0x5D
159#define IRGESTURE2_REG_ADC39H 0x5E
160#define IRGESTURE2_REG_ADC39L 0x5F
161#define IRGESTURE2_REG_ADC40H 0x60
162#define IRGESTURE2_REG_ADC40L 0x61
163#define IRGESTURE2_REG_ADC41H 0x62
164#define IRGESTURE2_REG_ADC41L 0x63
165#define IRGESTURE2_REG_ADC42H 0x64
166#define IRGESTURE2_REG_ADC42L 0x65
167#define IRGESTURE2_REG_ADC43H 0x66
168#define IRGESTURE2_REG_ADC43L 0x67
169#define IRGESTURE2_REG_ADC44H 0x68
170#define IRGESTURE2_REG_ADC44L 0x69
171#define IRGESTURE2_REG_ADC45H 0x6A
172#define IRGESTURE2_REG_ADC45L 0x6B
173#define IRGESTURE2_REG_ADC46H 0x6C
174#define IRGESTURE2_REG_ADC46L 0x6D
175#define IRGESTURE2_REG_ADC47H 0x6E
176#define IRGESTURE2_REG_ADC47L 0x6F
177#define IRGESTURE2_REG_ADC48H 0x70
178#define IRGESTURE2_REG_ADC48L 0x71
179#define IRGESTURE2_REG_ADC49H 0x72
180#define IRGESTURE2_REG_ADC49L 0x73
181#define IRGESTURE2_REG_ADC50H 0x74
182#define IRGESTURE2_REG_ADC50L 0x75
183#define IRGESTURE2_REG_ADC51H 0x76
184#define IRGESTURE2_REG_ADC51L 0x77
185#define IRGESTURE2_REG_ADC52H 0x78
186#define IRGESTURE2_REG_ADC52L 0x79
187#define IRGESTURE2_REG_ADC53H 0x7A
188#define IRGESTURE2_REG_ADC53L 0x7B
189#define IRGESTURE2_REG_ADC54H 0x7C
190#define IRGESTURE2_REG_ADC54L 0x7D
191#define IRGESTURE2_REG_ADC55H 0x7E
192#define IRGESTURE2_REG_ADC55L 0x7F
193#define IRGESTURE2_REG_ADC56H 0x80
194#define IRGESTURE2_REG_ADC56L 0x81
195#define IRGESTURE2_REG_ADC57H 0x82
196#define IRGESTURE2_REG_ADC57L 0x83
197#define IRGESTURE2_REG_ADC58H 0x84
198#define IRGESTURE2_REG_ADC58L 0x85
199#define IRGESTURE2_REG_ADC59H 0x86
200#define IRGESTURE2_REG_ADC59L 0x87
201#define IRGESTURE2_REG_COLUMN_GAIN_2_1 0xA5
202#define IRGESTURE2_REG_COLUMN_GAIN_4_3 0xA6
203#define IRGESTURE2_REG_COLUMN_GAIN_6_5 0xA7
204#define IRGESTURE2_REG_COLUMN_GAIN_8_7 0xA8
205#define IRGESTURE2_REG_COLUMN_GAIN_10_9 0xA9
206#define IRGESTURE2_REG_LED_CTRL 0xC1
224#define IRGESTRURE2_EXSYNC_INPUT 0x00
225#define IRGESTRURE2_EXSYNC_INPUT_SLAVE 0x10
226#define IRGESTRURE2_EXSYNC_INPUT_MASTER 0x20
227#define IRGESTRURE2_EOCINTE_ENABLE 0x04
233#define IRGESTURE2_SHUTDOWN 0x80
234#define IRGESTURE2_RESET 0x40
235#define IRGESTURE2_SYNC 0x10
236#define IRGESTURE2_ONE_SHOT_ENABLE 0x08
237#define IRGESTURE2_ONE_SHOT_TRIGGER 0x04
238#define IRGESTURE2_CONTINUOUS_CONVERSION 0x02
244#define IRGESTURE2_EOC_DELAY_0MS 0x00
245#define IRGESTURE2_EOC_DELAY_1p56MS 0x10
246#define IRGESTURE2_EOC_DELAY_3p12MS 0x20
247#define IRGESTURE2_EOC_DELAY_6p25MS 0x30
248#define IRGESTURE2_EOC_DELAY_12p49MS 0x40
249#define IRGESTURE2_EOC_DELAY_24p98MS 0x50
250#define IRGESTURE2_EOC_DELAY_49p97MS 0x60
251#define IRGESTURE2_EOC_DELAY_99p94MS 0x70
252#define IRGESTURE2_EOC_DELAY_199p98MS 0x80
253#define IRGESTURE2_EOC_DELAY_399p75MS 0x90
254#define IRGESTURE2_EOC_DELAY_799p5MS 0xA0
255#define IRGESTURE2_EOC_DELAY_1599MS 0xB0
256#define IRGESTURE2_INTEGRATION_TIME_6p25US 0x00
257#define IRGESTURE2_INTEGRATION_TIME_12p5US 0x02
258#define IRGESTURE2_INTEGRATION_TIME_25US 0x04
259#define IRGESTURE2_INTEGRATION_TIME_50US 0x06
260#define IRGESTURE2_INTEGRATION_TIME_100US 0x08
261#define IRGESTURE2_INTEGRATION_TIME_200US 0x0A
262#define IRGESTURE2_INTEGRATION_TIME_400US 0x0C
263#define IRGESTURE2_INTEGRATION_TIME_800US 0x0E
269#define IRGESTURE2_NRPT_1 0x00
270#define IRGESTURE2_NRPT_2 0x20
271#define IRGESTURE2_NRPT_4 0x40
272#define IRGESTURE2_NRPT_8 0x60
273#define IRGESTURE2_NRPT_16 0x80
274#define IRGESTURE2_NRPT_32 0xA0
275#define IRGESTURE2_NRPT_64 0xC0
276#define IRGESTURE2_NRPT_128 0xE0
277#define IRGESTURE2_NCDS_1 0x00
278#define IRGESTURE2_NCDS_2 0x04
279#define IRGESTURE2_NCDS_4 0x08
280#define IRGESTURE2_NCDS_8 0x0C
281#define IRGESTURE2_NCDS_16 0x10
282#define IRGESTURE2_NCDS_32 0x14
283#define IRGESTURE2_NCDS_64 0x18
284#define IRGESTURE2_NCDS_128 0x1C
285#define IRGESTURE2_CDSMODE 0x02
291#define IRGESTURE2_ALC_COARSE 0x40
292#define IRGESTURE2_ALCEN_ENABLE 0x08
293#define IRGESTURE2_PGA_1 0x00
294#define IRGESTURE2_PGA_1_PER_4 0x01
295#define IRGESTURE2_PGA_1_PER_16 0x02
296#define IRGESTURE2_PGA_1_PER_32 0x03
302#define IRGESTURE2_DUTY_CYCLE_1 0x00
303#define IRGESTURE2_DUTY_CYCLE_2 0x01
304#define IRGESTURE2_DUTY_CYCLE_3 0x02
305#define IRGESTURE2_DUTY_CYCLE_4 0x03
306#define IRGESTURE2_DUTY_CYCLE_5 0x04
307#define IRGESTURE2_DUTY_CYCLE_6 0x05
308#define IRGESTURE2_DUTY_CYCLE_7 0x06
309#define IRGESTURE2_DUTY_CYCLE_8 0x07
310#define IRGESTURE2_DUTY_CYCLE_9 0x08
311#define IRGESTURE2_DUTY_CYCLE_10 0x09
312#define IRGESTURE2_DUTY_CYCLE_11 0x0A
313#define IRGESTURE2_DUTY_CYCLE_12 0x0B
314#define IRGESTURE2_DUTY_CYCLE_13 0x0C
315#define IRGESTURE2_DUTY_CYCLE_14 0x0D
316#define IRGESTURE2_DUTY_CYCLE_15 0x0E
317#define IRGESTURE2_DUTY_CYCLE_16 0x0F
323#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p33 0x00
324#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p37 0x10
325#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p43 0x20
326#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p49 0x30
327#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p56 0x40
328#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p65 0x50
329#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p75 0x60
330#define IRGESTURE2_UPPER_CGAIN_FACTOR_0p86 0x70
331#define IRGESTURE2_UPPER_CGAIN_FACTOR_1p00 0x80
332#define IRGESTURE2_UPPER_CGAIN_FACTOR_1p14 0x90
333#define IRGESTURE2_UPPER_CGAIN_FACTOR_1p33 0xA0
334#define IRGESTURE2_UPPER_CGAIN_FACTOR_1p53 0xB0
335#define IRGESTURE2_UPPER_CGAIN_FACTOR_1p79 0xC0
336#define IRGESTURE2_UPPER_CGAIN_FACTOR_2p04 0xD0
337#define IRGESTURE2_UPPER_CGAIN_FACTOR_2p38 0xE0
338#define IRGESTURE2_UPPER_CGAIN_FACTOR_2p70 0xF0
339#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p33 0x00
340#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p37 0x01
341#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p43 0x02
342#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p49 0x03
343#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p56 0x04
344#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p65 0x05
345#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p75 0x06
346#define IRGESTURE2_LOWER_CGAIN_FACTOR_0p86 0x07
347#define IRGESTURE2_LOWER_CGAIN_FACTOR_1p00 0x08
348#define IRGESTURE2_LOWER_CGAIN_FACTOR_1p14 0x09
349#define IRGESTURE2_LOWER_CGAIN_FACTOR_1p33 0x0A
350#define IRGESTURE2_LOWER_CGAIN_FACTOR_1p53 0x0B
351#define IRGESTURE2_LOWER_CGAIN_FACTOR_1p79 0x0C
352#define IRGESTURE2_LOWER_CGAIN_FACTOR_2p04 0x0D
353#define IRGESTURE2_LOWER_CGAIN_FACTOR_2p38 0x0E
354#define IRGESTURE2_LOWER_CGAIN_FACTOR_2p70 0x0F
360#define IRGESTURE2_GAINSEL_CGAIN 0x00
361#define IRGESTURE2_GAINSEL_INTERNAL_TRIM 0x08
362#define IRGESTURE2_DRV_EN_DISABLE 0x00
363#define IRGESTURE2_DRV_EN_ENABLE 0x04
364#define IRGESTURE2_ELED_EN_DISABLE 0x00
365#define IRGESTURE2_ELED_EN_ENABLE 0x02
366#define IRGESTURE2_ELED_POL_NMOS 0x00
367#define IRGESTURE2_ELED_POL_PMOS 0x01
373#define IRGESTURE2_SPI_READ 0x80
374#define IRGESTURE2_SPI_WRITE 0x00
380#define IRGESTURE2_SENSOR_X_SIZE 10
381#define IRGESTURE2_SENSOR_Y_SIZE 6
382#define IRGESTURE2_NUM_SENSOR_PIXELS ( IRGESTURE2_SENSOR_X_SIZE * IRGESTURE2_SENSOR_Y_SIZE )
392#define IRGESTURE2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
393#define IRGESTURE2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
411#define IRGESTURE2_MAP_MIKROBUS( cfg, mikrobus ) \
412 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
413 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
414 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
415 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
416 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t irgesture2_init(irgesture2_t *ctx, irgesture2_cfg_t *cfg)
IR Gesture 2 initialization function.
void irgesture2_cfg_setup(irgesture2_cfg_t *cfg)
IR Gesture 2 configuration object setup function.
err_t irgesture2_generic_write(irgesture2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
IR Gesture 2 data writing function.
err_t irgesture2_read_pixels(irgesture2_t *ctx, int16_t *pixels, bool flip_pixels)
IR Gesture 2 read pixels function.
err_t irgesture2_write_register(irgesture2_t *ctx, uint8_t reg, uint8_t data_in)
IR Gesture 2 write register function.
err_t irgesture2_default_cfg(irgesture2_t *ctx)
IR Gesture 2 default configuration function.
err_t irgesture2_generic_read(irgesture2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
IR Gesture 2 data reading function.
uint8_t irgesture2_get_int_pin(irgesture2_t *ctx)
IR Gesture 2 get int pin function.
err_t irgesture2_read_register(irgesture2_t *ctx, uint8_t reg, uint8_t *data_out)
IR Gesture 2 read register function.
irgesture2_return_value_t
IR Gesture 2 Click return value data.
Definition irgesture2.h:464
@ IRGESTURE2_OK
Definition irgesture2.h:465
@ IRGESTURE2_ERROR
Definition irgesture2.h:466
This file contains SPI specific macros, functions, etc.
IR Gesture 2 Click configuration object.
Definition irgesture2.h:442
spi_master_chip_select_polarity_t cs_polarity
Definition irgesture2.h:455
pin_name_t sck
Definition irgesture2.h:446
spi_master_mode_t spi_mode
Definition irgesture2.h:454
pin_name_t mosi
Definition irgesture2.h:445
uint32_t spi_speed
Definition irgesture2.h:453
pin_name_t int_pin
Definition irgesture2.h:450
pin_name_t miso
Definition irgesture2.h:444
pin_name_t cs
Definition irgesture2.h:447
IR Gesture 2 Click context object.
Definition irgesture2.h:426
spi_master_t spi
Definition irgesture2.h:431
digital_in_t int_pin
Definition irgesture2.h:428
pin_name_t chip_select
Definition irgesture2.h:433