-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Espressif analogbufio implementation #7602
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! One structural comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Additional comments to @tannewt's.
BTW, see https://github.com/adafruit/circuitpython/actions/runs/4205312574/jobs/7297211968 pre-commit section for formatting changes. Also, we use spaces after commas in arg lists. |
Pre-commit: Fixed compilation error for other ESP32C3/ESP32S3/ESP32H2 boards Review comment: Removed the self->pin NULL check Review comment: Using raise_ValueError_invalid_pin when adc_index is not ADC_UNIT1 for ESP32 Review comment: Optimized the code to set data in buffer from DMA results Fix: For ESP32C3 boards continuing collecting samples after channel mismatch as DMA runs in alternating UNIT mode Fix: For ESP32S3 and ESP32H2 setting conversion mode to type2
96c1536
to
ead5751
Compare
I have committed the changes as per all the review comments received so far. Except for the translation related pre-commit failure everything seems to be fine. Please let me know how to resolve translation related error and also additional review comments if any. Following is the updated test code and output: Test code:
Output:
|
For the translate issue, at the top level of the repo, do You can run pre-commit locally to save the round-trips to GitHub. See https://learn.adafruit.com/building-circuitpython/build-circuitpython#install-pre-commit-3096511 and the links it references. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for persevering with all the formatting changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@milindmovasha If I understand correctly, you are allowing one-byte arrays or two-byte arrays to be passed in, but you always write two bytes. Is that correct?
Normally if a result is 16-bit words, we would design an API to require an array.array('H', ...)
(or maybe larger), instead of spreading the result over two bytes. That is why I was asking for further checking of the allowed type of the passed-buffer.
If the previous analogbufio
implementation is doing something similar, we should fix it as well.
@dhalbert yes, your understanding is correct. I will restrict the buffer type to |
…on as per review comment to support one shot conversion mode for analogbufio Added check for verifying the buffer type passed to readinto is H
I have restricted the buffer type to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good re my comments! I'm making a simple grammar change myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed my mind; "an array" to just "array", for space reasons, and to make translation easier.
Hello team, this is a PR for implementation of analogbuio module for espressif port. I have tested the code on ESP32S2 board adafruit_feather_esp32s2. The code supports other version of ESP32 chip however it is not tested. Please note this code is compatible with ESP IDF version 4.4.x. There have been changes in ESP IDF 5.0 implementation of ADC DMA and the module will have to be updated when CircuitPython moves to ESP IDF 5.0
Test code:
Sample output: