Index: firmware/App/Drivers/PressureSensor.c =================================================================== diff -u -r3edf8084a5028ee0d00a3fba496284e593e4254d -r72ae21d8343d3a2b07a47452ff48549e25f876df --- firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision 3edf8084a5028ee0d00a3fba496284e593e4254d) +++ firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision 72ae21d8343d3a2b07a47452ff48549e25f876df) @@ -15,34 +15,37 @@ * ***************************************************************************/ -#include "AlarmMgmtRO.h" -#include "FpgaRO.h" +#include "AlarmMgmtRO.h" +#include "FpgaRO.h" #include "Messaging.h" #include "PersistentAlarm.h" #include "PressureSensor.h" - -/** - * @addtogroup PressureSensor - * @{ - */ - -// ********** private definitions ********** +/** + * @addtogroup PressureSensor + * @{ + */ + +// ********** private definitions ********** + #define PRES_SENSORS_COUNT_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Pressure sensors read and error count timeout in milliseconds. #define ONE_BAR_TO_MILLI_BAR 1000 ///< 1 bar to milli-bar conversion. #define COUNTS_TO_MILLI_BAR 100 ///< Counts to milli-bar conversion. #define BAR_TO_MMHG ( 750.062F ) ///< Conversion factor for converting bar to mmHg. #define PRES_SENSORS_READ_ERR_MAX_CNT 0xFF ///< Pressure sensor read and error max count value -// ********** private data ********** - +#define PRES_MIN_PSI 0.0F ///< Minimum range of pressure sensors (in PSI) +#define PRES_MAX_PSI 145.038F ///< Maximum range of pressure sensors (in PSI) + +// ********** private data ********** + static OVERRIDE_F32_T currentPressureReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< Current pressure sensor pressure readings (overrideable). static OVERRIDE_F32_T currentPresTempReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< Current pressure sensor temperature readings (overrideable). static OVERRIDE_U32_T lastPressureReadCounter[ NUM_OF_PRESSURE_SENSORS ]; ///< Last pressure sensor read count (Overrideable). static OVERRIDE_U32_T lastPressureErrorCounter[ NUM_OF_PRESSURE_SENSORS ]; ///< Last pressure sensor error count (Overrideable). -// ********** private function prototypes ********** - +// ********** private function prototypes ********** + //static void checkPressureSensors( void ); /*********************************************************************//** @@ -100,31 +103,35 @@ void readPressureSensors( void ) { // Update and convert raw pressures to mmHg - currentPressureReadings[ PRESSURE_SENSOR_WATER_INLET_PRE_REG ].data = convertPressureReading2mmHg( getFPGAPRiRawPressure() ); - currentPressureReadings[ PRESSURE_SENSOR_WATER_INLET_POST_REG ].data = convertPressureReading2mmHg( getFPGAPRoRawPressure() ); - currentPressureReadings[ PRESSURE_SENSOR_WATER_INLET_PRE_COND ].data = convertPressureReading2mmHg( getFPGAPC2oRawPressure() ); - currentPressureReadings[ PRESSURE_SENSOR_PRE_RO_FILTER ].data = convertPressureReading2mmHg( getFPGAPPoRawPressure() ); - currentPressureReadings[ PRESSURE_SENSOR_POST_RO_FILTER ].data = convertPressureReading2mmHg( getFPGAPMpRawPressure() ); + currentPressureReadings[ M1_PRES ].data = convertPressureReading( getFPGAM1RawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ M3_PRES ].data = convertPressureReading( getFPGAM3RawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ P8_PRES ].data = convertPressureReading( getFPGAP8RawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ P13_PRES ].data = convertPressureReading( getFPGAP13RawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ P17_PRES ].data = convertPressureReading( getFPGAP17RawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ X1_PRES ].data = convertPressureReading( getFPGAX1RawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); // Update and convert raw pressure sensor temperatures to deg C - currentPresTempReadings[ PRESSURE_SENSOR_WATER_INLET_PRE_REG ].data = convertPressureTempReading2DegC( getFPGAPRiRawTemperature() ); - currentPresTempReadings[ PRESSURE_SENSOR_WATER_INLET_POST_REG ].data = convertPressureTempReading2DegC( getFPGAPRoRawTemperature() ); - currentPresTempReadings[ PRESSURE_SENSOR_WATER_INLET_PRE_COND ].data = convertPressureTempReading2DegC( getFPGAPC2oRawTemperature() ); - currentPresTempReadings[ PRESSURE_SENSOR_PRE_RO_FILTER ].data = convertPressureTempReading2DegC( getFPGAPPoRawTemperature() ); - currentPresTempReadings[ PRESSURE_SENSOR_POST_RO_FILTER ].data = convertPressureTempReading2DegC( getFPGAPMpRawTemperature() ); + currentPresTempReadings[ M1_PRES ].data = convertPressureTempReading2DegC( getFPGAM1RawTemperature() ); + currentPresTempReadings[ M3_PRES ].data = convertPressureTempReading2DegC( getFPGAM3RawTemperature() ); + currentPresTempReadings[ P8_PRES ].data = convertPressureTempReading2DegC( getFPGAP8RawTemperature() ); + currentPresTempReadings[ P13_PRES ].data = convertPressureTempReading2DegC( getFPGAP13RawTemperature() ); + currentPresTempReadings[ P17_PRES ].data = convertPressureTempReading2DegC( getFPGAP17RawTemperature() ); + currentPresTempReadings[ X1_PRES ].data = convertPressureTempReading2DegC( getFPGAX1RawTemperature() ); // Update read and error counters for each pressure sensor - lastPressureReadCounter[ PRESSURE_SENSOR_WATER_INLET_PRE_REG ].data = (U32)getFPGAPRiReadCount(); - lastPressureReadCounter[ PRESSURE_SENSOR_WATER_INLET_POST_REG ].data = (U32)getFPGAPRoReadCount(); - lastPressureReadCounter[ PRESSURE_SENSOR_WATER_INLET_PRE_COND ].data = (U32)getFPGAPC2oReadCount(); - lastPressureReadCounter[ PRESSURE_SENSOR_PRE_RO_FILTER ].data = (U32)getFPGAPPoReadCount(); - lastPressureReadCounter[ PRESSURE_SENSOR_POST_RO_FILTER ].data = (U32)getFPGAPMpReadCount(); + lastPressureReadCounter[ M1_PRES ].data = (U32)getFPGAM1ReadCount(); + lastPressureReadCounter[ M3_PRES ].data = (U32)getFPGAM3ReadCount(); + lastPressureReadCounter[ P8_PRES ].data = (U32)getFPGAP8ReadCount(); + lastPressureReadCounter[ P13_PRES ].data = (U32)getFPGAP13ReadCount(); + lastPressureReadCounter[ P17_PRES ].data = (U32)getFPGAP17ReadCount(); + lastPressureReadCounter[ X1_PRES ].data = (U32)getFPGAX1ReadCount(); - lastPressureErrorCounter[ PRESSURE_SENSOR_WATER_INLET_PRE_REG ].data = (U32)getFPGAPRiErrorCount(); - lastPressureErrorCounter[ PRESSURE_SENSOR_WATER_INLET_POST_REG ].data = (U32)getFPGAPRoErrorCount(); - lastPressureErrorCounter[ PRESSURE_SENSOR_WATER_INLET_PRE_COND ].data = (U32)getFPGAPC2oErrorCount(); - lastPressureErrorCounter[ PRESSURE_SENSOR_PRE_RO_FILTER ].data = (U32)getFPGAPPoErrorCount(); - lastPressureErrorCounter[ PRESSURE_SENSOR_POST_RO_FILTER ].data = (U32)getFPGAPMpErrorCount(); + lastPressureErrorCounter[ M1_PRES ].data = (U32)getFPGAM1ErrorCount(); + lastPressureErrorCounter[ M3_PRES ].data = (U32)getFPGAM3ErrorCount(); + lastPressureErrorCounter[ P8_PRES ].data = (U32)getFPGAP8ErrorCount(); + lastPressureErrorCounter[ P13_PRES ].data = (U32)getFPGAP13ErrorCount(); + lastPressureErrorCounter[ P17_PRES ].data = (U32)getFPGAP17ErrorCount(); + lastPressureErrorCounter[ X1_PRES ].data = (U32)getFPGAX1ErrorCount(); // // Monitor pressure sensor health // checkPressureSensors(); @@ -134,37 +141,18 @@ * @brief * The checkPressureSensors function checks the read and error counters for * each pressure sensor. - * @details \b Alarm: ALARM_ID_DD_HYD_OUTLET_PRES_TIMEOUT_FAULT if the - * hydraulics outlet pressure sensor is not able to be read. - * @details \b Alarm: ALARM_ID_DD_BIBAG_PRES_TIMEOUT_FAULT if the - * BiBag pressure sensor is not able to be read. - * @details \b Alarm: ALARM_ID_DD_SPENT_DIALYSATE_PRES_TIMEOUT_FAULT if the - * spent dialysate pressure sensor is not able to be read. - * @details \b Alarm: ALARM_ID_DD_FRESH_DIALYSATE_PRES_TIMEOUT_FAULT if the - * fresh dialysate pressure sensor is not able to be read. - * @details \b Alarm: ALARM_ID_DD_TRANSMEMB_PRES_TIMEOUT_FAULT if the - * Transmembrane pressure sensor is not able to be read. + * @details \b Alarm: TBD * @details \b Inputs: lastPressureReadCounter, lastPressureErrorCounter * @details \b Outputs: none * @return none *************************************************************************/ //static void checkPressureSensors( void ) //{ -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_WATER_INLET_INPUT_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_WATER_INLET_INPUT ) ); -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_WATER_INLET_OUTPUT_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_WATER_INLET_OUTPUT ) ); -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_HYDRAULICS_OUTLET_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_HYDRAULICS_OUTLET ) ); -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_BIBAG_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_BIBAG ) ); -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_SPENT_DIALYSATE_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_SPENT_DIALYSATE ) ); -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_FRESH_DIALYSATE_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_FRESH_DIALYSATE ) ); -// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_TRANSMEMBRANE_PRESSURE, getPressureSensorReadCount( PRESSURE_SENSOR_TRANSMEMBRANE ) ); +// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_WATER_INLET_INPUT_PRESSURE, getPressureSensorReadCount( M1_PRES ) ); +// checkFPGAPersistentAlarms( FPGA_PERS_ERROR_WATER_INLET_OUTPUT_PRESSURE, getPressureSensorReadCount( M3_PRES ) ); // -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_WATER_INLET_INPUT_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_WATER_INLET_INPUT ) ); -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_WATER_INLET_OUTPUT_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_WATER_INLET_OUTPUT ) ); -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_HYDRAULICS_OUTLET_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_HYDRAULICS_OUTLET ) ); -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_BIBAG_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_BIBAG ) ); -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_SPENT_DIALYSATE_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_SPENT_DIALYSATE ) ); -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_FRESH_DIALYSATE_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_FRESH_DIALYSATE ) ); -// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_TRANSMEMBRANE_PRESSURE, getPressureSensorErrorCount( PRESSURE_SENSOR_TRANSMEMBRANE ) ); +// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_WATER_INLET_INPUT_PRESSURE, getPressureSensorErrorCount( M1_PRES ) ); +// checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_WATER_INLET_OUTPUT_PRESSURE, getPressureSensorErrorCount( M3_PRES ) ); //} /*********************************************************************//** @@ -287,12 +275,12 @@ return result; } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + /*********************************************************************//** * @brief * The testPressureSensorReadingsOverride function overrides the value of @@ -309,7 +297,7 @@ return result; } - + /*********************************************************************//** * @brief * The testPressureSensorTemperatureReadingsOverride function overrides the @@ -360,5 +348,5 @@ return result; } - -/**@}*/ + +/**@}*/