ldc2 2.0.0.0
ldc2.h File Reference

This file contains API for LDC 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  ldc2_t
 LDC 2 Click context object. More...
 
struct  ldc2_cfg_t
 LDC 2 Click configuration object. More...
 

Macros

#define LDC2_REG_DEVICE_ID   0x00
 LDC 2 register map.
 
#define LDC2_REG_RP_MAX   0x01
 
#define LDC2_REG_RP_MIN   0x02
 
#define LDC2_REG_WDT_FREQ   0x03
 
#define LDC2_REG_LDC_CONFIG   0x04
 
#define LDC2_REG_COMPARATOR_THLD_HIGH   0x07
 
#define LDC2_REG_COMPARATOR_THLD_LOW   0x09
 
#define LDC2_REG_INTB_TERMINAL_CONFIG   0x0A
 
#define LDC2_REG_POWER_CONFIG   0x0B
 
#define LDC2_REG_STATUS   0x20
 
#define LDC2_REG_PROXIMITY_DATA   0x22
 
#define LDC2_REG_FREQ_CNT_DATA_LSB   0x23
 
#define LDC2_REG_FREQ_CNT_DATA_MID_BYTE   0x24
 
#define LDC2_REG_FREQ_CNT_DATA_MSB   0x25
 
#define LDC2_DEVICE_ID   0x84
 LDC 2 Device ID value.
 
#define LDC2_SPI_READ_MASK   0x80
 LDC 2 SPI read/write bit mask.
 
#define LDC2_SPI_WRITE_MASK   0x7F
 
#define LDC2_COMPARATOR_THLD_MIN   0x00
 LDC 2 Comparator threshold range.
 
#define LDC2_COMPARATOR_THLD_MAX   0xFF
 
#define LDC2_STATUS_OSC_STOPPED   0x80
 LDC 2 status register flags.
 
#define LDC2_STATUS_NO_NEW_DATA   0x40
 
#define LDC2_STATUS_WAKE_UP_DISABLED   0x20
 
#define LDC2_STATUS_PROX_DATA_LESS_THAN_THLD   0x10
 
#define LDC2_MHZ_TO_HZ   1000000.0
 LDC 2 contants.
 
#define LDC2_EXTERNAL_OSC_MHZ   1.8432
 
#define LDC2_PARALLEL_CAPACITANCE_uF   0.000047
 
#define LDC2_MIN_SENSOR_FREQ_CONST   68.94
 
#define LDC2_MIN_SENSOR_FREQ_DIVIDER   2500.0
 
#define LDC2_ROUND_TO_NEAREST_INT   0.5
 
#define LDC2_MATH_TWO_PI   6.28318530717958
 
#define LDC2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define LDC2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define LDC2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  ldc2_return_value_t { LDC2_OK = 0 , LDC2_ERROR = -1 }
 LDC 2 Click return value data. More...
 
enum  ldc2_rp_range_t {
  LDC2_RP_3926p991 = 0 , LDC2_RP_3141p593 , LDC2_RP_2243p995 , LDC2_RP_1745p329 ,
  LDC2_RP_1308p997 , LDC2_RP_981p748 , LDC2_RP_747p998 , LDC2_RP_581p776 ,
  LDC2_RP_436p332 , LDC2_RP_349p066 , LDC2_RP_249p333 , LDC2_RP_193p926 ,
  LDC2_RP_145p444 , LDC2_RP_109p083 , LDC2_RP_83p111 , LDC2_RP_64p642 ,
  LDC2_RP_48p481 , LDC2_RP_38p785 , LDC2_RP_27p704 , LDC2_RP_21p547 ,
  LDC2_RP_16p160 , LDC2_RP_12p120 , LDC2_RP_9p235 , LDC2_RP_7p182 ,
  LDC2_RP_5p387 , LDC2_RP_4p309 , LDC2_RP_3p078 , LDC2_RP_2p394 ,
  LDC2_RP_1p796 , LDC2_RP_1p347 , LDC2_RP_1p026 , LDC2_RP_0p798
}
 LDC 2 Click Rp range values. More...
 
enum  ldc2_amplitude_t { LDC2_AMPLITUDE_1V = 0 , LDC2_AMPLITUDE_2V , LDC2_AMPLITUDE_4V }
 LDC 2 Click amplitude values. More...
 
enum  ldc2_resp_time_t {
  LDC2_RESPONSE_TIME_192 = 2 , LDC2_RESPONSE_TIME_384 , LDC2_RESPONSE_TIME_768 , LDC2_RESPONSE_TIME_1536 ,
  LDC2_RESPONSE_TIME_3072 , LDC2_RESPONSE_TIME_6144
}
 LDC 2 Click response time values. More...
 
enum  ldc2_int_mode_t { LDC2_INTB_MODE_DISABLED = 0 , LDC2_INTB_MODE_WAKE_UP , LDC2_INTB_MODE_COMPARATOR_OUT , LDC2_INTB_MODE_DRDY = 4 }
 LDC 2 Click INTB Terminal configuration values. More...
 
enum  ldc2_pwr_mode_t { LDC2_PWR_MODE_STANDBY = 0 , LDC2_PWR_MODE_ACTIVE }
 LDC 2 Click Power configuration values. More...
 

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

This file contains API for LDC 2 Click Driver.

Enumeration Type Documentation

◆ ldc2_amplitude_t

LDC 2 Click amplitude values.

Enum values for amplitude settings.

Enumerator
LDC2_AMPLITUDE_1V 
LDC2_AMPLITUDE_2V 
LDC2_AMPLITUDE_4V 

◆ ldc2_int_mode_t

LDC 2 Click INTB Terminal configuration values.

Enum values for INTB terminal settings.

Enumerator
LDC2_INTB_MODE_DISABLED 
LDC2_INTB_MODE_WAKE_UP 
LDC2_INTB_MODE_COMPARATOR_OUT 
LDC2_INTB_MODE_DRDY 

◆ ldc2_pwr_mode_t

LDC 2 Click Power configuration values.

Enum values for Power settings.

Enumerator
LDC2_PWR_MODE_STANDBY 
LDC2_PWR_MODE_ACTIVE 

◆ ldc2_resp_time_t

LDC 2 Click response time values.

Enum values for response time settings.

Enumerator
LDC2_RESPONSE_TIME_192 
LDC2_RESPONSE_TIME_384 
LDC2_RESPONSE_TIME_768 
LDC2_RESPONSE_TIME_1536 
LDC2_RESPONSE_TIME_3072 
LDC2_RESPONSE_TIME_6144 

◆ ldc2_return_value_t

LDC 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
LDC2_OK 
LDC2_ERROR 

◆ ldc2_rp_range_t

LDC 2 Click Rp range values.

Enum values for Rp range settings.

Enumerator
LDC2_RP_3926p991 
LDC2_RP_3141p593 
LDC2_RP_2243p995 
LDC2_RP_1745p329 
LDC2_RP_1308p997 
LDC2_RP_981p748 
LDC2_RP_747p998 
LDC2_RP_581p776 
LDC2_RP_436p332 
LDC2_RP_349p066 
LDC2_RP_249p333 
LDC2_RP_193p926 
LDC2_RP_145p444 
LDC2_RP_109p083 
LDC2_RP_83p111 
LDC2_RP_64p642 
LDC2_RP_48p481 
LDC2_RP_38p785 
LDC2_RP_27p704 
LDC2_RP_21p547 
LDC2_RP_16p160 
LDC2_RP_12p120 
LDC2_RP_9p235 
LDC2_RP_7p182 
LDC2_RP_5p387 
LDC2_RP_4p309 
LDC2_RP_3p078 
LDC2_RP_2p394 
LDC2_RP_1p796 
LDC2_RP_1p347 
LDC2_RP_1p026 
LDC2_RP_0p798