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 LIGHT4_REG_UV_CALIB 0x08
70#define LIGHT4_REG_MOD_CHANNEL_CTRL 0x40
71#define LIGHT4_REG_ENABLE 0x80
72#define LIGHT4_REG_MEAS_MODE0 0x81
73#define LIGHT4_REG_MEAS_MODE1 0x82
74#define LIGHT4_REG_SAMPLE_TIME0 0x83
75#define LIGHT4_REG_SAMPLE_TIME1 0x84
76#define LIGHT4_REG_ALS_NR_SAMPLES0 0x85
77#define LIGHT4_REG_ALS_NR_SAMPLES1 0x86
78#define LIGHT4_REG_FD_NR_SAMPLES0 0x87
79#define LIGHT4_REG_FD_NR_SAMPLES1 0x88
80#define LIGHT4_REG_WTIME 0x89
81#define LIGHT4_REG_AILT0 0x8A
82#define LIGHT4_REG_AILT1 0x8B
83#define LIGHT4_REG_AILT2 0x8C
84#define LIGHT4_REG_AIHT0 0x8D
85#define LIGHT4_REG_AIHT1 0x8B
86#define LIGHT4_REG_AIHT2 0x8F
87#define LIGHT4_REG_AUX_ID 0x90
88#define LIGHT4_REG_REV_ID 0x91
89#define LIGHT4_REG_ID 0x92
90#define LIGHT4_REG_STATUS 0x93
91#define LIGHT4_REG_ALS_STATUS 0x94
92#define LIGHT4_REG_ALS_DATA0_LSB 0x95
93#define LIGHT4_REG_ALS_DATA0_MSB 0x96
94#define LIGHT4_REG_ALS_DATA1_LSB 0x97
95#define LIGHT4_REG_ALS_DATA1_MSB 0x98
96#define LIGHT4_REG_ALS_DATA2_LSB 0x99
97#define LIGHT4_REG_ALS_DATA2_MSB 0x9A
98#define LIGHT4_REG_ALS_STATUS2 0x9B
99#define LIGHT4_REG_ALS_STATUS3 0x9C
100#define LIGHT4_REG_STATUS2 0x9D
101#define LIGHT4_REG_STATUS3 0x9E
102#define LIGHT4_REG_STATUS4 0x9F
103#define LIGHT4_REG_STATUS5 0xA0
104#define LIGHT4_REG_CFG0 0xA1
105#define LIGHT4_REG_CFG1 0xA2
106#define LIGHT4_REG_CFG2 0xA3
107#define LIGHT4_REG_CFG3 0xA4
108#define LIGHT4_REG_CFG4 0xA5
109#define LIGHT4_REG_CFG5 0xA6
110#define LIGHT4_REG_CFG6 0xA7
111#define LIGHT4_REG_CFG7 0xA8
112#define LIGHT4_REG_CFG8 0xA9
113#define LIGHT4_REG_CFG9 0xAA
114#define LIGHT4_REG_AGC_NR_SAMPLES_LSB 0xAC
115#define LIGHT4_REG_AGC_NR_SAMPLES_MSB 0xAD
116#define LIGHT4_REG_TRIGGER_MODE 0xAE
117#define LIGHT4_REG_CONTROL 0xB1
118#define LIGHT4_REG_INTENAB 0xBA
119#define LIGHT4_REG_SIEN 0xBB
120#define LIGHT4_REG_MOD_COMP_CFG1 0xCE
121#define LIGHT4_REG_MEAS_SEQR_FD_0 0xCF
122#define LIGHT4_REG_MEAS_SEQR_ALS_FD_1 0xD0
123#define LIGHT4_REG_MEAS_SEQR_APERS_AND_VSYNC_WAIT 0xD1
124#define LIGHT4_REG_MEAS_SEQR_RESIDUAL_0 0xD2
125#define LIGHT4_REG_MEAS_SEQR_RESIDUAL_1_AND_WAIT 0xD3
126#define LIGHT4_REG_MEAS_SEQR_STEP0_MOD_GAINX_L 0xD4
127#define LIGHT4_REG_MEAS_SEQR_STEP0_MOD_GAINX_H 0xD5
128#define LIGHT4_REG_MEAS_SEQR_STEP1_MOD_GAINX_L 0xD6
129#define LIGHT4_REG_MEAS_SEQR_STEP1_MOD_GAINX_H 0xD7
130#define LIGHT4_REG_MEAS_SEQR_STEP2_MOD_GAINX_L 0xD8
131#define LIGHT4_REG_MEAS_SEQR_STEP2_MOD_GAINX_H 0xD9
132#define LIGHT4_REG_MEAS_SEQR_STEP3_MOD_GAINX_L 0xDA
133#define LIGHT4_REG_MEAS_SEQR_STEP3_MOD_GAINX_H 0xDB
134#define LIGHT4_REG_MEAS_SEQR_STEP0_MOD_PHDX_L 0xDC
135#define LIGHT4_REG_MEAS_SEQR_STEP0_MOD_PHDX_H 0xDD
136#define LIGHT4_REG_MEAS_SEQR_STEP1_MOD_PHDX_L 0xDE
137#define LIGHT4_REG_MEAS_SEQR_STEP1_MOD_PHDX_H 0xDF
138#define LIGHT4_REG_MEAS_SEQR_STEP2_MOD_PHDX_L 0xE0
139#define LIGHT4_REG_MEAS_SEQR_STEP2_MOD_PHDX_H 0xE1
140#define LIGHT4_REG_MEAS_SEQR_STEP3_MOD_PHDX_L 0xE2
141#define LIGHT4_REG_MEAS_SEQR_STEP3_MOD_PHDX_H 0xE3
142#define LIGHT4_REG_MOD_CALIB_CFG0 0xE4
143#define LIGHT4_REG_MOD_CALIB_CFG2 0xE6
144#define LIGHT4_REG_VSYNC_PERIOD_LSB 0xF2
145#define LIGHT4_REG_VSYNC_PERIOD_MSB 0xF3
146#define LIGHT4_REG_VSYNC_PERIOD_TARGET_LSB 0xF4
147#define LIGHT4_REG_VSYNC_PERIOD_TARGET_MSB 0xF5
148#define LIGHT4_REG_VSYNC_CONTROL 0xF6
149#define LIGHT4_REG_VSYNC_CFG 0xF7
150#define LIGHT4_REG_VSYNC_GPIO_INT 0xF8
151#define LIGHT4_REG_MOD_FIFO_DATA_CFG0 0xF9
152#define LIGHT4_REG_MOD_FIFO_DATA_CFG1 0xFA
153#define LIGHT4_REG_MOD_FIFO_DATA_CFG2 0xFB
154#define LIGHT4_REG_FIFO_THR 0xDC
155#define LIGHT4_REG_FIFO_STATUS0 0xFD
156#define LIGHT4_REG_FIFO_STATUS1 0xFE
157#define LIGHT4_REG_FIFO_DATA 0xFF
175#define LIGHT4_FDEN 0x40
176#define LIGHT4_AEN 0x02
177#define LIGHT4_PON 0x01
183#define LIGHT4_MOD2_DISABLE 0x04
184#define LIGHT4_MOD1_DISABLE 0x02
185#define LIGHT4_MOD0_DISABLE 0x01
186#define LIGHT4_MOD_ENABLE_ALL 0x00
192#define LIGHT4_MIEN 0x80
193#define LIGHT4_AIEN 0x04
194#define LIGHT4_FIEN 0x02
195#define LIGHT4_SIEN 0x01
201#define LIGHT4_SOFT_RESET 0x08
202#define LIGHT4_FIFO_CLR 0x02
203#define LIGHT4_CLEAR_SAI_ACTIVE 0x01
209#define LIGHT4_MEAS_SEQR_STEP_MASK 0xC0
210#define LIGHT4_ALS_DATA0_ANALOG_SATURATION_STATUS 0x20
211#define LIGHT4_ALS_DATA1_ANALOG_SATURATION_STATUS 0x10
212#define LIGHT4_ALS_DATA2_ANALOG_SATURATION_STATUS 0x08
213#define LIGHT4_ALS_DATA0_SCALED_STATUS 0x04
214#define LIGHT4_ALS_DATA1_SCALED_STATUS 0x02
215#define LIGHT4_ALS_DATA2_SCALED_STATUS 0x01
221#define LIGHT4_PIN_STATE_HIGH 0x01
222#define LIGHT4_PIN_STATE_LOW 0x00
228#define LIGHT4_AUX_ID 0x06
229#define LIGHT4_REV_ID 0x11
230#define LIGHT4_DEVICE_ID 0x5C
236#define LIGHT4_CHANNEL0_SEL 0x00
237#define LIGHT4_CHANNEL1_SEL 0x01
238#define LIGHT4_CHANNEL2_SEL 0x02
245#define LIGHT4_DEVICE_ADDRESS 0x39
263#define LIGHT4_MAP_MIKROBUS( cfg, mikrobus ) \
264 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
265 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
266 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
267 cfg.snc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
268 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t light4_init(light4_t *ctx, light4_cfg_t *cfg)
Light 4 initialization function.
err_t light4_generic_write(light4_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Light 4 I2C writing function.
err_t light4_read_reg(light4_t *ctx, uint8_t reg, uint8_t *data_out)
Light 4 Register reading function.
void light4_cfg_setup(light4_cfg_t *cfg)
Light 4 configuration object setup function.
err_t light4_generic_read(light4_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Light 4 I2C reading function.
err_t light4_read_channel_data(light4_t *ctx, uint8_t channel_sel, float *channel_data)
Light 4 get channel data function.
void light4_set_snc_pin(light4_t *ctx, uint8_t pin_state)
Light 4 set SNC pin function.
err_t light4_write_reg(light4_t *ctx, uint8_t reg, uint8_t data_in)
Light 4 Register writing function.
err_t light4_default_cfg(light4_t *ctx)
Light 4 default configuration function.
void light4_set_en_pin(light4_t *ctx, uint8_t pin_state)
Light 4 set EN pin function.
uint8_t light4_get_int_pin(light4_t *ctx)
Light 4 get INT pin function.
err_t light4_sw_reset(light4_t *ctx)
Light 4 Software reset function.
light4_return_value_t
Light 4 Click return value data.
Definition: light4.h:317
@ LIGHT4_OK
Definition: light4.h:318
@ LIGHT4_ERROR
Definition: light4.h:319
@ LIGHT4_ANALOG_SAT
Definition: light4.h:320
Light 4 Click configuration object.
Definition: light4.h:299
uint32_t i2c_speed
Definition: light4.h:307
pin_name_t snc
Definition: light4.h:304
pin_name_t scl
Definition: light4.h:300
pin_name_t en
Definition: light4.h:303
pin_name_t int_pin
Definition: light4.h:305
pin_name_t sda
Definition: light4.h:301
uint8_t i2c_address
Definition: light4.h:308
Light 4 Click context object.
Definition: light4.h:278
digital_in_t int_pin
Definition: light4.h:284
digital_out_t snc
Definition: light4.h:281
i2c_master_t i2c
Definition: light4.h:287
digital_out_t en
Definition: light4.h:280
uint8_t slave_address
Definition: light4.h:290