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 COLOR17_REG_CH0_EXP_RESMSB 0x00
74 #define COLOR17_REG_CH0_RESMSB_CNT_CRC 0x01
75 #define COLOR17_REG_CH1_EXP_RES_MSB 0x02
76 #define COLOR17_REG_CH1_RESMSB_CNT_CRC 0x03
77 #define COLOR17_REG_CH2_EXP_RES_MSB 0x04
78 #define COLOR17_REG_CH2_RESMSB_CNT_CRC 0x05
79 #define COLOR17_REG_CH3_EXP_RES_MSB 0x06
80 #define COLOR17_REG_CH4_RESMSB_CNT_CRC 0x07
81 #define COLOR17_REG_THLD_EXP_RES_L 0x08
82 #define COLOR17_REG_THLD_EXP_RES_H 0x09
83 #define COLOR17_REG_CONFIG_0 0x0A
84 #define COLOR17_REG_CONFIG_1 0x0B
85 #define COLOR17_REG_CONFIG_2 0x0C
86 #define COLOR17_REG_DEVICE_ID 0x11
104 #define COLOR17_DEVICE_ID 0x0821u
110 #define COLOR17_CONFIG_0_QWAKE_DIS 0x00
111 #define COLOR17_CONFIG_0_QWAKE_EN 0x01
112 #define COLOR17_CONFIG_0_RANGE_2_2KLUX 0x00
113 #define COLOR17_CONFIG_0_RANGE_4_5KLUX 0x01
114 #define COLOR17_CONFIG_0_RANGE_9KLUX 0x02
115 #define COLOR17_CONFIG_0_RANGE_18KLUX 0x03
116 #define COLOR17_CONFIG_0_RANGE_36KLUX 0x04
117 #define COLOR17_CONFIG_0_RANGE_72KLUX 0x05
118 #define COLOR17_CONFIG_0_RANGE_144KLUX 0x06
119 #define COLOR17_CONFIG_0_RANGE_AUTO 0x0C
120 #define COLOR17_CONFIG_0_CONV_600US 0x00
121 #define COLOR17_CONFIG_0_CONV_1_MS 0x01
122 #define COLOR17_CONFIG_0_CONV_1_8MS 0x02
123 #define COLOR17_CONFIG_0_CONV_3_4MS 0x03
124 #define COLOR17_CONFIG_0_CONV_6_5MS 0x04
125 #define COLOR17_CONFIG_0_CONV_12_7MS 0x05
126 #define COLOR17_CONFIG_0_CONV_25MS 0x06
127 #define COLOR17_CONFIG_0_CONV_50MS 0x07
128 #define COLOR17_CONFIG_0_CONV_100MS 0x08
129 #define COLOR17_CONFIG_0_CONV_200MS 0x09
130 #define COLOR17_CONFIG_0_CONV_400MS 0x0A
131 #define COLOR17_CONFIG_0_CONV_800MS 0x0B
132 #define COLOR17_CONFIG_0_OP_MODE_PD 0x00
133 #define COLOR17_CONFIG_0_OP_MODE_F_ONESHOT 0x01
134 #define COLOR17_CONFIG_0_OP_MODE_ONESHOT 0x02
135 #define COLOR17_CONFIG_0_OP_MODE_CONTINUOUS 0x03
136 #define COLOR17_CONFIG_0_LATCH_DIS 0x00
137 #define COLOR17_CONFIG_0_LATCH_EN 0x01
138 #define COLOR17_CONFIG_0_INT_POL_LOW 0x00
139 #define COLOR17_CONFIG_0_INT_POL_HIGH 0x01
140 #define COLOR17_CONFIG_0_FAULT_COUNT_0 0x00
141 #define COLOR17_CONFIG_0_FAULT_COUNT_2 0x01
142 #define COLOR17_CONFIG_0_FAULT_COUNT_4 0x02
143 #define COLOR17_CONFIG_0_FAULT_COUNT_8 0x03
149 #define COLOR17_CONFIG_1_MUST_READ_WRITE 0x8000u
150 #define COLOR17_CONFIG_1_THRESHOLD_CH0 0x00
151 #define COLOR17_CONFIG_1_THRESHOLD_CH1 0x01
152 #define COLOR17_CONFIG_1_THRESHOLD_CH2 0x02
153 #define COLOR17_CONFIG_1_THRESHOLD_CH3 0x03
154 #define COLOR17_CONFIG_1_INT_DIR_INPUT 0x00
155 #define COLOR17_CONFIG_1_INT_DIR_OUTPUT 0x01
156 #define COLOR17_CONFIG_1_INT_CFG_SMBUS_ALR 0x00
157 #define COLOR17_CONFIG_1_INT_CFG_NEXT_CH 0x01
158 #define COLOR17_CONFIG_1_INT_CFG_ALL_CH 0x03
159 #define COLOR17_CONFIG_1_I2C_BURST_DISABLE 0x00
160 #define COLOR17_CONFIG_1_I2C_BURST_ENABLE 0x01
166 #define COLOR17_CONFIG_2_FLAG_DISABLE 0x00
167 #define COLOR17_CONFIG_2_FLAG_ENABLE 0x01
173 #define COLOR17_SEL_CHANNEL_0 0x00
174 #define COLOR17_SEL_CHANNEL_1 0x01
175 #define COLOR17_SEL_CHANNEL_2 0x02
176 #define COLOR17_SEL_CHANNEL_3 0x03
183 #define COLOR17_DEVICE_ADDRESS_GND 0x44
184 #define COLOR17_DEVICE_ADDRESS_VCC 0x45
202 #define COLOR17_MAP_MIKROBUS( cfg, mikrobus ) \
203 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
204 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
205 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t int_cfg
Definition: color17.h:258
@ COLOR17_ERROR
Definition: color17.h:283
err_t color17_get_device_id(color17_t *ctx, uint16_t *device_id)
Color 17 gets device ID function.
void color17_cfg_setup(color17_cfg_t *cfg)
Color 17 configuration object setup function.
uint32_t i2c_speed
Definition: color17.h:238
err_t color17_default_cfg(color17_t *ctx)
Color 17 default configuration function.
pin_name_t sda
Definition: color17.h:234
pin_name_t scl
Definition: color17.h:233
@ COLOR17_OK
Definition: color17.h:282
i2c_master_t i2c
Definition: color17.h:220
digital_in_t int_pin
Definition: color17.h:217
err_t color17_generic_read(color17_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Color 17 I2C reading function.
uint8_t thld_ch_sel
Definition: color17.h:256
err_t color17_get_ch_measurement(color17_t *ctx, uint8_t ch, uint32_t *adc_codes)
Color 17 gets the channel measurements data function.
uint8_t qwake
Definition: color17.h:249
uint8_t flag_l
Definition: color17.h:272
uint8_t ovld_flag
Definition: color17.h:269
uint8_t slave_address
Definition: color17.h:223
err_t color17_get_status_flag(color17_t *ctx, color17_status_flag_t *status_flag)
Color 17 gets the status flag function.
uint8_t latch
Definition: color17.h:253
uint8_t conv_ready_flag
Definition: color17.h:270
err_t color17_get_measurement(color17_t *ctx, uint32_t *adc_codes)
Color 17 gets light and color measurement data function.
err_t color17_set_config(color17_t *ctx, color17_config_t config)
Color 17 set the configuration function.
err_t color17_get_cct(color17_t *ctx, float *cct, float *light_intensity)
Color 17 gets correlated color temperature data function.
err_t color17_generic_write(color17_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Color 17 I2C writing function.
uint8_t int_dir
Definition: color17.h:257
uint8_t flag_h
Definition: color17.h:271
Color 17 Click status flag object.
Definition: color17.h:268
pin_name_t int_pin
Definition: color17.h:236
uint8_t op_mode
Definition: color17.h:252
uint8_t color17_get_int_pin(color17_t *ctx)
Color 17 gets interrupt function.
Color 17 Click configuration data object.
Definition: color17.h:248
uint8_t i2c_address
Definition: color17.h:239
uint8_t fault_cnt
Definition: color17.h:255
uint8_t int_pol
Definition: color17.h:254
Color 17 Click context object.
Definition: color17.h:215
err_t color17_init(color17_t *ctx, color17_cfg_t *cfg)
Color 17 initialization function.
uint8_t conv_time
Definition: color17.h:251
uint8_t i2c_burst
Definition: color17.h:259
uint8_t range
Definition: color17.h:250
color17_return_value_t
Color 17 Click return value data.
Definition: color17.h:281
err_t color17_read_reg(color17_t *ctx, uint8_t reg, uint16_t *data_out)
Color 17 read register function.
err_t color17_write_reg(color17_t *ctx, uint8_t reg, uint16_t data_in)
Color 17write register function.
Color 17 Click configuration object.
Definition: color17.h:232