diff --git a/hardware/arduino/sam/cores/sam/wiring_analog.c b/hardware/arduino/sam/cores/sam/wiring_analog.c index da3ba8f44..0ef841004 100644 --- a/hardware/arduino/sam/cores/sam/wiring_analog.c +++ b/hardware/arduino/sam/cores/sam/wiring_analog.c @@ -107,6 +107,47 @@ uint32_t analogRead(uint32_t ulPin) } #endif +#if defined __SAM3X8E__ + switch ( g_APinDescription[ulPin].ulAnalogChannel ) + { + // Handling ADC 10 bits channels + case ADC0 : + case ADC1 : + case ADC2 : + case ADC3 : + case ADC4 : + case ADC5 : + case ADC6 : + case ADC7 : + case ADC8 : + case ADC9 : + case ADC10 : + case ADC11 : // Enable the corresponding channel + adc_enable_channel( ADC, ulChannel ); + + // Start the ADC + adc_start( ADC ); + + // Wait for end of conversion + while ((adc_get_status(ADC) & (1<