63 LOGw(
"No space to allocate buf");
69 LOGw(
"No space to allocate samples buf");
85 return _buf[buffer_id];
95 _buf[buffer_id] = ptr;
139 static_assert(std::is_unsigned<adc_sample_value_id_t>::value,
"value id should be unsigned");
161 static_assert(std::is_unsigned<adc_sample_value_id_t>::value,
"value id should be unsigned");
166 buf[value_id_in_channel] = value;
Class that keeps up the buffers used for ADC.
Definition: cs_AdcBuffer.h:35
static constexpr adc_sample_value_id_t getBufferLength()
Get total number of samples in a buffer.
Definition: cs_AdcBuffer.h:102
AdcBuffer()
Definition: cs_AdcBuffer.h:40
AdcBuffer(AdcBuffer const &)
Definition: cs_AdcBuffer.h:41
cs_ret_code_t init()
Allocate the buffers.
Definition: cs_AdcBuffer.h:56
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.
Definition: cs_AdcBuffer.h:137
static AdcBuffer & getInstance()
Singleton implementation.
Definition: cs_AdcBuffer.h:48
static constexpr adc_buffer_id_t getBufferCount()
Get number of buffers.
Definition: cs_AdcBuffer.h:123
adc_buffer_t * getBuffer(adc_buffer_id_t buffer_id)
Get buffer with given id.
Definition: cs_AdcBuffer.h:83
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.
Definition: cs_AdcBuffer.h:156
bool _allocated
Definition: cs_AdcBuffer.h:38
adc_buffer_t * _buf[ADC_BUFFER_COUNT]
Definition: cs_AdcBuffer.h:37
static constexpr adc_sample_value_id_t getChannelLength()
Get number of samples for each channel in a buffer.
Definition: cs_AdcBuffer.h:109
static constexpr adc_channel_id_t getChannelCount()
Get number of channels per buffer.
Definition: cs_AdcBuffer.h:116
static const adc_buffer_id_t ADC_BUFFER_COUNT
Definition: cs_AdcBuffer.h:27
static const adc_channel_id_t ADC_CHANNEL_COUNT
Definition: cs_AdcBuffer.h:18
static const uint32_t ADC_BUFFER_SAMPLE_COUNT
Definition: cs_AdcBuffer.h:24
static const adc_sample_value_id_t ADC_CHANNEL_SAMPLE_COUNT
Definition: cs_AdcBuffer.h:21
#define CS_ADC_NUM_CHANNELS
Definition: cs_Config.h:147
#define CS_ADC_NUM_BUFFERS
Definition: cs_Config.h:151
#define CS_ADC_NUM_SAMPLES_PER_CHANNEL
Definition: cs_Config.h:148
@ ERR_SUCCESS
Definition: cs_ErrorCodes.h:10
@ ERR_NO_SPACE
Definition: cs_ErrorCodes.h:25
#define assert(expr, message)
Author: Crownstone Team Date: 21 Sep., 2013 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-...
Definition: cs_Error.h:22
#define LOGw(fmt,...)
Definition: cs_Logger.h:92
#define LOGd(fmt,...)
Definition: cs_Logger.h:90
uint8_t adc_buffer_id_t
Definition: cs_Typedefs.h:30
int16_t adc_sample_value_t
Definition: cs_Typedefs.h:34
uint16_t cs_ret_code_t
Definition: cs_Typedefs.h:21
uint8_t adc_channel_id_t
Definition: cs_Typedefs.h:31
uint16_t adc_sample_value_id_t
Definition: cs_Typedefs.h:33
Struct communicated from the ADC class when it's done sampling a buffer.
Definition: cs_PacketsInternal.h:346
adc_sample_value_t * samples
Pointer to the samples.
Definition: cs_PacketsInternal.h:369