DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
fdc2214.h File Reference

TI FDC2114/2214 capacitance-to-digital field-sensing codec (DETWS_ENABLE_FDC2214). More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define FDC2214_REG_DATA_CH0_MSB   0x00
 
#define FDC2214_REG_DATA_CH0_LSB   0x01
 
#define FDC2214_REG_RCOUNT_CH0   0x08
 
#define FDC2214_REG_SETTLECOUNT_CH0   0x10
 
#define FDC2214_REG_CLOCK_DIVIDERS_CH0   0x14
 
#define FDC2214_REG_STATUS   0x18
 
#define FDC2214_REG_ERROR_CONFIG   0x19
 
#define FDC2214_REG_CONFIG   0x1A
 
#define FDC2214_REG_MUX_CONFIG   0x1B
 
#define FDC2214_REG_DRIVE_CURRENT_CH0   0x1E
 
#define FDC2214_REG_MANUFACTURER_ID   0x7E
 
#define FDC2214_REG_DEVICE_ID   0x7F
 
#define FDC2214_MANUFACTURER_ID   0x5449
 "TI".
 
#define FDC2214_DEVICE_ID   0x3055
 FDC2214 (the 12-bit FDC2114 reads 0x3054).
 
#define FDC2214_CONFIG_MAX   21
 Largest config sequence in bytes: 7 register writes * 3 bytes (reg, msb, lsb).
 

Functions

uint32_t fdc2214_data (uint16_t msb_reg, uint16_t lsb_reg)
 Combine a DATA MSB register (low 12 bits) and DATA LSB register into the 28-bit result.
 
uint8_t fdc2214_error (uint16_t msb_reg)
 The 4 error flags from the top of a DATA MSB register (bits 15:12).
 
uint64_t fdc2214_sensor_freq_hz (uint32_t data28, uint32_t fref_hz)
 Sensor frequency in Hz for a 28-bit result against a reference clock: data / 2^28 * fref.
 
size_t fdc2214_build_config (uint8_t *buf, size_t cap, uint16_t rcount, uint16_t settlecount)
 Emit a single-channel (CH0) continuous-conversion bring-up as (reg, val_msb, val_lsb) triples.
 
bool fdc2214_begin (uint8_t addr, uint16_t rcount, uint16_t settlecount)
 Verify the device id and apply the CH0 config at addr.
 
bool fdc2214_read_ch0 (uint32_t *out)
 Read channel 0's 28-bit conversion result into out.
 

Detailed Description

TI FDC2114/2214 capacitance-to-digital field-sensing codec (DETWS_ENABLE_FDC2214).

The FDC2x14 measures the resonant frequency of an external LC tank; a capacitance shift (a finger near the electrode, a liquid rising past it, a material change) moves that frequency, so watching the 28-bit conversion result gives proximity / level / material sensing without contact. Each channel's result is two 16-bit registers - a DATA MSB register whose top 4 bits are error flags and low 12 bits are the data MSB, and a DATA LSB register - which combine into the 28-bit reading. f_sensor = data / 2^28 * f_ref.

This codec is pure and host-tested: fdc2214_data combines the register pair, fdc2214_error pulls the flags, fdc2214_sensor_freq_hz scales to frequency, and fdc2214_build_config emits a single-channel continuous-conversion bring-up as (reg, msb, lsb) triples. On an ESP32 the binding replays that config and reads the channel over I2C (Wire); only that touches hardware. Bridge the readings northbound like any sensor.

Definition in file fdc2214.h.

Macro Definition Documentation

◆ FDC2214_REG_DATA_CH0_MSB

#define FDC2214_REG_DATA_CH0_MSB   0x00

Definition at line 29 of file fdc2214.h.

◆ FDC2214_REG_DATA_CH0_LSB

#define FDC2214_REG_DATA_CH0_LSB   0x01

Definition at line 30 of file fdc2214.h.

◆ FDC2214_REG_RCOUNT_CH0

#define FDC2214_REG_RCOUNT_CH0   0x08

Definition at line 31 of file fdc2214.h.

◆ FDC2214_REG_SETTLECOUNT_CH0

#define FDC2214_REG_SETTLECOUNT_CH0   0x10

Definition at line 32 of file fdc2214.h.

◆ FDC2214_REG_CLOCK_DIVIDERS_CH0

#define FDC2214_REG_CLOCK_DIVIDERS_CH0   0x14

Definition at line 33 of file fdc2214.h.

◆ FDC2214_REG_STATUS

#define FDC2214_REG_STATUS   0x18

Definition at line 34 of file fdc2214.h.

◆ FDC2214_REG_ERROR_CONFIG

#define FDC2214_REG_ERROR_CONFIG   0x19

Definition at line 35 of file fdc2214.h.

◆ FDC2214_REG_CONFIG

#define FDC2214_REG_CONFIG   0x1A

Definition at line 36 of file fdc2214.h.

◆ FDC2214_REG_MUX_CONFIG

#define FDC2214_REG_MUX_CONFIG   0x1B

Definition at line 37 of file fdc2214.h.

◆ FDC2214_REG_DRIVE_CURRENT_CH0

#define FDC2214_REG_DRIVE_CURRENT_CH0   0x1E

Definition at line 38 of file fdc2214.h.

◆ FDC2214_REG_MANUFACTURER_ID

#define FDC2214_REG_MANUFACTURER_ID   0x7E

Definition at line 39 of file fdc2214.h.

◆ FDC2214_REG_DEVICE_ID

#define FDC2214_REG_DEVICE_ID   0x7F

Definition at line 40 of file fdc2214.h.

◆ FDC2214_MANUFACTURER_ID

#define FDC2214_MANUFACTURER_ID   0x5449

"TI".

Definition at line 42 of file fdc2214.h.

◆ FDC2214_DEVICE_ID

#define FDC2214_DEVICE_ID   0x3055

FDC2214 (the 12-bit FDC2114 reads 0x3054).

Definition at line 43 of file fdc2214.h.

◆ FDC2214_CONFIG_MAX

#define FDC2214_CONFIG_MAX   21

Largest config sequence in bytes: 7 register writes * 3 bytes (reg, msb, lsb).

Definition at line 46 of file fdc2214.h.

Function Documentation

◆ fdc2214_data()

uint32_t fdc2214_data ( uint16_t  msb_reg,
uint16_t  lsb_reg 
)

Combine a DATA MSB register (low 12 bits) and DATA LSB register into the 28-bit result.

◆ fdc2214_error()

uint8_t fdc2214_error ( uint16_t  msb_reg)

The 4 error flags from the top of a DATA MSB register (bits 15:12).

◆ fdc2214_sensor_freq_hz()

uint64_t fdc2214_sensor_freq_hz ( uint32_t  data28,
uint32_t  fref_hz 
)

Sensor frequency in Hz for a 28-bit result against a reference clock: data / 2^28 * fref.

◆ fdc2214_build_config()

size_t fdc2214_build_config ( uint8_t *  buf,
size_t  cap,
uint16_t  rcount,
uint16_t  settlecount 
)

Emit a single-channel (CH0) continuous-conversion bring-up as (reg, val_msb, val_lsb) triples.

Writes RCOUNT, SETTLECOUNT, CLOCK_DIVIDERS, DRIVE_CURRENT, ERROR_CONFIG, MUX_CONFIG, then CONFIG last (CONFIG starts the conversion, so it must be written after the rest). Replay each triple as a 16-bit I2C register write.

Returns
bytes written (7 * 3 = 21), or 0 if cap < FDC2214_CONFIG_MAX.

◆ fdc2214_begin()

bool fdc2214_begin ( uint8_t  addr,
uint16_t  rcount,
uint16_t  settlecount 
)

Verify the device id and apply the CH0 config at addr.

Returns
true if present + acked.

◆ fdc2214_read_ch0()

bool fdc2214_read_ch0 ( uint32_t *  out)

Read channel 0's 28-bit conversion result into out.

Returns
false on I2C error.