Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
AdcBuffer Class Reference

Class that keeps up the buffers used for ADC. More...

#include <cs_AdcBuffer.h>

Collaboration diagram for AdcBuffer:

Public Member Functions

cs_ret_code_t init ()
 Allocate the buffers. More...
 
adc_buffer_tgetBuffer (adc_buffer_id_t buffer_id)
 Get buffer with given id. More...
 
adc_sample_value_t getValue (adc_buffer_id_t buffer_id, adc_channel_id_t channel_id, adc_sample_value_id_t value_id)
 Get a particular value from a buffer. More...
 
void setValue (adc_buffer_id_t buffer_id, adc_channel_id_t channel_id, adc_sample_value_id_t value_id, adc_sample_value_t value)
 For in-place filtering it is necessary to write a particular value into the buffer. More...
 

Static Public Member Functions

static AdcBuffergetInstance ()
 Singleton implementation. More...
 
static constexpr adc_sample_value_id_t getBufferLength ()
 Get total number of samples in a buffer. More...
 
static constexpr adc_sample_value_id_t getChannelLength ()
 Get number of samples for each channel in a buffer. More...
 
static constexpr adc_channel_id_t getChannelCount ()
 Get number of channels per buffer. More...
 
static constexpr adc_buffer_id_t getBufferCount ()
 Get number of buffers. More...
 

Private Member Functions

 AdcBuffer ()
 
 AdcBuffer (AdcBuffer const &)
 

Private Attributes

adc_buffer_t_buf [ADC_BUFFER_COUNT] = {nullptr}
 
bool _allocated = false
 

Detailed Description

Class that keeps up the buffers used for ADC.

  • Allocates the buffers.
  • Abstracts away the interleaved nature of the ADC samples.

Constructor & Destructor Documentation

◆ AdcBuffer() [1/2]

AdcBuffer::AdcBuffer ( )
inlineprivate

◆ AdcBuffer() [2/2]

AdcBuffer::AdcBuffer ( AdcBuffer const &  )
inlineprivate

Member Function Documentation

◆ getBuffer()

adc_buffer_t * AdcBuffer::getBuffer ( adc_buffer_id_t  buffer_id)
inline

Get buffer with given id.

◆ getBufferCount()

static constexpr adc_buffer_id_t AdcBuffer::getBufferCount ( )
inlinestaticconstexpr

Get number of buffers.

◆ getBufferLength()

static constexpr adc_sample_value_id_t AdcBuffer::getBufferLength ( )
inlinestaticconstexpr

Get total number of samples in a buffer.

◆ getChannelCount()

static constexpr adc_channel_id_t AdcBuffer::getChannelCount ( )
inlinestaticconstexpr

Get number of channels per buffer.

◆ getChannelLength()

static constexpr adc_sample_value_id_t AdcBuffer::getChannelLength ( )
inlinestaticconstexpr

Get number of samples for each channel in a buffer.

◆ getInstance()

static AdcBuffer & AdcBuffer::getInstance ( )
inlinestatic

Singleton implementation.

There is no foreseen need to have multiple objects instantiated. Note that this singleton implementation does not have dynamic memory allocation.

◆ getValue()

adc_sample_value_t AdcBuffer::getValue ( adc_buffer_id_t  buffer_id,
adc_channel_id_t  channel_id,
adc_sample_value_id_t  value_id 
)
inline

Get a particular value from a buffer.

The value_id is a reference to the index of a value within a channel (half of the buffer length).

Parameters
[in]buffer_idIndex to the buffer (0 up to getBufferCount() - 1)
[in]channel_idParticular channel within this buffer (0 or 1)
[in]value_idIndex to the value in the buffer (0 up to getChannelLength() - 1)
Returns
Particular value

◆ init()

cs_ret_code_t AdcBuffer::init ( )
inline

Allocate the buffers.

◆ setValue()

void AdcBuffer::setValue ( adc_buffer_id_t  buffer_id,
adc_channel_id_t  channel_id,
adc_sample_value_id_t  value_id,
adc_sample_value_t  value 
)
inline

For in-place filtering it is necessary to write a particular value into the buffer.

Parameters
[in]buffer_idIndex to the buffer (0 up to getBufferCount() - 1)
[in]channel_idParticular channel within this buffer (0 or 1)
[in]value_idIndex to the value in the buffer
[in]valueValue to be written to the buffer

Member Data Documentation

◆ _allocated

bool AdcBuffer::_allocated = false
private

◆ _buf

adc_buffer_t* AdcBuffer::_buf[ADC_BUFFER_COUNT] = {nullptr}
private

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