Skip to content
This repository has been archived by the owner on Feb 2, 2020. It is now read-only.

Commit

Permalink
Fixed #130. Prevent get Pin id if internal channels (16, 17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Palomino34 committed Jan 10, 2018
1 parent f732b1a commit 19196ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Targets/STM32F4/STM32F4_ADC.cpp
Expand Up @@ -115,7 +115,7 @@ TinyCLR_Result STM32F4_Adc_AcquireChannel(const TinyCLR_Adc_Provider* self, int3
if (chNum >= STM32F4_AD_NUM)
return TinyCLR_Result::NotAvailable;

if (!STM32F4_GpioInternal_OpenPin(STM32F4_Adc_GetPinForChannel(channel)))
if (chNum <=15 && !STM32F4_GpioInternal_OpenPin(STM32F4_Adc_GetPinForChannel(channel)))
return TinyCLR_Result::SharingViolation;

// init this channel if it's listed in the STM32F4_AD_CHANNELS array
Expand Down Expand Up @@ -149,7 +149,7 @@ TinyCLR_Result STM32F4_Adc_ReleaseChannel(const TinyCLR_Adc_Provider* self, int3

// free GPIO pin if this channel is listed in the STM32F4_AD_CHANNELS array
// and if it's not one of the internally connected ones as these channels don't take any GPIO pins
if (chNum < STM32F4_AD_NUM)
if (chNum <=15 && chNum < STM32F4_AD_NUM)
STM32F4_GpioInternal_ClosePin(STM32F4_Adc_GetPinForChannel(channel));

return TinyCLR_Result::Success;
Expand Down

0 comments on commit 19196ae

Please sign in to comment.