ldc2 2.0.0.0
LDC 2 Click Driver

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

Topics

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

Functions

void ldc2_cfg_setup (ldc2_cfg_t *cfg)
 LDC 2 configuration object setup function.
 
err_t ldc2_init (ldc2_t *ctx, ldc2_cfg_t *cfg)
 LDC 2 initialization function.
 
err_t ldc2_default_cfg (ldc2_t *ctx)
 LDC 2 default configuration function.
 
err_t ldc2_generic_write (ldc2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 LDC 2 data writing function.
 
err_t ldc2_generic_read (ldc2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 LDC 2 data reading function.
 
err_t ldc2_check_device_id (ldc2_t *ctx)
 LDC 2 check device ID function.
 
err_t ldc2_set_rp_range (ldc2_t *ctx, ldc2_rp_range_t rp_min, ldc2_rp_range_t rp_max)
 LDC 2 set Rp range function.
 
err_t ldc2_set_ldc_config (ldc2_t *ctx, ldc2_amplitude_t amplitude, ldc2_resp_time_t res_time)
 LDC 2 set LDC config function.
 
err_t ldc2_set_comparator_threshold (ldc2_t *ctx, uint8_t thld_low, uint8_t thld_high)
 LDC 2 set comparator threshold function.
 
err_t ldc2_set_interrupt_mode (ldc2_t *ctx, ldc2_int_mode_t mode)
 LDC 2 set interrupt mode function.
 
err_t ldc2_set_power_mode (ldc2_t *ctx, ldc2_pwr_mode_t mode)
 LDC 2 set power mode function.
 
err_t ldc2_get_status (ldc2_t *ctx, uint8_t *status)
 LDC 2 get status function.
 
err_t ldc2_read_raw_data (ldc2_t *ctx, uint8_t *prox_data, uint32_t *freq_cnt)
 LDC 2 read raw data function.
 
err_t ldc2_get_response_time (ldc2_t *ctx, uint16_t *res_time)
 LDC 2 get response time function.
 
err_t ldc2_get_sensor_frequency (ldc2_t *ctx, float *freq)
 LDC 2 get sensor frequency function.
 
err_t ldc2_get_rp_range (ldc2_t *ctx, float *rp_min, float *rp_max)
 LDC 2 get Rp range function.
 
err_t ldc2_set_wdt_frequency (ldc2_t *ctx)
 LDC 2 set watchdog timer frequency function.
 
uint8_t ldc2_get_int_pin (ldc2_t *ctx)
 LDC 2 get int pin function.
 
err_t ldc2_measure_resonance_impedance (ldc2_t *ctx, uint8_t *prox_data, float *rp_data)
 LDC 2 measure resonance impedance function.
 
err_t ldc2_measure_inductance (ldc2_t *ctx, float *freq, float *inductance)
 LDC 2 measure inductance function.
 

Detailed Description

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

◆ ldc2_cfg_setup()

void ldc2_cfg_setup ( ldc2_cfg_t * cfg)

LDC 2 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ ldc2_check_device_id()

err_t ldc2_check_device_id ( ldc2_t * ctx)

LDC 2 check device ID function.

This function reads and verifies the device ID.

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

◆ ldc2_default_cfg()

err_t ldc2_default_cfg ( ldc2_t * ctx)

LDC 2 default configuration function.

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

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

◆ ldc2_generic_read()

err_t ldc2_generic_read ( ldc2_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

LDC 2 data reading function.

This function reads a desired number of data bytes starting from the selected register by using SPI serial interface.

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

◆ ldc2_generic_write()

err_t ldc2_generic_write ( ldc2_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

LDC 2 data writing function.

This function writes a desired number of data bytes starting from the selected register by using SPI serial interface.

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

◆ ldc2_get_int_pin()

uint8_t ldc2_get_int_pin ( ldc2_t * ctx)

LDC 2 get int pin function.

This function returns the INT pin logic state.

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

◆ ldc2_get_response_time()

err_t ldc2_get_response_time ( ldc2_t * ctx,
uint16_t * res_time )

LDC 2 get response time function.

This function reads the response time value from the desired register and converts it to real response time value.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]res_time: Real response time value.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_get_rp_range()

err_t ldc2_get_rp_range ( ldc2_t * ctx,
float * rp_min,
float * rp_max )

LDC 2 get Rp range function.

This function reads the Rp min and max values from the desired registers and converts them to resistance in kOhm.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]rp_min: Rp min value in kOhm.
[out]rp_max: Rp max value in kOhm.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_get_sensor_frequency()

err_t ldc2_get_sensor_frequency ( ldc2_t * ctx,
float * freq )

LDC 2 get sensor frequency function.

This function reads and calculates the sensor frequency.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]freq: Sensor frequency in MHz.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_get_status()

err_t ldc2_get_status ( ldc2_t * ctx,
uint8_t * status )

LDC 2 get status function.

This function reads the status register.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]status: Status register content.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_init()

err_t ldc2_init ( ldc2_t * ctx,
ldc2_cfg_t * cfg )

LDC 2 initialization function.

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

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

◆ ldc2_measure_inductance()

err_t ldc2_measure_inductance ( ldc2_t * ctx,
float * freq,
float * inductance )

LDC 2 measure inductance function.

This function measures the inductance and sensor frequency.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]freq: Sensor frequency in MHz.
[out]inductance: Inductance in uH.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_measure_resonance_impedance()

err_t ldc2_measure_resonance_impedance ( ldc2_t * ctx,
uint8_t * prox_data,
float * rp_data )

LDC 2 measure resonance impedance function.

This function measures the resonance impedance and proximity data.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]prox_data: Proximity data.
[out]rp_data: Resonance impedance value in kOhm.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_read_raw_data()

err_t ldc2_read_raw_data ( ldc2_t * ctx,
uint8_t * prox_data,
uint32_t * freq_cnt )

LDC 2 read raw data function.

This function reads the proximity and frequency counter data.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[out]prox_data: Proximity data [8-bit].
[out]freq_cnt: Frequency counter data [24-bit].
Returns
  • 0 - Success,
  • 0x40 - No new data available,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_set_comparator_threshold()

err_t ldc2_set_comparator_threshold ( ldc2_t * ctx,
uint8_t thld_low,
uint8_t thld_high )

LDC 2 set comparator threshold function.

This function sets the comparator threshold low and high values.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[in]thld_low: Low threshold.
[in]thld_high: High threshold.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_set_interrupt_mode()

err_t ldc2_set_interrupt_mode ( ldc2_t * ctx,
ldc2_int_mode_t mode )

LDC 2 set interrupt mode function.

This function sets the interrupt pin mode.

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

◆ ldc2_set_ldc_config()

err_t ldc2_set_ldc_config ( ldc2_t * ctx,
ldc2_amplitude_t amplitude,
ldc2_resp_time_t res_time )

LDC 2 set LDC config function.

This function sets the oscillation amplitude and response time of the LDC config register.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[in]amplitude: Oscillation amplitude. See ldc2_amplitude_t enum definition for detailed explanation.
[in]res_time: Response time. See ldc2_resp_time_t enum definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_set_power_mode()

err_t ldc2_set_power_mode ( ldc2_t * ctx,
ldc2_pwr_mode_t mode )

LDC 2 set power mode function.

This function sets the power mode.

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

◆ ldc2_set_rp_range()

err_t ldc2_set_rp_range ( ldc2_t * ctx,
ldc2_rp_range_t rp_min,
ldc2_rp_range_t rp_max )

LDC 2 set Rp range function.

This function sets the Rp min and max registers.

Parameters
[in]ctx: Click context object. See ldc2_t object definition for detailed explanation.
[in]rp_min: Rp min value.
[in]rp_max: Rp max value. See ldc2_rp_range_t enum definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ ldc2_set_wdt_frequency()

err_t ldc2_set_wdt_frequency ( ldc2_t * ctx)

LDC 2 set watchdog timer frequency function.

This function sets the watchdog timer frequency based on the lowest sensor frequency.

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