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_i2c_master.h"
73#define PROXIMITY12_REG_AILT 0x2E
74#define PROXIMITY12_REG_AIHT 0x31
75#define PROXIMITY12_REG_PILT0 0x34
76#define PROXIMITY12_REG_PIHT0 0x36
77#define PROXIMITY12_REG_PILT1 0x38
78#define PROXIMITY12_REG_PIHT1 0x3A
79#define PROXIMITY12_REG_PILTR 0x3C
80#define PROXIMITY12_REG_PIHTR 0x3E
81#define PROXIMITY12_REG_FD_CFG0 0x40
82#define PROXIMITY12_REG_FD_CFG1 0x41
83#define PROXIMITY12_REG_FD_CFG2 0x42
84#define PROXIMITY12_REG_FD_CFG3 0x43
85#define PROXIMITY12_REG_FD_CFG4 0x44
86#define PROXIMITY12_REG_FD_CFG5 0x45
87#define PROXIMITY12_REG_FD_CFG6 0x46
88#define PROXIMITY12_REG_FD_CFG7 0x47
89#define PROXIMITY12_REG_FD_CFG8 0x48
90#define PROXIMITY12_REG_SYNC_DELAY 0x4F
91#define PROXIMITY12_REG_VSYNC_CFG0 0x53
92#define PROXIMITY12_REG_VSYNC_CFG1 0x54
93#define PROXIMITY12_REG_VSYNC_CFG2 0x56
94#define PROXIMITY12_REG_VSYNC_CFG3 0x57
95#define PROXIMITY12_REG_CALIB 0x69
96#define PROXIMITY12_REG_CALIBCFG0 0x6A
97#define PROXIMITY12_REG_CALIBCFG1 0x6B
98#define PROXIMITY12_REG_CALIBCFG2 0x6C
99#define PROXIMITY12_REG_CALIBSTAT 0x6D
100#define PROXIMITY12_REG_ENABLE 0x80
101#define PROXIMITY12_REG_MEAS_MODE0 0x81
102#define PROXIMITY12_REG_MEAS_MODE1 0x82
103#define PROXIMITY12_REG_TRIGGER_MODE 0x83
104#define PROXIMITY12_REG_ATIME 0x84
105#define PROXIMITY12_REG_ASTEP 0x85
106#define PROXIMITY12_REG_PTIME 0x87
107#define PROXIMITY12_REG_WTIPE 0x88
108#define PROXIMITY12_REG_MOD_GAIN_0_1 0x89
109#define PROXIMITY12_REG_MOD_GAIN_2_3 0x8A
110#define PROXIMITY12_REG_MOD_GAIN_4_5 0x8B
111#define PROXIMITY12_REG_MOD_GAIN_6_7 0x8C
112#define PROXIMITY12_REG_AGC_ENABLE 0x8D
113#define PROXIMITY12_REG_AUXID 0x90
114#define PROXIMITY12_REG_REVID 0x91
115#define PROXIMITY12_REG_ID 0x92
116#define PROXIMITY12_REG_CFG0 0x93
117#define PROXIMITY12_REG_CFG3 0x96
118#define PROXIMITY12_REG_CFG4 0x97
119#define PROXIMITY12_REG_PERS 0x9A
120#define PROXIMITY12_REG_CFG8 0x9B
121#define PROXIMITY12_REG_CFG9 0x9C
122#define PROXIMITY12_REG_CFG10 0x9D
123#define PROXIMITY12_REG_CFG11 0x9E
124#define PROXIMITY12_REG_CFG12 0x9F
125#define PROXIMITY12_REG_AZ_CONFIG 0xA4
126#define PROXIMITY12_REG_CFG20 0xA7
127#define PROXIMITY12_REG_PCFG1 0xAA
128#define PROXIMITY12_REG_PCFG2 0xAB
129#define PROXIMITY12_REG_PCFG3 0xAC
130#define PROXIMITY12_REG_PCFG4 0xAD
131#define PROXIMITY12_REG_PCFG5 0xAE
132#define PROXIMITY12_REG_PCFG6 0xAF
133#define PROXIMITY12_REG_PCFG7 0xB0
134#define PROXIMITY12_REG_POFFSET0 0xB1
135#define PROXIMITY12_REG_PXAVG 0xB3
136#define PROXIMITY12_REG_PBSLN 0xB5
137#define PROXIMITY12_REG_STATUS 0xB7
138#define PROXIMITY12_REG_STATUS2 0xB8
139#define PROXIMITY12_REG_STATUS3 0xB9
140#define PROXIMITY12_REG_STATUS4 0xBA
141#define PROXIMITY12_REG_STATUS5 0xBB
142#define PROXIMITY12_REG_STATUS7 0xBD
143#define PROXIMITY12_REG_STATUS8 0xBE
144#define PROXIMITY12_REG_STATUS9 0xBF
145#define PROXIMITY12_REG_ASTATUS 0xC0
146#define PROXIMITY12_REG_ADATA0 0xC1
147#define PROXIMITY12_REG_ADATA1 0xC4
148#define PROXIMITY12_REG_ADATA2 0xC7
149#define PROXIMITY12_REG_ADATA3 0xCA
150#define PROXIMITY12_REG_ADATA4 0xCD
151#define PROXIMITY12_REG_ADATA5 0xD0
152#define PROXIMITY12_REG_ADATA6 0xD3
153#define PROXIMITY12_REG_ADATA7 0xD6
154#define PROXIMITY12_REG_PSTATUS 0xD9
155#define PROXIMITY12_REG_PDATA0 0xDA
156#define PROXIMITY12_REG_PDATA1 0xDC
157#define PROXIMITY12_REG_PDATAR 0xDE
158#define PROXIMITY12_REG_GPIO 0xF2
159#define PROXIMITY12_REG_AGC_GAIN_MAX 0xF4
160#define PROXIMITY12_REG_INTENAB 0xF5
161#define PROXIMITY12_REG_CONTROL 0xF6
162#define PROXIMITY12_REG_POFFSET1 0xF7
163#define PROXIMITY12_REG_FIFO_MAP 0xF9
164#define PROXIMITY12_REG_FIFO_MAP2 0xFA
165#define PROXIMITY12_REG_FIFO_STATUS 0xFB
166#define PROXIMITY12_REG_FDATA 0xFC
184#define PROXIMITY12_ENABLE_FLICKER 0x40
185#define PROXIMITY12_ENABLE_ALS 0x10
186#define PROXIMITY12_ENABLE_PROX 0x08
187#define PROXIMITY12_ENABLE_POWER 0x01
193#define PROXIMITY12_MEAS_MODE0_CL_APF_VSYNC 0x40
194#define PROXIMITY12_MEAS_MODE0_EN_PROX_DIODE 0x0C
195#define PROXIMITY12_MEAS_MODE0_ALS_SET_A_DIODE 0x00
196#define PROXIMITY12_MEAS_MODE0_ALS_SET_B_DIODE 0x02
197#define PROXIMITY12_MEAS_MODE0_EN_ALS_DIODE 0x01
203#define PROXIMITY12_AGC_DISABLE_ALL_MOD 0x00
204#define PROXIMITY12_AGC_ENABLE_ALL_MOD 0xFF
205#define PROXIMITY12_AGC_ENABLE_MOD_7 0x80
206#define PROXIMITY12_AGC_ENABLE_MOD_6 0x40
207#define PROXIMITY12_AGC_ENABLE_MOD_5 0x20
208#define PROXIMITY12_AGC_ENABLE_MOD_4 0x10
209#define PROXIMITY12_AGC_ENABLE_MOD_3 0x08
210#define PROXIMITY12_AGC_ENABLE_MOD_2 0x04
211#define PROXIMITY12_AGC_ENABLE_MOD_1 0x02
212#define PROXIMITY12_AGC_ENABLE_MOD_0 0x01
213#define PROXIMITY12_MOD_GAIN_2X 0x00
214#define PROXIMITY12_MOD_GAIN_4X 0x01
215#define PROXIMITY12_MOD_GAIN_8X 0x02
216#define PROXIMITY12_MOD_GAIN_16X 0x03
217#define PROXIMITY12_MOD_GAIN_32X 0x04
218#define PROXIMITY12_MOD_GAIN_64X 0x05
219#define PROXIMITY12_MOD_GAIN_128X 0x06
220#define PROXIMITY12_MOD_GAIN_256X 0x07
221#define PROXIMITY12_MOD_GAIN_512X 0x08
222#define PROXIMITY12_MOD_GAIN_1024X 0x09
223#define PROXIMITY12_MOD_GAIN_2048X 0x0A
224#define PROXIMITY12_MOD_GAIN_4096X 0x0B
230#define PROXIMITY12_PROX_FILTER_ENABLE 0x08
231#define PROXIMITY12_PROX_FILTER_1 0x00
232#define PROXIMITY12_PROX_FILTER_2 0x01
233#define PROXIMITY12_PROX_FILTER_3 0x02
234#define PROXIMITY12_PROX_FILTER_4 0x03
235#define PROXIMITY12_PROX_FILTER_5 0x04
236#define PROXIMITY12_PROX_FILTER_6 0x05
237#define PROXIMITY12_PROX_FILTER_7 0x06
238#define PROXIMITY12_PROX_FILTER_8 0x07
244#define PROXIMITY12_ISINK_SCALER_0p5 0x00
245#define PROXIMITY12_ISINK_SCALER_1 0x01
246#define PROXIMITY12_ISINK_SCALER_1p5 0x02
247#define PROXIMITY12_ISINK_SCALER_2 0x03
248#define PROXIMITY12_ISINK_CURRENT_0mA 0x00
249#define PROXIMITY12_ISINK_CURRENT_1mA 0x01
250#define PROXIMITY12_ISINK_CURRENT_2mA 0x02
251#define PROXIMITY12_ISINK_CURRENT_3mA 0x03
252#define PROXIMITY12_ISINK_CURRENT_4mA 0x04
253#define PROXIMITY12_ISINK_CURRENT_5mA 0x05
254#define PROXIMITY12_ISINK_CURRENT_6mA 0x06
255#define PROXIMITY12_ISINK_CURRENT_7mA 0x07
261#define PROXIMITY12_PROX_GAIN_1X 0x00
262#define PROXIMITY12_PROX_GAIN_2X 0x01
263#define PROXIMITY12_PROX_GAIN_4X 0x02
264#define PROXIMITY12_PROX_GAIN_8X 0x03
270#define PROXIMITY12_AUXID 0x03
271#define PROXIMITY12_REVID 0x13
272#define PROXIMITY12_ID 0x40
279#define PROXIMITY12_SET_DEV_ADDR 0x39
297#define PROXIMITY12_MAP_MIKROBUS( cfg, mikrobus ) \
298 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
299 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
300 cfg.syn = MIKROBUS( mikrobus, MIKROBUS_CS ); \
301 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
302 cfg.gp2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
303 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
void proximity12_set_gp2_pin(proximity12_t *ctx, uint8_t state)
Proximity 12 set gp2 pin state function.
err_t proximity12_generic_read(proximity12_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Proximity 12 I2C reading function.
uint8_t proximity12_get_int_pin(proximity12_t *ctx)
Proximity 12 get int pin state function.
err_t proximity12_enable_measurement(proximity12_t *ctx, uint8_t en_mask)
Proximity 12 enable measurement function.
void proximity12_set_gp1_pin(proximity12_t *ctx, uint8_t state)
Proximity 12 set gp1 pin state function.
err_t proximity12_enable(proximity12_t *ctx, uint8_t en_mask)
Proximity 12 enable function.
err_t proximity12_wait_ptime(proximity12_t *ctx)
Proximity 12 wait ptime function.
err_t proximity12_set_proximity_gain(proximity12_t *ctx, uint8_t gain)
Proximity 12 set proximity gain function.
err_t proximity12_init(proximity12_t *ctx, proximity12_cfg_t *cfg)
Proximity 12 initialization function.
err_t proximity12_set_led_isink(proximity12_t *ctx, uint8_t scaler, uint8_t current)
Proximity 12 set led isink function.
err_t proximity12_set_proximity_filter(proximity12_t *ctx, uint8_t filter)
Proximity 12 set proximity filter function.
void proximity12_set_syn_pin(proximity12_t *ctx, uint8_t state)
Proximity 12 set syn pin state function.
void proximity12_cfg_setup(proximity12_cfg_t *cfg)
Proximity 12 configuration object setup function.
err_t proximity12_set_agc_mod_gain(proximity12_t *ctx, uint8_t en_mask, uint8_t gain)
Proximity 12 set agc modulator gain function.
err_t proximity12_read_als(proximity12_t *ctx, proximity12_als_data_t *als)
Proximity 12 read als data function.
err_t proximity12_generic_write(proximity12_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Proximity 12 I2C writing function.
err_t proximity12_proximity_calibration(proximity12_t *ctx)
Proximity 12 proximity calibration function.
err_t proximity12_read_proximity(proximity12_t *ctx, uint16_t *prox_data)
Proximity 12 read proximity function.
err_t proximity12_default_cfg(proximity12_t *ctx)
Proximity 12 default configuration function.
err_t proximity12_wait_atime(proximity12_t *ctx)
Proximity 12 wait atime function.
err_t proximity12_check_device_id(proximity12_t *ctx)
Proximity 12 check device ID function.
proximity12_return_value_t
Proximity 12 Click return value data.
Definition proximity12.h:371
@ PROXIMITY12_ERROR
Definition proximity12.h:373
@ PROXIMITY12_OK
Definition proximity12.h:372
Proximity 12 ALS data object.
Definition proximity12.h:354
uint32_t red
Definition proximity12.h:356
uint32_t ir1
Definition proximity12.h:361
uint32_t blue
Definition proximity12.h:358
uint32_t ir2
Definition proximity12.h:362
uint32_t leakage
Definition proximity12.h:359
uint32_t clear
Definition proximity12.h:355
uint32_t green
Definition proximity12.h:357
uint32_t wideband
Definition proximity12.h:360
Proximity 12 Click configuration object.
Definition proximity12.h:335
pin_name_t gp2
Definition proximity12.h:341
uint32_t i2c_speed
Definition proximity12.h:344
pin_name_t scl
Definition proximity12.h:336
pin_name_t int_pin
Definition proximity12.h:342
pin_name_t gp1
Definition proximity12.h:340
pin_name_t sda
Definition proximity12.h:337
pin_name_t syn
Definition proximity12.h:339
uint8_t i2c_address
Definition proximity12.h:345
Proximity 12 Click context object.
Definition proximity12.h:313
digital_out_t gp2
Definition proximity12.h:317
digital_out_t syn
Definition proximity12.h:315
digital_in_t int_pin
Definition proximity12.h:320
i2c_master_t i2c
Definition proximity12.h:323
digital_out_t gp1
Definition proximity12.h:316
uint8_t slave_address
Definition proximity12.h:326