mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-27 21:54:30 +01:00
Merge pull request #1634 from cmaglie/adc-fix
Improved ADC speed on Arduino Due
This commit is contained in:
commit
3ba9480972
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user