Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -rda0deea71ed5770d98a00943369b9c17321e139f -r8f4a39b5e2161444c61d3fa52734d218259ee001 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision da0deea71ed5770d98a00943369b9c17321e139f) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 8f4a39b5e2161444c61d3fa52734d218259ee001) @@ -144,6 +144,7 @@ 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. + BOOL hasCRCCheckBeenRequested; ///< Barometric sensor has CRC check been requested flag. } BARO_SENSOR_CONSTS_T; /// Barometric sensor coefficients @@ -670,6 +671,19 @@ /*********************************************************************//** * @brief + * The requestBaroSensorMFGInfoCheck function requests the baro sensor manufacturing + * information be checked. + * @details Inputs: none + * @details Outputs: baroConvConsts.hasCRCCheckBeenRequested + * @return none + *************************************************************************/ +void requestBaroSensorMFGInfoCheck( void ) +{ + baroConvConsts.hasCRCCheckBeenRequested = TRUE; +} + +/*********************************************************************//** + * @brief * The getADC2TempConversion function calculates the temperature from the * moving average ADC samples. * @details Inputs: tempEquationCoeffA, tempEquationCoeffB @@ -949,9 +963,6 @@ processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_THD_RTD, getFPGATHdInternalTemp() ); - // Make sure the baro sensor coefficients are not corrupted - checkBaroSensorCRC(); - baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); readCount = getFPGABaroReadCount(); @@ -1138,31 +1149,34 @@ *************************************************************************/ static void checkBaroSensorCRC( void ) { + // The baro CRC is the last 4 bits of the 16-bit manufacturing register 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 ) + if ( ( TRUE == hasCRCChanged ) || ( TRUE == baroConvConsts.hasCRCCheckBeenRequested ) ) { - U08 calculatedCRC; + U32 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; + baroCoeffs.mfgInfo = getFPGABaroMfgInfo(); + baroCoeffs.pressSensitivity = getFPGABaroPressureSensitivity(); + baroCoeffs.pressOffset = getFPGABaroPressureOffset(); + baroCoeffs.tempCoeffOfPressSens = getFPGABaroTempCoeffOfPressSensitvity(); + baroCoeffs.tempCoeffPressOffset = getFPGABaroTempCoeffOfPressOffset(); + baroCoeffs.referenceTemp = getFPGABaroReferenceTemperature(); + baroCoeffs.tempCoeffOfTemp = getFPGABaroTempCoeffOfTemperature(); + baroCoeffs.crc = 0x00; // Keep zero for the seventh byte in CRC4 formula + calculatedCRC = (U32)crc4( (U16*)&baroCoeffs, sizeof( baroCoeffs ) ); + baroConvConsts.coeffsCRC.data = baroCRC; + baroConvConsts.hasCRCBeenChecked = TRUE; + baroConvConsts.hasCRCCheckBeenRequested = FALSE; + SEND_EVENT_WITH_2_U32_DATA( DG_EVENT_BARO_SENSOR_MFG_CRC_CHECK, calculatedCRC, baroCRC ) + if ( calculatedCRC != baroCRC ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, calculatedCRC, baroCoeffs.crc ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_BAROMETRIC_SENSOR_COEFFS_BAD_CRC, calculatedCRC, baroCRC ); } } else if ( ( TRUE == didTimeout( baroConvConsts.waitForCoeffStartTimeMS, BARO_SENSOR_WAIT_FOR_COEFF_TIME_OUT_MS ) ) &&