2121#define __ADVANCED_ADC_H__
2222
2323#include " AdvancedAnalog.h"
24+ #if __has_include("pure_analog_pins.h")
25+ #include " pure_analog_pins.h"
26+ #endif
2427
2528struct adc_descr_t ;
2629
@@ -41,14 +44,22 @@ class AdvancedADC {
4144 adc_descr_t *descr;
4245 PinName adc_pins[AN_MAX_ADC_CHANNELS];
4346
47+ template <typename P>
48+ static inline PinName _toPinName (P p) {
49+ return analogPinToPinName (p);
50+ }
51+ #if __has_include("pure_analog_pins.h")
52+ static PinName _toPinName (PureAnalogPin p);
53+ #endif
54+
4455 public:
45- template <typename ... T >
46- AdvancedADC (pin_size_t p0, T ... args ): n_channels(0 ), descr(nullptr ) {
47- static_assert (sizeof ...(args ) < AN_MAX_ADC_CHANNELS,
56+ template <typename P0, typename ... P >
57+ AdvancedADC (P0 p0, P ... pins ): n_channels(0 ), descr(nullptr ) {
58+ static_assert (sizeof ...(pins ) < AN_MAX_ADC_CHANNELS,
4859 " A maximum of 16 channels can be sampled successively." );
4960
50- for (auto p : {p0, args ...}) {
51- adc_pins[n_channels++] = analogPinToPinName (p) ;
61+ for (PinName pin : { _toPinName (p0), _toPinName (pins) ... }) {
62+ adc_pins[n_channels++] = pin ;
5263 }
5364 }
5465 AdvancedADC (): n_channels(0 ), descr(nullptr ) {
@@ -72,6 +83,11 @@ class AdvancedADC {
7283 n_channels = n_pins;
7384 return begin (resolution, sample_rate, n_samples, n_buffers, start, sample_time);
7485 }
86+ #if __has_include("pure_analog_pins.h")
87+ int begin (uint32_t resolution, uint32_t sample_rate, size_t n_samples,
88+ size_t n_buffers, size_t n_pins, PureAnalogPin *pins, bool start=true ,
89+ adc_sample_time_t sample_time=AN_ADC_SAMPLETIME_8_5);
90+ #endif
7591 int start (uint32_t sample_rate);
7692 int stop ();
7793 void clear ();
0 commit comments