nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Types | Public Member Functions | Static Public Attributes
nrfcxx::sensor::adc::lpsm_wrapper Class Reference

A class that implements an LPM state machine around a periph::ADCClient. More...

#include <nrfcxx/sensor/adc.hpp>

Inheritance diagram for nrfcxx::sensor::adc::lpsm_wrapper:
nrfcxx::lpm::lpsm_capable

Public Types

using mutex_type = periph::ADCClient::mutex_type
 Mutex domain is that of the ADC.
 

Public Member Functions

 lpsm_wrapper (notifier_type notify, periph::ADCClient &client)
 Construct an instance. More...
 
template<typename Client = periph::ADCClient>
Client & client () const
 
int lpsm_calibrate ()
 Initiate a calibration. More...
 
int lpsm_bypass_calibration ()
 Set the internal flag that indicates calibration has been performed. More...
 
- Public Member Functions inherited from nrfcxx::lpm::lpsm_capable
virtual int lpsm_start ()
 Validate and prepare to initiate an LPM collection. More...
 
virtual int lpsm_sample ()
 Ask the LPM infrastructure to initiate a new sample. More...
 
lpm::state_machine::process_flags_type lpsm_process ()
 Make progress on an LPM collection. More...
 
int lpsm_stop ()
 
int lpsm_reset ()
 
int lpsm_process_rc () const
 Get the internal result code from the last invocation of lpsm_process_(). More...
 
const lpm::state_machinemachine () const
 Gain read-only access to the LPM machine state.
 

Static Public Attributes

static constexpr auto PF_CALIBRATED = lpm::state_machine::PF_APP_BASE << 0
 Sensor-specific indication from lpm::lpsm_capable::lpsm_process() that the ADC has been calibrated.
 

Additional Inherited Members

- Protected Types inherited from nrfcxx::lpm::lpsm_capable
using state_type = state_machine::state_type
 
using process_flags_type = state_machine::process_flags_type
 
- Protected Member Functions inherited from nrfcxx::lpm::lpsm_capable
 lpsm_capable (notifier_type notify)
 Create a state machine that records state and supports delayed transitions. More...
 
virtual int lpsm_process_ (int &delay, process_flags_type &pf)
 Override to implement machine-specific operations of lpsm_process(). More...
 
- Protected Attributes inherited from nrfcxx::lpm::lpsm_capable
state_machine machine_
 

Detailed Description

A class that implements an LPM state machine around a periph::ADCClient.

The state machine handles coordination of sampling and calibration, provides API to initiate a sample or calibration, and ensures client-specific operations to prepare for and cleanup after measurements are executed at the appropriate time.

lpm::lpsm_capable::lpsm_process() for this client returns the following flags:

lpsm_calibrate() should be invoked by the application on startup and whenever the ambient temperature changes by more than 10 Cel from the last calibration. Alternatively, applications may invoke lpsm_bypass_calibration() to indicate that calibration is managed externally.

Constructor & Destructor Documentation

◆ lpsm_wrapper()

nrfcxx::sensor::adc::lpsm_wrapper::lpsm_wrapper ( notifier_type  notify,
periph::ADCClient client 
)
inline

Construct an instance.

Parameters
notifyas with lpm::state_machine::state_machine.

Member Function Documentation

◆ lpsm_bypass_calibration()

int nrfcxx::sensor::adc::lpsm_wrapper::lpsm_bypass_calibration ( )

Set the internal flag that indicates calibration has been performed.

Applications may want to do this when calibration is managed through an external process.

Returns
zero on success, or an error if the machine is not in a state where calibration is allowed.

◆ lpsm_calibrate()

int nrfcxx::sensor::adc::lpsm_wrapper::lpsm_calibrate ( )

Initiate a calibration.

Returns
zero on success, or an error if the machine is not in a state where calibration is allowed.

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