Skip to content

Commit e0fd5b5

Browse files
committed
documentation: update docs on ADC support for Espressif devices
Add documentation for ADC on RISC-V and Xtensa Espressif devices. Signed-off-by: Filipe Cavalcanti <[email protected]>
1 parent e687ee7 commit e0fd5b5

File tree

12 files changed

+329
-12
lines changed

12 files changed

+329
-12
lines changed

Diff for: Documentation/platforms/risc-v/esp32c3/boards/esp32c3-generic/index.rst

+21
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ All of the configurations presented below can be tested by running the following
5353
Where <config_name> is the name of board configuration you want to use, i.e.: nsh, buttons, wifi...
5454
Then use a serial console terminal like ``picocom`` configured to 115200 8N1.
5555

56+
adc
57+
---
58+
59+
The ``adc`` configuration enables the ADC driver and the ADC example application.
60+
ADC Unit 1 is registered to ``/dev/adc0`` with channels 0, 1, 2 and 3 enabled by default.
61+
Currently, the ADC operates in oneshot mode.
62+
63+
More ADC channels can be enabled or disabled in ``ADC Configuration`` menu.
64+
65+
This example shows channels 0 and 1 connected to 3.3 V and channels 2 and 3 to GND (all readings
66+
show in units of mV)::
67+
68+
nsh> adc -n 1
69+
adc_main: g_adcstate.count: 1
70+
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
71+
Sample:
72+
1: channel: 0 value: 2900
73+
2: channel: 1 value: 2900
74+
3: channel: 2 value: 0
75+
4: channel: 3 value: 0
76+
5677
ble
5778
---
5879

Diff for: Documentation/platforms/risc-v/esp32c3/index.rst

+34-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ where:
131131
* ``ESPTOOL_BINDIR=./`` is the path of the externally-built 2nd stage bootloader and the partition table (if applicable): when built using the ``make bootloader``, these files are placed into ``nuttx`` folder.
132132
* ``ESPTOOL_BAUD`` is able to change the flash baud rate if desired.
133133

134-
Flashing NSH Example
134+
Flashing NSH Example
135135
--------------------
136136

137137
This example shows how to build and flash the ``nsh`` defconfig for the ESP32-C3-DevKitC-02 board::
@@ -343,7 +343,7 @@ The following list indicates the state of peripherals' support in NuttX:
343343
=========== ======= ====================
344344
Peripheral Support NOTES
345345
=========== ======= ====================
346-
ADC No
346+
ADC Yes Oneshot
347347
AES No
348348
Bluetooth Yes
349349
CAN/TWAI Yes
@@ -370,6 +370,38 @@ Watchdog Yes XTWDT supported
370370
Wi-Fi Yes WPA3-SAE supported
371371
=========== ======= ====================
372372

373+
Analog-to-digital converter (ADC)
374+
---------------------------------
375+
376+
Two ADC units are available for the ESP32-C3:
377+
378+
* ADC1 with 5 channels.
379+
* ADC2 with 1 channel and internal voltage reading. **This unit is not implemented.**
380+
381+
Those units are independent and can be used simultaneously. During bringup, GPIOs for selected channels are
382+
configured automatically to be used as ADC inputs.
383+
If available, ADC calibration is automatically applied (see
384+
`this page <https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32c3/api-reference/peripherals/adc_calibration.html>`__ for more details).
385+
Otherwise, a simple conversion is applied based on the attenuation and resolution.
386+
387+
The ADC unit is accessible using the ADC character driver, which returns data for the enabled channels.
388+
389+
The ADC1 unit can be enabled in the menu :menuselection:`System Type --> Peripheral Support --> Analog-to-digital converter (ADC)`.
390+
391+
Then, it can be customized in the menu :menuselection:`System Type --> ADC Configuration`, which includes operating mode, gain and channels.
392+
393+
========== ===========
394+
Channel ADC1 GPIO
395+
========== ===========
396+
0 0
397+
1 1
398+
2 2
399+
3 3
400+
4 4
401+
========== ===========
402+
403+
.. warning:: Maximum measurable voltage may saturate around 2900 mV.
404+
373405
Secure Boot and Flash Encryption
374406
================================
375407

Diff for: Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitc/index.rst

+25-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@ All of the configurations presented below can be tested by running the following
8888
Where <config_name> is the name of board configuration you want to use, i.e.: nsh, buttons, wifi...
8989
Then use a serial console terminal like ``picocom`` configured to 115200 8N1.
9090

91+
adc
92+
---
93+
94+
The ``adc`` configuration enables the ADC driver and the ADC example application.
95+
ADC Unit 1 is registered to ``/dev/adc0`` with channels 0, 1, 2 and 3 enabled by default.
96+
Currently, the ADC operates in oneshot mode.
97+
98+
More ADC channels can be enabled or disabled in ``ADC Configuration`` menu.
99+
100+
This example shows channels 0 and 1 connected to 3.3 V and channels 2 and 3 to GND (all readings
101+
show in units of mV)::
102+
103+
nsh> adc -n 1
104+
adc_main: g_adcstate.count: 1
105+
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
106+
Sample:
107+
1: channel: 0 value: 3611
108+
2: channel: 1 value: 3611
109+
3: channel: 2 value: 103
110+
4: channel: 3 value: 104
111+
91112
bmp180
92113
------
93114

@@ -110,10 +131,10 @@ the following output is expected::
110131
nsh> cap
111132
cap_main: Hardware initialized. Opening the capture device: /dev/capture0
112133
cap_main: Number of samples: 0
113-
pwm duty cycle: 50 %
114-
pwm frequence: 50 Hz
115-
pwm duty cycle: 50 %
116-
pwm frequence: 50 Hz
134+
pwm duty cycle: 50 %
135+
pwm frequence: 50 Hz
136+
pwm duty cycle: 50 %
137+
pwm frequence: 50 Hz
117138

118139
coremark
119140
--------

Diff for: Documentation/platforms/risc-v/esp32c6/index.rst

+29-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ The following list indicates the state of peripherals' support in NuttX:
331331
============== ======= ====================
332332
Peripheral Support NOTES
333333
============== ======= ====================
334-
ADC No Supports internal temperature sensor
334+
ADC Yes Oneshot and internal temperature sensor
335335
AES No
336336
Bluetooth No
337337
CAN/TWAI Yes
@@ -363,6 +363,34 @@ Wi-Fi Yes
363363
XTS No
364364
============== ======= ====================
365365

366+
Analog-to-digital converter (ADC)
367+
---------------------------------
368+
369+
One ADC unit is available for the ESP32-C6, with 7 channels.
370+
371+
During bringup, GPIOs for selected channels are configured automatically to be used as ADC inputs.
372+
If available, ADC calibration is automatically applied (see
373+
`this page <https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32c6/api-reference/peripherals/adc_calibration.html>`__ for more details).
374+
Otherwise, a simple conversion is applied based on the attenuation and resolution.
375+
376+
The ADC unit is accessible using the ADC character driver, which returns data for the enabled channels.
377+
378+
The ADC unit can be enabled in the menu :menuselection:`System Type --> Peripheral Support --> Analog-to-digital converter (ADC)`.
379+
380+
Then, it can be customized in the menu :menuselection:`System Type --> ADC Configuration`, which includes operating mode, gain and channels.
381+
382+
========== ===========
383+
Channel ADC1 GPIO
384+
========== ===========
385+
0 0
386+
1 1
387+
2 2
388+
3 3
389+
4 4
390+
5 5
391+
6 6
392+
========== ===========
393+
366394
_`Managing esptool on virtual environment`
367395
==========================================
368396

Diff for: Documentation/platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst

+22-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ESP32-H2-DevKitM-1 is an entry-level development board based on Bluetooth® Low
66
IEEE 802.15.4 combo module ESP32-H2-MINI-1 or ESP32-H2-MINI-1U. You can find the board schematic
77
`here <https://espressif-docs.readthedocs-hosted.com/projects/esp-dev-kits/en/latest/_static/esp32-h2-devkitm-1/esp32-h2-devkitm-1_v1.2_schematics_20230306.pdf>`_.
88

9-
Most of the I/O pins on the ESP32-H2-MINI-1/1U module are broken out to the pin headers on
9+
Most of the I/O pins on the ESP32-H2-MINI-1/1U module are broken out to the pin headers on
1010
both sides of this board for easy interfacing. Developers can either connect peripherals with
1111
jumper wires or mount ESP32-H2-DevKitM-1 on a breadboard.
1212

@@ -87,6 +87,27 @@ All of the configurations presented below can be tested by running the following
8787
Where <config_name> is the name of board configuration you want to use, i.e.: nsh, buttons, wifi...
8888
Then use a serial console terminal like ``picocom`` configured to 115200 8N1.
8989

90+
adc
91+
---
92+
93+
The ``adc`` configuration enables the ADC driver and the ADC example application.
94+
ADC Unit 1 is registered to ``/dev/adc0`` with channels 0, 1, 2 and 3 enabled by default.
95+
Currently, the ADC operates in oneshot mode.
96+
97+
More ADC channels can be enabled or disabled in ``ADC Configuration`` menu.
98+
99+
This example shows channels 0 and 1 connected to 3.3 V and channels 2 and 3 to GND (all readings
100+
show in units of mV)::
101+
102+
nsh> adc -n 1
103+
adc_main: g_adcstate.count: 1
104+
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
105+
Sample:
106+
1: channel: 0 value: 3713
107+
2: channel: 1 value: 3714
108+
3: channel: 2 value: 1
109+
4: channel: 3 value: 0
110+
90111
bmp180
91112
------
92113

Diff for: Documentation/platforms/risc-v/esp32h2/index.rst

+27-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ The following list indicates the state of peripherals' support in NuttX:
332332
============== ======= ====================
333333
Peripheral Support NOTES
334334
============== ======= ====================
335-
ADC No Supports internal temperature sensor
335+
ADC Yes Oneshot and internal temperature sensor
336336
AES No
337337
Bluetooth No
338338
CAN/TWAI Yes
@@ -363,6 +363,32 @@ Wifi No
363363
XTS No
364364
============== ======= ====================
365365

366+
Analog-to-digital converter (ADC)
367+
---------------------------------
368+
369+
One ADC unit is available for the ESP32-H2, with 5 channels.
370+
371+
During bringup, GPIOs for selected channels are configured automatically to be used as ADC inputs.
372+
If available, ADC calibration is automatically applied (see
373+
`this page <https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32h2/api-reference/peripherals/adc_calibration.html>`__ for more details).
374+
Otherwise, a simple conversion is applied based on the attenuation and resolution.
375+
376+
The ADC unit is accessible using the ADC character driver, which returns data for the enabled channels.
377+
378+
The ADC unit can be enabled in the menu :menuselection:`System Type --> Peripheral Support --> Analog-to-digital converter (ADC)`.
379+
380+
Then, it can be customized in the menu :menuselection:`System Type --> ADC Configuration`, which includes operating mode, gain and channels.
381+
382+
========== ===========
383+
Channel ADC1 GPIO
384+
========== ===========
385+
0 1
386+
1 2
387+
2 3
388+
3 4
389+
4 5
390+
========== ===========
391+
366392
_`Managing esptool on virtual environment`
367393
==========================================
368394

Diff for: Documentation/platforms/xtensa/esp32/boards/esp32-devkitc/index.rst

+21
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,27 @@ All of the configurations presented below can be tested by running the following
163163
Where <config_name> is the name of board configuration you want to use, i.e.: nsh, buttons, wifi...
164164
Then use a serial console terminal like ``picocom`` configured to 115200 8N1.
165165

166+
adc
167+
---
168+
169+
The ``adc`` configuration enables the ADC driver and the ADC example application.
170+
ADC Unit 1 is registered to ``/dev/adc0`` with channels 0, 3 and 4 enabled by default.
171+
Currently, the ADC operates in oneshot mode.
172+
173+
More ADC channels can be enabled or disabled in ``ADC Configuration`` menu.
174+
175+
This example shows channels 0 and 4 connected to GND and channel 3 to 3.3 V (all readings
176+
show in units of mV)::
177+
178+
nsh> adc -n 1
179+
adc_main: g_adcstate.count: 1
180+
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
181+
Sample:
182+
1: channel: 0 value: 142
183+
2: channel: 3 value: 3441
184+
3: channel: 4 value: 142
185+
186+
166187
audio
167188
-----
168189

Diff for: Documentation/platforms/xtensa/esp32/index.rst

+38-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ The following list indicates the state of peripherals' support in NuttX:
389389
========== ======= =====
390390
Peripheral Support NOTES
391391
========== ======= =====
392-
ADC No
392+
ADC Yes Oneshot
393393
AES Yes
394394
Bluetooth Yes
395395
Camera No
@@ -688,6 +688,43 @@ audio subsystem and develop specific usages of the I2S peripheral.
688688

689689
Please check for usage examples using the :doc:`ESP32 DevKitC </platforms/xtensa/esp32/boards/esp32-devkitc/index>`.
690690

691+
Analog-to-digital converter (ADC)
692+
=================================
693+
694+
Two ADC units are available for the ESP32:
695+
696+
* ADC1 with 8 channels
697+
* ADC2 with 10 channels
698+
699+
Those units are independent and can be used simultaneously. During bringup, GPIOs for selected channels are
700+
configured automatically to be used as ADC inputs.
701+
If available, ADC calibration is automatically applied (see
702+
`this page <https://docs.espressif.com/projects/esp-idf/en/v5.1/esp32/api-reference/peripherals/adc_calibration.html>`__ for more details).
703+
Otherwise, a simple conversion is applied based on the attenuation and resolution.
704+
705+
Each ADC unit is accessible using the ADC character driver, which returns data for the enabled channels.
706+
707+
The ADC unit can be enabled in the menu :menuselection:`System Type --> ESP32 Peripheral Selection --> Analog-to-digital converter (ADC)`.
708+
709+
Then, it can be customized in the menu :menuselection:`System Type --> ADC Configuration`, which includes operating mode, gain and channels.
710+
711+
========== =========== ===========
712+
Channel ADC1 GPIO ADC2 GPIO
713+
========== =========== ===========
714+
0 36 4
715+
1 37 0
716+
2 38 2
717+
3 39 15
718+
4 32 13
719+
5 33 12
720+
6 34 14
721+
7 35 27
722+
8 25
723+
9 26
724+
========== =========== ===========
725+
726+
.. warning:: ADC2 channels 1, 2 and 3 are used as strapping pins and can present undefined behavior.
727+
691728
Using QEMU
692729
==========
693730

Diff for: Documentation/platforms/xtensa/esp32s2/boards/esp32s2-saola-1/index.rst

+21
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,27 @@ All of the configurations presented below can be tested by running the following
9898
Where <config_name> is the name of board configuration you want to use, i.e.: nsh, buttons, wifi...
9999
Then use a serial console terminal like ``picocom`` configured to 115200 8N1.
100100

101+
adc
102+
---
103+
104+
The ``adc`` configuration enables the ADC driver and the ADC example application.
105+
ADC Unit 1 is registered to ``/dev/adc0`` with channels 0, 1, 2 and 3 enabled by default.
106+
Currently, the ADC operates in oneshot mode.
107+
108+
More ADC channels can be enabled or disabled in ``ADC Configuration`` menu.
109+
110+
This example shows channels 0 and 1 connected to 3.3 V and channels 2 and 3 to GND (all readings
111+
show in units of mV)::
112+
113+
nsh> adc -n 1
114+
adc_main: g_adcstate.count: 1
115+
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
116+
Sample:
117+
1: channel: 0 value: 3061
118+
2: channel: 1 value: 3061
119+
3: channel: 2 value: 106
120+
4: channel: 3 value: 99
121+
101122
audio
102123
-----
103124

0 commit comments

Comments
 (0)