Go to the documentation of this file.
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 COLOR16_REG_AUXID 0x58
70 #define COLOR16_REG_REVID 0x59
71 #define COLOR16_REG_ID 0x5A
72 #define COLOR16_REG_CFG_12 0x66
73 #define COLOR16_REG_ENABLE 0x80
74 #define COLOR16_REG_ATIME 0x81
75 #define COLOR16_REG_WTIME 0x83
76 #define COLOR16_REG_SP_TH_L_LSB 0x84
77 #define COLOR16_REG_SP_TH_L_MSB 0x85
78 #define COLOR16_REG_SP_TH_H_LSB 0x86
79 #define COLOR16_REG_SP_TH_H_MSB 0x87
80 #define COLOR16_REG_STATUS 0x93
81 #define COLOR16_REG_ASTATUS 0x94
82 #define COLOR16_REG_DATA_0_L 0x95
83 #define COLOR16_REG_DATA_0_H 0x96
84 #define COLOR16_REG_DATA_1_L 0x97
85 #define COLOR16_REG_DATA_1_H 0x98
86 #define COLOR16_REG_DATA_2_L 0x99
87 #define COLOR16_REG_DATA_2_H 0x9A
88 #define COLOR16_REG_DATA_3_L 0x9B
89 #define COLOR16_REG_DATA_3_H 0x9C
90 #define COLOR16_REG_DATA_4_L 0x9D
91 #define COLOR16_REG_DATA_4_H 0x9E
92 #define COLOR16_REG_DATA_5_L 0x9F
93 #define COLOR16_REG_DATA_5_H 0xA0
94 #define COLOR16_REG_DATA_6_L 0xA1
95 #define COLOR16_REG_DATA_6_H 0xA2
96 #define COLOR16_REG_DATA_7_L 0xA3
97 #define COLOR16_REG_DATA_7_H 0xA4
98 #define COLOR16_REG_DATA_8_L 0xA5
99 #define COLOR16_REG_DATA_8_H 0xA6
100 #define COLOR16_REG_DATA_9_L 0xA7
101 #define COLOR16_REG_DATA_9_H 0xA8
102 #define COLOR16_REG_DATA_10_L 0xA9
103 #define COLOR16_REG_DATA_10_H 0xAA
104 #define COLOR16_REG_DATA_11_L 0xAB
105 #define COLOR16_REG_DATA_11_H 0xAC
106 #define COLOR16_REG_DATA_12_L 0xAD
107 #define COLOR16_REG_DATA_12_H 0xAE
108 #define COLOR16_REG_DATA_13_L 0xAF
109 #define COLOR16_REG_DATA_13_H 0xB0
110 #define COLOR16_REG_DATA_14_L 0xB1
111 #define COLOR16_REG_DATA_14_H 0xB2
112 #define COLOR16_REG_DATA_15_L 0xB3
113 #define COLOR16_REG_DATA_15_H 0xB4
114 #define COLOR16_REG_DATA_16_L 0xB5
115 #define COLOR16_REG_DATA_16_H 0xB6
116 #define COLOR16_REG_DATA_17_L 0xB7
117 #define COLOR16_REG_DATA_17_H 0xB8
118 #define COLOR16_REG_STATUS_2 0x90
119 #define COLOR16_REG_STATUS_3 0x91
120 #define COLOR16_REG_STATUS_5 0xBB
121 #define COLOR16_REG_STATUS_4 0xBC
122 #define COLOR16_REG_CFG_0 0xBF
123 #define COLOR16_REG_CFG_1 0xC6
124 #define COLOR16_REG_CFG_3 0xC7
125 #define COLOR16_REG_CFG_6 0xF5
126 #define COLOR16_REG_CFG_8 0xC9
127 #define COLOR16_REG_CFG_9 0xCA
128 #define COLOR16_REG_CFG_10 0x65
129 #define COLOR16_REG_PERS 0xCF
130 #define COLOR16_REG_GPIO 0x6B
131 #define COLOR16_REG_ASTEP_LSB 0xD4
132 #define COLOR16_REG_ASTEP_MSB 0xD5
133 #define COLOR16_REG_CFG_20 0xD6
134 #define COLOR16_REG_LED 0xCD
135 #define COLOR16_REG_AGC_GAIN_MAX 0xD7
136 #define COLOR16_REG_AZ_CONFIG 0xDE
137 #define COLOR16_REG_FD_TIME_1 0xE0
138 #define COLOR16_REG_FD_TIME_2 0xE2
139 #define COLOR16_REG_FD_CFG_0 0xDF
140 #define COLOR16_REG_FD_STATUS 0xE3
141 #define COLOR16_REG_INTENAB 0xF9
142 #define COLOR16_REG_CONTROL 0xFA
143 #define COLOR16_REG_FIFO_MAP 0xFC
144 #define COLOR16_REG_FIFO_LVL 0xFD
145 #define COLOR16_REG_FDATA_L 0xFE
146 #define COLOR16_REG_FDATA_H 0xFF
164 #define COLOR16_ENABLE_FDEN 0x40
165 #define COLOR16_ENABLE_SMUXEN 0x10
166 #define COLOR16_ENABLE_WEN 0x08
167 #define COLOR16_ENABLE_SP_EN 0x02
168 #define COLOR16_ENABLE_PON 0x01
169 #define COLOR16_ENABLE_POFF 0x00
175 #define COLOR16_CFG_0_LOW_POWER 0x20
176 #define COLOR16_CFG_0_REG_BANK 0x10
177 #define COLOR16_CFG_0_WLONG 0x04
183 #define COLOR16_CFG_1_AGAIN_0p5 0x00
184 #define COLOR16_CFG_1_AGAIN_1 0x01
185 #define COLOR16_CFG_1_AGAIN_2 0x02
186 #define COLOR16_CFG_1_AGAIN_4 0x03
187 #define COLOR16_CFG_1_AGAIN_8 0x04
188 #define COLOR16_CFG_1_AGAIN_16 0x05
189 #define COLOR16_CFG_1_AGAIN_32 0x06
190 #define COLOR16_CFG_1_AGAIN_64 0x07
191 #define COLOR16_CFG_1_AGAIN_128 0x08
192 #define COLOR16_CFG_1_AGAIN_256 0x09
193 #define COLOR16_CFG_1_AGAIN_512 0x0A
194 #define COLOR16_CFG_1_AGAIN_1024 0x0B
195 #define COLOR16_CFG_1_AGAIN_2048 0x0C
196 #define COLOR16_CFG_1_AGAIN_MASK 0x1F
202 #define COLOR16_CFG_20_FD_FIFO_8BIT 0x80
203 #define COLOR16_CFG_20_AUTO_SMUX_6CH 0x00
204 #define COLOR16_CFG_20_AUTO_SMUX_12CH 0x40
205 #define COLOR16_CFG_20_AUTO_SMUX_18CH 0x60
206 #define COLOR16_CFG_20_AUTO_SMUX_MASK 0x60
212 #define COLOR16_CONTROL_SW_RESET 0x08
213 #define COLOR16_CONTROL_SP_MAN_AZ 0x04
214 #define COLOR16_CONTROL_FIFO_CLR 0x02
215 #define COLOR16_CONTROL_CLEAR_SAI_ACT 0x01
221 #define COLOR16_LED_OFF 0x00
222 #define COLOR16_LED_ON 0x80
223 #define COLOR16_LED_DRIVE_CURR_MIN 4
224 #define COLOR16_LED_DRIVE_CURR_MAX 258
225 #define COLOR16_LED_DRIVE_CURR_STEP 2
226 #define COLOR16_LED_DRIVE_CURR_DEFAULT 8
232 #define COLOR16_STATUS_ASAT 0x80
233 #define COLOR16_STATUS_AINT 0x08
234 #define COLOR16_STATUS_FINT 0x04
235 #define COLOR16_STATUS_SINT 0x01
241 #define COLOR16_ASTATUS_ASAT 0x80
242 #define COLOR16_ASTATUS_AGAIN_MASK 0x0F
248 #define COLOR16_STATUS_2_AVALID 0x40
249 #define COLOR16_STATUS_2_ASAT_DIG 0x10
250 #define COLOR16_STATUS_2_ASAT_ANA 0x08
251 #define COLOR16_STATUS_2_FDSAT_ANA 0x02
252 #define COLOR16_STATUS_2_FDSAT_DIG 0x01
258 #define COLOR16_DEVICE_ID 0x81
264 #define COLOR16_ACCESS_REG_BANK_ABOVE_80H 0
265 #define COLOR16_ACCESS_REG_BANK_20H_7FH 1
271 #define COLOR16_SINGLE_STEP_MS 0.00278f
272 #define COLOR16_ATIME_MAX 255
273 #define COLOR16_ASTEP_MAX 65534
274 #define COLOR16_INTEGRATION_TIME_MAX ( ( float ) ( COLOR16_ATIME_MAX + 1 ) * ( COLOR16_ASTEP_MAX + 1 ) * COLOR16_SINGLE_STEP_MS )
275 #define COLOR16_INTEGRATION_TIME_MIN COLOR16_SINGLE_STEP_MS
276 #define COLOR16_INTEGRATION_TIME_DEFAULT 90.0f
277 #define COLOR16_WAIT_STEP_MS 2.78f
278 #define COLOR16_WTIME_MAX 255
279 #define COLOR16_WAIT_TIME_MAX ( ( float ) ( COLOR16_WTIME_MAX + 1 ) * COLOR16_WAIT_STEP_MS )
280 #define COLOR16_WAIT_TIME_MIN COLOR16_WAIT_STEP_MS
281 #define COLOR16_WAIT_TIME_DEFAULT 100.0f
288 #define COLOR16_DEVICE_ADDRESS 0x39
306 #define COLOR16_MAP_MIKROBUS( cfg, mikrobus ) \
307 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
308 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
309 cfg.ldr = MIKROBUS( mikrobus, MIKROBUS_AN ); \
310 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint16_t ch_fd_3
Definition: color16.h:340
err_t color16_read_register(color16_t *ctx, uint8_t reg, uint8_t *data_out)
Color 16 read register function.
@ COLOR16_ERROR
Definition: color16.h:388
pin_name_t ldr
Definition: color16.h:373
uint8_t status
Definition: color16.h:321
digital_out_t ldr
Definition: color16.h:351
Color 16 Click configuration object.
Definition: color16.h:369
uint16_t ch_f3
Definition: color16.h:330
i2c_master_t i2c
Definition: color16.h:357
digital_in_t int_pin
Definition: color16.h:354
err_t color16_generic_read(color16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Color 16 I2C reading function.
uint32_t i2c_speed
Definition: color16.h:376
err_t color16_read_data(color16_t *ctx, color16_data_t *data_out)
Color 16 read data function.
pin_name_t scl
Definition: color16.h:370
uint16_t ch_fxl
Definition: color16.h:325
err_t color16_set_reg_bank_access(color16_t *ctx, uint8_t reg_bank)
Color 16 set reg bank access function.
err_t color16_generic_write(color16_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Color 16 I2C writing function.
pin_name_t int_pin
Definition: color16.h:374
err_t color16_enable_ext_led(color16_t *ctx, uint8_t led_curr)
Color 16 enable ext led function.
err_t color16_read_register_word(color16_t *ctx, uint8_t reg, uint16_t *data_out)
Color 16 read register word function.
uint8_t i2c_address
Definition: color16.h:377
Color 16 Click data object.
Definition: color16.h:320
void color16_set_ldr_pin(color16_t *ctx, uint8_t state)
Color 16 set ldr pin function.
err_t color16_init(color16_t *ctx, color16_cfg_t *cfg)
Color 16 initialization function.
uint16_t ch_2x_vis_2
Definition: color16.h:333
uint16_t ch_f4
Definition: color16.h:331
err_t color16_set_integration_time_ms(color16_t *ctx, float int_time_ms)
Color 16 set integration time ms function.
err_t color16_write_register(color16_t *ctx, uint8_t reg, uint8_t data_in)
Color 16 write register function.
uint16_t ch_f6
Definition: color16.h:332
uint16_t ch_f2
Definition: color16.h:329
uint8_t slave_address
Definition: color16.h:360
Color 16 Click context object.
Definition: color16.h:349
uint8_t color16_get_int_pin(color16_t *ctx)
Color 16 get int pin function.
color16_return_value_t
Color 16 Click return value data.
Definition: color16.h:386
uint16_t ch_fd_1
Definition: color16.h:328
@ COLOR16_OK
Definition: color16.h:387
uint16_t ch_f7
Definition: color16.h:337
err_t color16_disable_ext_led(color16_t *ctx)
Color 16 disable ext led function.
uint16_t ch_nir
Definition: color16.h:326
err_t color16_set_wait_time_ms(color16_t *ctx, float wait_time_ms)
Color 16 set wait time ms function.
pin_name_t sda
Definition: color16.h:371
err_t color16_check_communication(color16_t *ctx)
Color 16 check communication function.
uint16_t ch_f8
Definition: color16.h:338
err_t color16_write_register_word(color16_t *ctx, uint8_t reg, uint16_t data_in)
Color 16 write register word function.
uint16_t ch_f5
Definition: color16.h:336
uint16_t ch_fz
Definition: color16.h:323
err_t color16_default_cfg(color16_t *ctx)
Color 16 default configuration function.
uint16_t ch_fy
Definition: color16.h:324
uint16_t ch_2x_vis_1
Definition: color16.h:327
uint16_t ch_fd_2
Definition: color16.h:334
void color16_cfg_setup(color16_cfg_t *cfg)
Color 16 configuration object setup function.
uint16_t ch_2x_vis_3
Definition: color16.h:339
uint8_t astatus
Definition: color16.h:322
uint16_t ch_f1
Definition: color16.h:335