ADC Improvements - #6360
Open
bjoernQ wants to merge 2 commits into
Open
ADC Improvements#6360bjoernQ wants to merge 2 commits into
bjoernQ wants to merge 2 commits into
Conversation
bjoernQ
force-pushed
the
try-fix-adc
branch
from
September 22, 2026 09:43
dfc0b4e to
9eea597
Compare
bugadani
reviewed
Sep 22, 2026
Comment on lines
118
to
124
| // The diff is signed and subtracted from the attenuation-0 reference point, so a negative | ||
| // diff raises the code. | ||
| let code11 = if diff_code11 & (1 << 5) != 0 { | ||
| code0 + (diff_code11 & 0x1f) | ||
| } else { | ||
| code0 + diff_code11 | ||
| code0 - diff_code11 | ||
| } - 123; |
Contributor
There was a problem hiding this comment.
This should probably be extracted into an n-bit signed subtraction, I think this isn't the only place we use something similar?
bugadani
reviewed
Sep 22, 2026
| // This chip does not follow the ESP32-C6 layout: there are no reference-connect | ||
| // bits, and the ground-connect bits live in register 8. | ||
| // | ||
| // See <https://github.com/espressif/esp-idf/blob/v6.1/components/soc/esp32c5/include/soc/regi2c_saradc.h> |
Contributor
There was a problem hiding this comment.
Keep the link, drop the comment. The chip also doesn't follow a bunch of other things, calling out C6 is a sort of "why I'm changing this" comment, not something that needs to be kept. LLMs do this way too much.
bjoernQ
marked this pull request as ready for review
September 22, 2026 15:54
bjoernQ
force-pushed
the
try-fix-adc
branch
from
September 22, 2026 15:54
9eea597 to
bc84370
Compare
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tester: https://github.com/bjoernQ/adc-foo
This aligns the ADC implementation with what is found in ESP-IDF (6.1)
The tester now shows numbers very close between ESP-IDF and this branch. (i.e. deviations in the same range as multiple runs of the IDF tester, with the exception of S31: Rust reads about 0.35% higher than IDF
, lets dig into that in a follow up given the current support status of S31). The same raw values result in the same calibrated reads.
Changelog
esp-hal
adc::AdcCalSourceandAdcCalScheme::adc_cal.