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 LIGHTMIXSENS_REG_ENABLE 0x80
74#define LIGHTMIXSENS_REG_ATIME 0x81
75#define LIGHTMIXSENS_REG_PTIME 0x82
76#define LIGHTMIXSENS_REG_WTIME 0x83
77#define LIGHTMIXSENS_REG_AILT 0x84
78#define LIGHTMIXSENS_REG_AIHT 0x86
79#define LIGHTMIXSENS_REG_PILT 0x88
80#define LIGHTMIXSENS_REG_PIHT 0x8A
81#define LIGHTMIXSENS_REG_PERS 0x8C
82#define LIGHTMIXSENS_REG_CFG0 0x8D
83#define LIGHTMIXSENS_REG_PCFG0 0x8E
84#define LIGHTMIXSENS_REG_PCFG1 0x8F
85#define LIGHTMIXSENS_REG_CFG1 0x90
86#define LIGHTMIXSENS_REG_REVID 0x91
87#define LIGHTMIXSENS_REG_ID 0x92
88#define LIGHTMIXSENS_REG_STATUS 0x93
89#define LIGHTMIXSENS_REG_CDATA 0x94
90#define LIGHTMIXSENS_REG_RDATA 0x96
91#define LIGHTMIXSENS_REG_GDATA_IRDATA 0x98
92#define LIGHTMIXSENS_REG_BDATA 0x9A
93#define LIGHTMIXSENS_REG_PDATA 0x9C
94#define LIGHTMIXSENS_REG_REVID2 0x9E
95#define LIGHTMIXSENS_REG_CFG2 0x9F
96#define LIGHTMIXSENS_REG_CFG3 0xAB
97#define LIGHTMIXSENS_REG_POFFSET 0xC0
98#define LIGHTMIXSENS_REG_AZCFG 0xD6
99#define LIGHTMIXSENS_REG_CALIB 0xD7
100#define LIGHTMIXSENS_REG_CALIBCFG 0xD9
101#define LIGHTMIXSENS_REG_CALIBSTAT 0xDC
102#define LIGHTMIXSENS_REG_INTENAB 0xDD
120#define LIGHTMIXSENS_ATIME_WTIME_CONST 2.8
121#define LIGHTMIXSENS_PTIME_CONST 88
122#define LIGHTMIXSENS_WTIME_INCR_FACTOR 12
124#define LIGHTMIXSENS_ENABLE_WAIT 0x08
125#define LIGHTMIXSENS_ENABLE_PROX 0x04
126#define LIGHTMIXSENS_ENABLE_ALS 0x02
127#define LIGHTMIXSENS_ENABLE_OSC 0x01
128#define LIGHTMIXSENS_DISABLE_ALL 0x00
130#define LIGHTMIXSENS_PCFG1_GAIN_1x 0x00
131#define LIGHTMIXSENS_PCFG1_GAIN_2x 0x40
132#define LIGHTMIXSENS_PCFG1_GAIN_4x 0x80
133#define LIGHTMIXSENS_PCFG1_GAIN_8x 0xC0
134#define LIGHTMIXSENS_PCFG1_DRIVE_6mA 0x00
135#define LIGHTMIXSENS_PCFG1_DRIVE_12mA 0x01
136#define LIGHTMIXSENS_PCFG1_DRIVE_18mA 0x02
137#define LIGHTMIXSENS_PCFG1_DRIVE_192mA 0x1F
139#define LIGHTMIXSENS_CFG0_WLONG 0x04
141#define LIGHTMIXSENS_CFG1_IR_TO_GREEN 0x08
142#define LIGHTMIXSENS_CFG1_AGAIN_1x 0x00
143#define LIGHTMIXSENS_CFG1_AGAIN_4x 0x01
144#define LIGHTMIXSENS_CFG1_AGAIN_16x 0x02
145#define LIGHTMIXSENS_CFG1_AGAIN_64x 0x03
147#define LIGHTMIXSENS_CFG2_AGAINMAX 0x10
148#define LIGHTMIXSENS_CFG2_AGAINL 0x04
150#define LIGHTMIXSENS_CFG3_INT_READ_CLEAR 0x80
151#define LIGHTMIXSENS_CFG3_SAI 0x10
157#define LIGHTMIXSENS_FLAG_ASAT 0x80
158#define LIGHTMIXSENS_FLAG_PSAT 0x40
159#define LIGHTMIXSENS_FLAG_PINT 0x20
160#define LIGHTMIXSENS_FLAG_AINT 0x10
161#define LIGHTMIXSENS_FLAG_CINT 0x08
162#define LIGHTMIXSENS_FLAG_PSAT_REFL 0x02
163#define LIGHTMIXSENS_FLAG_PSAT_AMB 0x01
169#define LIGHTMIXSENS_CALIB_ELECTRICAL 0x20
170#define LIGHTMIXSENS_CALIB_OFFSET_START 0x01
172#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_0 0x00
173#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_1 0x20
174#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_3 0x40
175#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_7 0x60
176#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_15 0x80
177#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_31 0xA0
178#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_63 0xC0
179#define LIGHTMIXSENS_CALIBCFG_PROX_TARGET_127 0xE0
180#define LIGHTMIXSENS_CALIBCFG_AUTO_OFFSET_ADJ 0x08
181#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_DIS 0x00
182#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_2 0x01
183#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_4 0x02
184#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_8 0x03
185#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_16 0x04
186#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_32 0x05
187#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_64 0x06
188#define LIGHTMIXSENS_CALIBCFG_PROX_AVG_128 0x07
190#define LIGHTMIXSENS_CALIBSTAT_FINISHED 0x01
191#define LIGHTMIXSENS_DUMMY_DATA 0x00
198#define LIGHTMIXSENS_SET_DEV_ADDR 0x39
216#define LIGHTMIXSENS_MAP_MIKROBUS( cfg, mikrobus ) \
217 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
218 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
219 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
void lightmixsens_wait_atime(lightmixsens_t *ctx)
Wait ALS/Color Intregration Time Done function.
err_t lightmixsens_write_byte(lightmixsens_t *ctx, uint8_t reg_addr, uint8_t data_in)
Generic Write Byte function.
void lightmixsens_cfg_setup(lightmixsens_cfg_t *cfg)
Light mix sens configuration object setup function.
void lightmixsens_get_status(lightmixsens_t *ctx, uint8_t flag_mask, uint8_t *status)
Get Status function.
void lightmixsens_switch_ir_to_green(lightmixsens_t *ctx)
Switch IR To Green Channel function.
err_t lightmixsens_read_byte(lightmixsens_t *ctx, uint8_t reg_addr, uint8_t *data_out)
Generic Read Byte function.
void lightmixsens_generic_write(lightmixsens_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Light mix sens I2C writing function.
err_t lightmixsens_write_word(lightmixsens_t *ctx, uint8_t reg_addr, uint16_t data_in)
Generic Write Word function.
err_t lightmixsens_read_word(lightmixsens_t *ctx, uint8_t reg_addr, uint16_t *data_out)
Generic Read Word function.
void lightmixsens_wait_wtime(lightmixsens_t *ctx)
Wait WTIME + WLONG Done function.
void lightmixsens_generic_read(lightmixsens_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Light mix sens I2C reading function.
err_t lightmixsens_init(lightmixsens_t *ctx, lightmixsens_cfg_t *cfg)
Light mix sens initialization function.
void lightmixsens_wait_ptime(lightmixsens_t *ctx)
Wait Proximity Sample Time Done function.
void lightmixsens_default_cfg(lightmixsens_t *ctx)
Light mix sens default configuration function.
void lightmixsens_switch_ir_to_prox(lightmixsens_t *ctx)
Switch IR To Proximity function.
lightmixsens_return_value_t
Light mix sens Click return value data.
Definition lightmixsens.h:275
@ LIGHTMIXSENS_OK
Definition lightmixsens.h:276
@ LIGHTMIXSENS_ERROR
Definition lightmixsens.h:277
Light mix sens Click configuration object.
Definition lightmixsens.h:246
uint32_t i2c_speed
Definition lightmixsens.h:252
pin_name_t scl
Definition lightmixsens.h:247
pin_name_t int_pin
Definition lightmixsens.h:250
pin_name_t sda
Definition lightmixsens.h:248
uint8_t i2c_address
Definition lightmixsens.h:253
Light mix sens Click data object.
Definition lightmixsens.h:262
uint16_t lightmixsens_rdata
Definition lightmixsens.h:264
uint16_t lightmixsens_cdata
Definition lightmixsens.h:263
uint8_t lightmixsens_pdata
Definition lightmixsens.h:267
uint16_t lightmixsens_bdata
Definition lightmixsens.h:266
uint16_t lightmixsens_gdata
Definition lightmixsens.h:265
Light mix sens Click context object.
Definition lightmixsens.h:229
digital_in_t int_pin
Definition lightmixsens.h:231
i2c_master_t i2c
Definition lightmixsens.h:234
uint8_t slave_address
Definition lightmixsens.h:237