22 lines
524 B
C
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_ */
|