Skip to content

Conversation

@efra-mx-aqua
Copy link
Contributor

@efra-mx-aqua efra-mx-aqua commented May 16, 2023

Some hardware configuration require rely on the ALERT/RDY pin to know when and ADC conversion is completed.

  • A pin called int-gpios can optionally be define in the DT.
  • The polling thread is left as fallback, when the pin is not defined.
  • The semaphore is only used if the thread is running
  • It introduces a new DT macro DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY
    Fixes adc: ads1115: do conversion using the RDY pin #57952

@zephyrbot zephyrbot added platform: TI SimpleLink Texas Instruments SimpleLink MCU area: ADC Analog-to-Digital Converter (ADC) area: Devicetree Binding PR modifies or adds a Device Tree binding labels May 16, 2023
@efra-mx-aqua efra-mx-aqua force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch 2 times, most recently from f48b09e to 955bbc9 Compare May 16, 2023 14:49
@efra-mx-aqua efra-mx-aqua changed the title drivers: adc: ads1x1x: add support for RDY pin draft: drivers: adc: ads1x1x: add support for RDY pin May 17, 2023
@efra-mx-aqua efra-mx-aqua force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch 3 times, most recently from 360ca6a to 6d305ba Compare May 17, 2023 14:25
@efra-mx-aqua efra-mx-aqua changed the title draft: drivers: adc: ads1x1x: add support for RDY pin drivers: adc: ads1x1x: add support for RDY pin May 17, 2023
@efra-mx-aqua
Copy link
Contributor Author

This ready for review

Copy link
Member

@XenuIsWatching XenuIsWatching left a comment

Choose a reason for hiding this comment

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

I'm thinking a test case may need to be added for building with the TRIGGER support within https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/drivers/build_all/adc

@efra-mx-aqua efra-mx-aqua force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch from 6d305ba to dc9329b Compare May 19, 2023 09:33
@efra-mx-aqua
Copy link
Contributor Author

I'm thinking a test case may need to be added for building with the TRIGGER support within https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/drivers/build_all/adc

I am not familiar with those tests, do you have any pointers? It seems all the drivers are only built with the default configuration

By default it is built with CONFIG=ADC_ADS1X1X_TRIGGER=y

@efra-mx-aqua
Copy link
Contributor Author

@XenuIsWatching I have done the changes you requested

@efra-mx-aqua efra-mx-aqua force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch from dc9329b to 31f611d Compare May 19, 2023 11:04
Copy link
Member

@XenuIsWatching XenuIsWatching left a comment

Choose a reason for hiding this comment

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

I have a comment on #ifdef CONFIG_ADC_ADS1X1X_TRIGGER, but I'm beginning to think there is a better way to infer this from the dts without needing a kConfig at all. If the dts has the define for the alert-rdy-gpios, then it should be implied that it is to use the interrupt pin rather than threaded output.

Maybe just use the macro #ifdef DT_ANY_INST_HAS_PROP_STATUS_OKAY(alert_rdy_gpios) rather than the Kconfig. This should allow it for if at least 1 ads1x1x has the alert-rdy-gpios defined, then it will compile all the code need for the interrupt pin without needing to think about enabling or disabling the kconfig

Copy link
Member

@XenuIsWatching XenuIsWatching left a comment

Choose a reason for hiding this comment

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

Please fix the compliance issues from the CI and it appears there's another issue with compiling.... other than that it looks good

@efra-mx-aqua efra-mx-aqua force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch from d1bccba to d33a194 Compare May 23, 2023 12:15
@efra-mx efra-mx force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch from d84f67d to 880b4d9 Compare March 11, 2024 02:45
@zephyrbot zephyrbot requested a review from decsny March 11, 2024 02:46
@efra-mx efra-mx force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch from 880b4d9 to c2eed75 Compare March 11, 2024 15:13
@sslupsky
Copy link
Contributor

sslupsky commented Mar 14, 2024

@efra-mx Thanks for this. I was forced to write my own out of tree driver a while ago to support this feature. One thing that you might consider giving some thought to with regard to this driver is the mux. Unfortunately, this driver does not support sequencing the input mux so this driver is unusable for anyone that has more than one channel connected to the ADC's inputs.

@efra-mx
Copy link
Contributor

efra-mx commented Mar 16, 2024

@efra-mx Thanks for this. I was forced to write my own out of tree driver a while ago to support this feature. One thing that you might consider giving some thought to with regard to this driver is the mux. Unfortunately, this driver does not support sequencing the input mux so this driver is unusable for anyone that has more than one channel connected to the ADC's inputs.

It is not unusable, but it indeed requires a different configuration, you only need different configuration and get one channel at the time

XenuIsWatching
XenuIsWatching previously approved these changes Mar 19, 2024
@decsny
Copy link
Member

decsny commented Mar 19, 2024

@XenuIsWatching well process here has been very slow. I have rebased several times, but it has become pointless since nobody is doing the review of the other files.

This MR sill become 1-year old. How could we improve that?

I need review from @vaishnavachath @mbolivar-ampere

You can follow the escalation path if needed

@sslupsky
Copy link
Contributor

It is not unusable, but it indeed requires a different configuration, you only need different configuration and get one channel at the time

I am not clear by what you mean. The driver as written only configures one input channel so this driver does not work if you ask it to configure two or more input channels. It returns an ENOTSUP error:

if (channel_cfg->channel_id != 0) {
LOG_ERR("unsupported channel id '%d'", channel_cfg->channel_id);
return -ENOTSUP;
}

Are you suggesting that the user reconfigure the ADC manually every time? Having to manually update the configuration for each sample means the user cannot use the adc_sequence features and must duplicate a significant amount of the sampling scaffolding that is already provided by the ADC API.

I am not sure what the Zephyr policy is regarding what elements of the ADC API are mandatory but it seems necessary to include support for adc_sequence since the adc_sequence types are always included (not conditional) in the data structure:
https://github.com/zephyrproject-rtos/zephyr/blob/1680223003355673decdf18e7fd98efd9fbd2502/drivers/adc/adc_context.h#L55C1-L74C1

@sslupsky
Copy link
Contributor

This looks incorrect:
https://github.com/efra-mx/zephyr/blame/c2eed75ed0658c445f3bac66b9159a96a3b38269/drivers/adc/adc_ads1x1x.c#L481-L482

The COMP_MODE bit sets the comparator mode, it does not disable the comparator. The COMP_QUE bits disable the comparator.

Also, you should consider initializing the COMP_POL, COMP_LAT and COMP_QUE bits.

Should the config include support for specifying a comparator configuration in the dts for users that use the comparator function?

@XenuIsWatching
Copy link
Member

This looks incorrect: https://github.com/efra-mx/zephyr/blame/c2eed75ed0658c445f3bac66b9159a96a3b38269/drivers/adc/adc_ads1x1x.c#L481-L482

The COMP_MODE bit sets the comparator mode, it does not disable the comparator. The COMP_QUE bits disable the comparator.

Also, you should consider initializing the COMP_POL, COMP_LAT and COMP_QUE bits.

Yeah... that makes sense... but that probably should be in a seperate PR

@XenuIsWatching
Copy link
Member

I did speak to @mbolivar-ampere over Discord, he said he doesn't see anything crazy but he'm not maintaining DT right now due to dayjob time constraints. I'll ping around on "pr-help" on Discord then

@efra-mx
Copy link
Contributor

efra-mx commented Mar 21, 2024 via email

Copy link
Member

Choose a reason for hiding this comment

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

@efra-mx-aqua @efra-mx this comment is still open, there are devices in the list which does not expose alert/rdy GPIO, sorry for the delay in review

@sslupsky
Copy link
Contributor

This looks incorrect: https://github.com/efra-mx/zephyr/blame/c2eed75ed0658c445f3bac66b9159a96a3b38269/drivers/adc/adc_ads1x1x.c#L481-L482
The COMP_MODE bit sets the comparator mode, it does not disable the comparator. The COMP_QUE bits disable the comparator.
Also, you should consider initializing the COMP_POL, COMP_LAT and COMP_QUE bits.

Yeah... that makes sense... but that probably should be in a seperate PR

I disagree. This PR is already a year old. Let's get this right and fix the alert issue properly and resolve this known issue and also add the missing adc sequence that is an essential component of the ADC API.

@efra-mx
Copy link
Contributor

efra-mx commented Mar 22, 2024 via email

@efra-mx
Copy link
Contributor

efra-mx commented Mar 22, 2024 via email

@XenuIsWatching
Copy link
Member

This looks incorrect: https://github.com/efra-mx/zephyr/blame/c2eed75ed0658c445f3bac66b9159a96a3b38269/drivers/adc/adc_ads1x1x.c#L481-L482
The COMP_MODE bit sets the comparator mode, it does not disable the comparator. The COMP_QUE bits disable the comparator.
Also, you should consider initializing the COMP_POL, COMP_LAT and COMP_QUE bits.

Yeah... that makes sense... but that probably should be in a seperate PR

I disagree. This PR is already a year old. Let's get this right and fix the alert issue properly and resolve this known issue and also add the missing adc sequence that is an essential component of the ADC API.

A PR should be doing one thing and that is independent of what this is doing. You are welcome to submit your own PR with that code integrated from your OOT driver, and I will take a look when you do so.

Add a new macro, DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY
name, evaluates to 1 if any enabled instance of `compat` has the
property or to zero if it hasn't.

This macro can be useful in drivers for a family of devices.

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
Some hardware configuration require rely on the ALERT/RDY
pin to know when and ADC conversion is completed.

The polling thread is left as fallback, when the pin
is not defined.

Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
@efra-mx efra-mx force-pushed the ads1x1x-do-conversion-using-the-pin-rdy branch from c2eed75 to 277bad6 Compare March 27, 2024 20:14
@efra-mx
Copy link
Contributor

efra-mx commented Mar 27, 2024

@vaishnavachath done i have fixed that

@sslupsky
Copy link
Contributor

A PR should be doing one thing and that is independent of what this is doing. You are welcome to submit your own PR with that code integrated from your OOT driver, and I will take a look when you do so.

I understand this PR is adding the support for the ALERT/RDY pin? The COMP_POL, COMP_LAT and COMP_QUE configuration is essential to the proper operation of this feature. So, at a minimum, this PR should address this particular issue.

I also suggested the mux should be addressed. I do agree that supporting the mux is not part of the original scope of the PR. This driver should not have been merged without this capability. Nevertheless, this PR does move the yardstick an inch or two forward so that is progress.

Regarding your suggestion that I make a PR. The length of time it takes to get anything merged in Zephyr is outrageous. Frankly, I don't want to have to keep rebasing a PR for a year or two until it gets merged. I did that already and finally closed the PR's because nobody seemed to care about the bugs in some of the drivers. You are welcome to go pick it out of my repo and submit the PR.

@decsny
Copy link
Member

decsny commented Mar 27, 2024

A PR should be doing one thing and that is independent of what this is doing. You are welcome to submit your own PR with that code integrated from your OOT driver, and I will take a look when you do so.

I understand this PR is adding the support for the ALERT/RDY pin? The COMP_POL, COMP_LAT and COMP_QUE configuration is essential to the proper operation of this feature. So, at a minimum, this PR should address this particular issue.

I also suggested the mux should be addressed. I do agree that supporting the mux is not part of the original scope of the PR. This driver should not have been merged without this capability. Nevertheless, this PR does move the yardstick an inch or two forward so that is progress.

Regarding your suggestion that I make a PR. The length of time it takes to get anything merged in Zephyr is outrageous. Frankly, I don't want to have to keep rebasing a PR for a year or two until it gets merged. I did that already and finally closed the PR's because nobody seemed to care about the bugs in some of the drivers. You are welcome to go pick it out of my repo and submit the PR.

Don't know when you were having those PRs but lately the project is trying to address the review velocity, there are new rules about escalation, strict expectations of assignees, and there is a public merge queue site that the release team is constantly monitoring every day, I suggest you to try again

? GPIO_INT_EDGE_FALLING
: GPIO_INT_DISABLE;

gpio_pin_interrupt_configure(config->alert_rdy.port, config->alert_rdy.pin,
Copy link
Member

@XenuIsWatching XenuIsWatching Mar 28, 2024

Choose a reason for hiding this comment

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

I saw the change in a previous commit, but looks like the change where this was using gpio_pin_interrupt_configure_dt() and checking the return value was also lost....
The original commit was here: d84f67d

Anyways I did recover your old commit with some "git fu".
You can recover with the following commands

git fetch https://github.com/zephyrproject-rtos/zephyr.git d84f67dc114c6472306ecd111b2885fccb131426:my_lost_branch

Then reset your branch to that, and rebase to main

Copy link
Member

@XenuIsWatching XenuIsWatching left a comment

Choose a reason for hiding this comment

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

see comment here: #57954 (comment)

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ADC Analog-to-Digital Converter (ADC) area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree platform: TI SimpleLink Texas Instruments SimpleLink MCU Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adc: ads1115: do conversion using the RDY pin

9 participants