-
Notifications
You must be signed in to change notification settings - Fork 2.1k
drivers: add a common driver for ADS1X1X #21694
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
base: master
Are you sure you want to change the base?
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.
Please also note the static errors about whitespaces.
extern void auto_init_ads101x(void); | ||
auto_init_ads101x(); | ||
} | ||
if (IS_USED(MODULE_ADS1X1X)){ |
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.
This might not cover all cases currently. If you specify USEMODULE+=ads101x
or USEMODULE+=ads111x
in your application, the module will not be automatically initialized.
Also the ads1x1x
driver will not be loaded. Typically you'd add the pseudomodule resolution to drivers/Makefile.dep
file (keep in mind the alphabetical order).
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.
However this will cause a name conflict with the current ads101x
driver.
7fa0aca
to
c8ed156
Compare
c8ed156
to
ce1acd9
Compare
ce1acd9
to
3c14d95
Compare
c342f4f
to
5e3525b
Compare
I don't see mention of the author's of the existing driver with the rename. Does this new driver really start from scratch with no influences from the existing one? |
Doing a |
In this case, how should I handle defines that are common to both Also, if I rename these defines to be specific, then functions in ads1x1x.c would need to know exactly which module they are handling, probably requiring #if macros… Finally, I’m not entirely clear on how the user is expected to select which ADS version they want to use. It would be really helpful if you could provide a small example to illustrate the intended usage, if possible. |
I think that would be logical.
As far as I can tell, the only code in the entire driver that needs to know which hardware flavor it is operating on is the
Referring to my above statement, again, I don't see the driver containing any device specific code, aside from the one conversion function. |
One architectural issue that I have with this PR, is that it renames the existing driver. The existing driver claims to support both flavors of the hardware, I see no reason to rename it. I prefer the new name you have chosen over the old one, but not enough to justify breaking compatibility with existing users of the driver. The rename also complicates version control, and PR review. |
The The problem with that, is the saul's |
5fdfff6
to
b6ab944
Compare
1f96022
to
58ffa37
Compare
Contribution description
While attempting to create a driver for my ADS1115 (this PR), I realized that a driver already exists here. However, the existing driver does not fully support the ADS111x family (datasheet here), which differs from the ADS101x series (datasheet here in several aspects such as bit resolution and maximum sample rate (see page 3 of the datasheet).
I have therefore implemented a common driver for the ADS1x1x family, better documented and inspired by the existing ADS101x driver. This unified driver supports both ADS101x and ADS111x variants, handling their differences internally.
Testing procedure
I adapted the existing test
tests/drivers/ads101x
to create `tests/drivers/ads111x and compared the outputs to ensure identical behavior and no regressions.It may be worth adding a helper function to verify the configuration register after each write, to ensure it contains the expected value.
Open questions
Element.io
, @Enoch247 pointed out that my current family-selection system is exclusive, which prevents supporting a case where both an ADS101x and an ADS111x driver are used in the same application. How should this be handled?i2c_read_regs
andi2c_write_regs
every time?I2C_NODEV
andI2C_NOI2C
, so I am not sure I have used them correctly throughout the driver.Issues/PRs references
Follow-up from PR
See the original issue : #21612