mixer-slider/firmware/slider/adc.h

56 lines
881 B
C
Raw Normal View History

2019-02-09 21:33:45 +01:00
/*
* adc.h
*
* Created on: 08.02.2019
* Author: julian
*/
#ifndef ADC_H_
#define ADC_H_
#include <stdint.h>
typedef uint16_t adc_sample_t;
typedef struct {
adc_sample_t * ptr;
uint8_t size;
} adc_buffer_t;
typedef void (*adc_interrupt_t)(volatile adc_buffer_t * buf);
typedef struct adc {
adc_buffer_t buffer;
uint8_t current_channel;
adc_sample_t * current_sample;
uint8_t channel_mask;
adc_interrupt_t interrupt;
} adc_t;
// the adc instance
extern volatile adc_t adc;
enum {
ADC_CHANNEL_0 = 0x01,
ADC_CHANNEL_1 = 0x02,
ADC_CHANNEL_2 = 0x04,
ADC_CHANNEL_3 = 0x08,
ADC_CHANNEL_4 = 0x10,
ADC_CHANNEL_5 = 0x20,
ADC_CHANNEL_6 = 0x40,
ADC_CHANNEL_7 = 0x80,
ADC_CHANNEL_ALL = 0xFF,
};
void adc_init(adc_buffer_t buffer, uint8_t channel_mask);
void adc_on_done(adc_interrupt_t interrupt);
void adc_start();
void adc_stop();
#endif /* ADC_H_ */