light2  2.1.0.0
Modules | Functions
Light 2 Click Driver

API for configuring and manipulating Light 2 Click driver. More...

Modules

 Light 2 Registers List
 List of registers of Light 2 Click driver.
 
 Light 2 Registers Settings
 Settings for registers of Light 2 Click driver.
 
 Light 2 MikroBUS Map
 MikroBUS pin mapping of Light 2 Click driver.
 

Functions

void light2_cfg_setup (light2_cfg_t *cfg)
 Light 2 configuration object setup function. More...
 
err_t light2_init (light2_t *ctx, light2_cfg_t *cfg)
 Light 2 initialization function. More...
 
err_t light2_default_cfg (light2_t *ctx)
 Light 2 default configuration function. More...
 
err_t light2_generic_write (light2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Light 2 I2C writing function. More...
 
err_t light2_generic_read (light2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Light 2 I2C reading function. More...
 
err_t light2_write_config (light2_t *ctx, uint8_t data_in)
 Light 2 write config function. More...
 
err_t light2_read_raw_data (light2_t *ctx, uint16_t *data_out)
 Light 2 raw data reading function. More...
 
err_t light2_get_cal_const (light2_t *ctx)
 Light 2 get calculation constant function. More...
 
err_t light2_get_light_data (light2_t *ctx, float *light_data)
 Light 2 get light data function. More...
 

Detailed Description

API for configuring and manipulating Light 2 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

◆ light2_cfg_setup()

void light2_cfg_setup ( light2_cfg_t cfg)

Light 2 configuration object setup function.

This function initializes Click configuration structure to initial values.

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

◆ light2_default_cfg()

err_t light2_default_cfg ( light2_t ctx)

Light 2 default configuration function.

This function executes a default configuration of Light 2 Click board.

Parameters
[in]ctx: Click context object. See light2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ light2_generic_read()

err_t light2_generic_read ( light2_t ctx,
uint8_t  reg,
uint8_t *  data_out,
uint8_t  len 
)

Light 2 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 light2_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ light2_generic_write()

err_t light2_generic_write ( light2_t ctx,
uint8_t  reg,
uint8_t *  data_in,
uint8_t  len 
)

Light 2 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 light2_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ light2_get_cal_const()

err_t light2_get_cal_const ( light2_t ctx)

Light 2 get calculation constant function.

This function is used to get a calculation constant depending on Light 2 Click board configuration.

Parameters
[in]ctx: Click context object. See light2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Use this function after any changes to the configuration to get calculation factor.

◆ light2_get_light_data()

err_t light2_get_light_data ( light2_t ctx,
float *  light_data 
)

Light 2 get light data function.

This function is used to read light data of Light 2 Click board configuration.

Parameters
[in]ctx: Click context object. See light2_t object definition for detailed explanation.
[out]light_data: Read data in LUX.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ light2_init()

err_t light2_init ( light2_t ctx,
light2_cfg_t cfg 
)

Light 2 initialization function.

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

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

◆ light2_read_raw_data()

err_t light2_read_raw_data ( light2_t ctx,
uint16_t *  data_out 
)

Light 2 raw data reading function.

This function reads raw data from the ADC of Light 2 Click board.

Parameters
[in]ctx: Click context object. See light2_t object definition for detailed explanation.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ light2_write_config()

err_t light2_write_config ( light2_t ctx,
uint8_t  data_in 
)

Light 2 write config function.

This function is used to set configuration for Light 2 Click board.

Parameters
[in]ctx: Click context object. See light2_t object definition for detailed explanation.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.