ADCDMAGen3_RK
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
ADCDMAGen3 Class Reference

Analog to digital conversion using DMA for Particle Gen 3 devices (Argon, Boron, Xenon) More...

#include <ADCDMAGen3_RK.h>

Public Member Functions

ret_code_t init ()
 Initialize the ADC. More...
 
void start ()
 Start sampling. More...
 
void stop ()
 Stop sampling.
 
void uninit ()
 Uninitialize the ADC and free its resources. More...
 
void restoreDefaults ()
 Restore the bit size, oversampling, and IRQ settings used by analogRead().
 
ADCDMAGen3withSingleBuffer (size_t size)
 Set a single buffer of the specified size, allocated on the heap during init() More...
 
ADCDMAGen3withSingleBuffer (size_t size, nrf_saadc_value_t *buf)
 Set a single buffer of the specified size and pointer to buffer. More...
 
ADCDMAGen3withDoubleBuffer (size_t size)
 Set double buffers, each one of the specified size, allocated on the heap during init() More...
 
ADCDMAGen3withDoubleBuffer (size_t size, nrf_saadc_value_t *buf0, nrf_saadc_value_t *buf1)
 Set double buffers, each one of the specified size. More...
 
ADCDMAGen3withDoubleBufferSplit (size_t size, nrf_saadc_value_t *buf)
 Set double buffers, created by taking a larger buffer and splitting it into two halves. More...
 
ADCDMAGen3withSampleFreqHz (size_t sampleFreqHz)
 Sets the sampling frequency. More...
 
size_t getSampleFreqHz () const
 Gets the sampling frequency in Hertz (samples per second).
 
ADCDMAGen3withHardwareTimer (nrfx_timer_t hardwareTimer)
 Sets the hardware timer to use if using automatic acquisition. More...
 
ADCDMAGen3withResolution (nrf_saadc_resolution_t resolution)
 Sets the ADC resolution. More...
 
nrf_saadc_resolution_t getResolution () const
 Gets the ADC resolution. More...
 
ADCDMAGen3withOversample (nrf_saadc_oversample_t oversample, nrf_saadc_burst_t burst)
 Sets the oversampling mode and burst mode. More...
 
nrf_saadc_oversample_t getOversample () const
 Get the oversample setting. More...
 
nrf_saadc_burst_t getBurstMode () const
 Get the burstMode setting (true = burst mode enabled, false = disabled) More...
 
ADCDMAGen3withInterruptPriority (uint8_t interruptPriority)
 Sets the interrupt priority for ADC interrupts. More...
 
uint8_t getInterruptPriority () const
 Gets the interrupt priority. More...
 
ADCDMAGen3withReferenceGain (nrf_saadc_reference_t reference, nrf_saadc_gain_t gain)
 Set ADC reference and gain. More...
 
nrf_saadc_reference_t getReference () const
 Gets the voltage reference. More...
 
nrf_saadc_gain_t getGain () const
 Get the gain. More...
 
ADCDMAGen3withAcqTime (nrf_saadc_acqtime_t acqTime)
 Get the acquisition time. More...
 
nrf_saadc_acqtime_t getAcqTime () const
 Get the acquisition time setting. More...
 
ADCDMAGen3withSamplePin (pin_t pin)
 Sample a single pin. More...
 
ADCDMAGen3withSampleMultiplePins (std::initializer_list< pin_t > pins)
 Sample multiple pins. More...
 
ADCDMAGen3withTimerCcChannel (nrf_timer_cc_channel_t timerCcChannel)
 Set the timer CC channel. The default is NRF_TIMER_CC_CHANNEL0. More...
 
nrf_timer_cc_channel_t getTimerCcChannel () const
 Gets the timer CC channel.
 
ADCDMAGen3withTimerShortMask (nrf_timer_short_mask_t timerShortMask)
 Set the timer short mask. The default is NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK. More...
 
nrf_timer_short_mask_t getTimerShortMask () const
 Get the timer short mask.
 
ADCDMAGen3withContinuousMode (bool continuousMode=true)
 Enable continuous mode. This is the default. More...
 
ADCDMAGen3withOneShotMode ()
 Enable one-shot mode (the opposite of continuous mode) More...
 
ADCDMAGen3withBufferCallback (std::function< void(nrf_saadc_value_t *buf, size_t size)> bufferCallback)
 Sets the buffer callback function. More...
 
nrf_saadc_input_t particlePinToAIN (pin_t pin) const
 Convert a Particle Pin A0 - A7 into the underlying ADC channel. More...
 
void attachTimerInterrupt ()
 Attaches the timer interrupt to user code for the specified hardwareTimer. More...
 
void detachTimerInterrupt ()
 Detaches the timer interrupt for the specified hardwareTimer. More...
 
void freeBufferPoolIfNecessary ()
 Frees allocated buffer pools (if they were allocated and not passed in)
 

Protected Types

enum  SetupState {
  NOT_INITIALIZED, ATTACH_INTERRUPT, SAADC_INIT, TIMER_INIT,
  PPI_ALLOC, COMPLETE
}
 State constants for how much of the initialization completed.
 

Protected Member Functions

void adcCallback (nrfx_saadc_evt_t const *event)
 ADC callback function. More...
 

Static Protected Member Functions

static void timerCallbackStatic (nrf_timer_event_t eventType, void *context)
 Timer callback function. More...
 
static void adcCallbackStatic (nrfx_saadc_evt_t const *event)
 ADC callback function. More...
 
static void adcEmptyCallbackStatic (nrfx_saadc_evt_t const *event)
 ADC callback function used by restoreDefaults.
 

Protected Attributes

size_t sampleFreqHz = 16000
 Sample frequency in Hertz (samples per second) More...
 
nrfx_timer_t hardwareTimer = NRFX_TIMER_INSTANCE(4)
 The hardware timer to use. More...
 
nrfx_saadc_config_t saadcConfig = NRFX_SAADC_DEFAULT_CONFIG
 SAADC configuration. More...
 
nrf_saadc_channel_config_t channelConfig = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1)
 SAADC channel configuration. More...
 
nrfx_timer_config_t timerConfig = NRFX_TIMER_DEFAULT_CONFIG
 Timer configuration. More...
 
nrf_timer_cc_channel_t timerCcChannel = NRF_TIMER_CC_CHANNEL0
 Timer CC channel. More...
 
nrf_timer_short_mask_t timerShortMask = NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK
 Timer Short Mask. More...
 
std::vector< pin_t > pinList
 List of pins to sample. More...
 
size_t bufferSize = 512
 Buffer size. More...
 
size_t poolSize = 2
 Number of buffers (1 or 2) More...
 
nrf_saadc_value_t * bufferPool [2] = { 0, 0 }
 Pointers to the buffers. The number of non-zero entries depends on poolSize. More...
 
bool freeBufferPool = true
 Whether to delete[] the buffers when calling freeBufferPoolIfNecessary() More...
 
SetupState setupState = SetupState::NOT_INITIALIZED
 State constants for how far the initialization completed. More...
 
nrf_ppi_channel_t ppiChannel = NRF_PPI_CHANNEL0
 The PPI channel to use. More...
 
bool continuousMode = true
 Whether the sampling is one-shot or continuous. More...
 
std::function< void(nrf_saadc_value_t *buf, size_t size)> bufferCallback = 0
 

Static Protected Attributes

static ADCDMAGen3instance = 0
 

Detailed Description

Analog to digital conversion using DMA for Particle Gen 3 devices (Argon, Boron, Xenon)

Note: You can only instantiate one of these per application since there can only be one ADC DMA in use at a time (though you can sample multiple channels).

Configuration is done using the withXXX() methods and can be chained, fluent-style.

After setting it up, use the init() method to initialize the ADC DMA.

Member Function Documentation

◆ adcCallback()

void ADCDMAGen3::adcCallback ( nrfx_saadc_evt_t const *  event)
protected

ADC callback function.

This is called from adcCallbackStatic when an ADC event occurs. It calls bufferCallback if defined on NRFX_SAADC_EVT_DONE.

◆ adcCallbackStatic()

void ADCDMAGen3::adcCallbackStatic ( nrfx_saadc_evt_t const *  event)
staticprotected

ADC callback function.

This is the callback function passed to nrfx_saadc_init. It calls addCallback (not static) using the instance static member to find the class instance (there can only be one).

◆ attachTimerInterrupt()

void ADCDMAGen3::attachTimerInterrupt ( )

Attaches the timer interrupt to user code for the specified hardwareTimer.

Calls attachInterruptDirect() based on hardwareTimer.p_reg

◆ detachTimerInterrupt()

void ADCDMAGen3::detachTimerInterrupt ( )

Detaches the timer interrupt for the specified hardwareTimer.

Calls detachInterrupt() based on hardwareTimer.p_reg

◆ getAcqTime()

nrf_saadc_acqtime_t ADCDMAGen3::getAcqTime ( ) const
inline

Get the acquisition time setting.

See withAcqTime() for values.

◆ getBurstMode()

nrf_saadc_burst_t ADCDMAGen3::getBurstMode ( ) const
inline

Get the burstMode setting (true = burst mode enabled, false = disabled)

See withOversample() for for information.

◆ getGain()

nrf_saadc_gain_t ADCDMAGen3::getGain ( ) const
inline

Get the gain.

See withReferenceGain() for values.

◆ getInterruptPriority()

uint8_t ADCDMAGen3::getInterruptPriority ( ) const
inline

Gets the interrupt priority.

See withInterruptPriority() for values

◆ getOversample()

nrf_saadc_oversample_t ADCDMAGen3::getOversample ( ) const
inline

Get the oversample setting.

See withOversample() for values

◆ getReference()

nrf_saadc_reference_t ADCDMAGen3::getReference ( ) const
inline

Gets the voltage reference.

See withReferenceGain() for values.

◆ getResolution()

nrf_saadc_resolution_t ADCDMAGen3::getResolution ( ) const
inline

Gets the ADC resolution.

See withResolution() for an explanation of return values.

◆ init()

ret_code_t ADCDMAGen3::init ( )

Initialize the ADC.

You typically use the withXXX() methods to configure the settings, then when you are done, call init().

You can change settings and call init() again if desired.

This call does not start sampling, use start() to do that.

◆ particlePinToAIN()

nrf_saadc_input_t ADCDMAGen3::particlePinToAIN ( pin_t  pin) const

Convert a Particle Pin A0 - A7 into the underlying ADC channel.

Particle ADC nRF pin_p notes Pin Chan Pin 0 P0.02 NRF_SAADC_INPUT_AIN0 A7 on SoMs A0 1 P0.03 NRF_SAADC_INPUT_AIN1 A1 2 P0.04 NRF_SAADC_INPUT_AIN2 3 P0.05 NRF_SAADC_INPUT_AIN3 A6 on SoMs, BAT on Argon and Xenon A2 4 P0.28 NRF_SAADC_INPUT_AIN4 A3 5 P0.29 NRF_SAADC_INPUT_AIN5 A4 6 P0.30 NRF_SAADC_INPUT_AIN6 A5 7 P0.31 NRF_SAADC_INPUT_AIN7

◆ start()

void ADCDMAGen3::start ( )
inline

Start sampling.

The default is to sample continuously (or until stop() is called).

If you use withOneShotMode(), then the first buffer is filled and the sampling is stopped automatically and you should not call stop().

◆ timerCallbackStatic()

void ADCDMAGen3::timerCallbackStatic ( nrf_timer_event_t  eventType,
void *  context 
)
staticprotected

Timer callback function.

This is the callback function passed to nrfx_timer_init. It doesn't currently do anything useful as the timer event is handled by PPI not code.

◆ uninit()

void ADCDMAGen3::uninit ( )

Uninitialize the ADC and free its resources.

You do not need to stop() before uninit(). Once you uninit() you can switch back to using analogRead() however you should also call restoreDefault() to make sure the settings used by analogRead() are restored properly.

◆ withAcqTime()

ADCDMAGen3& ADCDMAGen3::withAcqTime ( nrf_saadc_acqtime_t  acqTime)
inline

Get the acquisition time.

Parameters
acqTimeThe acquisition time value
  • NRF_SAADC_ACQTIME_3US - 3 microseconds
  • NRF_SAADC_ACQTIME_5US - 5 microseconds
  • NRF_SAADC_ACQTIME_10US - 10 microseconds (default)
  • NRF_SAADC_ACQTIME_15US - 15 microseconds
  • NRF_SAADC_ACQTIME_20US - 20 microseconds
  • NRF_SAADC_ACQTIME_40US - 40 microseconds

Longer acquisition times allows for higher resistance inputs, but lower the maximum sampling frequency

◆ withBufferCallback()

ADCDMAGen3& ADCDMAGen3::withBufferCallback ( std::function< void(nrf_saadc_value_t *buf, size_t size)>  bufferCallback)
inline

Sets the buffer callback function.

Parameters
bufferCallbackThe function to call when a buffer is filled

The bufferCallback function must have this prototype:

void bufferCallback(nrf_saadc_value_t *buf, size_t size);

The buf is not used after this call completes, so you can modify it in place if desired for efficiency, but you must not rely on the contents after you return from the callback because it will be reused and filled with new data.

Note that the buffer callback is called from an interrupt context so you must take care in what functions you call from it. In particular:

  • No allocating of memory
  • No long-running code
  • No blocking functions
  • Avoid all Particle.* functions like Particle.publish
  • Beware of using things like Serial.print that are not thread-safe

◆ withContinuousMode()

ADCDMAGen3& ADCDMAGen3::withContinuousMode ( bool  continuousMode = true)
inline

Enable continuous mode. This is the default.

In continuous mode, the ADC is sampled continuously until stop() is called. Each full buffer triggers the bufferCallback.

The opposite of continuous mode is one shot mode, enabled using withOneShotMode().

◆ withDoubleBuffer() [1/2]

ADCDMAGen3 & ADCDMAGen3::withDoubleBuffer ( size_t  size)

Set double buffers, each one of the specified size, allocated on the heap during init()

Parameters
sizesize in samples, not bytes. Each sample is 16-bits (2 bytes). And since it's a double buffer, 4 * size bytes will be allocated on the heap.

Double buffers should be used with continuous mode is enabled (the default).

◆ withDoubleBuffer() [2/2]

ADCDMAGen3 & ADCDMAGen3::withDoubleBuffer ( size_t  size,
nrf_saadc_value_t *  buf0,
nrf_saadc_value_t *  buf1 
)

Set double buffers, each one of the specified size.

Parameters
sizesize in samples, not bytes. Each sample is 16-bits (2 bytes).
buf0Pointer to a buffer of samples. Note that each sample a nrf_saadc_value_t (16 bits, 2 bytes). You must not deallocate this buffer. It's typically allocated as a global variable.
buf1Pointer to a buffer of samples. Note that each sample a nrf_saadc_value_t (16 bits, 2 bytes). You must not deallocate this buffer. It's typically allocated as a global variable.

Double buffers should be used with continuous mode is enabled (the default).

◆ withDoubleBufferSplit()

ADCDMAGen3 & ADCDMAGen3::withDoubleBufferSplit ( size_t  size,
nrf_saadc_value_t *  buf 
)

Set double buffers, created by taking a larger buffer and splitting it into two halves.

Parameters
sizesize in samples, not bytes, of buf Each sample is 16-bits (2 bytes). The sample size will be half that, because the buffer is split into two half-buffers.
bufPointer to a buffer of samples. Note that each sample a nrf_saadc_value_t (16 bits, 2 bytes). You must not deallocate this buffer. It's typically allocated as a global variable.

Double buffers should be used with continuous mode is enabled (the default).

◆ withHardwareTimer()

ADCDMAGen3& ADCDMAGen3::withHardwareTimer ( nrfx_timer_t  hardwareTimer)
inline

Sets the hardware timer to use if using automatic acquisition.

  • 0: Softdevice - do not use
  • 1: Radio - probably best to not use, might work if not using BLE or mesh
  • 2: Usart (Serial1) Can use if not using Serial1.
  • 3: Usart (Serial2 on Xenon) Cannot be used on Argon or Boron because it's required by NCP.
  • 4: NFC - recommended (unless you need NFC). This is the default.

Using a hardware timer is necessary to control the frequency of sampling. It's possible to manually trigger a single sample, but that tends to not be very useful and isn't supported by this library.

◆ withInterruptPriority()

ADCDMAGen3& ADCDMAGen3::withInterruptPriority ( uint8_t  interruptPriority)
inline

Sets the interrupt priority for ADC interrupts.

  • APP_IRQ_PRIORITY_HIGHEST
  • APP_IRQ_PRIORITY_HIGH
  • APP_IRQ_PRIORITY_MID
  • APP_IRQ_PRIORITY_LOW (default)
  • APP_IRQ_PRIORITY_LOWEST

◆ withOneShotMode()

ADCDMAGen3& ADCDMAGen3::withOneShotMode ( )
inline

Enable one-shot mode (the opposite of continuous mode)

In one-shot mode, the buffer is filled once then sampling stops. The ADC is left configured. You can resume sampling again using start().

◆ withOversample()

ADCDMAGen3& ADCDMAGen3::withOversample ( nrf_saadc_oversample_t  oversample,
nrf_saadc_burst_t  burst 
)
inline

Sets the oversampling mode and burst mode.

Parameters
oversampleThe oversampling value. The default is disabled.
  • NRF_SAADC_OVERSAMPLE_DISABLED (default)
  • NRF_SAADC_OVERSAMPLE_2X
  • NRF_SAADC_OVERSAMPLE_4X
  • NRF_SAADC_OVERSAMPLE_8X
  • NRF_SAADC_OVERSAMPLE_16X
  • NRF_SAADC_OVERSAMPLE_32X
  • NRF_SAADC_OVERSAMPLE_64X
  • NRF_SAADC_OVERSAMPLE_128X
  • NRF_SAADC_OVERSAMPLE_256X
Parameters
burstEnable burst mode. Default is disabled.
  • NRF_SAADC_BURST_DISABLED (default)
  • NRF_SAADC_BURST_ENABLED

When enabling oversampling, multiple samples are taken and averaged to reduce noise. For example, if NRF_SAADC_OVERSAMPLE_4X is set, then 4 samples are taken and averaged.

If burst mode is enabled, then those 4 samples are taken as quickly as possible.

If burst mode is disabled, then those 4 samples are taken one on each trigger, resulting in a buffer taking 4 times longer to fill up, for example.

◆ withReferenceGain()

ADCDMAGen3& ADCDMAGen3::withReferenceGain ( nrf_saadc_reference_t  reference,
nrf_saadc_gain_t  gain 
)
inline

Set ADC reference and gain.

Parameters
referencethe voltage reference
  • NRF_SAADC_REFERENCE_INTERNAL - 0.6V
  • NRF_SAADC_REFERENCE_VDD4 - VDD/4, typically 3.3V, so 0.9V. This is the default and what is used by analogRead()
Parameters
gainthe gain on the input signal
  • NRF_SAADC_GAIN1_6 - 1/6 gain, commonly used with the internal reference to allow for 0 - 3.6V)
  • NRF_SAADC_GAIN1_5 - 1/5 gain
  • NRF_SAADC_GAIN1_4 - 1/4 gain, commonly used with VDD4, so the input is from 0 to VDD (default)
  • NRF_SAADC_GAIN1_3 - 1/3 gain
  • NRF_SAADC_GAIN1_2 - 1/2 gain
  • NRF_SAADC_GAIN1 - no gain
  • NRF_SAADC_GAIN2 - 2x gain
  • NRF_SAADC_GAIN4 - 4x gain

The default setting is NRF_SAADC_REFERENCE_VDD4, NRF_SAADC_GAIN1_4. Another common setting is NRF_SAADC_REFERENCE_INTERNAL, NRF_SAADC_GAIN1_6.

◆ withResolution()

ADCDMAGen3& ADCDMAGen3::withResolution ( nrf_saadc_resolution_t  resolution)
inline

Sets the ADC resolution.

  • NRF_SAADC_RESOLUTION_8BIT
  • NRF_SAADC_RESOLUTION_10BIT
  • NRF_SAADC_RESOLUTION_12BIT (default)
  • NRF_SAADC_RESOLUTION_14BIT

Note that the values stored in the buffer are always 16-bit values (even if the resolution is 8 bit).

◆ withSampleFreqHz()

ADCDMAGen3& ADCDMAGen3::withSampleFreqHz ( size_t  sampleFreqHz)
inline

Sets the sampling frequency.

Parameters
sampleFreqHzThe sampling frequency in Hertz or samples per second. Default is 16000.

Maximum is around 200000 however make sure you also reduce the acqTime to NRF_SAADC_ACQTIME_3US when using the maximum sampling frequency.

◆ withSampleMultiplePins()

ADCDMAGen3& ADCDMAGen3::withSampleMultiplePins ( std::initializer_list< pin_t >  pins)
inline

Sample multiple pins.

Parameters
pinsList of pins

To use this, pass the list of pins within {}. For example:

adc.withSampleMultiplePins( { A0, A1, A2, A3 } );

Calling this replaces the previous list of pins to sample. If withSamplePin() was previously called, that pin will no longer be sampled (unless it's in this list of pins).

To sample a single pin you can pass one pin in the {} or use withSamplePin().

◆ withSamplePin()

ADCDMAGen3& ADCDMAGen3::withSamplePin ( pin_t  pin)
inline

Sample a single pin.

Parameters
pinThe pin. Typically A0 - A5 on Gen 3, except for the B Series SoM which also supports A6 and A7.

Calling this more than once replaces the previously sampled pin. If withSampleMultiplePins was previously called, calling this will sample only this pin.

To sample multiple pins sequentially, use withSampleMultiplePins();

◆ withSingleBuffer() [1/2]

ADCDMAGen3 & ADCDMAGen3::withSingleBuffer ( size_t  size)

Set a single buffer of the specified size, allocated on the heap during init()

Parameters
sizesize in samples, not bytes. Each sample is 16-bits (2 bytes).

Single buffer should only be used in with withOneShotMode(). If you are continuously sampling you should use double buffer mode so writes can continue in the other buffer while you are handling the full buffer.

◆ withSingleBuffer() [2/2]

ADCDMAGen3 & ADCDMAGen3::withSingleBuffer ( size_t  size,
nrf_saadc_value_t *  buf 
)

Set a single buffer of the specified size and pointer to buffer.

Parameters
sizesize in samples, not bytes. Each sample is 16-bits (2 bytes).
bufPointer to a buffer of samples. Note that each sample a nrf_saadc_value_t (16 bits, 2 bytes). You must not deallocate this buffer. It's typically allocated as a global variable.

Single buffer should only be used in with withOneShotMode(). If you are continuously sampling you should use double buffer mode so writes can continue in the other buffer while you are handling the full buffer.

◆ withTimerCcChannel()

ADCDMAGen3& ADCDMAGen3::withTimerCcChannel ( nrf_timer_cc_channel_t  timerCcChannel)
inline

Set the timer CC channel. The default is NRF_TIMER_CC_CHANNEL0.

You probably won't need to change this value. If you do, set it before calling init().

◆ withTimerShortMask()

ADCDMAGen3& ADCDMAGen3::withTimerShortMask ( nrf_timer_short_mask_t  timerShortMask)
inline

Set the timer short mask. The default is NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK.

You probably won't need to change this value. If you do, set it before calling init().

Field Documentation

◆ bufferCallback

std::function<void(nrf_saadc_value_t *buf, size_t size)> ADCDMAGen3::bufferCallback = 0
protected
Parameters
Callbackfunction that is called when a buffer is filled

Note that this callback is called in an interrupt context so you need to be careful about what you do in it. Set it using withBufferCallback().

◆ bufferPool

nrf_saadc_value_t* ADCDMAGen3::bufferPool[2] = { 0, 0 }
protected

Pointers to the buffers. The number of non-zero entries depends on poolSize.

Set using withSingleBuffer() or withDoubleBuffer(). You must set this before calling init().

◆ bufferSize

size_t ADCDMAGen3::bufferSize = 512
protected

Buffer size.

Set using withSingleBuffer() or withDoubleBuffer(). You must set this before calling init().

◆ channelConfig

nrf_saadc_channel_config_t ADCDMAGen3::channelConfig = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1)
protected

SAADC channel configuration.

Note: we override settings in NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE in the constructor for this class. Use with withXXX() methods to change fields before calling init(). The pin is updated before use (multiple times if using multi-pin mode).

You must set this before calling init().

◆ continuousMode

bool ADCDMAGen3::continuousMode = true
protected

Whether the sampling is one-shot or continuous.

The default is continuous. You should always use double buffers when using continuous mode. Use withOneShotMode() to set this to false.

◆ freeBufferPool

bool ADCDMAGen3::freeBufferPool = true
protected

Whether to delete[] the buffers when calling freeBufferPoolIfNecessary()

Set using withSingleBuffer() or withDoubleBuffer(). You should not modify this member.

◆ hardwareTimer

nrfx_timer_t ADCDMAGen3::hardwareTimer = NRFX_TIMER_INSTANCE(4)
protected

The hardware timer to use.

Set using withHardwareTimer(). You must set this before calling init().

◆ instance

ADCDMAGen3 * ADCDMAGen3::instance = 0
staticprotected
Parameters
Globalinstance of this class

Since there is only one SAADC engine on the nRF52, you can only have one instance of this class. It is stored in this variable. It's used from the static callbacks to find the singleton instance of this class.

◆ pinList

std::vector<pin_t> ADCDMAGen3::pinList
protected

List of pins to sample.

Set using withSamplePin() or withSampleMultiplePins(). You must set this before calling init().

◆ poolSize

size_t ADCDMAGen3::poolSize = 2
protected

Number of buffers (1 or 2)

Set using withSingleBuffer() or withDoubleBuffer(). You must set this before calling init().

◆ ppiChannel

nrf_ppi_channel_t ADCDMAGen3::ppiChannel = NRF_PPI_CHANNEL0
protected

The PPI channel to use.

DeviceOS uses PPI channel

◆ saadcConfig

nrfx_saadc_config_t ADCDMAGen3::saadcConfig = NRFX_SAADC_DEFAULT_CONFIG
protected

SAADC configuration.

Note: we override settings in NRFX_SAADC_DEFAULT_CONFIG in the constructor for this class. Use with withXXX() methods to change fields before calling init().

◆ sampleFreqHz

size_t ADCDMAGen3::sampleFreqHz = 16000
protected

Sample frequency in Hertz (samples per second)

Set using withSampleFreqHz(). You must set this before calling init().

◆ setupState

SetupState ADCDMAGen3::setupState = SetupState::NOT_INITIALIZED
protected

State constants for how far the initialization completed.

Set during init() and used during uninit().

◆ timerCcChannel

nrf_timer_cc_channel_t ADCDMAGen3::timerCcChannel = NRF_TIMER_CC_CHANNEL0
protected

Timer CC channel.

You normally don't need to override this setting, but if you do, use withTimerCcChannel() and withTimerShortMask().

Default value is NRF_TIMER_CC_CHANNEL0. You must set this before calling init().

◆ timerConfig

nrfx_timer_config_t ADCDMAGen3::timerConfig = NRFX_TIMER_DEFAULT_CONFIG
protected

Timer configuration.

You normally don't need to override these settings. You must set this before calling init().

◆ timerShortMask

nrf_timer_short_mask_t ADCDMAGen3::timerShortMask = NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK
protected

Timer Short Mask.

You normally don't need to override this setting, but if you do, use withTimerCcChannel() and withTimerShortMask().

Default value is NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK. You must set this before calling init().


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