35#include "mikrosdk_version.h"
38#if mikroSDK_GET_VERSION < 20800ul
39#include "rcu_delays.h"
45#include "drv_digital_out.h"
46#include "drv_digital_in.h"
47#include "drv_i2c_master.h"
69#define LIGHT3_REG_RESULT_MSB_CH0 0x00
70#define LIGHT3_REG_RESULT_LSB_CH0 0x01
71#define LIGHT3_REG_RESULT_MSB_CH1 0x02
72#define LIGHT3_REG_RESULT_LSB_CH1 0x03
73#define LIGHT3_REG_RESULT_FIFO_MSB_CH0 0x04
74#define LIGHT3_REG_RESULT_FIFO_LSB_CH0 0x05
75#define LIGHT3_REG_RESULT_FIFO_MSB_CH1 0x06
76#define LIGHT3_REG_RESULT_FIFO_LSB_CH1 0x07
77#define LIGHT3_REG_TRESHOLD_LOW 0x08
78#define LIGHT3_REG_TRESHOLD_HIGH 0x09
79#define LIGHT3_REG_CONFIG 0x0A
80#define LIGHT3_REG_INT_CONFIG 0x0B
81#define LIGHT3_REG_ERROR_FLAGS 0x0C
82#define LIGHT3_REG_DEVICE_ID 0x11
100#define LIGHT3_QWAKE_EN 0x8000u
101#define LIGHT3_RANGE_561_LUX 0x0000u
102#define LIGHT3_RANGE_1_1_KLUX 0x0400u
103#define LIGHT3_RANGE_2_2_KLUX 0x0800u
104#define LIGHT3_RANGE_4_4_KLUX 0x0C00u
105#define LIGHT3_RANGE_8_9_KLUX 0x1000u
106#define LIGHT3_RANGE_17_9_KLUX 0x1400u
107#define LIGHT3_RANGE_35_9_KLUX 0x1800u
108#define LIGHT3_RANGE_71_8_KLUX 0x1C00u
109#define LIGHT3_RANGE_143_KLUX 0x2000u
110#define LIGHT3_RANGE_AUTO_RANGE 0x3000u
111#define LIGHT3_CONV_TIME_600_US 0x0000u
112#define LIGHT3_CONV_TIME_1_MS 0x0040u
113#define LIGHT3_CONV_TIME_1_8_MS 0x0080u
114#define LIGHT3_CONV_TIME_3_4_MS 0x00C0u
115#define LIGHT3_CONV_TIME_6_5_MS 0x0100u
116#define LIGHT3_CONV_TIME_12_7_MS 0x0140u
117#define LIGHT3_CONV_TIME_25_MS 0x0180u
118#define LIGHT3_CONV_TIME_50_MS 0x01C0u
119#define LIGHT3_CONV_TIME_100_MS 0x0200u
120#define LIGHT3_CONV_TIME_200_MS 0x0240u
121#define LIGHT3_CONV_TIME_400_MS 0x0280u
122#define LIGHT3_CONV_TIME_800_MS 0x02C0u
123#define LIGHT3_MODE_POWER_DOWN 0x0000u
124#define LIGHT3_MODE_AUTO_RANGE_ONE_SHOT 0x0010u
125#define LIGHT3_MODE_ONE_SHOT 0x0020u
126#define LIGHT3_MODE_CONTINUOUS 0x0030u
127#define LIGHT3_LATCH 0x0008u
128#define LIGHT3_INT_POL_ACTIVE_LOW 0x0000u
129#define LIGHT3_INT_POL_ACTIVE_HIGH 0x0004u
130#define LIGHT3_FAULT_COUNT_1 0x0000u
131#define LIGHT3_FAULT_COUNT_2 0x0001u
132#define LIGHT3_FAULT_COUNT_4 0x0002u
133#define LIGHT3_FAULT_COUNT_8 0x0003u
139#define LIGHT3_INT_CONFIG_REG_DEF_VALUE 0x8000u
140#define LIGHT3_TRESHOLD_CH0_SEL 0x0000u
141#define LIGHT3_TRESHOLD_CH1_SEL 0x0020u
142#define LIGHT3_INT_DIR_INPUT 0x0000u
143#define LIGHT3_INT_DIR_OUTPUT 0x0010u
144#define LIGHT3_INT_CFG_SMBUS_ALERT 0x0000u
145#define LIGHT3_INT_EVERY_CONV 0x0004u
146#define LIGHT3_INT_EVERY_2_CONV 0x0008u
147#define LIGHT3_INT_EVERY_4_CONV 0x000Cu
148#define LIGHT3_I2C_BURST_ENABLED 0x0001u
154#define LIGHT3_LUX_CONV_FACTOR 0.000535f
160#define LIGHT3_PIN_STATE_LOW 0x00
161#define LIGHT3_PIN_STATE_HIGH 0x01
168#define LIGHT3_DEVICE_ADDRESS_0 0x44
169#define LIGHT3_DEVICE_ADDRESS_1 0x45
187#define LIGHT3_MAP_MIKROBUS( cfg, mikrobus ) \
188 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
189 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
190 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:233
@ LIGHT3_OK
Definition: light3.h:234
@ LIGHT3_ERROR
Definition: light3.h:235
Light 3 Click configuration object.
Definition: light3.h:217
uint32_t i2c_speed
Definition: light3.h:223
pin_name_t scl
Definition: light3.h:218
pin_name_t int_pin
Definition: light3.h:221
pin_name_t sda
Definition: light3.h:219
uint8_t i2c_address
Definition: light3.h:224
Light 3 Click context object.
Definition: light3.h:200
digital_in_t int_pin
Definition: light3.h:202
i2c_master_t i2c
Definition: light3.h:205
uint8_t slave_address
Definition: light3.h:208