Merge pull request #1634 from cmaglie/adc-fix

Improved ADC speed on Arduino Due
This commit is contained in:
Cristian Maglie 2013-11-12 00:57:28 -08:00
commit 3ba9480972
1 changed files with 6 additions and 2 deletions

View File

@ -130,6 +130,7 @@ uint32_t analogRead(uint32_t ulPin)
#endif
#if defined __SAM3X8E__ || defined __SAM3X8H__
static uint32_t latestSelectedChannel = -1;
switch ( g_APinDescription[ulPin].ulAnalogChannel )
{
// Handling ADC 12 bits channels
@ -147,7 +148,10 @@ uint32_t analogRead(uint32_t ulPin)
case ADC11 :
// Enable the corresponding channel
adc_enable_channel( ADC, ulChannel );
if (ulChannel != latestSelectedChannel) {
adc_enable_channel( ADC, ulChannel );
latestSelectedChannel = ulChannel;
}
// Start the ADC
adc_start( ADC );
@ -161,7 +165,7 @@ uint32_t analogRead(uint32_t ulPin)
ulValue = mapResolution(ulValue, ADC_RESOLUTION, _readResolution);
// Disable the corresponding channel
adc_disable_channel(ADC, ulChannel);
//adc_disable_channel(ADC, ulChannel);
break;