mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
parent
fdf10eb663
commit
1fc54f5003
@ -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