ambient20 2.1.0.0
Ambient 20 Click Driver

API for configuring and manipulating Ambient 20 Click driver. More...

Topics

 Ambient 20 Registers List
 List of registers of Ambient 20 Click driver.
 
 Ambient 20 Registers Settings
 Settings for registers of Ambient 20 Click driver.
 
 Ambient 20 MikroBUS Map
 MikroBUS pin mapping of Ambient 20 Click driver.
 

Functions

void ambient20_cfg_setup (ambient20_cfg_t *cfg)
 Ambient 20 configuration object setup function.
 
err_t ambient20_init (ambient20_t *ctx, ambient20_cfg_t *cfg)
 Ambient 20 initialization function.
 
err_t ambient20_default_cfg (ambient20_t *ctx)
 Ambient 20 default configuration function.
 
err_t ambient20_generic_write (ambient20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Ambient 20 I2C writing function.
 
err_t ambient20_generic_read (ambient20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Ambient 20 I2C reading function.
 
err_t ambient20_sw_reset (ambient20_t *ctx)
 Ambient 20 software reset function.
 
err_t ambient20_get_manufacturer_id (ambient20_t *ctx, uint8_t *manufacturer_id)
 Ambient 20 read manufacturer id function.
 
err_t ambient20_get_part_id (ambient20_t *ctx, uint8_t *part_id)
 Ambient 20 read part id function.
 
err_t ambient20_enable_wait_mode (ambient20_t *ctx)
 Ambient 20 enable wait mode function.
 
err_t ambient20_disable_wait_mode (ambient20_t *ctx)
 Ambient 20 disable wait mode function.
 
err_t ambient20_set_meas_mode (ambient20_t *ctx, uint8_t meas_mode)
 Ambient 20 set measurement mode function.
 
err_t ambient20_set_gain (ambient20_t *ctx, uint8_t data0_gain, uint8_t data1_gain)
 Ambient 20 set data gain function.
 
err_t ambient20_enable_meas (ambient20_t *ctx)
 Ambient 20 enable measurements function.
 
err_t ambient20_disable_meas (ambient20_t *ctx)
 Ambient 20 disable measurements function.
 
err_t ambient20_check_valid (ambient20_t *ctx)
 Ambient 20 check valid bit function.
 
err_t ambient20_read_data0 (ambient20_t *ctx, uint16_t *data0_out)
 Ambient 20 read data0 function.
 
err_t ambient20_read_data1 (ambient20_t *ctx, uint16_t *data1_out)
 Ambient 20 read data1 function.
 
err_t ambient20_get_data_lux (ambient20_t *ctx, float *data0_out, float *data1_out)
 Ambient 20 read light function.
 

Detailed Description

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

◆ ambient20_cfg_setup()

void ambient20_cfg_setup ( ambient20_cfg_t * cfg)

Ambient 20 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ ambient20_check_valid()

err_t ambient20_check_valid ( ambient20_t * ctx)

Ambient 20 check valid bit function.

This function is used to check valid bit of the Ambient 20 Click. Valid bit is used to check status of the AMBIENT20_MODE_CONTROL1_REG, AMBIENT20_MODE_CONTROL2_REG and AMBIENT20_MODE_CONTROL3_REG data.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
Returns
  • 0 - Measurment data is updated,
  • -1 - Measurment data is not updated.
Note
None.

◆ ambient20_default_cfg()

err_t ambient20_default_cfg ( ambient20_t * ctx)

Ambient 20 default configuration function.

This function executes a default configuration of Ambient 20 click board.

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

◆ ambient20_disable_meas()

err_t ambient20_disable_meas ( ambient20_t * ctx)

Ambient 20 disable measurements function.

This function is used to disable measurment mode of the Ambient 20 Click.

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

◆ ambient20_disable_wait_mode()

err_t ambient20_disable_wait_mode ( ambient20_t * ctx)

Ambient 20 disable wait mode function.

This function disables wait mode. Wait mode can be enabled only when MEAS_MODE is set in 55mS mode. When this mode is active, measurement time is same as in 100mS mode.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Wait mode can be enabled only when MEAS_MODE is set in 55mS mode.

◆ ambient20_enable_meas()

err_t ambient20_enable_meas ( ambient20_t * ctx)

Ambient 20 enable measurements function.

This function is used to set the Ambient 20 Click into measurment mode.

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

◆ ambient20_enable_wait_mode()

err_t ambient20_enable_wait_mode ( ambient20_t * ctx)

Ambient 20 enable wait mode function.

This function is enableing wait mode. Wait mode can be enabled only when MEAS_MODE is set in 55mS mode. When this mode is active, measurement time is same as in 100mS mode.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Wait mode can be enabled only when MEAS_MODE is set in 55mS mode.

◆ ambient20_generic_read()

err_t ambient20_generic_read ( ambient20_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Ambient 20 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 ambient20_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.

◆ ambient20_generic_write()

err_t ambient20_generic_write ( ambient20_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Ambient 20 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 ambient20_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.

◆ ambient20_get_data_lux()

err_t ambient20_get_data_lux ( ambient20_t * ctx,
float * data0_out,
float * data1_out )

Ambient 20 read light function.

This function is used to read ambient lighting data of both channels.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
[out]data0_out: Data0 read data.
[out]data1_out: Data1 read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient20_get_manufacturer_id()

err_t ambient20_get_manufacturer_id ( ambient20_t * ctx,
uint8_t * manufacturer_id )

Ambient 20 read manufacturer id function.

This function is performing reading of the manufacturer id by using I2C serial interface.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
[out]manufacturer_id: Read manufacturer id.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient20_get_part_id()

err_t ambient20_get_part_id ( ambient20_t * ctx,
uint8_t * part_id )

Ambient 20 read part id function.

This function is performing reading of the part id by using I2C serial interface.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
[out]part_id: Read part id.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient20_init()

err_t ambient20_init ( ambient20_t * ctx,
ambient20_cfg_t * cfg )

Ambient 20 initialization function.

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

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

◆ ambient20_read_data0()

err_t ambient20_read_data0 ( ambient20_t * ctx,
uint16_t * data0_out )

Ambient 20 read data0 function.

This function is used to read data0 channel data.

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

◆ ambient20_read_data1()

err_t ambient20_read_data1 ( ambient20_t * ctx,
uint16_t * data1_out )

Ambient 20 read data1 function.

This function is used to read data1 channel data.

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

◆ ambient20_set_gain()

err_t ambient20_set_gain ( ambient20_t * ctx,
uint8_t data0_gain,
uint8_t data1_gain )

Ambient 20 set data gain function.

This function is used to set ADC data gain. This function only uses 3 alredy provided modes, other settings are prohibited.

Parameters
[in]ctx: Click context object. See ambient20_t object definition for detailed explanation.
[in]data0_gain: Data 0 gain value.
[in]data1_gain: Data 1 gain value.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Only use provided gain values, other values are prohibited.

◆ ambient20_set_meas_mode()

err_t ambient20_set_meas_mode ( ambient20_t * ctx,
uint8_t meas_mode )

Ambient 20 set measurement mode function.

This function is used to set measurement mode for DATA0 and DATA0, provided modes are 100mS and 55mS mode.

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

◆ ambient20_sw_reset()

err_t ambient20_sw_reset ( ambient20_t * ctx)

Ambient 20 software reset function.

This function is performing software reset by setting SW_RESET bit by using I2C serial interface.

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