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