Chrispy
High-performance multichannel ADC sampling and audio recording.
Loading...
Searching...
No Matches
Adc.h File Reference
#include <Arduino.h>
#include <stddef.h>
#include <stdint.h>
#include "Timer.h"

Go to the source code of this file.

Data Structures

struct  adc::Channel
 Single ADC channel (pin + metadata). More...
 

Namespaces

namespace  adc
 

Enumerations

enum struct  adc::BitResolution : uint8_t { adc::Eight = 8 , adc::Ten = 10 }
 Supported bit resolutions for ADC sampling. More...
 
enum struct  adc::AutotriggerSource : uint8_t {
  adc::FreeRunning = 0b000 , adc::AnalogComparator = 0b001 , adc::ExternalIrq0 = 0b010 , adc::TimCnt0CmpA = 0b011 ,
  adc::TimCnt0Ovf = 0b100 , adc::TimCnt1CmpB = 0b101 , adc::TimCnt1Ovf = 0b110 , adc::TimCnt1Cap = 0b111
}
 Potential sources for ADC interrupts to be triggered by. More...
 

Functions

size_t adc::bytes_per_sample (BitResolution res)
 
bool adc::init (uint8_t _nchannels, Channel *_channels, uint8_t *_buf, size_t _sz)
 Initialize ADC module with these parameters for sampling.
 
int8_t adc::start (BitResolution res, uint32_t sample_rate, size_t ch_window_sz=1, uint32_t warmup_ms=100)
 Start ADC sampling at a certain rate with a given bit resolution.
 
uint32_t adc::stop ()
 Stops ADC sampling and performs cleanup on registers.
 
uint32_t adc::collected ()
 
void adc::on ()
 Activate internal board's ADC.
 
void adc::off ()
 Turn off ADC.
 
void adc::sleep ()
 Turn off ADC and enter sleep mode.
 
int8_t adc::swap_buffer (uint8_t **buf, size_t &sz, size_t &ch_index)
 Retrieve a buffer from the module belonging to a specific channel, writing the size and channel index to the reference arguments.
 
int8_t adc::drain_buffer (uint8_t **buf, size_t &sz, size_t &ch_index)
 NOT SAFE TO USE WHEN THE ADC IS ENABLED!