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

adc: iio: hardware: add buffering support to the powerboard ADC #27

Merged
merged 7 commits into from
Sep 27, 2023

Conversation

hnez
Copy link
Member

@hnez hnez commented Jun 13, 2023

This PR adds buffering support to the powerboard ADC. The main benefit of this change is that voltage and current samples are now taken at the exact same point int time, enabling better instantaneous power measurements.

This feature relies on kernel support for buffering in the powerboard ADC and a fix to libiio to allow enabling the buffer for the ADC, both of which are not currently included in meta-lxatac.

Related Pull Requests

src/adc/iio/hardware.rs Outdated Show resolved Hide resolved
src/adc/iio/hardware.rs Outdated Show resolved Hide resolved
src/adc/iio/hardware.rs Show resolved Hide resolved
This makes working with the channel constants a bit less unwieldy.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
…able

Under some circumstances it can happen that all steps of the ADC setup
succeed but reading the first set of values fails.
Currently this special case results in the thread waiting for the values
busy-looping forever.
Delay signaling "setup ready" until we avtually have a first reading.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
... via the timestamp value. Previously the consumers of iio adc values
were not notified about a iio thread that exited unexpectedly, meaning
they only found out via e.g. timeouts (or not at all).
Give the iio thread a way to tell the other threads about issues.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This is in preparation for the use of buffered iio for the powerboard ADC.
This commit does not add the buffering yet but instead only splits the
mainboard ADC handling and powerboard ADC handling into separate threads,
as the two ADCs will work at independent sampling rates, which means reading
values should not block on the respective other ADC.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This means the STM32/baseboard ADC and the powerboard ADC can share
most of their setup routine.
The main difference is that the powerboard ADC uses a software trigger
(iio-trig-hrtimer) instead of a hardware timer like the STM32 ADC does.

The software trigger has to first be created via the configs,
making new_powerboard() a bit different from new_stm32().

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
And 4x oversampling. The slower sampling rate and oversampling factor is
still sufficient to keep the noise level low and reduces the CPU load a bit.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
Previously the iio thread code contained a lot of .unwrap() calls and
explicit panics. Now it contains a few less and gained some comments
where it still .unwrap()s.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez hnez merged commit 7794446 into linux-automation:main Sep 27, 2023
10 checks passed
@hnez hnez deleted the iio-buffering branch September 27, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants