ambient12 2.0.0.0
Ambient 12 Click Driver

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

Topics

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

Functions

void ambient12_cfg_setup (ambient12_cfg_t *cfg)
 Ambient 12 configuration object setup function.
 
err_t ambient12_init (ambient12_t *ctx, ambient12_cfg_t *cfg)
 Ambient 12 initialization function.
 
err_t ambient12_read_an_pin_value (ambient12_t *ctx, uint16_t *data_out)
 Ambient 12 read AN pin value function.
 
err_t ambient12_read_an_pin_voltage (ambient12_t *ctx, float *data_out)
 Ambient 12 read AN pin voltage level function.
 
err_t ambient12_read_raw_adc (ambient12_t *ctx, uint16_t *raw_adc)
 Ambient 12 read raw ADC function.
 
err_t ambient12_read_adc_voltage (ambient12_t *ctx, float *voltage)
 Ambient 12 read ADC voltage function.
 
void ambient12_set_gc1_pin (ambient12_t *ctx, uint8_t state)
 Ambient 12 set GC1 pin state function.
 
void ambient12_set_gc2_pin (ambient12_t *ctx, uint8_t state)
 Ambient 12 set GC2 pin state function.
 
void ambient12_set_gain_mode (ambient12_t *ctx, uint8_t mode)
 Ambient 12 set gain mode function.
 
int32_t ambient12_voltage_to_lux (ambient12_t *ctx, float voltage)
 Ambient 12 voltage to illuminance function.
 

Detailed Description

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

◆ ambient12_cfg_setup()

void ambient12_cfg_setup ( ambient12_cfg_t * cfg)

Ambient 12 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ ambient12_init()

err_t ambient12_init ( ambient12_t * ctx,
ambient12_cfg_t * cfg )

Ambient 12 initialization function.

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

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

◆ ambient12_read_adc_voltage()

err_t ambient12_read_adc_voltage ( ambient12_t * ctx,
float * voltage )

Ambient 12 read ADC voltage function.

This function reads raw 12-bit ADC data and converts it to voltage by using I2C serial interface.

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

◆ ambient12_read_an_pin_value()

err_t ambient12_read_an_pin_value ( ambient12_t * ctx,
uint16_t * data_out )

Ambient 12 read AN pin value function.

This function reads results of AD conversion of the AN pin.

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

◆ ambient12_read_an_pin_voltage()

err_t ambient12_read_an_pin_voltage ( ambient12_t * ctx,
float * data_out )

Ambient 12 read AN pin voltage level function.

This function reads results of AD conversion of the AN pin and converts them to proportional voltage level.

Parameters
[in]ctx: Click context object. See ambient12_t object definition for detailed explanation.
[out]data_out: Output voltage level of the analog pin [V].
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered configuration of the ADC (resolution, reference voltage).

◆ ambient12_read_raw_adc()

err_t ambient12_read_raw_adc ( ambient12_t * ctx,
uint16_t * raw_adc )

Ambient 12 read raw ADC function.

This function reads raw 12-bit ADC data by using I2C serial interface.

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

◆ ambient12_set_gain_mode()

void ambient12_set_gain_mode ( ambient12_t * ctx,
uint8_t mode )

Ambient 12 set gain mode function.

This function sets the gain mode.

Parameters
[in]ctx: Click context object. See ambient12_t object definition for detailed explanation.
[in]mode:
  • 0 - Shutdown,
  • 1 - H-Gain - up to 1000 Lux,
  • 2 - M-Gain - up to 10000 Lux,
  • 3 - L-Gain - up to 100000 Lux.
Returns
None.
Note
None.

◆ ambient12_set_gc1_pin()

void ambient12_set_gc1_pin ( ambient12_t * ctx,
uint8_t state )

Ambient 12 set GC1 pin state function.

This function sets the GC1 pin to desired logic state.

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

◆ ambient12_set_gc2_pin()

void ambient12_set_gc2_pin ( ambient12_t * ctx,
uint8_t state )

Ambient 12 set GC2 pin state function.

This function sets the GC2 pin to desired logic state.

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

◆ ambient12_voltage_to_lux()

int32_t ambient12_voltage_to_lux ( ambient12_t * ctx,
float voltage )

Ambient 12 voltage to illuminance function.

This function calculates illuminance (lux) based on the voltage input.

Parameters
[in]voltage: Voltage from IOUT (volts).
Returns
  • >=0 Illuminance in lux,
  • <0 Gain mode error.
Note
Gain mode must be set before this function call.