Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hardware/arduino/sam/cores/arduino/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ uint32_t analogRead(uint32_t ulPin)
case ADC11 :

// Enable the corresponding channel
if (ulChannel != latestSelectedChannel) {
if (adc_get_channel_status(ADC, ulChannel) != 1) {
adc_enable_channel( ADC, ulChannel );
if ( latestSelectedChannel != (uint32_t)-1 )
if ( latestSelectedChannel != (uint32_t)-1 && ulChannel != latestSelectedChannel)
adc_disable_channel( ADC, latestSelectedChannel );
latestSelectedChannel = ulChannel;
}
Expand Down
7 changes: 7 additions & 0 deletions hardware/arduino/sam/cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ extern void pinMode( uint32_t ulPin, uint32_t ulMode )
return ;
}

#if defined __SAM3X8E__ || defined __SAM3X8H__
if(g_APinDescription[ulPin].ulPinType != NO_ADC && adc_get_channel_status(ADC, g_APinDescription[ulPin].ulADCChannelNumber))
{
adc_disable_channel( ADC, g_APinDescription[ulPin].ulADCChannelNumber);
}
#endif

switch ( ulMode )
{
case INPUT:
Expand Down