nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Types | Static Public Member Functions | Static Public Attributes | Friends
nrfcxx::periph::ADC Class Reference

Wrapper around the ADC or SAADC peripheral. More...

#include <nrfcxx/periph.hpp>

Inheritance diagram for nrfcxx::periph::ADC:
nrfcxx::nrf5::series::ADC_Peripheral nrfcxx::nrf5::series::ADC_Base

Public Types

enum  state_type : uint8_t {
  state_type::available, state_type::claimed, state_type::calibrating, state_type::starting,
  state_type::sampling, state_type::stopping
}
 Genericized states of the ADC. More...
 
using peripheral = nrf5::series::ADC_Variant
 The underlying variant traits class.
 

Static Public Member Functions

static void irq_handler ()
 Implementation for ADCSeriesVariant_IRQHandler required by this module.
 
static uint8_t state ()
 Return the current ADC state.
 
static bool busy ()
 Expose the series-specific function. More...
 

Static Public Attributes

static constexpr auto & INSTANCE
 Reference to the variant-specific instance characteristics. More...
 

Friends

class ADCClient
 

Additional Inherited Members

- Protected Types inherited from nrfcxx::nrf5::series::ADC_Peripheral
using mutex_type = mutex_irq< static_cast< IRQn_Type >(nrf5::ADC.IRQn)>
 
- Static Protected Member Functions inherited from nrfcxx::nrf5::series::ADC_Peripheral
static constexpr bool near_zero (uint16_t v_adc16)
 Test whether a value appears to be indistinguishable from zero. More...
 
static constexpr unsigned int make_config (int ain, unsigned int res, unsigned int prescale, unsigned int refsel, unsigned int extrefsel=ADC_CONFIG_EXTREFSEL_None)
 Helper to build up a ADC CONFIG. More...
 
static bool busy ()
 Return true iff the ADC has an in-progress conversion.
 
static void trigger ()
 Initiate an ADC sample with the current configuration. More...
 
static void enable_bi ()
 
static void disable_bi ()
 
static int calibrate_bi ()
 
static int start_bi ()
 
static void stopped_bi ()
 
- Static Protected Member Functions inherited from nrfcxx::nrf5::series::ADC_Base
static void setup_result_bi (volatile uint16_t *ptr, uint16_t maxcnt=1)
 Record the destination address and count of ADC samples. More...
 
- Static Protected Attributes inherited from nrfcxx::nrf5::series::ADC_Peripheral
static constexpr IRQn_Type IRQn = ADC_IRQn
 
static constexpr unsigned int VBG_mV = 1200
 nRF51 reference voltage is 1.2 V.
 
static constexpr uint16_t TOLERANCE_adc16 = (1U << 7)
 ADC offset error is documented +/- 2%, with a 1.5% error for VBG. More...
 
static constexpr uint32_t inten
 
static uint16_t result_idx_
 
- Static Protected Attributes inherited from nrfcxx::nrf5::series::ADC_Base
static volatile uint16_t * result_ptr_
 
static uint16_t result_maxcnt_
 

Detailed Description

Wrapper around the ADC or SAADC peripheral.

The peripheral that provides A2D capabilities is completely incompatible between nRF51 and nRF52. This class extends a series-specific base with basic common functionality. To use it consult the series-specific class that this extends:

All interaction with this is performed using an ADCClient subclass, which may support single or multiple-channel collections.

This module requires that the series-specific IRQ handler process events to fulfill its obligations. To reduce code space this handler is not normally installed. Applications that require must install it by providing this definition in an application implementation source file: extern "C" { void ADCSeriesVariant_IRQHandler (void) { nrfcxx::periph::ADC::irq_handler(); } } and by issuing these commands to enable the peripheral: nvic_SetPriority(nrfcxx::periph::ADC::INSTANCE.IRQn, IRQ_PRIORITY_APP_HIGH); // or APP_LOW nvic_EnableIRQ(nrfcxx::periph::ADC::INSTANCE.IRQn); In addition the ADCClient::calibrate function should be invoked prior to first use and whenever the processor temperature changes by more than 10 Cel.

Member Enumeration Documentation

◆ state_type

enum nrfcxx::periph::ADC::state_type : uint8_t
strong

Genericized states of the ADC.

Enumerator
available 

ADC is unclaimed.

Transitions to claimed on ADCClient::claim().

claimed 

ADC is owned by a client but is not started.

In this state the ADC's configuration may be safely changed.

Transitions:

calibrating 

ADC is being calibrated via ADCClient::calibrate()

Transitions to stopping on receipt of CALIBRATEDONE.

starting 

ADC is in the process of starting via ADCClient::sample()

Transitions to sampling on receipt of STARTED.

sampling 

ADC is collecting a sample via ADCClient::sample()

Transitions to stopping when the sample has been completed.

stopping 

ADC is in the process of stopping in the final stages of ADCClient::calibrate() or ADCClient::sample().

Transitions to claimed on receipt of STOPPED.

Member Function Documentation

◆ busy()

static bool nrfcxx::nrf5::series::ADC_Peripheral::busy
inlinestatic

Expose the series-specific function.

See also
nrf5::series::ADC_Peripheral::busy
nrf5::series::SAADC_Peripheral::busy

Field Documentation

◆ INSTANCE

constexpr auto& nrfcxx::periph::ADC::INSTANCE
staticconstexpr
Initial value:
{
}

Reference to the variant-specific instance characteristics.


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