42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
66#define PROXIMITY5_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define PROXIMITY5_RETVAL uint8_t
78#define PROXIMITY5_OK 0x00
79#define PROXIMITY5_INIT_ERROR 0xFF
95#define ALS_IT_100_ms 1
96#define ALS_IT_200_ms 2
97#define ALS_IT_400_ms 3
98#define ALS_IT_800_ms 7
105#define ALS_WHITE_SD_ON 0
106#define ALS_WHITE_SD_OFF 1
113#define PS_DUTY_1_40 0
114#define PS_DUTY_1_80 1
115#define PS_DUTY_1_160 2
116#define PS_DUTY_1_320 3
138#define GEST_INT_DIS 0
139#define GEST_MODE_EN 1
140#define GEST_MODE_DIS 0
141#define PS_GAIN_TWO_STEP 1
142#define PS_GAIN_SINGLX8 2
143#define PS_GAIN_SINGLX1 3
146#define PS_NS_TWO_STEPX4 0
147#define PS_NS_TWO_STEP 1
151#define PS_INT_CLOS_AWAY 3
158#define LED_I_LOW_DIS 0
159#define LED_I_LOW_EN 1
160#define IRED_SEL_IRED1 0
161#define IRED_SEL_IRED2 1
162#define IRED_SEL_IRED3 2
163#define PS_SMART_PERS_DIS 0
164#define PS_SMART_PERS_EN 1
170#define PS_MS_LOG_OUT 1
172#define PS_SC_EN_OFF 0
179#define PS_SC_CUR_1X 0
180#define PS_SC_CUR_2X 1
181#define PS_SC_CUR_4X 2
182#define PS_SC_CUR_8X 3
184#define PS_SP_TYPX1_5 1
201#define CMD_ALS_CONF1 0x00
202#define CMD_ALS_CONF2 0x00
203#define CMD_ALS_CONF1_2 0x00
204#define CMD_ALS_THDH_L 0x01
205#define CMD_ALS_THDH_H 0x01
206#define CMD_ALS_THDH_L_M 0x01
207#define CMD_ALS_THDL_L 0x02
208#define CMD_ALS_THDL_H 0x02
209#define CMD_ALS_THDL_L_M 0x02
210#define CMD_PS_CONF1 0x03
211#define CMD_PS_CONF2 0x03
212#define CMD_PS_CONF1_2 0x03
213#define CMD_PS_CONF3 0x04
214#define CMD_PS_MS 0x04
215#define CMD_PS_CONF3_MS 0x04
216#define CMD_PS_CANC_L 0x05
217#define CMD_PS_CANC_M 0x05
218#define CMD_PS_CANC_L_M 0x05
219#define CMD_PS_THDH_L 0x06
220#define CMD_PS_THDH_M 0x06
221#define CMD_PS_THDH_L_M 0x06
222#define CMD_PS_THDL_L 0x07
223#define CMD_PS_THDL_M 0x07
224#define CMD_PS_THDL_L_M 0x07
225#define CMD_PS1_DATA_L 0x08
226#define CMD_PS1_DATA_M 0x08
227#define CMD_PS1_DATA_L_M 0x08
228#define CMD_PS2_DATA_L 0x09
229#define CMD_PS2_DATA_M 0x09
230#define CMD_PS2_DATA_L_M 0x09
231#define CMD_PS3_DATA_L 0x0A
232#define CMD_PS3_DATA_M 0x0A
233#define CMD_PS3_DATA_L_M 0x0A
234#define CMD_ALS_DATA_L 0x0B
235#define CMD_ALS_DATA_M 0x0B
236#define CMD_ALS_DATA_L_M 0x0B
237#define CMD_WHITE_DATA_L 0x0C
238#define CMD_WHITE_DATA_M 0x0C
239#define CMD_WHITE_DATA_L_M 0x0C
241#define CMD_INT_FLAG 0x0D
244#define CMD_ID_L_M 0x0E
251#define PROXIMITY5_ADDR 0x60
#define PROXIMITY5_RETVAL
Definition proximity5.h:76
uint16_t proximity5_read_reg(proximity5_t *ctx, uint8_t addr)
16bit read function.
void proximity5_default_cfg(proximity5_t *ctx)
Click Default Configuration function.
void proximity5_generic_read(proximity5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void proximity5_generic_write(proximity5_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
PROXIMITY5_RETVAL proximity5_init(proximity5_t *ctx, proximity5_cfg_t *cfg)
Initialization function.
void proximity5_get_values(proximity5_t *ctx, uint16_t *prox_val)
Proximity value get function.
uint16_t proximity5_get_id(proximity5_t *ctx)
16bit read function.
void proximity5_cfg_setup(proximity5_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition proximity5.h:285
uint32_t i2c_speed
Definition proximity5.h:297
pin_name_t scl
Definition proximity5.h:288
pin_name_t int_pin
Definition proximity5.h:293
pin_name_t sda
Definition proximity5.h:289
uint8_t i2c_address
Definition proximity5.h:298
Click ctx object definition.
Definition proximity5.h:266
digital_in_t int_pin
Definition proximity5.h:269
i2c_master_t i2c
Definition proximity5.h:273
uint8_t slave_address
Definition proximity5.h:277
Click calibration unions.
Definition proximity5.h:306
unsigned char ALL
Definition proximity5.h:307
unsigned char ALS_IT
Definition proximity5.h:315
unsigned char ALS_PERS
Definition proximity5.h:313
unsigned char ALS_INT_EN
Definition proximity5.h:312
unsigned char RES
Definition proximity5.h:314
unsigned char ALS_SD
Definition proximity5.h:311
Definition proximity5.h:321
unsigned char ALL
Definition proximity5.h:322
unsigned char WHITE_SD
Definition proximity5.h:326
unsigned char RES
Definition proximity5.h:327
Definition proximity5.h:357
uint16_t ALS_DATA_M
Definition proximity5.h:363
uint16_t ALL
Definition proximity5.h:358
uint16_t ALS_DATA_L
Definition proximity5.h:362
Definition proximity5.h:333
uint16_t ALS_THDH_L
Definition proximity5.h:338
uint16_t ALS_THDH_M
Definition proximity5.h:339
uint16_t ALL
Definition proximity5.h:334
Definition proximity5.h:345
uint16_t LS_THDL_M
Definition proximity5.h:351
uint16_t ALL
Definition proximity5.h:346
uint16_t LS_THDL_L
Definition proximity5.h:350
Definition proximity5.h:533
uint16_t ID_M
Definition proximity5.h:539
uint16_t ALL
Definition proximity5.h:534
uint16_t ID_L
Definition proximity5.h:538
Definition proximity5.h:514
uint8_t PS_IF_CLOSE
Definition proximity5.h:520
uint8_t ALS_IF_H
Definition proximity5.h:523
uint8_t ALS_IF_L
Definition proximity5.h:524
uint8_t PS_SPFLAG
Definition proximity5.h:525
uint8_t ALL
Definition proximity5.h:515
uint8_t RES1
Definition proximity5.h:521
uint8_t RES0
Definition proximity5.h:522
uint8_t PS_IF_AWAY
Definition proximity5.h:519
uint8_t GEST_DATA_RDY_FLG
Definition proximity5.h:526
Definition proximity5.h:466
uint16_t PS1_DATA_L
Definition proximity5.h:471
uint16_t PS1_DATA_M
Definition proximity5.h:472
uint16_t ALL
Definition proximity5.h:467
Definition proximity5.h:478
uint16_t PS2_DATA_M
Definition proximity5.h:483
uint16_t ALL
Definition proximity5.h:479
uint16_t PS2_DATA_L
Definition proximity5.h:482
Definition proximity5.h:489
uint16_t PS3_DATA_L
Definition proximity5.h:494
uint16_t PS3_DATA_M
Definition proximity5.h:495
uint16_t ALL
Definition proximity5.h:490
Definition proximity5.h:430
uint16_t PS_CANC_L
Definition proximity5.h:435
uint16_t ALL
Definition proximity5.h:431
uint16_t PS_CANC_M
Definition proximity5.h:436
Definition proximity5.h:369
uint8_t PS_SD
Definition proximity5.h:373
uint8_t PS_DUTY
Definition proximity5.h:376
uint8_t ALL
Definition proximity5.h:370
uint8_t PS_IT
Definition proximity5.h:374
uint8_t PS_PERS
Definition proximity5.h:375
Definition proximity5.h:382
uint8_t PS_GAIN
Definition proximity5.h:389
uint8_t PS_HD
Definition proximity5.h:388
uint8_t PS_NS
Definition proximity5.h:387
uint8_t ALL
Definition proximity5.h:383
uint8_t GEST_INTEN
Definition proximity5.h:391
uint8_t PS_INT_EN
Definition proximity5.h:386
uint8_t GEST_MODE
Definition proximity5.h:390
Definition proximity5.h:397
uint8_t LED_I_LOW
Definition proximity5.h:408
uint8_t PS_SC_EN
Definition proximity5.h:402
uint8_t PS_MS
Definition proximity5.h:403
uint8_t PS_AF
Definition proximity5.h:405
uint8_t IRED_SEL
Definition proximity5.h:407
uint8_t ALL
Definition proximity5.h:398
uint8_t PS_TRIG
Definition proximity5.h:404
uint8_t PS_SMART_PERS
Definition proximity5.h:406
Definition proximity5.h:414
uint8_t LED_I
Definition proximity5.h:419
uint8_t ALL
Definition proximity5.h:415
uint8_t RES
Definition proximity5.h:423
uint8_t PS_SC_CUR
Definition proximity5.h:422
uint8_t PS_SP
Definition proximity5.h:421
uint8_t PS_SPO
Definition proximity5.h:420
Definition proximity5.h:454
uint16_t PS_THDH_L
Definition proximity5.h:459
uint16_t ALL
Definition proximity5.h:455
uint16_t PS_THDH_M
Definition proximity5.h:460
Definition proximity5.h:442
uint16_t PS_THDL_M
Definition proximity5.h:448
uint16_t ALL
Definition proximity5.h:443
uint16_t PS_THDL_L
Definition proximity5.h:447
Definition proximity5.h:501
uint16_t ALL
Definition proximity5.h:502
uint16_t WHITE_DATA_M
Definition proximity5.h:507
uint16_t WHITE_DATA_L
Definition proximity5.h:506