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 COLOR18_REG_CONTROL_SCL 0x24
74 #define COLOR18_REG_MOD_OFFSET0_LSB 0x40
75 #define COLOR18_REG_MOD_OFFSET0_MSB 0x41
76 #define COLOR18_REG_MOD_OFFSET1_LSB 0x42
77 #define COLOR18_REG_MOD_OFFSET1_MSB 0x43
78 #define COLOR18_REG_MOD_OFFSET2_LSB 0x44
79 #define COLOR18_REG_MOD_OFFSET2_MSB 0x45
80 #define COLOR18_REG_MOD_OFFSET3_LSB 0x46
81 #define COLOR18_REG_MOD_OFFSET3_MSB 0x47
82 #define COLOR18_REG_MOD_OFFSET4_LSB 0x48
83 #define COLOR18_REG_MOD_OFFSET4_MSB 0x49
84 #define COLOR18_REG_MOD_OFFSET5_LSB 0x4A
85 #define COLOR18_REG_MOD_OFFSET5_MSB 0x4B
86 #define COLOR18_REG_MOD_OFFSET6_LSB 0x4C
87 #define COLOR18_REG_MOD_OFFSET6_MSB 0x4D
88 #define COLOR18_REG_MOD_OFFSET7_LSB 0x4E
89 #define COLOR18_REG_MOD_OFFSET7_MSB 0x4F
90 #define COLOR18_REG_OSCEN 0x7F
91 #define COLOR18_REG_ENABLE 0x80
92 #define COLOR18_REG_MEAS_MODE0 0x81
93 #define COLOR18_REG_MEAS_MODE1 0x82
94 #define COLOR18_REG_SAMPLE_TIME0 0x83
95 #define COLOR18_REG_SAMPLE_TIME1 0x84
96 #define COLOR18_REG_SAMPLE_TIME_ALTERNATIVE0 0x85
97 #define COLOR18_REG_SAMPLE_TIME_ALTERNATIVE1 0x86
98 #define COLOR18_REG_ALS_NR_SAMPLES0 0x87
99 #define COLOR18_REG_ALS_NR_SAMPLES1 0x88
100 #define COLOR18_REG_ALS_NR_SAMPLES_ALTERNATIVE0 0x89
101 #define COLOR18_REG_ALS_NR_SAMPLES_ALTERNATIVE1 0x8A
102 #define COLOR18_REG_FD_NR_SAMPLES0 0x8B
103 #define COLOR18_REG_FD_NR_SAMPLES1 0x8C
104 #define COLOR18_REG_FD_NR_SAMPLES_ALTERNATIVE0 0x8D
105 #define COLOR18_REG_FD_NR_SAMPLES_ALTERNATIVE1 0x8E
106 #define COLOR18_REG_WTIME 0x8F
107 #define COLOR18_REG_AUX_ID 0x90
108 #define COLOR18_REG_REV_ID 0x91
109 #define COLOR18_REG_ID 0x92
110 #define COLOR18_REG_AILT0 0x93
111 #define COLOR18_REG_AILT1 0x94
112 #define COLOR18_REG_AILT2 0x95
113 #define COLOR18_REG_AIHT0 0x96
114 #define COLOR18_REG_AIHT1 0x97
115 #define COLOR18_REG_AIHT2 0x98
116 #define COLOR18_REG_AGC_NR_SAMPLES0 0x99
117 #define COLOR18_REG_AGC_NR_SAMPLES1 0x9A
118 #define COLOR18_REG_STATUS 0x9B
119 #define COLOR18_REG_STATUS2 0x9C
120 #define COLOR18_REG_STATUS3 0x9D
121 #define COLOR18_REG_STATUS4 0x9E
122 #define COLOR18_REG_STATUS5 0x9F
123 #define COLOR18_REG_STATUS6 0xA0
124 #define COLOR18_REG_CFG0 0xA1
125 #define COLOR18_REG_CFG1 0xA2
126 #define COLOR18_REG_CFG2 0xA3
127 #define COLOR18_REG_CFG3 0xA4
128 #define COLOR18_REG_CFG4 0xA5
129 #define COLOR18_REG_CFG5 0xA6
130 #define COLOR18_REG_CFG6 0xA7
131 #define COLOR18_REG_CFG7 0xA8
132 #define COLOR18_REG_CFG8 0xA9
133 #define COLOR18_REG_CFG9 0xAA
134 #define COLOR18_REG_MOD_CHANNEL_CTRL 0xAB
135 #define COLOR18_REG_TRIGGER_MODE 0xAD
136 #define COLOR18_REG_OSC_TUNE 0xAE
137 #define COLOR18_REG_VSYNC_GPIO_INT 0xB0
138 #define COLOR18_REG_INTENAB 0xBA
139 #define COLOR18_REG_SIEN 0xBB
140 #define COLOR18_REG_CONTROL 0xBC
141 #define COLOR18_REG_ALS_DATA_STATUS 0xBD
142 #define COLOR18_REG_ALS_DATA_FIRST 0xBE
143 #define COLOR18_REG_ALS_DATA 0xBF
144 #define COLOR18_REG_MEAS_SEQR_STEP0_MOD_GAINX_0 0xC0
145 #define COLOR18_REG_MEAS_SEQR_STEP0_MOD_GAINX_1 0xC1
146 #define COLOR18_REG_MEAS_SEQR_STEP0_MOD_GAINX_2 0xC2
147 #define COLOR18_REG_MEAS_SEQR_STEP0_MOD_GAINX_3 0xC3
148 #define COLOR18_REG_MEAS_SEQR_STEP1_MOD_GAINX_0 0xC4
149 #define COLOR18_REG_MEAS_SEQR_STEP1_MOD_GAINX_1 0xC5
150 #define COLOR18_REG_MEAS_SEQR_STEP1_MOD_GAINX_2 0xC6
151 #define COLOR18_REG_MEAS_SEQR_STEP1_MOD_GAINX_3 0xC7
152 #define COLOR18_REG_MEAS_SEQR_STEP2_MOD_GAINX_0 0xC8
153 #define COLOR18_REG_MEAS_SEQR_STEP2_MOD_GAINX_1 0xC9
154 #define COLOR18_REG_MEAS_SEQR_STEP2_MOD_GAINX_2 0xCA
155 #define COLOR18_REG_MEAS_SEQR_STEP2_MOD_GAINX_3 0xCB
156 #define COLOR18_REG_MEAS_SEQR_STEP3_MOD_GAINX_0 0xCC
157 #define COLOR18_REG_MEAS_SEQR_STEP3_MOD_GAINX_1 0xCD
158 #define COLOR18_REG_MEAS_SEQR_STEP3_MOD_GAINX_2 0xCE
159 #define COLOR18_REG_MEAS_SEQR_STEP3_MOD_GAINX_3 0xCF
160 #define COLOR18_REG_MEAS_SEQR_STEP0_FD 0xD0
161 #define COLOR18_REG_MEAS_SEQR_STEP1_FD 0xD1
162 #define COLOR18_REG_MEAS_SEQR_STEP2_FD 0xD2
163 #define COLOR18_REG_MEAS_SEQR_STEP3_FD 0xD3
164 #define COLOR18_REG_MEAS_SEQR_STEP0_RESIDUAL 0xD4
165 #define COLOR18_REG_MEAS_SEQR_STEP1_RESIDUAL 0xD5
166 #define COLOR18_REG_MEAS_SEQR_STEP2_RESIDUAL 0xD6
167 #define COLOR18_REG_MEAS_SEQR_STEP3_RESIDUAL 0xD7
168 #define COLOR18_REG_MEAS_SEQR_STEP0_ALS 0xD8
169 #define COLOR18_REG_MEAS_SEQR_STEP1_ALS 0xD9
170 #define COLOR18_REG_MEAS_SEQR_STEP2_ALS 0xDA
171 #define COLOR18_REG_MEAS_SEQR_STEP3_ALS 0xDB
172 #define COLOR18_REG_MEAS_SEQR_APERS_AND_VSYNC_WAIT 0xDC
173 #define COLOR18_REG_MEAS_SEQR_AGC 0xDD
174 #define COLOR18_REG_MEAS_SEQR_SMUX_AND_SAMPLE_TIME 0xDE
175 #define COLOR18_REG_MEAS_SEQR_WAIT_AND_TS_ENABLE 0xDF
176 #define COLOR18_REG_MOD_CALIB_CFG0 0xE0
177 #define COLOR18_REG_MOD_CALIB_CFG2 0xE2
178 #define COLOR18_REG_MOD_CALIB_CFG3 0xE3
179 #define COLOR18_REG_MOD_COMP_CFG2 0xE7
180 #define COLOR18_REG_MOD_RESIDUAL_CFG0 0xE8
181 #define COLOR18_REG_MOD_RESIDUAL_CFG1 0xE9
182 #define COLOR18_REG_MOD_RESIDUAL_CFG2 0xEA
183 #define COLOR18_REG_VSYNC_DELAY_CFG0 0xEB
184 #define COLOR18_REG_VSYNC_DELAY_CFG1 0xEC
185 #define COLOR18_REG_VSYNC_PERIOD0 0xED
186 #define COLOR18_REG_VSYNC_PERIOD1 0xEE
187 #define COLOR18_REG_VSYNC_PERIOD_TARGET0 0xEF
188 #define COLOR18_REG_VSYNC_PERIOD_TARGET1 0xF0
189 #define COLOR18_REG_VSYNC_CONTROL 0xF1
190 #define COLOR18_REG_VSYNC_CFG 0xF2
191 #define COLOR18_REG_FIFO_THR 0xF3
192 #define COLOR18_REG_MOD_FIFO_DATA_CFG0 0xF4
193 #define COLOR18_REG_MOD_FIFO_DATA_CFG1 0xF5
194 #define COLOR18_REG_MOD_FIFO_DATA_CFG2 0xF6
195 #define COLOR18_REG_MOD_FIFO_DATA_CFG3 0xF7
196 #define COLOR18_REG_MOD_FIFO_DATA_CFG4 0xF8
197 #define COLOR18_REG_MOD_FIFO_DATA_CFG5 0xF9
198 #define COLOR18_REG_MOD_FIFO_DATA_CFG6 0xFA
199 #define COLOR18_REG_MOD_FIFO_DATA_CFG7 0xFB
200 #define COLOR18_REG_FIFO_STATUS0 0xFC
201 #define COLOR18_REG_FIFO_STATUS1 0xFD
202 #define COLOR18_REG_FIFO_DATA_PROTOCOL 0xFE
203 #define COLOR18_REG_FIFO_DATA 0xFF
221 #define COLOR18_CONTROL_SCL_SOFT_RESET 0x01
227 #define COLOR18_OSCEN_PON_INIT 0x04
228 #define COLOR18_OSCEN_OSCEN_STATUS 0x02
229 #define COLOR18_OSCEN_OSCEN 0x01
235 #define COLOR18_ENABLE_FDEN 0x40
236 #define COLOR18_ENABLE_AEN 0x02
237 #define COLOR18_ENABLE_PON 0x01
243 #define COLOR18_WTIME_DEFAULT 0x46
249 #define COLOR18_TRIGGER_MODE_OFF 0x00
250 #define COLOR18_TRIGGER_MODE_NORMAL 0x01
251 #define COLOR18_TRIGGER_MODE_LONG 0x02
252 #define COLOR18_TRIGGER_MODE_FAST 0x03
253 #define COLOR18_TRIGGER_MODE_FASTLONG 0x04
254 #define COLOR18_TRIGGER_MODE_VSYNC 0x05
255 #define COLOR18_TRIGGER_MODE_MASK 0x07
261 #define COLOR18_INTENAB_MIEN 0x80
262 #define COLOR18_INTENAB_AIEN 0x08
263 #define COLOR18_INTENAB_FIEN 0x04
264 #define COLOR18_INTENAB_SIEN 0x01
270 #define COLOR18_FIFO_THR_DEFAULT 15
276 #define COLOR18_CONTROL_FIFO_CLR 0x02
277 #define COLOR18_CONTROL_CLEAR_SAI_ACTIVE 0x01
283 #define COLOR18_DEVICE_ID 0x68
290 #define COLOR18_DEVICE_ADDRESS 0x39
308 #define COLOR18_MAP_MIKROBUS( cfg, mikrobus ) \
309 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
310 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
311 cfg.vsync = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
312 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t slave_address
Definition: color18.h:350
err_t color18_read_data(color18_t *ctx, color18_data_t *data_out)
Color 18 read data function.
uint16_t ir
Definition: color18.h:326
color18_return_value_t
Color 18 Click return value data.
Definition: color18.h:376
err_t color18_write_regs(color18_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Color 18 write regs function.
uint16_t flicker
Definition: color18.h:330
err_t color18_check_communication(color18_t *ctx)
Color 18 check communication function.
err_t color18_soft_reset(color18_t *ctx)
Color 18 soft reset function.
err_t color18_read_reg(color18_t *ctx, uint8_t reg, uint8_t *data_out)
Color 18 read reg function.
uint32_t i2c_speed
Definition: color18.h:366
err_t color18_default_cfg(color18_t *ctx)
Color 18 default configuration function.
void color18_set_vsync_pin(color18_t *ctx, uint8_t state)
Color 18 set vsync pin state function.
err_t color18_write_reg_word(color18_t *ctx, uint8_t reg, uint16_t data_in)
Color 18 write reg word function.
err_t color18_read_regs(color18_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Color 18 read regs function.
err_t color18_write_reg(color18_t *ctx, uint8_t reg, uint8_t data_in)
Color 18 write reg function.
pin_name_t sda
Definition: color18.h:361
err_t color18_clear_fifo(color18_t *ctx)
Color 18 clear fifo function.
@ COLOR18_ERROR
Definition: color18.h:378
uint8_t i2c_address
Definition: color18.h:367
i2c_master_t i2c
Definition: color18.h:347
uint16_t clear
Definition: color18.h:329
void color18_cfg_setup(color18_cfg_t *cfg)
Color 18 configuration object setup function.
err_t color18_init(color18_t *ctx, color18_cfg_t *cfg)
Color 18 initialization function.
err_t color18_read_reg_word(color18_t *ctx, uint8_t reg, uint16_t *data_out)
Color 18 read reg word function.
@ COLOR18_OK
Definition: color18.h:377
err_t color18_read_fifo_size(color18_t *ctx, uint16_t *fifo_size)
Color 18 read fifo size function.
uint16_t z
Definition: color18.h:325
uint16_t x
Definition: color18.h:323
Color 18 Click data object.
Definition: color18.h:322
digital_in_t int_pin
Definition: color18.h:344
Color 18 Click context object.
Definition: color18.h:339
pin_name_t scl
Definition: color18.h:360
uint16_t hgh
Definition: color18.h:328
uint8_t color18_get_int_pin(color18_t *ctx)
Color 18 get int pin state function.
pin_name_t vsync
Definition: color18.h:363
pin_name_t int_pin
Definition: color18.h:364
digital_out_t vsync
Definition: color18.h:341
uint16_t hgl
Definition: color18.h:327
uint16_t y
Definition: color18.h:324
Color 18 Click configuration object.
Definition: color18.h:359