ambient21 2.1.0.0
Ambient 21 Click Driver

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

Topics

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

Functions

void ambient21_cfg_setup (ambient21_cfg_t *cfg)
 Ambient 21 configuration object setup function.
 
err_t ambient21_init (ambient21_t *ctx, ambient21_cfg_t *cfg)
 Ambient 21 initialization function.
 
err_t ambient21_default_cfg (ambient21_t *ctx)
 Ambient 21 default configuration function.
 
err_t ambient21_generic_write (ambient21_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Ambient 21 I2C writing function.
 
err_t ambient21_generic_read (ambient21_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Ambient 21 I2C reading function.
 
err_t ambient21_write_register (ambient21_t *ctx, uint8_t reg, uint8_t data_in)
 Ambient 21 write register function.
 
err_t ambient21_read_register (ambient21_t *ctx, uint8_t reg, uint8_t *data_out)
 Ambient 21 read register function.
 
err_t ambient21_write_spec_func (ambient21_t *ctx, uint8_t spec_func)
 Ambient 21 write spec func function.
 
uint8_t ambient21_get_int_pin (ambient21_t *ctx)
 Ambient 21 get int pin function.
 
err_t ambient21_check_communication (ambient21_t *ctx)
 Ambient 21 check communication function.
 
err_t ambient21_clear_interrupts (ambient21_t *ctx)
 Ambient 21 clear interrupts function.
 
err_t ambient21_set_config (ambient21_t *ctx, uint8_t again, uint8_t atime)
 Ambient 21 set config function.
 
err_t ambient21_read_raw_data (ambient21_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
 Ambient 21 read raw data function.
 
err_t ambient21_measure_light_level (ambient21_t *ctx, uint16_t *lux)
 Ambient 21 measure light level function.
 

Detailed Description

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

◆ ambient21_cfg_setup()

void ambient21_cfg_setup ( ambient21_cfg_t * cfg)

Ambient 21 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ ambient21_check_communication()

err_t ambient21_check_communication ( ambient21_t * ctx)

Ambient 21 check communication function.

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

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

◆ ambient21_clear_interrupts()

err_t ambient21_clear_interrupts ( ambient21_t * ctx)

Ambient 21 clear interrupts function.

This function clears all interrupts by sending the INT clear special function command.

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

◆ ambient21_default_cfg()

err_t ambient21_default_cfg ( ambient21_t * ctx)

Ambient 21 default configuration function.

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

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

◆ ambient21_generic_read()

err_t ambient21_generic_read ( ambient21_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Ambient 21 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 ambient21_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 (up to 24 bytes).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient21_generic_write()

err_t ambient21_generic_write ( ambient21_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Ambient 21 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 ambient21_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 (up to 13 bytes).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient21_get_int_pin()

uint8_t ambient21_get_int_pin ( ambient21_t * ctx)

Ambient 21 get int pin function.

This function returns the INT pin logic state.

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

◆ ambient21_init()

err_t ambient21_init ( ambient21_t * ctx,
ambient21_cfg_t * cfg )

Ambient 21 initialization function.

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

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

◆ ambient21_measure_light_level()

err_t ambient21_measure_light_level ( ambient21_t * ctx,
uint16_t * lux )

Ambient 21 measure light level function.

This function reads the raw ADC data from two channels and then measures the light level in lux based on those readings.

Parameters
[in]ctx: Click context object. See ambient21_t object definition for detailed explanation.
[out]lux: Ambient light level in Lux.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
In order to improve the lux calculation accuracy, measure and adjust the AMBIENT21_LUX_GDF (glass and device factors) value.

◆ ambient21_read_raw_data()

err_t ambient21_read_raw_data ( ambient21_t * ctx,
uint16_t * ch_0,
uint16_t * ch_1 )

Ambient 21 read raw data function.

This function checks if the data is ready and then reads the raw ADC data from two channels.

Parameters
[in]ctx: Click context object. See ambient21_t object definition for detailed explanation.
[out]ch_0: Raw data from channel 0.
[out]ch_1: Raw data from channel 1.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient21_read_register()

err_t ambient21_read_register ( ambient21_t * ctx,
uint8_t reg,
uint8_t * data_out )

Ambient 21 read register function.

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

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

◆ ambient21_set_config()

err_t ambient21_set_config ( ambient21_t * ctx,
uint8_t again,
uint8_t atime )

Ambient 21 set config function.

This function sets again and atime settings and calculates the ctx->cpl.

Parameters
[in]ctx: Click context object. See ambient21_t object definition for detailed explanation.
[in]again: ALS gain level
  • 0 - 1X,
  • 1 - 25X,
  • 2 - 428X,
  • 3 - 9876X.
[in]atime: ALS time
  • 0 - 100ms,
  • 1 - 200ms,
  • 2 - 300ms,
  • 3 - 400ms,
  • 4 - 500ms,
  • 5 - 600ms.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient21_write_register()

err_t ambient21_write_register ( ambient21_t * ctx,
uint8_t reg,
uint8_t data_in )

Ambient 21 write register function.

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

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

◆ ambient21_write_spec_func()

err_t ambient21_write_spec_func ( ambient21_t * ctx,
uint8_t spec_func )

Ambient 21 write spec func function.

This function writes a special function command byte.

Parameters
[in]ctx: Click context object. See ambient21_t object definition for detailed explanation.
[in]spec_func: Special function command byte.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.