Skip to content

soc_esp32::sar

SAR ADC facts shared by ADC1, ADC2 and any future SAR user.

Only the pieces that are genuinely identical across the SAR channels live here: the input-attenuation encoding and the 12-bit full-scale count. They were previously declared once in esp32-adc and again, identically, in esp32-adc2 — two definitions that had to agree by hand.

The per-channel power-up and read sequences deliberately stay in their own drivers. ADC1, ADC2 and the radio-shared SAR differ in load-bearing ways — the ADC2/Wi-Fi interlock, the hall sensor on ADC1, different MEAS_START and ATTEN register instances — that a single shared routine would only have to special-case back apart, and those sequences carry a documented history of silent, hardware-only bugs.

enum Attenuation {
Db0,
Db2_5,
Db6,
Db11,
}

Input attenuation for a SAR conversion.

The input range is not 0–3.3 V by default. At 0 dB the ADC saturates around 1.1 V; the wider ranges trade accuracy for headroom.

Attenuation Usable input, roughly
0 dB 0–1.1 V
2.5 dB 0–1.5 V
6 dB 0–2.2 V
11 dB 0–3.9 V, clipped by the 3.3 V supply

Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq

const FULL_SCALE: u16;

Full-scale count of a 12-bit conversion.