From 431f3ea5fe7f7810225549e006dcd6588083733b Mon Sep 17 00:00:00 2001 From: Thibaut VIARD Date: Tue, 10 Apr 2012 18:27:43 +0200 Subject: [PATCH] [sam] preliminary update for analog --- .../arduino/sam/cores/sam/wiring_analog.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) 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<