color9 2.0.0.0
color9.h File Reference

This file contains API for Color 9 Click driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  color9_t
 Click ctx object definition. More...
 
struct  color9_cfg_t
 Click configuration structure definition. More...
 

Macros

#define COLOR9_SLAVE_ADDR   0x52
 
#define COLOR9_MAIN_CTRL   0x00
 
#define COLOR9_LS_MEAS_RATE   0x04
 
#define COLOR9_LS_GAIN   0x05
 
#define COLOR9_PART_ID   0x06
 
#define COLOR9_MAIN_STATUS   0x07
 
#define COLOR9_LS_DATA_IR_0   0x0A
 
#define COLOR9_LS_DATA_IR_1   0x0B
 
#define COLOR9_LS_DATA_IR_2   0x0C
 
#define COLOR9_LS_DATA_GREEN_0   0x0D
 
#define COLOR9_LS_DATA_GREEN_1   0x0E
 
#define COLOR9_LS_DATA_GREEN_2   0x0F
 
#define COLOR9_LS_DATA_BLUE_0   0x10
 
#define COLOR9_LS_DATA_BLUE_1   0x11
 
#define COLOR9_LS_DATA_BLUE_2   0x12
 
#define COLOR9_LS_DATA_RED_0   0x13
 
#define COLOR9_LS_DATA_RED_1   0x14
 
#define COLOR9_LS_DATA_RED_2   0x15
 
#define COLOR9_INT_CFG   0x19
 
#define COLOR9_INT_PERSISTENCE   0x1A
 
#define COLOR9_LS_THRES_UP_0   0x21
 
#define COLOR9_LS_THRES_UP_1   0x22
 
#define COLOR9_LS_THRES_UP_2   0x23
 
#define COLOR9_LS_THRES_LOW_0   0x24
 
#define COLOR9_LS_THRES_LOW_1   0x25
 
#define COLOR9_LS_THRES_LOW_2   0x26
 
#define COLOR9_LS_THRES_VAR   0x27
 
#define COLOR9_MAIN_CTRL_SW_RESET   0x10
 
#define COLOR9_MAIN_CTRL_CS_MODE   0x04
 
#define COLOR9_MAIN_CTRL_LS_EN   0x02
 
#define COLOR9_LS_MEAS_BITWIDTH_20   0x00
 
#define COLOR9_LS_MEAS_BITWIDTH_19   0x01
 
#define COLOR9_LS_MEAS_BITWIDTH_18   0x02
 
#define COLOR9_LS_MEAS_BITWIDTH_17   0x03
 
#define COLOR9_LS_MEAS_BITWIDTH_16   0x04
 
#define COLOR9_LS_MEAS_BITWIDTH_13   0x05
 
#define COLOR9_LS_MEAS_RATE_25ms   0x00
 
#define COLOR9_LS_MEAS_RATE_50ms   0x01
 
#define COLOR9_LS_MEAS_RATE_100ms   0x02
 
#define COLOR9_LS_MEAS_RATE_200ms   0x03
 
#define COLOR9_LS_MEAS_RATE_500ms   0x04
 
#define COLOR9_LS_MEAS_RATE_1000ms   0x05
 
#define COLOR9_LS_MEAS_RATE_2000ms   0x06
 
#define COLOR9_LS_GAIN_1   0x00
 
#define COLOR9_LS_GAIN_3   0x01
 
#define COLOR9_LS_GAIN_6   0x02
 
#define COLOR9_LS_GAIN_9   0x03
 
#define COLOR9_LS_GAIN_18   0x04
 
#define COLOR9_INT_CFG_IR_CH   0x00
 
#define COLOR9_INT_CFG_ALS_GREEN_CH   0x01
 
#define COLOR9_INT_CFG_RED_CH   0x02
 
#define COLOR9_INT_CFG_BLUE_CH   0x03
 
#define COLOR9_INT_CFG_LS_THRESHOLD_INT_MODE   0x00
 
#define COLOR9_INT_CFG_LS_VARIATION_INT_MODE   0x01
 
#define COLOR9_INT_CFG_LS_INT_ENABLE   0x01
 
#define COLOR9_INT_CFG_LS_INT_DISABLE   0x00
 
#define COLOR9_INT_PERSISTENCE_ANYVAL_TRIGGER   0x00
 
#define COLOR9_INT_PERSISTENCE_SECOND_COUNT_TRIGGER   0x01
 
#define COLOR9_INT_PERSISTENCE_SIXTEEN_COUNT_TRIGGER   0x0F
 
#define COLOR9_LS_THRES_VAR_COUNT_8   0x00
 
#define COLOR9_LS_THRES_VAR_COUNT_16   0x01
 
#define COLOR9_LS_THRES_VAR_COUNT_32   0x02
 
#define COLOR9_LS_THRES_VAR_COUNT_64   0x03
 
#define COLOR9_LS_THRES_VAR_COUNT_1024   0x07
 
#define COLOR9_MAP_MIKROBUS(cfg, mikrobus)
 
#define COLOR9_RETVAL   uint8_t
 
#define COLOR9_OK   0x00
 
#define COLOR9_INIT_ERROR   0xFF
 

Functions

void color9_cfg_setup (color9_cfg_t *cfg)
 Config Object Initialization function.
 
COLOR9_RETVAL color9_init (color9_t *ctx, color9_cfg_t *cfg)
 Initialization function.
 
void color9_write (color9_t *ctx, uint8_t reg_addr, uint8_t r_data)
 Generic write function.
 
uint8_t color9_read (color9_t *ctx, uint8_t reg_addr)
 Generic read function.
 
void color9_sw_reset (color9_t *ctx)
 Software reset function.
 
uint32_t color9_get_Ir (color9_t *ctx)
 Get value of IR measurement reading.
 
uint32_t color9_get_green (color9_t *ctx)
 Gets value of Green measurement reading.
 
uint32_t color9_get_blue (color9_t *ctx)
 Gets value of Blue measurement reading.
 
uint32_t color9_get_red (color9_t *ctx)
 Gets value of Red measurement reading.
 
uint8_t color9_get_status_reg (color9_t *ctx)
 Status register value.
 
void color9_meas_rate (color9_t *ctx, uint8_t resolution, uint8_t meas_rate)
 Configure measurement rates.
 
void color9_reg_ctrl (color9_t *ctx, uint8_t cfg)
 Function for setting the main configuration register.
 
void color9_set_gain (color9_t *ctx, uint8_t g_setting)
 Function for gain setting.
 
void color9_int_config (color9_t *ctx, uint8_t int_select, uint8_t int_mode, uint8_t cfg_setting)
 Interrupt configuration.
 
void color9_sample_compare (color9_t *ctx, uint8_t num_of_compares)
 Configre number of compares between samples.
 
uint32_t color9_read_32 (color9_t *ctx, uint8_t reg_addr)
 Generic read function for 32 bits.
 
void color9_write_32 (color9_t *ctx, uint8_t reg_addr, uint32_t treas_val)
 Generic write function for 32 bits.
 
void color9_similarity_count (color9_t *ctx, uint8_t sim_set)
 Similarity count.
 
void color9_upper_tresset (color9_t *ctx, uint32_t set_val)
 Upper Tresset.
 
void color9_lower_tresset (color9_t *ctx, uint32_t set_val)
 Lower Tresset.
 

Detailed Description

This file contains API for Color 9 Click driver.