color14 2.0.0.0
Color 14 Click Driver

API for configuring and manipulating Color 14 Click driver. More...

Topics

 Color 14 Registers List
 List of registers of Color 14 Click driver.
 
 Color 14 Registers Settings
 Settings for registers of Color 14 Click driver.
 
 Color 14 MikroBUS Map
 MikroBUS pin mapping of Color 14 Click driver.
 

Functions

void color14_cfg_setup (color14_cfg_t *cfg)
 Color 14 configuration object setup function.
 
err_t color14_init (color14_t *ctx, color14_cfg_t *cfg)
 Color 14 initialization function.
 
err_t color14_generic_write (color14_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 Color 14 I2C writing function.
 
err_t color14_generic_read (color14_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 Color 14 I2C reading function.
 
uint8_t color14_get_int (color14_t *ctx)
 Get interrupt pin state.
 
err_t color14_get_proximity (color14_t *ctx, uint16_t *ps_data)
 Read proximity data from device.
 
err_t color14_get_als (color14_t *ctx, float *als_data)
 Read lux data from device.
 
err_t color14_ls_color (color14_t *ctx, uint8_t ls_reg, uint32_t *ls_data)
 Read ls data from color registers.
 
err_t color14_get_rgb_ir (color14_t *ctx, color14_color_t *color_data)
 Read color data from device.
 
float color14_get_als_resolution (color14_t *ctx)
 Get resolution for the lux calculation.
 

Detailed Description

API for configuring and manipulating Color 14 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ color14_cfg_setup()

void color14_cfg_setup ( color14_cfg_t * cfg)

Color 14 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See color14_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ color14_generic_read()

err_t color14_generic_read ( color14_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

Color 14 I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
[in]reg: Start register address.
[out]rx_buf: Output read data.
[in]rx_len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ color14_generic_write()

err_t color14_generic_write ( color14_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

Color 14 I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
[in]reg: Start register address.
[in]tx_buf: Data to be written.
[in]tx_len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.

◆ color14_get_als()

err_t color14_get_als ( color14_t * ctx,
float * als_data )

Read lux data from device.

This function reads adc data and calculates lux data from device.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
[out]als_data: Output read data.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
The device should be configured for ALS reading before calling this function. Bit RGB_MODE should be 0 and LS_EN should be 1, of the MAIN_CTRL register. The function will call function color14_get_als_resolution on it's first iteration for calculating lux data for its configuration. If you change the configuration of the device After calling this function once you need to call color14_get_als_resolution separately to set lux_resolution in the context object for getting current calculation of lux data.

◆ color14_get_als_resolution()

float color14_get_als_resolution ( color14_t * ctx)

Get resolution for the lux calculation.

Function reads configuration from device and returns corresponding lux resolution, and sets member lux_resolution of context object.

Parameters
[in,out]ctx: Click context object. See color14_t object definition for detailed explanation.
[out]ps_data: Output read data.
Returns
Resolution for the current configuration of als data.

◆ color14_get_int()

uint8_t color14_get_int ( color14_t * ctx)

Get interrupt pin state.

Read int_pin state.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
Returns
Interrupt state.

◆ color14_get_proximity()

err_t color14_get_proximity ( color14_t * ctx,
uint16_t * ps_data )

Read proximity data from device.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
[out]ps_data: Output read data.
Returns
  • 0 - Success,
  • -1 - Error,
  • -2 - Overflow,
  • -4 - Error configuration.
See #err_t definition for detailed explanation.
Note
Device should be configured for proximity reading before calling this function. Bit PS_EN should be 1, of the MAIN_CTRL register.

◆ color14_get_rgb_ir()

err_t color14_get_rgb_ir ( color14_t * ctx,
color14_color_t * color_data )

Read color data from device.

This function reads red, green, blue, and ir registers data and sets data in color_data object.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
[out]color_data: Color data object. See color14_color_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
The device should be configured for RGB reading before calling this function. Bits RGB_MODE and LS_EN, of the MAIN_CTRL register, should be set to 1.

◆ color14_init()

err_t color14_init ( color14_t * ctx,
color14_cfg_t * cfg )

Color 14 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See color14_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See color14_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ color14_ls_color()

err_t color14_ls_color ( color14_t * ctx,
uint8_t ls_reg,
uint32_t * ls_data )

Read ls data from color registers.

This function reads data from reg, green, blue or ir registers and returns data to ls_data.

Parameters
[in]ctx: Click context object. See color14_t object definition for detailed explanation.
[in]ls_reg: LSB register address of data.
[out]ls_data: Output read data.
Returns
  • 0 - Success,
  • -1 - Error,
  • -3 - Error Parameter.
See #err_t definition for detailed explanation.
Note
The device should be configured to enable LS reading before calling this function. You can configure it by setting LS_EN bit of the MAIN_CTRL register. Depending of the reading you want to use you can configure RGB_MODE bit to 0 if you want ALS data from COLOR14_REG_LS_DATA_GREEN_0 register or to 1 if you want RGB data from LS registers.