Index: firmware/App/Drivers/TemperatureSensors.c =================================================================== diff -u -r9e6e86f604c8cce7c1704ae55d1e026de3422782 -r325e67dab10f6666702bf0f1256015b31e58de4f --- firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 9e6e86f604c8cce7c1704ae55d1e026de3422782) +++ firmware/App/Drivers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 325e67dab10f6666702bf0f1256015b31e58de4f) @@ -55,10 +55,7 @@ #define NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 80.0F ///< Non fluid temperature sensors path maximum allowed temperature in C. #define TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ( 5 * MS_PER_SECOND ) ///< Temperature sensor out of range persistent period in milliseconds. #define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. -#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. #define TEMP_READ_COUNTER_MAX_VALUE 255 ///< FPGA temperature sensor read counter max value. -#define BARO_SENSOR_CRC_MAX_VALUE 65535 ///< Baro sensor coefficients CRC max value 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. @@ -77,39 +74,13 @@ S32 adcNextIndex; ///< Next ADC read index S32 adcRunningSum; ///< ADC running sum F32 maxAllowedTemp; ///< Maximum allowed temperature of the sensor - S32 baroTempSnsrDiff; ///< Barometric sensor temperature difference } TEMP_SENSOR_T; -/// Barometric sensor temperature conversion -typedef struct -{ - U16 refTemperature; ///< Barometric sensor reference temperature. - U16 temperatureCoeff; ///< Barometric sensor temperature coefficient. - OVERRIDE_U32_T coeffsCRC; ///< Barometric sensor coefficients CRC. - U32 waitForCoeffStartTimeMS; ///< Barometric sensor wait for coefficients start time in milliseconds. - BOOL hasCRCBeenChecked; ///< Barometric sensor has CRC been checked flag. -} BARO_SENSOR_CONSTS_T; - -/// Barometric sensor - 6 type of coefficients -typedef struct -{ - U16 mfgInfo; ///< Barometric sensor manufacturing info. - U16 pressSensitivity; ///< Barometric sensor pressure sensitivity. - U16 pressOffset; ///< Barometric sensor pressure offset. - U16 tempCoeffOfPressSens; ///< Barometric sensor temperature coefficient of pressure sensor. - U16 tempCoeffPressOffset; ///< Barometric sensor temperature coefficient of pressure offset. - U16 referenceTemp; ///< Barometric sensor reference temperature. - U16 tempCoeffOfTemp; ///< Barometric sensor temperature coefficient of Temperature sensor. - U16 crc; ///< Barometric sensor CRC of the coefficients. -} BARO_SENSORS_COEFFS_T; - // ********** private data ********** static TEMP_SENSOR_T tempSensors [ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors' data structure. static OVERRIDE_F32_T temperatureValue[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature values with override static OVERRIDE_U32_T lastTemperatureReadCounter; ///< Temperature sensors read count from FPGA. -static OVERRIDE_U32_T lastBaroTempReadCounter; ///< Barometric sensor read count from FPGA. -static BARO_SENSOR_CONSTS_T baroConvConsts; ///< Barometric sensor conversion constants. //static DD_TEMP_SENSORS_CAL_RECORD_T tempSensorCalRecord; ///< Temperature sensors calibration record. @@ -118,7 +89,6 @@ static F32 getADC2TempConversion( F32 avgADC, U32 gain, U32 refResistance, U32 zeroDegResistance, F32 adcConversionCoeff ); static void processTempSnsrsADCRead( U32 sensorIndex, U32 adc ); static void processADCRead( U32 sensorIndex, S32 adc ); -static void checkBaroSensorCRC( void ); static void checkTemperatureSensors( void ); static void getCalibrationAppliedTemperatureValue( U32 sesnorIndex, F32* temperature ); @@ -134,30 +104,23 @@ U08 i; F32 conversionCoeff = 1.0F / 13584.0F; - baroConvConsts.coeffsCRC.data = 0; - baroConvConsts.hasCRCBeenChecked = FALSE; - baroConvConsts.waitForCoeffStartTimeMS = 0; - for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; ++i ) { memset( &tempSensors[ i ], 0x0, sizeof( TEMP_SENSOR_T ) ); //benignPolynomialCalRecord( &tempSensorCalRecord.tempSensors[ i ] ); } - // Initialize the barometric sensor's temperature conversion constants - memset( &baroConvConsts, 0x0, sizeof( BARO_SENSOR_CONSTS_T ) ); - // Initialize TH1 (primary heater), TH2(outlet Heat Exchanger), TAUX ( Inlet Heat exchanger), // TH3 ( Trim Heater) constants. tempSensors[ D1_TEMP ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; tempSensors[ D1_TEMP ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; tempSensors[ D1_TEMP ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; tempSensors[ D1_TEMP ].maxAllowedTemp = TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; - tempSensors[ X6_TEMP ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; - tempSensors[ X6_TEMP ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; - tempSensors[ X6_TEMP ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; - tempSensors[ X6_TEMP ].maxAllowedTemp = TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; + tempSensors[ D78_TEMP ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; + tempSensors[ D78_TEMP ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; + tempSensors[ D78_TEMP ].zeroDegreeResistance = PRIMARY_HEATER_TEMP_SENSORS_0_DEGREE_RESISTANCE; + tempSensors[ D78_TEMP ].maxAllowedTemp = TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; tempSensors[ D4_TEMP ].gain = PRIMARY_HEATER_TEMP_SENSORS_GAIN; tempSensors[ D4_TEMP ].refResistance = PRIMARY_HEATER_TEMP_SENSORS_REF_RESISTANCE; @@ -173,14 +136,11 @@ tempSensors[ BRD_TEMP ].conversionCoeff = conversionCoeff; tempSensors[ BRD_TEMP ].maxAllowedTemp = NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; - tempSensors[ BARO_TEMP ].maxAllowedTemp = NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C; - // Persistent alarm for the temperature sensors range check initPersistentAlarm( ALARM_ID_DD_TEMPERATURE_SENSOR_OUT_OF_RANGE, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS, TEMP_SENSORS_OUT_OF_RANGE_TIME_OUT_MS ); // Initialize the FPGA persistent alarms initFPGAPersistentAlarm( FPGA_PERS_ERROR_RTD_ADC_TEMP_SENSORS, ALARM_ID_DD_RTD_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); - initFPGAPersistentAlarm( FPGA_PERS_ERROR_BARO_SENSOR, ALARM_ID_DD_BARO_SENSOR_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); } /*********************************************************************//** @@ -213,36 +173,10 @@ /*********************************************************************//** * @brief - * The getBaroSensorTemperatureDiff function returns the barometric pressure - * sensor's temperature difference. - * @details \b Inputs: tempSensors - * @details \b Outputs: none - * @return barometric pressure sensor temperature difference - *************************************************************************/ -S32 getBaroSensorTemperatureDiff( void ) -{ - return tempSensors[ BARO_TEMP ].baroTempSnsrDiff; -} - -/*********************************************************************//** - * @brief - * The setBaroSensorCoefficientReadStartTime function populates the start - * time of baro sensor coefficient read transaction initiated to FPGA. - * @details \b Inputs: none - * @details \b Outputs: baroConvConsts - * @return none - *************************************************************************/ -void setBaroSensorCoefficientReadStartTime( void ) -{ - baroConvConsts.waitForCoeffStartTimeMS = getMSTimerCount(); -} - -/*********************************************************************//** - * @brief * The readTemperatureSensors function reads the temperature sensor * value from FPGA. * @details \b Inputs: FPGA - * @details \b Outputs: lastTemperatureReadCounter,lastBaroTempReadCounter + * @details \b Outputs: lastTemperatureReadCounter * @return none *************************************************************************/ void readTemperatureSensors( void ) @@ -252,26 +186,12 @@ //Read temperature sensors processTempSnsrsADCRead( D1_TEMP, getFPGAD1Temp() ); - processTempSnsrsADCRead( X6_TEMP, getFPGAX6Temp() ); + processTempSnsrsADCRead( D78_TEMP, getFPGAD78Temp() ); processTempSnsrsADCRead( D4_TEMP, getFPGAD4Temp() ); processTempSnsrsADCRead( D50_TEMP, getFPGAD50Temp() ); - //TODO: Read Board temperture + //TODO: Read Board temperature //processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_COND_TEMP_SENSOR, getFPGACondSnsrInternalTemp() ); - - //Read Baro temperature sensor - if ( getCurrentOperationMode() != DD_MODE_INIT ) - { -#ifdef ENABLE_ALARM_1 - // Make sure the baro sensor coefficients are not corrupted - checkBaroSensorCRC(); -#endif - baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); - baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); - lastBaroTempReadCounter.data = (U32)getFPGABaroReadCount(); - - processTempSnsrsADCRead( BARO_TEMP, getFPGABaroTemperature() ); - } } /*********************************************************************//** @@ -296,42 +216,17 @@ /*********************************************************************//** * @brief - * The getBaroTempSensorsReadCount function gets the barometric temperature sensor - * read count. - * @details \b Inputs: lastBaroTempReadCounter - * @details \b Outputs: none - * @return The barometric temperature sensor read count. - *************************************************************************/ -U32 getBaroTempSensorsReadCount( void ) -{ - U32 result = lastBaroTempReadCounter.data; - - if ( OVERRIDE_KEY == lastBaroTempReadCounter.override ) - { - result = lastBaroTempReadCounter.ovData; - } - - return result; -} - -/*********************************************************************//** - * @brief * The checkTemperatureSensors function checks the temperature sensor * freshness and see if there is any read failures from 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 - * @details \b Alarms: ALARM_ID_DD_BARO_SENSOR_FPGA_FAULT when baro temperature sensor - * read count not updated periodically * @return none *************************************************************************/ static void checkTemperatureSensors( void ) { checkFPGAPersistentAlarms( FPGA_PERS_ERROR_RTD_ADC_TEMP_SENSORS, getTemperatureSensorsReadCount() ); -#ifdef ENABLE_ALARM_1 - checkFPGAPersistentAlarms( FPGA_PERS_ERROR_BARO_SENSOR, getBaroTempSensorsReadCount() ); -#endif } /*********************************************************************//** @@ -416,7 +311,7 @@ switch( sensorIndex ) { case D1_TEMP: - case X6_TEMP: + case D78_TEMP: case D4_TEMP: case D50_TEMP: temperature = getADC2TempConversion( avgADCReads, (U32)tempSensors [ sensorIndex ].gain, (U32)tempSensors [ sensorIndex ].refResistance, @@ -427,17 +322,6 @@ //TODO : Need details on calculations. break; - case BARO_TEMP: - { - S32 baroTempSensorsDiff = (S32)avgADCReads - ( baroConvConsts.refTemperature * TWO_TO_POWER_OF_8 ); - S64 differenceTimesCoefficient = (S64)baroTempSensorsDiff * (S64)baroConvConsts.temperatureCoeff; - S64 baroSnsrTemperature = BARO_SENSOR_REFERENCE_TEMP_C + ( differenceTimesCoefficient / TWO_TO_POWER_OF_23 ); - - temperature = (F32)( baroSnsrTemperature / 100.0F ); - tempSensors[ sensorIndex ].baroTempSnsrDiff = baroTempSensorsDiff; - } - break; - default: // Wrong sensor was called, raise an alarm SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED2, sensorIndex ); @@ -493,53 +377,6 @@ /*********************************************************************//** * @brief - * The checkBaroSensorCRC function gets all the barometric sensor coefficients - * and calls crc4 function to calculate the CRC of the coefficients and compares - * them to the provided CRC by the manufacturer. - * @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 mismatch or timeout. - * @return none - *************************************************************************/ -static void checkBaroSensorCRC( void ) -{ - U32 baroCRC = (U32)getFPGABaroCoeffsCRC(); - BOOL hasCRCChanged = ( baroCRC != getU32OverrideValue( &baroConvConsts.coeffsCRC ) ? TRUE : FALSE ); - - // Once FPGA is ready get the barometric sensor's temperature conversion constants - if ( TRUE == hasCRCChanged ) - { - U08 calculatedCRC; - BARO_SENSORS_COEFFS_T baroCoeffs; - - baroCoeffs.mfgInfo = getFPGABaroMfgInfo(); - baroCoeffs.pressSensitivity = getFPGABaroPressureSensitivity(); - baroCoeffs.pressOffset = getFPGABaroPressureOffset(); - baroCoeffs.tempCoeffOfPressSens = getFPGABaroTempCoeffOfPressSensitvity(); - baroCoeffs.tempCoeffPressOffset = getFPGABaroTempCoeffOfPressOffset(); - baroCoeffs.referenceTemp = getFPGABaroReferenceTemperature(); - baroCoeffs.tempCoeffOfTemp = getFPGABaroTempCoeffOfTemperature(); - baroCoeffs.crc = MASK_OFF_LSB & getFPGABaroCoeffsCRC(); - calculatedCRC = crc4( (U16*)&baroCoeffs, sizeof( baroCoeffs ) ); - baroConvConsts.coeffsCRC.data = baroCRC; - baroCRC = (U16)( baroCRC & MASK_OFF_MSB ) & MASK_OFF_NIBBLE_MSB; - baroConvConsts.hasCRCBeenChecked = TRUE; - - if ( calculatedCRC != baroCRC ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, calculatedCRC, baroCoeffs.crc ); - } - } - else if ( ( TRUE == didTimeout( baroConvConsts.waitForCoeffStartTimeMS, BARO_SENSOR_WAIT_FOR_COEFF_TIME_OUT_MS ) ) && - ( FALSE == baroConvConsts.hasCRCBeenChecked ) ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, 0, baroCRC ); - } -} - -/*********************************************************************//** - * @brief * The getCalibrationAppliedTemperatureValue function applies the calibration * values to the provided temperature value * @details \b Inputs: tempSensorCalRecord @@ -559,7 +396,7 @@ //calId = CAL_DATA_INLET_HEAT_EXCHANGER_TEMP; break; - case X6_TEMP: + case D78_TEMP: //calId = CAL_DATA_OUTLET_HEAT_EXCHANGER_TEMP; break; @@ -571,10 +408,6 @@ //calId = CAL_DATA_TRIM_HEATER_TEMP; break; - case BARO_TEMP: - //calId = CAL_DATA_BARMOTERIC_TEMP; - break; - default: // Set the calibration temperature value as num of meaning calibration is not needed for the provided sensor //calId = NUM_OF_CAL_DATA_TEMP_SENSORS; @@ -631,38 +464,4 @@ return result; } -/*********************************************************************//** - * @brief - * The testBaroTemperatureReadCounterOverride function sets the override value - * of the baro temperature read counter. - * @details Inputs: lastBaroTempReadCounter - * @details Outputs: lastBaroTempReadCounter - * @param message Override message from Dialin which includes the read - * counter value to override for the baro sensor. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testBaroTemperatureReadCounterOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &lastBaroTempReadCounter, 0, TEMP_READ_COUNTER_MAX_VALUE ); - - return result; -} - -/*********************************************************************//** - * @brief - * The testBaroTemperatureReadCounterOverride function sets the override value - * of the baro temperature read counter. - * @details Inputs: lastBaroTempReadCounter - * @details Outputs: lastBaroTempReadCounter - * @param message Override message from Dialin which includes the CRC - * value to override for the baro sensor. - * @return TRUE if override successful, FALSE if not - *************************************************************************/ -BOOL testBaroTemperatureCRCOverride( MESSAGE_T *message ) -{ - BOOL result = u32Override( message, &baroConvConsts.coeffsCRC, 0, BARO_SENSOR_CRC_MAX_VALUE ); - - return result; -} - /**@}*/