Fixed temperature ADC conversion bug on mbxxx.

The conversion was made from an incorrect source when
the GPIO pin was not PB7.
Added functions and macros used to select the correct
ADC channel.
This commit is contained in:
Salvatore Pitrulli 2011-04-20 12:14:11 +02:00
parent faf2943e02
commit 01a7a78a94
4 changed files with 60 additions and 9 deletions

View file

@ -348,3 +348,34 @@ int16s halConvertValueToVolts(int16u value)
}
return V;
}
int8u halGetADCChannelFromGPIO(int32u io)
{
switch(io)
{
case PORTB_PIN(5):
return ADC_MUX_ADC0;
case PORTB_PIN(6):
return ADC_MUX_ADC1;
case PORTB_PIN(7):
return ADC_MUX_ADC2;
case PORTC_PIN(1):
return ADC_MUX_ADC3;
case PORTA_PIN(4):
return ADC_MUX_ADC4;
case PORTA_PIN(5):
return ADC_MUX_ADC5;
case PORTB_PIN(0):
return ADC_MUX_VREF;
default :
return 0x0F; // Invalid analogue source
}
}