-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Expand support for ads1x4s0x series ADCs #83569
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
Conversation
72406ed
to
533aea5
Compare
I've skipped through the list of precision ADC from TI (there are astonishingly plenty of them) and it looks like the pattern ads1x4s0x does not match something this driver doesn't (or shouldn't) support. |
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.
The rename commit should already reflect the changes as well for instance in the CMakeLists.txt. Basically, the usual approach is not to squash the commits but keep them as they are, but ensure that every commit by itself can be used respectively built.
@benediktibk Sorry about the force push... I scraped my macro commit. The only changes are around the lines you commented on. Also, I added two I think I'm ready for you to review again. |
a74d4f2
to
7c90029
Compare
As you are changing an already existing binding, could you please add a section to the release notes? |
Ok, done another round of fixups. |
@benediktibk Since you mentioned this, maybe I should also write something into the release note. |
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.
Mentioning the added support for the other types in the release notes would be the cherry on the top.
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. A few nitpicking comments only.
02160ef
to
a41a065
Compare
Ok, fixed the format issues. |
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.
LGTM. The first commit says that "this commit shall be squashed into the next one before merging". Do you still intend to do this? I think it could stay as it is now.
@anangl Ok. I will keep them as they are now and edit the commit message to remove that line. |
…evices Renamed ads114s0x/8 to ads1x4s0x. Signed-off-by: Terry Geng <terry@terriex.com>
Renamed ads114s0x/8 to ads1x4s0x. Signed-off-by: Terry Geng <terry@terriex.com>
Refactor code for ADS114S08 (12 ch, 16 bit) to accommodate ADS114S06 (6 ch, 16 bit), ADS124S06 (6 ch, 24 bit), and ADS124S08 (12 ch, 24 bit). Signed-off-by: Terry Geng <terry@terriex.com>
Fixed commit message and updated release note. Rebased against main. Should be ready to go. |
The existing support is only for
ADS114S08
(16-bit, 12-channel). It has one sisterADS114S06
(16-bit, 6-channel).Meanwhile, there are the 24-bit variations
ADS124S06
andADS124S08
, which are pin-to-pin compatible with theADS114S0X
series. Their documents are almost verbatim identical to theADS114S0X
series with a slightly different read format.This PR expands support to the remaining three chips,
ADS114S06
,ADS124S06
, andADS124S08
.Since this is a refactor involving many name changes, I separate the file rename into a commit to make the changes to the actual code more visible. It will be squashed before this PR is ready for merging.
As for the other two commits:
drivers/adc/adc_lmp90xxx.c
, introducing two variables in the config structure to save the resolution and number of channels for different variations. It also includes branching statements in the read functions to do the conversion from the raw data to integers correctly. It has a memory footprint ofThe second commit presents a different way of implementing the same. I define the read functions in a separate template file and populate the right resolution and channel number using macros. I would think this is more elegant since most boards will have only one type ofADS1X4S0X
and it's a waste of resources to save the resolution and channel numbers into the stack, and use extra branching statement to perform the check every time the read is invoked. It has a slightly smaller memory footprint compared to the previous one.I would leave the decision of which one to use to the reviewer. These three (or two) commits will be squashed into one before merging.Our reviewer @benediktibk has pointed out a better way out. I implemented that instead.
Testing
Tested with an ADS124S06 chip with a
rpi_pico
.The 16-bit read was tested with setting
compatible = "ti,ads114s06";
in the overlay. Since the 16-bit read will ignore the last byte of the response from the chip, it should still behave but with only reduced precision.My overlay file:
Note: the 24-bit read will not work with the examples in
samples/drivers/adc/
since they assume 16-bit input. One has to change the buffer toint32_t
to see the correct behavior.The correct conversion (assume the read buffer is
buf
):or