spectrometer2 2.0.0.0
Spectrometer 2 Click Driver

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

Topics

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

Functions

void spectrometer2_cfg_setup (spectrometer2_cfg_t *cfg)
 Spectrometer 2 configuration object setup function.
 
err_t spectrometer2_init (spectrometer2_t *ctx, spectrometer2_cfg_t *cfg)
 Spectrometer 2 initialization function.
 
err_t spectrometer2_default_cfg (spectrometer2_t *ctx)
 Spectrometer 2 default configuration function.
 
err_t spectrometer2_generic_write (spectrometer2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Spectrometer 2 I2C writing function.
 
err_t spectrometer2_generic_read (spectrometer2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Spectrometer 2 I2C reading function.
 
err_t spectrometer2_write_register (spectrometer2_t *ctx, uint8_t reg, uint8_t data_in)
 Spectrometer 2 write register function.
 
err_t spectrometer2_read_register (spectrometer2_t *ctx, uint8_t reg, uint8_t *data_out)
 Spectrometer 2 read register function.
 
err_t spectrometer2_check_communication (spectrometer2_t *ctx)
 Spectrometer 2 check communication function.
 
uint8_t spectrometer2_get_int_pin (spectrometer2_t *ctx)
 Spectrometer 2 get int pin function.
 
uint8_t spectrometer2_get_an_pin (spectrometer2_t *ctx)
 Spectrometer 2 get an pin function.
 
err_t spectrometer2_get_data (spectrometer2_t *ctx, spectrometer2_als_channels_t *als_channels)
 Spectrometer 2 get data function.
 
err_t spectrometer2_clear_interrupt (spectrometer2_t *ctx)
 Spectrometer 2 clear interrupt function.
 
err_t spectrometer2_set_exposure_time (spectrometer2_t *ctx, float exp_time)
 Spectrometer 2 set exposure time function.
 
err_t spectrometer2_set_inter_measurement_period (spectrometer2_t *ctx, float im_period)
 Spectrometer 2 set inter measurement period function.
 
uint8_t spectrometer2_get_color (spectrometer2_hsl_t *hsl)
 Spectrometer 2 get color function.
 
void spectrometer2_rgbc_to_hsl (spectrometer2_als_channels_t *rgbc, spectrometer2_hsl_t *hsl)
 Spectrometer 2 rgbc to hsl function.
 

Detailed Description

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

◆ spectrometer2_cfg_setup()

void spectrometer2_cfg_setup ( spectrometer2_cfg_t * cfg)

Spectrometer 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ spectrometer2_check_communication()

err_t spectrometer2_check_communication ( spectrometer2_t * ctx)

Spectrometer 2 check communication function.

This function checks the communication by reading and verifying the device ID.

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ spectrometer2_clear_interrupt()

err_t spectrometer2_clear_interrupt ( spectrometer2_t * ctx)

Spectrometer 2 clear interrupt function.

This function clears the interrupts by writing to the INTERRUPT_CTRL register.

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ spectrometer2_default_cfg()

err_t spectrometer2_default_cfg ( spectrometer2_t * ctx)

Spectrometer 2 default configuration function.

This function executes a default configuration of Spectrometer 2 click board.

Parameters
[in]ctx: Click context object. See spectrometer2_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.

◆ spectrometer2_generic_read()

err_t spectrometer2_generic_read ( spectrometer2_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Spectrometer 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 spectrometer2_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.

◆ spectrometer2_generic_write()

err_t spectrometer2_generic_write ( spectrometer2_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Spectrometer 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 spectrometer2_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.

◆ spectrometer2_get_an_pin()

uint8_t spectrometer2_get_an_pin ( spectrometer2_t * ctx)

Spectrometer 2 get an pin function.

This function returns the AN pin logic state.

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ spectrometer2_get_color()

uint8_t spectrometer2_get_color ( spectrometer2_hsl_t * hsl)

Spectrometer 2 get color function.

This function returns the color name flag from the input HSL color.

Parameters
[out]hsl: HSL (hue, saturation, lightness) input value. See spectrometer2_hsl_t object definition for detailed explanation.
Returns
Color name flag. See color flags macro definition for detailed explanation.
Note
None.

◆ spectrometer2_get_data()

err_t spectrometer2_get_data ( spectrometer2_t * ctx,
spectrometer2_als_channels_t * als_channels )

Spectrometer 2 get data function.

This function reads data from 6 ALS channels (Red, Visible, Blue, Green, IR, Clear).

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
[out]als_channels: ALS channels (Red, Visible, Blue, Green, IR, Clear). See spectrometer2_als_channels_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ spectrometer2_get_int_pin()

uint8_t spectrometer2_get_int_pin ( spectrometer2_t * ctx)

Spectrometer 2 get int pin function.

This function returns the INT pin logic state.

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ spectrometer2_init()

err_t spectrometer2_init ( spectrometer2_t * ctx,
spectrometer2_cfg_t * cfg )

Spectrometer 2 initialization function.

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

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

◆ spectrometer2_read_register()

err_t spectrometer2_read_register ( spectrometer2_t * ctx,
uint8_t reg,
uint8_t * data_out )

Spectrometer 2 read register function.

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

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

◆ spectrometer2_rgbc_to_hsl()

void spectrometer2_rgbc_to_hsl ( spectrometer2_als_channels_t * rgbc,
spectrometer2_hsl_t * hsl )

Spectrometer 2 rgbc to hsl function.

This function converts RGBC (red, green, blue, clear) to HSL (hue, saturation, lightness) color value.

Parameters
[out]rgbc: RGBC (red, green, blue, clear) input value. See spectrometer2_als_channels_t object definition for detailed explanation.
[out]hsl: HSL (hue, saturation, lightness) input value. See spectrometer2_hsl_t object definition for detailed explanation.
Returns
None.
Note
None.

◆ spectrometer2_set_exposure_time()

err_t spectrometer2_set_exposure_time ( spectrometer2_t * ctx,
float exp_time )

Spectrometer 2 set exposure time function.

This function sets the exposure time.

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
[in]exp_time: Exposure time in milliseconds [1.6-1638.4].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ spectrometer2_set_inter_measurement_period()

err_t spectrometer2_set_inter_measurement_period ( spectrometer2_t * ctx,
float im_period )

Spectrometer 2 set inter measurement period function.

This function sets the inter measurement period.

Parameters
[in]ctx: Click context object. See spectrometer2_t object definition for detailed explanation.
[in]im_period: Inter measurement period in milliseconds [0.0-5227.5].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ spectrometer2_write_register()

err_t spectrometer2_write_register ( spectrometer2_t * ctx,
uint8_t reg,
uint8_t data_in )

Spectrometer 2 write register function.

This function writes a desired data to the selected register by using I2C serial interface.

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