ambient17 2.0.0.0
Ambient 17 Click Driver

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

Topics

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

Functions

void ambient17_cfg_setup (ambient17_cfg_t *cfg)
 Ambient 17 configuration object setup function.
 
err_t ambient17_init (ambient17_t *ctx, ambient17_cfg_t *cfg)
 Ambient 17 initialization function.
 
err_t ambient17_default_cfg (ambient17_t *ctx)
 Ambient 17 default configuration function.
 
err_t ambient17_generic_write (ambient17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
 Ambient 17 I2C writing function.
 
err_t ambient17_generic_read (ambient17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
 Ambient 17 I2C reading function.
 
err_t ambient17_write_register (ambient17_t *ctx, uint8_t reg, uint8_t data_in)
 Ambient 17 write register function.
 
err_t ambient17_read_register (ambient17_t *ctx, uint8_t reg, uint8_t *data_out)
 Ambient 17 read register function.
 
err_t ambient17_check_communication (ambient17_t *ctx)
 Ambient 17 check communication function.
 
uint8_t ambient17_get_int_pin (ambient17_t *ctx)
 Ambient 17 get INT pin function.
 
err_t ambient17_clear_interrupts (ambient17_t *ctx)
 Ambient 17 clear interrupts function.
 
err_t ambient17_set_atime (ambient17_t *ctx, float atime_ms)
 Ambient 17 set atime function.
 
err_t ambient17_set_wtime (ambient17_t *ctx, float wtime_ms)
 Ambient 17 set wtime function.
 
err_t ambient17_set_again (ambient17_t *ctx, uint8_t again)
 Ambient 17 set again function.
 
err_t ambient17_read_raw_data (ambient17_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
 Ambient 17 read raw data function.
 
err_t ambient17_measure_light_level (ambient17_t *ctx, uint16_t *lux)
 Ambient 17 measure light level function.
 

Detailed Description

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

◆ ambient17_cfg_setup()

void ambient17_cfg_setup ( ambient17_cfg_t * cfg)

Ambient 17 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ ambient17_check_communication()

err_t ambient17_check_communication ( ambient17_t * ctx)

Ambient 17 check communication function.

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

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

◆ ambient17_clear_interrupts()

err_t ambient17_clear_interrupts ( ambient17_t * ctx)

Ambient 17 clear interrupts function.

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

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

◆ ambient17_default_cfg()

err_t ambient17_default_cfg ( ambient17_t * ctx)

Ambient 17 default configuration function.

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

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

◆ ambient17_generic_read()

err_t ambient17_generic_read ( ambient17_t * ctx,
uint8_t reg,
uint8_t * rx_buf,
uint8_t rx_len )

Ambient 17 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 ambient17_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.
Note
None.

◆ ambient17_generic_write()

err_t ambient17_generic_write ( ambient17_t * ctx,
uint8_t reg,
uint8_t * tx_buf,
uint8_t tx_len )

Ambient 17 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 ambient17_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.
Note
None.

◆ ambient17_get_int_pin()

uint8_t ambient17_get_int_pin ( ambient17_t * ctx)

Ambient 17 get INT pin function.

This function returns the INT pin logic state.

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

◆ ambient17_init()

err_t ambient17_init ( ambient17_t * ctx,
ambient17_cfg_t * cfg )

Ambient 17 initialization function.

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

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

◆ ambient17_measure_light_level()

err_t ambient17_measure_light_level ( ambient17_t * ctx,
uint16_t * lux )

Ambient 17 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 ambient17_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
None.

◆ ambient17_read_raw_data()

err_t ambient17_read_raw_data ( ambient17_t * ctx,
uint16_t * ch_0,
uint16_t * ch_1 )

Ambient 17 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 ambient17_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.

◆ ambient17_read_register()

err_t ambient17_read_register ( ambient17_t * ctx,
uint8_t reg,
uint8_t * data_out )

Ambient 17 read register function.

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

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

◆ ambient17_set_again()

err_t ambient17_set_again ( ambient17_t * ctx,
uint8_t again )

Ambient 17 set again function.

This function sets the ALS gain level in the CONTROL register.

Parameters
[in]ctx: Click context object. See ambient17_t object definition for detailed explanation.
[in]again: ALS gain level
  • 0 - 1X,
  • 1 - 8X,
  • 2 - 16X,
  • 3 - 120X.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient17_set_atime()

err_t ambient17_set_atime ( ambient17_t * ctx,
float atime_ms )

Ambient 17 set atime function.

This function sets the ATIME register for the selected ALS integration time.

Parameters
[in]ctx: Click context object. See ambient17_t object definition for detailed explanation.
[in]atime_ms: Als integration time. Valid values from 2.73 to 699.88 milliseconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ambient17_set_wtime()

err_t ambient17_set_wtime ( ambient17_t * ctx,
float wtime_ms )

Ambient 17 set wtime function.

This function sets the WTIME register for the selected wait time.

Parameters
[in]ctx: Click context object. See ambient17_t object definition for detailed explanation.
[in]wtime_ms: Wait time period. Valid values from 2.73 to 699.88 milliseconds.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Wait time must be enabled in the ENABLE register.

◆ ambient17_write_register()

err_t ambient17_write_register ( ambient17_t * ctx,
uint8_t reg,
uint8_t data_in )

Ambient 17 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 ambient17_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.