Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -r721bd715bef050760e5c0f79044d1cba642c8354 -rde18b3784a9a5ab48d11cb6ce2c651de390ee0e9 --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 721bd715bef050760e5c0f79044d1cba642c8354) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision de18b3784a9a5ab48d11cb6ce2c651de390ee0e9) @@ -458,13 +458,21 @@ break; case PRESSURE_SENSOR_BAROMETRIC: - baroConvConsts.pressureSensitivity = getFPGABaroPressureSensitivity(); - baroConvConsts.pressureSensitivityTempCoeff = getFPGABaroTempCoeffOfPressSensitvity(); - baroConvConsts.pressureOffset = getFPGABaroPressureOffset(); - baroConvConsts.pressureOffsetTempCoeff = getFPGABaroTempCoeffOfPressOffset(); - pressureBeforeCal = calculateBaroPressure( (U32)adcSum ); - pressures[ sensorId ].data = getCalibrationAppliedPressure( sensorId, pressureBeforeCal ); - msrdPressureSum[ sensorId ] = 0; + { + DG_OP_MODE_T opMode = getCurrentOperationMode(); + // Do not read the barometric pressure in treatment modes. + // Baro pressure is not read during treatment and it keeps the value that it was last read prior to treatment modes. + if ( ( opMode != DG_MODE_GENE ) && ( opMode != DG_MODE_FILL ) && ( opMode != DG_MODE_DRAI ) ) + { + baroConvConsts.pressureSensitivity = getFPGABaroPressureSensitivity(); + baroConvConsts.pressureSensitivityTempCoeff = getFPGABaroTempCoeffOfPressSensitvity(); + baroConvConsts.pressureOffset = getFPGABaroPressureOffset(); + baroConvConsts.pressureOffsetTempCoeff = getFPGABaroTempCoeffOfPressOffset(); + pressureBeforeCal = calculateBaroPressure( (U32)adcSum ); + pressures[ sensorId ].data = getCalibrationAppliedPressure( sensorId, pressureBeforeCal ); + msrdPressureSum[ sensorId ] = 0; + } + } break; #ifndef _VECTORCAST_ @@ -613,10 +621,16 @@ case PRESSURE_SENSOR_BAROMETRIC: if ( baroConvConsts.pressureSensitivity != 0 ) { - // Check the baro and alarm if out of range. Make sure the conversion coefficients of the sensor has been read and received from FPGA - pressureReading = getBaroPressurePSI(); - isBaroOutOfRange = ( ( pressureReading < MIN_VALID_BARO_PRESSURE_PSIA ) || ( pressureReading > MAX_VALID_BARO_PRESSURE_PSIA ) ? TRUE : FALSE ); - checkPersistentAlarm( ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE, isBaroOutOfRange, (F32)sensorId, pressureReading ); + DG_OP_MODE_T opMode = getCurrentOperationMode(); + + // Do not check the barometric pressure during the treatment modes. + if ( ( opMode != DG_MODE_GENE ) && ( opMode != DG_MODE_FILL ) && ( opMode != DG_MODE_DRAI ) ) + { + // Check the baro and alarm if out of range. Make sure the conversion coefficients of the sensor has been read and received from FPGA + pressureReading = getBaroPressurePSI(); + isBaroOutOfRange = ( ( pressureReading < MIN_VALID_BARO_PRESSURE_PSIA ) || ( pressureReading > MAX_VALID_BARO_PRESSURE_PSIA ) ? TRUE : FALSE ); + checkPersistentAlarm( ALARM_ID_DG_BARO_PRESSURE_OUT_OF_RANGE, isBaroOutOfRange, (F32)sensorId, pressureReading ); + } } break; Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r721bd715bef050760e5c0f79044d1cba642c8354 -rde18b3784a9a5ab48d11cb6ce2c651de390ee0e9 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 721bd715bef050760e5c0f79044d1cba642c8354) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision de18b3784a9a5ab48d11cb6ce2c651de390ee0e9) @@ -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(); @@ -1142,23 +1153,24 @@ 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; 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 = 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; + baroConvConsts.hasCRCCheckBeenRequested = FALSE; if ( calculatedCRC != baroCRC ) { Index: firmware/App/Controllers/TemperatureSensors.h =================================================================== diff -u -r721bd715bef050760e5c0f79044d1cba642c8354 -rde18b3784a9a5ab48d11cb6ce2c651de390ee0e9 --- firmware/App/Controllers/TemperatureSensors.h (.../TemperatureSensors.h) (revision 721bd715bef050760e5c0f79044d1cba642c8354) +++ firmware/App/Controllers/TemperatureSensors.h (.../TemperatureSensors.h) (revision de18b3784a9a5ab48d11cb6ce2c651de390ee0e9) @@ -73,6 +73,7 @@ S32 getBaroSensorTemperatureDiff( void ); void checkDialysateTemperatureSensors( void ); +void requestBaroSensorMFGInfoCheck( void ); BOOL testSetMeasuredTemperatureOverride( U32 sensorIndex, F32 temperature ); BOOL testResetMeasuredTemperatureOverride( U32 sensorIndex ); Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -re52fb9e8ad2d770523af286fa8d756595c3cac5e -rde18b3784a9a5ab48d11cb6ce2c651de390ee0e9 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision e52fb9e8ad2d770523af286fa8d756595c3cac5e) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision de18b3784a9a5ab48d11cb6ce2c651de390ee0e9) @@ -35,6 +35,7 @@ #include "SystemComm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" +#include "TemperatureSensors.h" #include "Timers.h" #include "Valves.h" @@ -289,6 +290,7 @@ { pendingStartDGRequest = FALSE; signalSyncToHD(); + requestBaroSensorMFGInfoCheck(); requestNewOperationMode( DG_MODE_GENE ); } else if ( TRUE == pendingStartDGFlushRequest ) Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r721bd715bef050760e5c0f79044d1cba642c8354 -rde18b3784a9a5ab48d11cb6ce2c651de390ee0e9 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 721bd715bef050760e5c0f79044d1cba642c8354) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision de18b3784a9a5ab48d11cb6ce2c651de390ee0e9) @@ -102,6 +102,15 @@ #define FPGA_READ_V3_START_BYTE_NUM 256 ///< FPGA V3 read sensors start byte number. #define FPGA_READ_V3_END_BYTE_NUM 430 ///< FPGA V3 read sensors end byte number. +/* + * NOTE: in MS5839-02BA manufacturing information as well as the CRC of the mfg information is stored in the manufacturing register. + * 1. Bits 0..4 are the mfg information + * 2. Bits 5..11 are the version (not used) + * 3. Bits 12..15 are the CRC + */ +#define FPGA_BARO_SENSOR_MFG_INFO_BITS 0x001F ///< FPGA baro sensor manufacturing information first 4 bits. +#define FPGA_BARO_SENSOR_CRC_BITS 0xF000 ///< FPGA baro sensor CRC 4 bits. + /// FPGA size of V3 read bytes. #define FPGA_SIZE_OF_V3_READ_BYTES ( FPGA_READ_V3_END_BYTE_NUM - FPGA_READ_V3_START_BYTE_NUM ) @@ -236,7 +245,7 @@ U16 fpgaBaroPROMCoeff4; ///< Reg 444. Barometric sensor PROM coefficient 4 U16 fpgaBaroPROMCoeff5; ///< Reg 446. Barometric sensor PROM coefficient 5 U16 fpgaBaroPROMCoeff6; ///< Reg 448. Barometric sensor PROM coefficient 6 - U16 fpgaBaroPROMCRC; ///< Reg 450. Barometric sensor PROM CRC + U16 unused; ///< Reg 450. Unused register U32 fpgaBaroPressure; ///< Reg 452. Barometric sensor pressure value U32 fpgaBaroTemperature; ///< Reg 456. Barometric sensor temperature sensor U08 fpgaTHdRTDReadCount; ///< Reg 460. THD RTD read count @@ -2384,7 +2393,7 @@ *************************************************************************/ U16 getFPGABaroMfgInfo( void ) { - return fpgaSensorReadings.fpgaBaroManufacInfo; + return fpgaSensorReadings.fpgaBaroManufacInfo & FPGA_BARO_SENSOR_MFG_INFO_BITS; } /*********************************************************************//** @@ -2475,7 +2484,7 @@ *************************************************************************/ U16 getFPGABaroCoeffsCRC( void ) { - return fpgaSensorReadings.fpgaBaroPROMCRC; + return fpgaSensorReadings.fpgaBaroManufacInfo & FPGA_BARO_SENSOR_CRC_BITS; } /*********************************************************************//**