-
Notifications
You must be signed in to change notification settings - Fork 26
feat(adc): Update to support newer chips; improve API consistency; improve continuous adc performance; remove warnings #668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9efc3cd
feat(adc): Update to support newer chips; improve API consistency; im…
finger563 863dfa3
update so the sample rate and window size are kconfig configurable an…
finger563 dfca031
fix sa for esp_idf_version macro
finger563 0b42719
fix(adc): Address PR review feedback
finger563 e88bad4
fix(adc): Harden ContinuousAdc thread-safety; document thread-safety …
finger563 4839c14
docs(adc): Document why derived multi-unit conversion mode is ALTER, …
finger563 61a40fb
docs(adc): Explain ALTER vs BOTH conversion modes with usage examples
finger563 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| menu "ADC Example Configuration" | ||
|
|
||
| choice EXAMPLE_HARDWARE | ||
| prompt "Hardware" | ||
| default EXAMPLE_HARDWARE_QTPY_ESP32 if IDF_TARGET_ESP32 | ||
| default EXAMPLE_HARDWARE_QTPY_ESP32S3 if IDF_TARGET_ESP32S3 | ||
| default EXAMPLE_HARDWARE_M5STACK_TAB5 if IDF_TARGET_ESP32P4 | ||
| default EXAMPLE_HARDWARE_CUSTOM | ||
| help | ||
| Which hardware to run the example on. The board selections | ||
| configure the ADC unit and channels to pins which are usable | ||
| (exposed) on that board; select custom to choose the ADC unit and | ||
| channels yourself. | ||
|
|
||
| config EXAMPLE_HARDWARE_QTPY_ESP32 | ||
| depends on IDF_TARGET_ESP32 | ||
| bool "Adafruit QtPy ESP32 Pico" | ||
| help | ||
| Uses ADC unit 1, channels 4 and 5: the pins labeled 'TX' | ||
| (GPIO32) and 'SCL' (GPIO33), the only ADC1-capable pins | ||
| exposed on the board. | ||
|
|
||
| config EXAMPLE_HARDWARE_QTPY_ESP32S3 | ||
| depends on IDF_TARGET_ESP32S3 | ||
| bool "Adafruit QtPy ESP32-S3" | ||
| help | ||
| Uses ADC unit 1, channels 7 and 8: the pins labeled 'A3' | ||
| (GPIO8) and 'A2' (GPIO9). | ||
|
|
||
| config EXAMPLE_HARDWARE_M5STACK_TAB5 | ||
| depends on IDF_TARGET_ESP32P4 | ||
| bool "M5Stack Tab5" | ||
| help | ||
| Uses ADC unit 1, channels 0 and 1: GPIO16 and GPIO17, which | ||
| are exposed on the Tab5's expansion header. | ||
|
|
||
| NOTE: the Grove connector's signal pins (GPIO53/54) are ADC | ||
| unit 2 channels 4/5 and work with the oneshot ADC, but ADC2 | ||
| continuous (DMA) conversions on the ESP32-P4 currently | ||
| produce all-zero samples with esp-idf, so this example uses | ||
| ADC1 pins instead. | ||
|
|
||
| config EXAMPLE_HARDWARE_CUSTOM | ||
| bool "Custom" | ||
| help | ||
| Select the ADC unit and channels yourself. | ||
| endchoice | ||
|
|
||
| config EXAMPLE_ADC_UNIT | ||
| int "ADC unit (1 or 2)" if EXAMPLE_HARDWARE_CUSTOM | ||
| range 1 2 | ||
| default 1 | ||
| help | ||
| The ADC unit both channels are read from. | ||
|
|
||
| NOTE: the continuous (DMA) part of the example requires a | ||
| DMA-capable unit; on ESP32, ESP32-C3, and ESP32-S3 that is only | ||
| unit 1. On ESP32-P4, ADC2 continuous conversions currently | ||
| produce all-zero samples with esp-idf, so prefer unit 1 there as | ||
| well. | ||
|
|
||
| config EXAMPLE_ADC_CHANNEL_1 | ||
| int "First ADC channel" if EXAMPLE_HARDWARE_CUSTOM | ||
| range 0 9 | ||
| default 4 if EXAMPLE_HARDWARE_QTPY_ESP32 | ||
| default 7 if EXAMPLE_HARDWARE_QTPY_ESP32S3 | ||
| default 0 if EXAMPLE_HARDWARE_M5STACK_TAB5 | ||
| default 2 | ||
| help | ||
| The first ADC channel to read. Which GPIO a channel maps to is | ||
| chip specific; see the ADC section of your chip's technical | ||
| reference manual (e.g. ADC1 channels 0-7 are GPIO 36-39/32-35 on | ||
| ESP32, GPIO 1-10 on ESP32-S3, GPIO 16-23 on ESP32-P4). | ||
|
|
||
| config EXAMPLE_ADC_CHANNEL_2 | ||
| int "Second ADC channel" if EXAMPLE_HARDWARE_CUSTOM | ||
| range 0 9 | ||
| default 5 if EXAMPLE_HARDWARE_QTPY_ESP32 | ||
| default 8 if EXAMPLE_HARDWARE_QTPY_ESP32S3 | ||
| default 1 if EXAMPLE_HARDWARE_M5STACK_TAB5 | ||
| default 3 | ||
| help | ||
| The second ADC channel to read. See EXAMPLE_ADC_CHANNEL_1 for the | ||
| channel-to-GPIO mapping. | ||
|
|
||
| config EXAMPLE_ADC_SAMPLE_RATE_HZ | ||
| int "Continuous ADC Sample Rate (Hz)" | ||
| range 0 1000000 | ||
| default 20000 if EXAMPLE_HARDWARE_QTPY_ESP32 | ||
| default 20000 if EXAMPLE_HARDWARE_QTPY_ESP32S3 | ||
| default 10000 if EXAMPLE_HARDWARE_M5STACK_TAB5 | ||
| default 20000 | ||
| help | ||
| The sample rate for the continuous ADC readings. The example | ||
| uses a DMA buffer to read samples from the ADC. The example prints the average of each | ||
| channel's samples every second, so if you set the sample rate to | ||
| 1000 Hz, it will print the average of 1000 samples per channel | ||
| every second. | ||
|
|
||
| config EXAMPLE_ADC_WINDOW_SIZE_BYTES | ||
| int "Continuous ADC Window Size (Bytes)" | ||
| range 0 65536 | ||
| default 1024 if EXAMPLE_HARDWARE_QTPY_ESP32 | ||
| default 1024 if EXAMPLE_HARDWARE_QTPY_ESP32S3 | ||
| default 256 if EXAMPLE_HARDWARE_M5STACK_TAB5 | ||
| default 1024 | ||
| help | ||
| The size of the DMA buffer used for continuous ADC readings. The | ||
| example prints the average of each channel's samples every second, | ||
| so if you set the sample rate to 1000 Hz and the window size to | ||
| 1000 bytes, it will print the average of 1000 samples per channel | ||
| every second. | ||
|
|
||
| endmenu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.