Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u -rfefb47e88a5285e99498efb830fdceb9e95c2c3e -re3699de422fa3ba1b8145c4cc44257702c9e336f --- firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision fefb47e88a5285e99498efb830fdceb9e95c2c3e) +++ firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision e3699de422fa3ba1b8145c4cc44257702c9e336f) @@ -59,6 +59,12 @@ #define BARO_SENSOR_REFERENCE_TEMP_C 2000 ///< Barometric sensor reference temperature in C. #define BARO_SENSOR_WAIT_FOR_COEFF_TIME_OUT_MS ( 20 * MS_PER_SECOND ) ///< Barometric sensor wait for coefficients timeout in milliseconds. +static const U32 TEMP_EQUATION_RESISTOR_CALC = 1 << ( TEMP_SENSORS_ADC_BITS - 1 ); ///< Temperature sensors resistor calculation (2^(24 - 1)). +static const F32 TEMP_EQUATION_COEFF_A = 3.9083E-3; ///< ADC to temperature conversion coefficient A. +static const F32 TEMP_EQUATION_COEFF_B = -5.775E-7; ///< ADC to temperature conversion coefficient B. +static const U32 TWO_TO_POWER_OF_8 = ( 1 << 8 ); ///< 2^8. +static const U32 TWO_TO_POWER_OF_23 = ( 1 << 23 ); ///< 2^23. + /// Temperature sensor struct. typedef struct { @@ -106,12 +112,6 @@ //static DD_TEMP_SENSORS_CAL_RECORD_T tempSensorCalRecord; ///< Temperature sensors calibration record. -static const U32 TEMP_EQUATION_RESISTOR_CALC = 1 << ( TEMP_SENSORS_ADC_BITS - 1 ); ///< Temperature sensors resistor calculation (2^(24 - 1)). -static const F32 TEMP_EQUATION_COEFF_A = 3.9083E-3; ///< ADC to temperature conversion coefficient A. -static const F32 TEMP_EQUATION_COEFF_B = -5.775E-7; ///< ADC to temperature conversion coefficient B. -static const U32 TWO_TO_POWER_OF_8 = ( 1 << 8 ); ///< 2^8. -static const U32 TWO_TO_POWER_OF_23 = ( 1 << 23 ); ///< 2^23. - // ********** private function prototypes ********** static F32 getADC2TempConversion( F32 avgADC, U32 gain, U32 refResistance, U32 zeroDegResistance, F32 adcConversionCoeff ); @@ -282,9 +282,8 @@ *************************************************************************/ U32 getTemperatureSensorsReadCount( void ) { - U32 result = 0; + U32 result = lastTemperatureReadCounter.data; - result = lastTemperatureReadCounter.data; if ( OVERRIDE_KEY == lastTemperatureReadCounter.override ) { result = lastTemperatureReadCounter.ovData; @@ -303,9 +302,8 @@ *************************************************************************/ U32 getBaroTempSensorsReadCount( void ) { - U32 result = 0; + U32 result = lastBaroTempReadCounter.data; - result = lastBaroTempReadCounter.data; if ( OVERRIDE_KEY == lastBaroTempReadCounter.override ) { result = lastBaroTempReadCounter.ovData; @@ -318,7 +316,7 @@ * @brief * The checkTemperatureSensors function checks the temperature sensor * freshness and see if there is any read failures from FPGA. - * @details \b Inputs: FPGA + * @details \b Inputs: Temperature sensors reading from FPGA * @details \b Outputs: none * @details \b Alarms: ALARM_ID_DD_RTD_SENSORS_FPGA_FAULT when temperature sensor * read count not updated periodically @@ -387,9 +385,8 @@ /*********************************************************************//** * @brief - * The processADCRead function receives the ADC value and the sensor - * index and calculates the running sum and the moving average of the ADCs - * The temperatureSensorsADCRead and tempSensorsAvgADCValues are updated. + * The processADCRead function updates the ADC count moving average for a + * given temperature sensor. * @details \b Inputs: tempSensors * @details \b Outputs: tempSensors * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid temperature @@ -472,30 +469,16 @@ for ( sensorId = TEMPSENSORS_FIRST; sensorId < NUM_OF_TEMPERATURE_SENSORS; sensorId++ ) { - switch ( sensorId ) - { - case TEMPSENSORS_INLET_HEAT_EXCHANGER: - case TEMPSENSORS_OUTLET_HEAT_EXCHANGER: - case TEMPSENSORS_HYDRAULICS_PRIMARY_HEATER: - case TEMPSENSORS_TRIMMER_HEATER: - case TEMPSENSORS_BAROMETRIC_TEMP_SENSOR: - // Get temperature value. - temperature = getTemperatureValue( sensorId ); - // Check both temperature and to be in range - if ( ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ sensorId ].maxAllowedTemp ) ) && - ( getCurrentOperationMode() != DD_MODE_INIT ) ) - { - isTemperatureOutOfRange |= TRUE; - sensorInAlarm = sensorId; - alarmTemperature = temperature; - } - break; - - default: - // Ignore the other sensors - break; - } - + // Get temperature value. + temperature = getTemperatureValue( sensorId ); + // Check both temperature and to be in range + if ( ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ sensorId ].maxAllowedTemp ) ) && + ( getCurrentOperationMode() != DD_MODE_INIT ) ) + { + isTemperatureOutOfRange |= TRUE; + sensorInAlarm = sensorId; + alarmTemperature = temperature; + } } checkPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, isTemperatureOutOfRange, sensorInAlarm, alarmTemperature ); @@ -512,7 +495,7 @@ * @details \b Inputs: hasBaroCoeffsBeenChecked * @details \b Outputs: hasBaroCoeffsBeenChecked * @details \b Alarms: ALARM_ID_DD_BAROMETRIC_SENSOR_COEFFS_BAD_CRC when baro - * temperature sensor coefficient CRC changes. + * temperature sensor coefficient CRC mismatch or timeout. * @return none *************************************************************************/ static void checkBaroSensorCRC( void )