1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-18 07:52:14 +01:00

[sam] preliminary update for analog

This commit is contained in:
Thibaut VIARD 2012-04-10 18:27:43 +02:00
parent 650d2e9a1a
commit 431f3ea5fe

View File

@ -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<<ulChannel)) == 0);
// Read the value
ulValue=adc_get_value( ADC, ulChannel );
// Disable the corresponding channel
adc_disable_channel( ADC, ulChannel );
// Stop the ADC
// adc_stop( ADC ) ; // never do adc_stop() else we have to reconfigure the ADC each time
break;
// Compiler could yell because we don't handle DAC pins
default :
ulValue=0;
break;
}
#endif
return ulValue;
}