Skip to content

Commit c26a6f7

Browse files
committed
docs: Add index page for ADC
1 parent 450baac commit c26a6f7

File tree

12 files changed

+225
-24
lines changed

12 files changed

+225
-24
lines changed

docs/conf_common.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,13 @@
214214

215215
DSLP_STUB_DOCS = ['api-guides/deep-sleep-stub.rst']
216216

217-
ADC_DOCS = ['api-reference/peripherals/adc_oneshot.rst', 'api-reference/peripherals/adc_calibration.rst']
218-
ADC_DMA_DOCS = ['api-reference/peripherals/adc_continuous.rst']
217+
ADC_DOCS = [
218+
'api-reference/peripherals/adc/index.rst',
219+
'api-reference/peripherals/adc/adc_oneshot.rst',
220+
'api-reference/peripherals/adc/adc_calibration.rst',
221+
]
222+
223+
ADC_DMA_DOCS = ['api-reference/peripherals/adc/adc_continuous.rst']
219224

220225
ANA_CMPR_DOCS = ['api-reference/peripherals/ana_cmpr.rst']
221226

docs/en/api-reference/peripherals/adc_calibration.rst renamed to docs/en/api-reference/peripherals/adc/adc_calibration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ The {IDF_TARGET_NAME} ADC is sensitive to noise, leading to large discrepancies
199199

200200
.. only:: esp32
201201

202-
.. figure:: ../../../_static/diagrams/adc/adc-noise-graph.jpg
202+
.. figure:: ../../../../_static/diagrams/adc/adc-noise-graph.jpg
203203
:align: center
204204
:alt: ADC noise mitigation
205205

docs/en/api-reference/peripherals/adc_continuous.rst renamed to docs/en/api-reference/peripherals/adc/adc_continuous.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ Analog to Digital Converter (ADC) Continuous Mode Driver
33

44
:link_to_translation:`zh_CN:[中文]`
55

6-
{IDF_TARGET_ADC_NUM:default="two", esp32c2="one", esp32c6="one", esp32h2="one", esp32c5="one", esp32c61="one"}
7-
86
Introduction
97
------------
108

119
The Analog to Digital Converter is integrated on the chip and is capable of measuring analog signals from specific analog IO pads. Additionally, the Direct Memory Access (DMA) functionality is utilized to efficiently retrieve ADC conversion results.
1210

13-
{IDF_TARGET_NAME} has {IDF_TARGET_ADC_NUM} ADC unit(s), which can be used in scenarios like:
11+
{IDF_TARGET_NAME} has {IDF_TARGET_SOC_ADC_PERIPH_NUM} ADC unit(s), which can be used in scenarios like:
1412

1513
- Generate one-shot ADC conversion result
1614
- Generate continuous ADC conversion results

docs/en/api-reference/peripherals/adc_oneshot.rst renamed to docs/en/api-reference/peripherals/adc/adc_oneshot.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Introduction
88

99
The Analog to Digital Converter is integrated on the chip and is capable of measuring analog signals from specific analog IO pins.
1010

11-
{IDF_TARGET_NAME} has {SOC_ADC_PERIPH_NUM} ADC unit(s), which can be used in scenario(s) like:
11+
{IDF_TARGET_NAME} has {IDF_TARGET_SOC_ADC_PERIPH_NUM} ADC unit(s), which can be used in scenario(s) like:
1212

1313
.. list::
1414

@@ -194,11 +194,10 @@ Thread Safety
194194
- :cpp:func:`adc_oneshot_new_unit`
195195
- :cpp:func:`adc_oneshot_config_channel`
196196
- :cpp:func:`adc_oneshot_read`
197+
- :cpp:func:`adc_oneshot_del_unit`
197198

198199
Above functions are guaranteed to be thread-safe. Therefore, you can call them from different RTOS tasks without protection by extra locks.
199200

200-
- :cpp:func:`adc_oneshot_del_unit` is not thread-safe. Besides, concurrently calling this function may result in failures of the above thread-safe APIs.
201-
202201

203202
.. _adc-oneshot-kconfig-options:
204203

@@ -217,5 +216,4 @@ Application Examples
217216
API Reference
218217
-------------
219218

220-
.. include-build-file:: inc/adc_types.inc
221219
.. include-build-file:: inc/adc_oneshot.inc
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Analog to Digital Converter (ADC)
2+
=================================
3+
4+
:link_to_translation:`zh_CN:[中文]`
5+
6+
Overview
7+
--------
8+
9+
This guide provides a comprehensive overview of the ADC (Analog to Digital Converter) controller on {IDF_TARGET_NAME}. It begins by introducing core ADC concepts such as conversion principles, raw data resolution, reference voltage, and attenuation. Then it walks through the two supported ADC driver modes — oneshot mode and continuous mode — along with ADC calibration, which helps improve accuracy.
10+
11+
{IDF_TARGET_NAME} integrates {IDF_TARGET_SOC_ADC_PERIPH_NUM} ADC(s) for measuring analog signals from multiple input channels. For details about the number of measurement channels (analog-enabled pins), voltage ranges, and other ADC characteristics, please refer to the `datasheet <{IDF_TARGET_DATASHEET_EN_URL}>`__.
12+
13+
14+
ADC Conversion
15+
---------------
16+
17+
ADC conversion is the process of converting an input analog voltage to a digital value. The results provided by the ADC driver APIs are raw data values that represent the analog input in digital form.
18+
19+
By default, the bit width of these raw ADC results is 12 bits. This means the input voltage range is divided into 4096 (2\ :sup:`12`) discrete levels, which defines the minimum detectable change in input signal.
20+
21+
The voltage ``Vdata`` corresponding to a raw ADC result ``data`` is calculated as:
22+
23+
.. math::
24+
25+
V_{data} = \frac{data}{2^{bitwidth} - 1} \times V_{ref}
26+
27+
Where:
28+
29+
- ``data`` is the raw ADC result.
30+
- ``bitwidth`` is the resolution of the ADC result (e.g., 12 bits).
31+
- ``Vref`` is the ADC’s reference voltage.
32+
33+
By design, ``Vref`` is set to 1100 mV. However, due to manufacturing variations, the actual value may range between 1000 mV and 1200 mV depending on the chip.
34+
35+
To obtain calibrated and accurate voltage values, refer to the section :doc:`adc_calibration`, which explains how to use the ADC calibration driver to adjust the raw results based on the actual ``Vref`` value.
36+
37+
38+
ADC Attenuation
39+
---------------
40+
41+
The ADC can measure analog voltages from 0 V to ``Vref``. To measure higher voltages, input signals can be attenuated before being passed to the ADC.
42+
43+
The supported attenuation levels are:
44+
45+
- 0 dB (k≈100%)
46+
- 2.5 dB (k≈75%)
47+
- 6 dB (k≈50%)
48+
- 12 dB (k≈25%)
49+
50+
Higher attenuation levels allow the ADC to measure higher input voltages. The voltage ``Vdata`` after applying attenuation can be calculated using:
51+
52+
.. math::
53+
54+
V_{data} = \frac{V_{ref}}{k}\times{\frac{data}{2^{bitwidth} - 1}}
55+
56+
Where:
57+
58+
- ``k`` is the ratio value corresponding to the attenuation level.
59+
- Other variables are as defined above.
60+
61+
.. only:: not esp32
62+
63+
For detailed input voltage ranges associated with each attenuation setting, refer to the `datasheet <{IDF_TARGET_DATASHEET_EN_URL}>`__ > Electrical Characteristics > ADC Characteristics.
64+
65+
.. only:: esp32
66+
67+
For detailed input voltage ranges associated with each attenuation setting, refer to the `datasheet <{IDF_TARGET_DATASHEET_EN_URL}>`__ > Function Description > Analog Peripherals > Analog-to-Digital Converter (ADC).
68+
69+
Driver Usage
70+
------------
71+
72+
.. list::
73+
74+
- ADC unit supports **oneshot mode**. Oneshot mode is suitable for oneshot sampling: ADC samples one channel at a time.
75+
:SOC_ADC_DMA_SUPPORTED: - Each ADC unit supports **continuous mode**. Continuous mode is designed for continuous sampling: ADC sequentially samples a group of channels or continuously samples a single channel.
76+
77+
See the guide below for implementation details:
78+
79+
.. toctree::
80+
:maxdepth: 2
81+
82+
adc_oneshot
83+
:SOC_ADC_DMA_SUPPORTED: adc_continuous
84+
85+
86+
ADC Calibration
87+
----------------
88+
89+
The ADC calibration driver corrects deviations through software to obtain more accurate output results.
90+
91+
For more information, refer to the following guide:
92+
93+
.. toctree::
94+
:maxdepth: 2
95+
96+
adc_calibration
97+
98+
API Reference
99+
-------------
100+
101+
.. include-build-file:: inc/adc_channel.inc
102+
.. include-build-file:: inc/adc_types.inc

docs/en/api-reference/peripherals/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ Peripherals API
66
.. toctree::
77
:maxdepth: 1
88

9-
:SOC_ADC_SUPPORTED: adc_oneshot
10-
:SOC_ADC_DMA_SUPPORTED: adc_continuous
11-
:SOC_ADC_SUPPORTED: adc_calibration
9+
:SOC_ADC_SUPPORTED: adc/index
1210
:SOC_ANA_CMPR_SUPPORTED: ana_cmpr
1311
:SOC_BITSCRAMBLER_SUPPORTED: bitscrambler
1412
:SOC_MIPI_CSI_SUPPORTED: camera_driver

docs/page_redirects.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ api-reference/storage/spi_flash api-reference/peripherals/spi_fl
2727
api-reference/storage/spi_flash_concurrency api-reference/peripherals/spi_flash/spi_flash_concurrency
2828
api-reference/storage/spi_flash_override_driver api-reference/peripherals/spi_flash/spi_flash_override_driver
2929
api-reference/storage/spi_flash_optional_feature api-reference/peripherals/spi_flash/spi_flash_optional_feature
30+
api-reference/peripherals/adc_oneshot /api-reference/peripherals/adc/adc_oneshot
31+
api-reference/peripherals/adc_continuous api-reference/peripherals/adc/adc_continuous
32+
api-reference/peripherals/adc_calibration api-reference/peripherals/adc/adc_calibration
33+
api-reference/peripherals/adc api-reference/peripherals/adc/index
3034

3135

3236
get-started/idf-monitor api-guides/tools/idf-monitor

docs/zh_CN/api-reference/peripherals/adc_calibration.rst renamed to docs/zh_CN/api-reference/peripherals/adc/adc_calibration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ ADC 校准驱动程序会提供 ADC 校准方案。对于驱动程序来说,
199199

200200
.. only:: esp32
201201

202-
.. figure:: ../../../_static/diagrams/adc/adc-noise-graph.jpg
202+
.. figure:: ../../../../_static/diagrams/adc/adc-noise-graph.jpg
203203
:align: center
204204
:alt: ADC 噪声抑制
205205

docs/zh_CN/api-reference/peripherals/adc_continuous.rst renamed to docs/zh_CN/api-reference/peripherals/adc/adc_continuous.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33

44
:link_to_translation:`en:[English]`
55

6-
{IDF_TARGET_ADC_NUM:default="两", esp32c2="一", esp32c6="一", esp32h2="一", esp32c5="一", esp32c61="一"}
7-
86
简介
97
------------
108

119
{IDF_TARGET_NAME} 芯片集成了模数转换器 (ADC),支持测量特定模拟 IO 管脚的模拟信号。此外,ADC 还支持直接内存访问 (DMA) 功能,高效获取 ADC 转换结果。
1210

13-
{IDF_TARGET_NAME} 具有 {IDF_TARGET_ADC_NUM} 个 ADC 单元,可应用于以下场景:
11+
{IDF_TARGET_NAME} 具有 {IDF_TARGET_SOC_ADC_PERIPH_NUM} 个 ADC 单元,可应用于以下场景:
1412

1513
- 生成单次 ADC 转换结果
1614
- 生成连续 ADC 转换结果

docs/zh_CN/api-reference/peripherals/adc_oneshot.rst renamed to docs/zh_CN/api-reference/peripherals/adc/adc_oneshot.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
模数转换器集成于芯片,支持测量特定模拟 IO 管脚的模拟信号。
1010

11-
{IDF_TARGET_NAME} 有 {SOC_ADC_PERIPH_NUM} 个 ADC 单元,可以在以下场景使用:
11+
{IDF_TARGET_NAME} 有 {IDF_TARGET_SOC_ADC_PERIPH_NUM} 个 ADC 单元,可以在以下场景使用:
1212

1313
.. list::
1414

@@ -194,11 +194,10 @@ flash 写入/擦除、OTA 等原因都可能导致 cache 禁用,此时,默
194194
- :cpp:func:`adc_oneshot_new_unit`
195195
- :cpp:func:`adc_oneshot_config_channel`
196196
- :cpp:func:`adc_oneshot_read`
197+
- :cpp:func:`adc_oneshot_del_unit`
197198

198199
上述函数均为线程安全,使用时,可以直接从不同的 RTOS 任务中调用以上函数,无需额外锁保护。
199200

200-
- :cpp:func:`adc_oneshot_del_unit` 非线程安全。此外,与上文中线程安全的函数一起调用该函数时,可能导致线程安全函数的调用出错。
201-
202201

203202
.. _adc-oneshot-kconfig-options:
204203

@@ -217,5 +216,4 @@ Kconfig 选项
217216
API 参考
218217
-------------
219218

220-
.. include-build-file:: inc/adc_types.inc
221219
.. include-build-file:: inc/adc_oneshot.inc

0 commit comments

Comments
 (0)