ECE3849/sampling.h
Killorin 15a478c9aa Switched to DMA
84% load with 1Msps no DMA

2.4% load with 2Msps with DMA
2025-04-24 10:40:44 -04:00

22 lines
524 B
C

#ifndef SAMPLING_H_
#define SAMPLING_H_
#include <stdint.h>
#define ADC_BUFFER_SIZE 2048 // size must be a power of 2
// index wrapping macro
#define ADC_BUFFER_WRAP(i) ((i) & (ADC_BUFFER_SIZE - 1))
volatile int32_t gADCBufferIndex;
volatile uint16_t gADCBuffer[ADC_BUFFER_SIZE]; // circular buffer
volatile uint32_t gADCErrors; // number of missed ADC deadlines
// initialize ADC and ISR
void start_sampler(void);
void set_frequency(uint64_t microseconds);
int32_t getADCBufferIndex(void);
#endif /* SAMPLING_H_ */