HomeFreeBSD

Ensure a measurement is complete before reading the result in ads111x.

Description

Ensure a measurement is complete before reading the result in ads111x.
Also, disable the comparator by default; it's not used for anything.

The previous logic would start a measurement, and then pause_sbt() for the
averaging time currently configured in the chip. After waiting that long,
the code would blindly read the measurement register and return its value.
The problem is that the chip's idea of averaging time is based on its
internal free-running 1MHz oscillator, which may be running at a wildly
different rate than the kernel clock. If the chip's internal timer was
running slower than the kernel clock, we'd end up grabbing a stale result
from an old measurement.

The driver now still uses pause_sbt() to yield the cpu while waiting for
the measurement to complete, but after sleeping it checks the chip's status
register to ensure the measurement engine is idle. If it's not, the driver
uses a retry loop to wait a bit (5% of the original wait time) then check
again for completion.

Details

Provenance
ianAuthored on
Parents
rS351884: Set required program for all acl tests
Branches
Unknown
Tags
Unknown