Index: firmware/App/Drivers/PressureSensor.c =================================================================== diff -u -r3edf8084a5028ee0d00a3fba496284e593e4254d -rce66580e076bffa157868ff7e422556f78a95cac --- firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision 3edf8084a5028ee0d00a3fba496284e593e4254d) +++ firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision ce66580e076bffa157868ff7e422556f78a95cac) @@ -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[ PRESSURE_SENSOR_WATER_INLET_PRE_REG ].data = convertPressureReading( getFPGAPRiRawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ PRESSURE_SENSOR_WATER_INLET_POST_REG ].data = convertPressureReading( getFPGAPRoRawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ PRESSURE_SENSOR_WATER_INLET_PRE_COND ].data = convertPressureReading( getFPGAPC2oRawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ PRESSURE_SENSOR_PRE_RO_FILTER ].data = convertPressureReading( getFPGAPPoRawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ PRESSURE_SENSOR_POST_RO_FILTER ].data = convertPressureReading( getFPGAPMpRawPressure(), PRES_MIN_PSI, PRES_MAX_PSI ); + currentPressureReadings[ PRESSURE_SENSOR_PRE_RO_PUMP ].data = convertPressureReading( getFPGAPPiRawPressure(), 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[ PRESSURE_SENSOR_PRE_RO_PUMP ].data = convertPressureTempReading2DegC( getFPGAPPiRawTemperature() ); // 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[ PRESSURE_SENSOR_PRE_RO_PUMP ].data = (U32)getFPGAPPiReadCount(); 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[ PRESSURE_SENSOR_PRE_RO_PUMP ].data = (U32)getFPGAPPiErrorCount(); // // Monitor pressure sensor health // checkPressureSensors(); @@ -287,12 +294,12 @@ return result; } - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + /*********************************************************************//** * @brief * The testPressureSensorReadingsOverride function overrides the value of @@ -309,7 +316,7 @@ return result; } - + /*********************************************************************//** * @brief * The testPressureSensorTemperatureReadingsOverride function overrides the @@ -360,5 +367,5 @@ return result; } - -/**@}*/ + +/**@}*/