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

ADC instance to measure board Vdd. More...

#include <nrfcxx/sensor/adc.hpp>

Inheritance diagram for nrfcxx::sensor::adc::vdd:
nrfcxx::periph::ADCClient

Public Types

using vdd_callback_bi = std::function< void(unsigned int vdd_mV)>
 Type for a function invoked from the ADC IRQ to provide the calculated VDD. More...
 
- Public Types inherited from nrfcxx::periph::ADCClient
using flags_type = unsigned int
 Type for client-specific flags.
 
using queued_callback_type = std::function< void(int rc)>
 Signature for application notification of completed queue operation. More...
 
using peripheral = ADC::peripheral
 
using mutex_type = peripheral::mutex_type
 Mutex required to inhibit ADC interrupts.
 

Public Member Functions

 vdd (vdd_callback_bi callback=nullptr)
 Construct an instance that measures board Vdd. More...
 
int convert_adc16_mV (unsigned int vdd_adc16) const
 Convert a measured voltage to VDD voltage. More...
 
unsigned int vdd_mV () const
 Return the result of the most recent measurement. More...
 
- Public Member Functions inherited from nrfcxx::periph::ADCClient
virtual ~ADCClient ()
 Release the peripheral when the client is destructed.
 
int claim ()
 Attempt to claim exclusive use of the ADC peripheral. More...
 
int release ()
 Release the ADC peripheral. More...
 
int calibrate (const notifier_type &notify={})
 Calibrate the ADC. More...
 
virtual int sample_setup ()
 Overridable function to set up for an ADC measurement. More...
 
virtual void sample_teardown ()
 Reverse the effects of sample_setup_(). More...
 
int sample (const notifier_type &notify={})
 Trigger a client-specific collection. More...
 
int queue (const notifier_type &notify, const queued_callback_type &qnotify={}, bool calibrate=false)
 Queue an operation to be initiated as soon as the ADC becomes available. More...
 
int queue (bool calibrate=false)
 Overload when no notifications are required. More...
 

Additional Inherited Members

- Protected Types inherited from nrfcxx::periph::ADCClient
enum  flags_e : flags_type { FL_QUEUED_SAMPLE = 0x0001, FL_QUEUED_CALIBRATE = 0x0002, FL_QUEUED_Msk = FL_QUEUED_SAMPLE | FL_QUEUED_CALIBRATE, FL_SUBCLASS_BASE = 0x0010 }
 Defined values for flags. More...
 
- Protected Member Functions inherited from nrfcxx::periph::ADCClient
int sample_bi_ (const notifier_type &notify)
 Implements sample() given that the mutex is already held.
 
void complete_queue_bi_ ()
 
virtual int nrf51_next_bi_ (size_t ci)
 Function used to reconfigure ADC for next sample within the collection. More...
 
- Static Protected Member Functions inherited from nrfcxx::periph::ADCClient
static void process_queue_bi_ ()
 
- Protected Attributes inherited from nrfcxx::periph::ADCClient
flags_type flags_ = 0
 Flags for use by the core infrastructure and client specifications. More...
 

Detailed Description

ADC instance to measure board Vdd.

Member Typedef Documentation

◆ vdd_callback_bi

using nrfcxx::sensor::adc::vdd::vdd_callback_bi = std::function<void(unsigned int vdd_mV)>

Type for a function invoked from the ADC IRQ to provide the calculated VDD.

Note
Functions of this type will be invoked by the ADC IRQ and so are treated as though within a mutex-protected scope.
Unlike the callback provided to a base ADC module there is no provision to control the ADC within the callback.
Parameters
vdd_mVthe calculated Vdd expressed in millivolts.

Constructor & Destructor Documentation

◆ vdd()

nrfcxx::sensor::adc::vdd::vdd ( vdd_callback_bi  callback = nullptr)
inline

Construct an instance that measures board Vdd.

Parameters
callbackoptional callback to provide the result to the application. This is invoked after the result has been stored in the instance. If no callback is provided there is no notification that the result has completed.

Member Function Documentation

◆ convert_adc16_mV()

int nrfcxx::sensor::adc::vdd::convert_adc16_mV ( unsigned int  vdd_adc16) const

Convert a measured voltage to VDD voltage.

Parameters
vdd_adc16the measured voltage in 16-bit ADC counts.
Returns
The estimated digital voltage in millivolts.

◆ vdd_mV()

unsigned int nrfcxx::sensor::adc::vdd::vdd_mV ( ) const
inline

Return the result of the most recent measurement.

The value is zeroed on successful invocation of trigger(), and is set to the measured Vdd value only when conversion completes.

Returns
the measured Vdd in millivolts.

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