|
Chrispy
High-performance multichannel ADC sampling and audio recording.
|
Data Structures | |
| struct | adc::AdcFrame |
| Private/static data member for use by the ISR. | |
| struct | adc::Adc |
| Singleton instance of the ADC. | |
Namespaces | |
| namespace | adc |
Macros | |
| #define | TEN_BIT_BIAS 0x1FF |
| #define | TEN_TO_SIXTEEN_BIT(x) (((x) - TEN_BIT_BIAS) << 6) |
| #define | MUX_MASK 0b11111 |
| #define | SOURCE_MASK 0b111 |
| #define | LOW_CHANNEL_MASK 0b111 |
| #define | HIGH_CHANNEL_MASK ~LOW_CHANNEL_MASK |
| #define | PRESCALER_MASK 0b111 |
| #define | DIV_128 0b111 |
| #define | DIV_64 0b110 |
| #define | DIV_32 0b101 |
| #define | DIV_16 0b100 |
| #define | DIV_8 0b011 |
| #define | DIV_4 0b010 |
| #define | DIV_2 0b001 |
| #define | DIV_2_2 0b000 |
| #define | MIN_BUF_SZ_PER_CHANNEL 512 |
| #define | ADC_CYCLES_PER_SAMPLE 13.5 |
Functions | |
| adc::ISR (ADC_vect) | |
| Interrupt service routine responsible for reading samples from the ADC. | |
| int8_t | adc::drain_buffer (uint8_t **buf, size_t &sz, size_t &ch_index) |
| NOT SAFE TO USE WHEN THE ADC IS ENABLED! | |
| 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. | |
| bool | adc::init (uint8_t _nchannels, Channel *_channels, uint8_t *_buf, size_t _sz) |
| Initialize ADC module with these parameters for sampling. | |
| 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::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::collected () |
| uint32_t | adc::stop () |
| Stops ADC sampling and performs cleanup on registers. | |
| size_t | adc::bytes_per_sample (BitResolution res) |
Variables | |
| const size_t | adc::MAX_CHANNEL_COUNT = 16 |
| Number of channels supported by the ADC (0 - 15). | |
| #define ADC_CYCLES_PER_SAMPLE 13.5 |
| #define DIV_128 0b111 |
| #define DIV_16 0b100 |
| #define DIV_2 0b001 |
| #define DIV_2_2 0b000 |
| #define DIV_32 0b101 |
| #define DIV_4 0b010 |
| #define DIV_64 0b110 |
| #define DIV_8 0b011 |
| #define HIGH_CHANNEL_MASK ~LOW_CHANNEL_MASK |
| #define LOW_CHANNEL_MASK 0b111 |
| #define MIN_BUF_SZ_PER_CHANNEL 512 |
| #define MUX_MASK 0b11111 |
| #define PRESCALER_MASK 0b111 |
| #define SOURCE_MASK 0b111 |
| #define TEN_BIT_BIAS 0x1FF |
| #define TEN_TO_SIXTEEN_BIT | ( | x | ) | (((x) - TEN_BIT_BIAS) << 6) |