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 LIGHT3_REG_RESULT_MSB_CH0 0x00
74#define LIGHT3_REG_RESULT_LSB_CH0 0x01
75#define LIGHT3_REG_RESULT_MSB_CH1 0x02
76#define LIGHT3_REG_RESULT_LSB_CH1 0x03
77#define LIGHT3_REG_RESULT_FIFO_MSB_CH0 0x04
78#define LIGHT3_REG_RESULT_FIFO_LSB_CH0 0x05
79#define LIGHT3_REG_RESULT_FIFO_MSB_CH1 0x06
80#define LIGHT3_REG_RESULT_FIFO_LSB_CH1 0x07
81#define LIGHT3_REG_TRESHOLD_LOW 0x08
82#define LIGHT3_REG_TRESHOLD_HIGH 0x09
83#define LIGHT3_REG_CONFIG 0x0A
84#define LIGHT3_REG_INT_CONFIG 0x0B
85#define LIGHT3_REG_ERROR_FLAGS 0x0C
86#define LIGHT3_REG_DEVICE_ID 0x11
104#define LIGHT3_QWAKE_EN 0x8000u
105#define LIGHT3_RANGE_561_LUX 0x0000u
106#define LIGHT3_RANGE_1_1_KLUX 0x0400u
107#define LIGHT3_RANGE_2_2_KLUX 0x0800u
108#define LIGHT3_RANGE_4_4_KLUX 0x0C00u
109#define LIGHT3_RANGE_8_9_KLUX 0x1000u
110#define LIGHT3_RANGE_17_9_KLUX 0x1400u
111#define LIGHT3_RANGE_35_9_KLUX 0x1800u
112#define LIGHT3_RANGE_71_8_KLUX 0x1C00u
113#define LIGHT3_RANGE_143_KLUX 0x2000u
114#define LIGHT3_RANGE_AUTO_RANGE 0x3000u
115#define LIGHT3_CONV_TIME_600_US 0x0000u
116#define LIGHT3_CONV_TIME_1_MS 0x0040u
117#define LIGHT3_CONV_TIME_1_8_MS 0x0080u
118#define LIGHT3_CONV_TIME_3_4_MS 0x00C0u
119#define LIGHT3_CONV_TIME_6_5_MS 0x0100u
120#define LIGHT3_CONV_TIME_12_7_MS 0x0140u
121#define LIGHT3_CONV_TIME_25_MS 0x0180u
122#define LIGHT3_CONV_TIME_50_MS 0x01C0u
123#define LIGHT3_CONV_TIME_100_MS 0x0200u
124#define LIGHT3_CONV_TIME_200_MS 0x0240u
125#define LIGHT3_CONV_TIME_400_MS 0x0280u
126#define LIGHT3_CONV_TIME_800_MS 0x02C0u
127#define LIGHT3_MODE_POWER_DOWN 0x0000u
128#define LIGHT3_MODE_AUTO_RANGE_ONE_SHOT 0x0010u
129#define LIGHT3_MODE_ONE_SHOT 0x0020u
130#define LIGHT3_MODE_CONTINUOUS 0x0030u
131#define LIGHT3_LATCH 0x0008u
132#define LIGHT3_INT_POL_ACTIVE_LOW 0x0000u
133#define LIGHT3_INT_POL_ACTIVE_HIGH 0x0004u
134#define LIGHT3_FAULT_COUNT_1 0x0000u
135#define LIGHT3_FAULT_COUNT_2 0x0001u
136#define LIGHT3_FAULT_COUNT_4 0x0002u
137#define LIGHT3_FAULT_COUNT_8 0x0003u
143#define LIGHT3_INT_CONFIG_REG_DEF_VALUE 0x8000u
144#define LIGHT3_TRESHOLD_CH0_SEL 0x0000u
145#define LIGHT3_TRESHOLD_CH1_SEL 0x0020u
146#define LIGHT3_INT_DIR_INPUT 0x0000u
147#define LIGHT3_INT_DIR_OUTPUT 0x0010u
148#define LIGHT3_INT_CFG_SMBUS_ALERT 0x0000u
149#define LIGHT3_INT_EVERY_CONV 0x0004u
150#define LIGHT3_INT_EVERY_2_CONV 0x0008u
151#define LIGHT3_INT_EVERY_4_CONV 0x000Cu
152#define LIGHT3_I2C_BURST_ENABLED 0x0001u
158#define LIGHT3_LUX_CONV_FACTOR 0.000535f
164#define LIGHT3_PIN_STATE_LOW 0x00
165#define LIGHT3_PIN_STATE_HIGH 0x01
171#define LIGHT3_SW_RESET_ADDRESS 0x00
172#define LIGHT3_SW_RESET_COMMAND 0x06
179#define LIGHT3_DEVICE_ADDRESS_0 0x44
180#define LIGHT3_DEVICE_ADDRESS_1 0x45
198#define LIGHT3_MAP_MIKROBUS( cfg, mikrobus ) \
199 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
200 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
201 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t light3_get_ch0_data(light3_t *ctx, float *lux)
Light 3 read CH0 data function.
err_t light3_sw_reset(light3_t *ctx)
Light 3 software reset function.
err_t light3_get_ch1_fifo_data(light3_t *ctx, float *lux)
Light 3 read CH1 FIFO data function.
err_t light3_init(light3_t *ctx, light3_cfg_t *cfg)
Light 3 initialization function.
err_t light3_get_ch1_data(light3_t *ctx, float *lux)
Light 3 read CH1 data function.
err_t light3_generic_read(light3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Light 3 I2C reading function.
err_t light3_generic_write(light3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Light 3 I2C writing function.
err_t light3_write_reg(light3_t *ctx, uint8_t reg, uint16_t data_in)
Light 3 register writing function.
err_t light3_read_reg(light3_t *ctx, uint8_t reg, uint16_t *data_out)
Light 3 register reading function.
void light3_cfg_setup(light3_cfg_t *cfg)
Light 3 configuration object setup function.
err_t light3_default_cfg(light3_t *ctx)
Light 3 default configuration function.
uint8_t light3_get_int_pin(light3_t *ctx)
Light 3 get INT pin state function.
err_t light3_get_ch0_fifo_data(light3_t *ctx, float *lux)
Light 3 read CH0 FIFO data function.
light3_return_value_t
Light 3 Click return value data.
Definition: light3.h:244
@ LIGHT3_OK
Definition: light3.h:245
@ LIGHT3_ERROR
Definition: light3.h:246
Light 3 Click configuration object.
Definition: light3.h:228
uint32_t i2c_speed
Definition: light3.h:234
pin_name_t scl
Definition: light3.h:229
pin_name_t int_pin
Definition: light3.h:232
pin_name_t sda
Definition: light3.h:230
uint8_t i2c_address
Definition: light3.h:235
Light 3 Click context object.
Definition: light3.h:211
digital_in_t int_pin
Definition: light3.h:213
i2c_master_t i2c
Definition: light3.h:216
uint8_t slave_address
Definition: light3.h:219