2626
2727struct adc_descr_t ;
2828
29+ typedef enum {
30+ AN_ADC_SAMPLETIME_1_5 = ADC_SAMPLETIME_1CYCLE_5,
31+ AN_ADC_SAMPLETIME_2_5 = ADC_SAMPLETIME_2CYCLES_5,
32+ AN_ADC_SAMPLETIME_8_5 = ADC_SAMPLETIME_8CYCLES_5,
33+ AN_ADC_SAMPLETIME_16_5 = ADC_SAMPLETIME_16CYCLES_5,
34+ AN_ADC_SAMPLETIME_32_5 = ADC_SAMPLETIME_32CYCLES_5,
35+ AN_ADC_SAMPLETIME_64_5 = ADC_SAMPLETIME_64CYCLES_5,
36+ AN_ADC_SAMPLETIME_387_5 = ADC_SAMPLETIME_387CYCLES_5,
37+ AN_ADC_SAMPLETIME_810_5 = ADC_SAMPLETIME_810CYCLES_5,
38+ } adc_sample_time_t ;
39+
2940class AdvancedADC {
3041 private:
3142 size_t n_channels;
@@ -49,9 +60,10 @@ class AdvancedADC {
4960 bool available ();
5061 SampleBuffer read ();
5162 int begin (uint32_t resolution, uint32_t sample_rate, size_t n_samples,
52- size_t n_buffers, bool start=true );
63+ size_t n_buffers, bool start=true , adc_sample_time_t sample_time=AN_ADC_SAMPLETIME_8_5 );
5364 int begin (uint32_t resolution, uint32_t sample_rate, size_t n_samples,
54- size_t n_buffers, size_t n_pins, pin_size_t *pins, bool start=true ) {
65+ size_t n_buffers, size_t n_pins, pin_size_t *pins, bool start=true ,
66+ adc_sample_time_t sample_time=AN_ADC_SAMPLETIME_8_5) {
5567 if (n_pins > AN_MAX_ADC_CHANNELS) {
5668 n_pins = AN_MAX_ADC_CHANNELS;
5769 }
@@ -60,7 +72,7 @@ class AdvancedADC {
6072 }
6173
6274 n_channels = n_pins;
63- return begin (resolution, sample_rate, n_samples, n_buffers, start);
75+ return begin (resolution, sample_rate, n_samples, n_buffers, start, sample_time );
6476 }
6577 int start (uint32_t sample_rate);
6678 int stop ();
@@ -79,7 +91,8 @@ class AdvancedADCDual {
7991 n_channels (0 ), adc1(adc1_in), adc2(adc2_in) {
8092 }
8193 ~AdvancedADCDual ();
82- int begin (uint32_t resolution, uint32_t sample_rate, size_t n_samples, size_t n_buffers);
94+ int begin (uint32_t resolution, uint32_t sample_rate, size_t n_samples,
95+ size_t n_buffers, adc_sample_time_t sample_time=AN_ADC_SAMPLETIME_8_5);
8396 int stop ();
8497};
8598
0 commit comments