Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r07c30fa0dd429227ad93942a0db115998dc03b6c -rfba89d67dd2bef913e85a13563e2aa49f0e2e2f5 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 07c30fa0dd429227ad93942a0db115998dc03b6c) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision fba89d67dd2bef913e85a13563e2aa49f0e2e2f5) @@ -158,7 +158,7 @@ static void getHeaterInternalTemp( U32 TCIndex, U32 CJIndex ); static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc, U32 fpgaError, U32 fpgaCount ); -static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U32 adc, U32 fpgaError, U32 fpgaCount ); +static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U16 adc, U32 fpgaError, U32 fpgaCount ); static BOOL isADCReadValid( U32 sensorIndex, U32 fpgaError, U32 fpgaCount ); static void processADCRead( U32 sensorIndex, S32 adc ); static void publishTemperatureSensorsData( void ); @@ -464,7 +464,7 @@ } // Check which heater's internal temperature is being calculated - if ( TCIndex == TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE ) + if ( TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE == TCIndex ) { tempSensors[ TEMPSENSORS_PRIMARY_HEATER_INTERNAL ].temperatureValues.data = temperature; } @@ -492,7 +492,7 @@ { S32 convertedADC = (S32)( adc & MASK_OFF_U32_MSB ); - if ( isADCReadValid( sensorIndex, fpgaError, fpgaCount ) ) + if ( TRUE == isADCReadValid( sensorIndex, fpgaError, fpgaCount ) ) { processADCRead( sensorIndex, convertedADC ); } @@ -513,32 +513,12 @@ * @param fpgaCount reported read count by FPGA * @return none *************************************************************************/ -static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U32 adc, U32 fpgaError, U32 fpgaCount ) +static void processHtrsTempSnsrsADCRead( U32 sensorIndex, U16 adc, U32 fpgaError, U32 fpgaCount ) { - U16 adcConv = 0; - S16 convertedADC = 0; - - if ( ( sensorIndex == TEMPSENSORS_PRIMARY_HEATER_THERMO_COUPLE ) || ( sensorIndex == TEMPSENSORS_TRIMMER_HEATER_THERMO_COUPLE ) ) + if ( TRUE == isADCReadValid( sensorIndex, fpgaError, fpgaCount ) ) { - // Cast the adc from U32 to U16 and shift it to left by 2 - adcConv = ( (U16)adc ) << SHIFT_BITS_BY_2; - // Cast from U16 to S16 and shift the bits to right by 2 - // so if the sign bit is 1, the sign bit is extended - convertedADC = ( (S32)adcConv ) >> SHIFT_BITS_BY_2; + processADCRead( sensorIndex, (S32)adc ); } - else if ( ( sensorIndex == TEMPSENSORS_PRIMARY_HEATER_COLD_JUNCTION ) || ( sensorIndex == TEMPSENSORS_TRIMMER_HEATER_COLD_JUNCTION ) ) - { - // Cast the adc from U32 to U16 and shift it by 4 - adcConv = ( (U16)adc ) << SHIFT_BITS_BY_4; - // Cast from U16 to S16 and shift the bits to right by 4 - // so if the sign bit is 1, the sign bit is extended - convertedADC = ( (S32)adcConv ) >> SHIFT_BITS_BY_4; - } - - if ( isADCReadValid( sensorIndex, fpgaError, fpgaCount ) ) - { - processADCRead( sensorIndex, (S32)convertedADC ); - } } /*********************************************************************//**