Skip to content
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

drivers/ads101x: Changes for Common ADC API #10619

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Dec 15, 2018

Contribution description

This PR provides

  • the changes of ADS101x/ADS111x driver for compatibility with the ADC extension API in PR drivers/adc_ng: Added common ADC API #13247 which makes it possible to use ADS101x/ADS111x devices as ADC extensions.
  • a shell based test application which demonstrates the use of the ADS101x/ADS111x devices
    as ADC extension

This PR serves as a proof-of-concept for the Common ADC API in PR #13247 using an example of an existing ADC driver.

Testing procedure

The test application can be used with up to two ADS101x/ADS111x devices. It is recommended to use two ADS1115 device where the the second ADS1115 is used as ADS1013 to see the differences between the two ADC extension devices. Compile the test application for any board that supports I2C.

CFLAGS="-DADS101X_PARAM_ADDR_2=\(0x49\) -DADS101X_PARAM_DEVICE_2=\(ADS101X_DEV_ADS1013\)" \
make flash -C tests/driver_ads101x_ext_api BOARD=...

Issues/PRs references

Depends on PR #13247

@gschorcht gschorcht added Area: tests Area: tests and testing framework Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR Area: drivers Area: Device drivers labels Dec 15, 2018
@ZetaR60 ZetaR60 self-assigned this Dec 15, 2018
@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@gschorcht gschorcht added the State: waiting for other PR State: The PR requires another PR to be merged first label Aug 10, 2019
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@stale
Copy link

stale bot commented Feb 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Feb 11, 2020
@gschorcht gschorcht added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Feb 11, 2020
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Feb 11, 2020
@gschorcht
Copy link
Contributor Author

Requires some work to make compatible with PR #13247.

@gschorcht gschorcht force-pushed the drivers_ads101x_ext_api branch from 31bb4fb to aa522a6 Compare February 14, 2020 10:39
@gschorcht gschorcht changed the title drivers/ads101x: Changes for ADC extension API drivers/ads101x: Changes for Common ADC API Feb 14, 2020
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments inline.

I wonder if we couldn't get the test be driver independet. E.g. every non-peripheral driver could contain a check like this:

#if (ADC_NG_NUMOF == 1) && defined(MODULE_ADS101X)
const adc_ng_backend_t adc_ng_backends[ADC_NG_NUMOF] = {
    {
        .driver = &ads101x_adc_ng_driver,
        .handle = &ads101x_devs[0]
    }
};
#endif

Combined with auto-init this should just work without any support of either board or application, as long as exactly one ADC-NG driver (with only one entry in params) is used. I bet that this is also the common case. And only applications/boards actually having multiple ADCs would have go through the pain of providing the backends themselves.

Once the cross file arrays land in RIOT, this would also work without board/application support for any number of drivers :-)

@gschorcht
Copy link
Contributor Author

gschorcht commented Feb 14, 2020

Some comments inline.

I wonder if we couldn't get the test be driver independet. E.g. every non-peripheral driver could contain a check like this:

#if (ADC_NG_NUMOF == 1) && defined(MODULE_ADS101X)
const adc_ng_backend_t adc_ng_backends[ADC_NG_NUMOF] = {
    {
        .driver = &ads101x_adc_ng_driver,
        .handle = &ads101x_devs[0]
    }
};
#endif

Combined with auto-init this should just work without any support of either board or application, as long as exactly one ADC-NG driver (with only one entry in params) is used. I bet that this is also the common case. And only applications/boards actually having multiple ADCs would have go through the pain of providing the backends themselves.

Once the cross file arrays land in RIOT, this would also work without board/application support for any number of drivers :-)

👍 Seems to be a good idea. I suppose you would place that code fragment in the drivers code.

@gschorcht
Copy link
Contributor Author

gschorcht commented Feb 14, 2020

Seems to be a good idea. I suppose you would place that code fragment in the drivers code.

To place this in drivers code requires to make ads101x_devs visible, i.e. , to remove keyword static which is already the case for some other drivers. Furthermore, auto-init only works when saul is enabled.

@gschorcht
Copy link
Contributor Author

Seems to be a good idea. I suppose you would place that code fragment in the drivers code.

To place this in drivers code requires to make ads101x_devs visible, i.e. , to remove keyword static which is already the case for some other drivers. Furthermore, auto-init only works when saul is enabled.

@maribu It works indeed without any board definition if module saul_default is used and the driver code reuses the devices that are auto-initialized in sys/aut-init/saul. In fact, the only difference to tests/adc_ng is that module adc_ng_default is no used and modules ads101x and saul_default are used. main.c is exactly the same.

The question is how we can test each ADC driver that supports adc_ng without duplicating the test. It would be great if RIOT's test architecure would support variants of the same test application.

@maribu
Copy link
Member

maribu commented Feb 14, 2020

if module saul_default

I'm working on a PR to split auto-initialization of the drivers and SAUL, so that sensors/actuators can also be auto-initialized in case SAUL is not used.

It would be great if RIOT's test architecure would support variants of the same test application.

Some tests can be controlled using environment parameters. E.g. we could introduce a variable like

BACKEND ?= periph_adc_ng

and if someone would run with BACKEND=ads101x make instead, the ads101x backend would be chosen instead. That might not be a solution for hardware in the loop testing, but for manual testing this should be fine.

@gschorcht
Copy link
Contributor Author

gschorcht commented Feb 14, 2020

if module saul_default

I'm working on a PR to split auto-initialization of the drivers and SAUL, so that sensors/actuators can also be auto-initialized in case SAUL is not used.

👍

Some tests can be controlled using environment parameters. E.g. we could introduce a variable like

BACKEND ?= periph_adc_ng

and if someone would run with BACKEND=ads101x make instead, the ads101x backend would be chosen instead. That might not be a solution for hardware in the loop testing, but for manual testing this should be fine.

Hm, that still can't be automated. What I meant is to have a script that automatically compiles and tests variants of the same test application, for example for different BACKEND modules.

Changes for compatibility with the Common ADC API. With these changes ADS101x/ADS111x devices can be used as ADC extensions.
Application to test ADS101x/ADS111x devices with the Common ADC API as ADC extension.
@gschorcht gschorcht force-pushed the drivers_ads101x_ext_api branch from aa522a6 to ff6027f Compare February 15, 2020 09:46
@stale
Copy link

stale bot commented Aug 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 19, 2020
@maribu
Copy link
Member

maribu commented Aug 19, 2020

Not stale, I'll resume work on the ADC-NG API hopefully soon. Then this can get in as well :-)

@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Aug 19, 2020
@stale
Copy link

stale bot commented Mar 19, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Mar 19, 2021
@gschorcht gschorcht added the State: don't stale State: Tell state-bot to ignore this issue label Mar 20, 2021
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Mar 20, 2021
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 21, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: tests Area: tests and testing framework Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR State: don't stale State: Tell state-bot to ignore this issue State: waiting for other PR State: The PR requires another PR to be merged first State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants