Pigweed
 
Loading...
Searching...
No Matches
pw::analog::AnalogInput Class Referenceabstract

#include <analog_input.h>

Inheritance diagram for pw::analog::AnalogInput:
pw::analog::MicrovoltInput

Classes

struct  Limits
 

Public Member Functions

Result< int32_t > TryReadFor (chrono::SystemClock::duration timeout)
 
virtual Result< int32_t > TryReadUntil (chrono::SystemClock::time_point deadline)=0
 
virtual Limits GetLimits () const =0
 

Detailed Description

Base interface for getting analog-to-digital (ADC) samples from one ADC channel in a thread-safe manner.

The ADC backend interface is up to the user to define and implement for now. This gives flexibility for the ADC driver implementation.

AnalogInput controls a specific input / channel where the ADC peripheral may be shared across multiple channels that may be controlled by multiple threads. The implementer of this pure virtual interface is responsible for ensuring thread safety and access at the driver level.

Member Function Documentation

◆ GetLimits()

virtual Limits pw::analog::AnalogInput::GetLimits ( ) const
pure virtual
Returns
The range of the ADC sample. These values do not change at runtime.

◆ TryReadFor()

Result< int32_t > pw::analog::AnalogInput::TryReadFor ( chrono::SystemClock::duration  timeout)
inline

Blocks until the specified timeout duration has elapsed or the ADC sample has been returned, whichever comes first.

This method is thread safe.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: Returns a sample.
* 
*     RESOURCE_EXHAUSTED: ADC peripheral in use.
* 
*     DEADLINE_EXCEEDED: Timed out waiting for a sample.
* 
*  Other statuses left up to the implementer.
* 
*  

◆ TryReadUntil()

virtual Result< int32_t > pw::analog::AnalogInput::TryReadUntil ( chrono::SystemClock::time_point  deadline)
pure virtual

Blocks until the deadline time has been reached or the ADC sample has been returned, whichever comes first.

This method is thread safe.

Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: Returns a sample on success.
* 
*     RESOURCE_EXHAUSTED: ADC peripheral in use.
* 
*     DEADLINE_EXCEEDED: Timed out waiting for a sample.
* 
*  Other statuses left up to the implementer.
* 
*  

The documentation for this class was generated from the following file: