← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff
path: root/include/EZADC.h
blob: 08b66ef1666e19a8c028b36cecca4f91534f36ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "esp_log.h"
#include "esp_adc/adc_oneshot.h"
#include "esp_adc/adc_cali.h"
#include "esp_adc/adc_cali_scheme.h"

static int adc_raw[2][10];
static int voltage[2][10];

typedef struct {
  adc_oneshot_unit_handle_t adc_handle;
  adc_oneshot_unit_init_cfg_t adc_init_config;
  adc_oneshot_chan_cfg_t adc_config;
  adc_cali_handle_t adc_cali_handle;
  adc_cali_line_fitting_config_t cali_config;
  adc_channel_t channel;
} ADC;

static const adc_channel_t ezadc_channel[] = {ADC_CHANNEL_0,
					      ADC_CHANNEL_1,
					      ADC_CHANNEL_2,
					      ADC_CHANNEL_3,
					      ADC_CHANNEL_4,
					      ADC_CHANNEL_5,
					      ADC_CHANNEL_6,
					      ADC_CHANNEL_7,
					      ADC_CHANNEL_8,
					      ADC_CHANNEL_9};

void init_adc(ADC* adc);

void config_adc(ADC* adc, int config_channel);

void teardown_adc(ADC* adc);

int ez_read(ADC* adc);//, int adc_raw[2][10], int voltage[2][10]);