Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -rdc0d9b087c609e71cacdb7f0395cccf29d749c00 -r5a882c7292cea58e74b5a28d4e85dd60e741b834 --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision dc0d9b087c609e71cacdb7f0395cccf29d749c00) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 5a882c7292cea58e74b5a28d4e85dd60e741b834) @@ -16,11 +16,11 @@ ***************************************************************************/ #include -#include "Pressures.h" #include "AlarmMgmt.h" #include "FPGA.h" #include "InternalADC.h" #include "OperationModes.h" +#include "Pressures.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TaskPriority.h" @@ -40,46 +40,46 @@ #define PRESSURE_SAMPLES_TO_AVERAGE (200 / TASK_PRIORITY_INTERVAL) ///< Averaging pressure data over the reporting interval. #define PRESSURE_AVERAGE_MULTIPLIER (1.0 / (F32)PRESSURE_SAMPLES_TO_AVERAGE) ///< Optimization - multiplying is faster than dividing. -#define PRESSURE_SENSORS_ADC_BITS 12U ///< Pressure sensors ADC bits -#define PRESSURE_SENSORS_ADC_MAX_COUNT ( pow(2, PRESSURE_SENSORS_ADC_BITS) - 1 ) ///< Pressure sensors max ADC count +#define PRESSURE_SENSORS_ADC_BITS 12U ///< Pressure sensors ADC bits. +#define PRESSURE_SENSORS_ADC_MAX_COUNT ( pow(2, PRESSURE_SENSORS_ADC_BITS) - 1 ) ///< Pressure sensors max ADC count. -#define MIN_INLET_WATER_PRESSURE 25 ///< Minimum water input pressure -#define INLET_WATER_PRESSURE_PERSISTENCE_COUNT ( 5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Persistence count for pressure out of range error -#define PRESSURES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the pressures data is published on the CAN bus. +#define MIN_INLET_WATER_PRESSURE 25 ///< Minimum water input pressure. +#define INLET_WATER_PRESSURE_PERSISTENCE_COUNT ( 5 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Persistence count for pressure out of range error. +#define PRESSURES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the pressures data is published on the CAN bus. /// Defined states for the pressures monitor state machine. typedef enum PresOccl_States { - PRESSURE_INIT_STATE = 0, ///< Initialization state. - PRESSURE_CONTINUOUS_READ_STATE, ///< Continuous read sensors state. - NUM_OF_PRESSURE_STATES ///< Number of pressure monitor states. + PRESSURE_INIT_STATE = 0, ///< Initialization state + PRESSURE_CONTINUOUS_READ_STATE, ///< Continuous read sensors state + NUM_OF_PRESSURE_STATES ///< Number of pressure monitor states } PRESSURE_STATE_T; /// Defined states for the pressures self test state machine. typedef enum Pressures_Self_Test_States { - PRESSURE_SELF_TEST_STATE_START = 0, ///< Self test start state. - PRESSURE_TEST_STATE_IN_PROGRESS, ///< Self test in progress state. - PRESSURE_TEST_STATE_COMPLETE, ///< Self test completed state. - NUM_OF_PRESSURE_SELF_TEST_STATES ///< Number of pressure self test states. + PRESSURE_SELF_TEST_STATE_START = 0, ///< Self test start state + PRESSURE_TEST_STATE_IN_PROGRESS, ///< Self test in progress state + PRESSURE_TEST_STATE_COMPLETE, ///< Self test completed state + NUM_OF_PRESSURE_SELF_TEST_STATES ///< Number of pressure self test states } PRESSURE_SELF_TEST_STATE_T; // ********** private data ********** -static PRESSURE_STATE_T pressuresState; ///< current state of pressure monitor state machine. -static U32 pressuresDataPublicationTimerCounter = 0; ///< used to schedule pressure data publication to CAN bus. +static PRESSURE_STATE_T pressuresState; ///< current state of pressure monitor state machine. +static U32 pressuresDataPublicationTimerCounter = 0; ///< used to schedule pressure data publication to CAN bus. -/// interval (in ms/task interval) at which to publish pressures data to CAN bus. -static OVERRIDE_U32_T pressuresDataPublishInterval = { PRESSURES_DATA_PUB_INTERVAL, PRESSURES_DATA_PUB_INTERVAL, 0, 0 }; -static OVERRIDE_F32_T pressures[ NUM_OF_PRESSURE_SENSORS ]; ///< Measured pressure from sensors. +static OVERRIDE_U32_T pressuresDataPublishInterval = { PRESSURES_DATA_PUB_INTERVAL, + PRESSURES_DATA_PUB_INTERVAL, 0, 0 }; /// Pressure data publish interval. +static OVERRIDE_F32_T pressures[ NUM_OF_PRESSURE_SENSORS ]; ///< Measured pressure from sensors. -static S32 measuredPressureReadingsSum[ NUM_OF_PRESSURE_SENSORS ]; ///< Raw pressure sensor sums for averaging. -static U32 pressureFilterCounter = 0; ///< Used to schedule pressure sensor filtering. -static U32 inletWaterLowPressureCounter = 0; ///< Persistence counter for inlet water low pressure -static U32 inletWaterPressureInRangeCounter = 0; ///< Persistence counter for inlet water in range pressure +static S32 measuredPressureReadingsSum[ NUM_OF_PRESSURE_SENSORS ]; ///< Raw pressure sensor sums for averaging. +static U32 pressureFilterCounter = 0; ///< Used to schedule pressure sensor filtering. +static U32 inletWaterLowPressureCounter = 0; ///< Persistence counter for inlet water low pressure. +static U32 inletWaterPressureInRangeCounter = 0; ///< Persistence counter for inlet water in range pressure. -static PRESSURE_SELF_TEST_STATE_T pressuresSelfTestState; ///< Current pressure self test state. -static SELF_TEST_STATUS_T pressuresSelfTestResult; ///< Self test result of the Pressures module +static PRESSURE_SELF_TEST_STATE_T pressuresSelfTestState; ///< Current pressure self test state. +static SELF_TEST_STATUS_T pressuresSelfTestResult; ///< Self test result of the Pressures module. // ********** private function prototypes ********** @@ -121,7 +121,8 @@ /*********************************************************************//** * @brief - * The execPressures function executes the pressure monitor. + * The execPressures function executes the pressures' monitor state machine + * and publish pressures' data. * @details * Inputs : pressuresState * Outputs : pressuresState @@ -152,11 +153,11 @@ /*********************************************************************//** * @brief - * The handlePressuresInitState function handles the pressures initialize state \n + * The handlePressuresInitState function handles the pressures initialize state * of the pressures monitor state machine. * @details - * Inputs : TBD - * Outputs : TBD + * Inputs : none + * Outputs : none * @return next state *************************************************************************/ static PRESSURE_STATE_T handlePressuresInitState( void ) @@ -168,10 +169,10 @@ /*********************************************************************//** * @brief - * The handlePressuresContReadState function handles the continuous read state \n + * The handlePressuresContReadState function handles the continuous read state * of the pressures monitor state machine. * @details - * Inputs : TBD + * Inputs : pressureFilterCounter * Outputs : pressure sensor values updated * @return next state *************************************************************************/ @@ -222,8 +223,7 @@ /*********************************************************************//** * @brief - * The getPublishPresOcclDataInterval function gets the pressure/occlusion data \n - * publication interval. + * The getPublishPressuresDataInterval function gets the pressure data publish internval. * @details * Inputs : pressuresDataPublishInterval * Outputs : none @@ -243,11 +243,11 @@ /*********************************************************************//** * @brief - * The checkInletPressures function checks inlet water pressure value + * The checkInletPressure function checks inlet water pressure value * and triggers an alarm when pressure value is out of allowed range. * @details - * Inputs : pressures[] - * Outputs : none + * Inputs : RO pump inlet pressure sensor value + * Outputs : Triggers or clears pressure persistent alarm * @return none *************************************************************************/ void checkInletPressure( void ) @@ -278,7 +278,8 @@ * The getMeasuredArterialPressure function gets the current arterial pressure. * @details * Inputs : arterialPressure - * Outputs : none + * Outputs : none + * @param pressureID pressure sensor ID * @return the current arterial pressure (in mmHg). *************************************************************************/ F32 getMeasuredDGPressure( U32 pressureID ) @@ -306,11 +307,10 @@ /*********************************************************************//** * @brief - * The publishPressuresData function publishes DG pressures data at the \n - * set interval. + * The publishPressuresData function publishes DG pressures data at a set interval. * @details * Inputs : pressuresDataPublicationTimerCounter - * Outputs : DG Pressures data are published to CAN bus. + * Outputs : Pressures data are published to CAN bus * @return none *************************************************************************/ static void publishPressuresData( void ) @@ -343,8 +343,7 @@ /*********************************************************************//** * @brief - * The execPressureSelfTest function executes the state machine for the \n - * Pressures self test. + * The execPressureSelfTest function executes the pressures self test's state machine. * @details * Inputs : pressuresSelfTestState * Outputs : pressuresSelfTestState @@ -381,11 +380,10 @@ * @brief * The handleSelfTestADCCheck function checks whether the ADC reads and * report status back. If the reads are above the maximum 12bit ADC count - * or below 0, it will throw an alarm. + * or equals zero, it will throw an alarm. * @details - * Inputs : none - * Outputs : none - * @param none + * Inputs : ADC reading for RO pump inlet pressure sensor + * Outputs : Performed ADC check self test. * @return result (SELF_TEST_STATUS_T) *************************************************************************/ static SELF_TEST_STATUS_T handleSelfTestADCCheck( void ) @@ -407,15 +405,14 @@ * TEST SUPPORT FUNCTIONS *************************************************************************/ - /*********************************************************************//** * @brief - * The testSetPressuresDataPublishIntervalOverride function overrides the \n - * pressure and occlusion data publish interval. + * The testSetPressuresDataPublishIntervalOverride function overrides the + * pressure data publish interval. * @details * Inputs : none * Outputs : pressuresDataPublishInterval - * @param value override pressure and occlusion data publish interval with (in ms) + * @param value value to override pressure data publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetPressuresDataPublishIntervalOverride( U32 value ) @@ -436,7 +433,7 @@ /*********************************************************************//** * @brief - * The testResetPressuresDataPublishIntervalOverride function resets the override \n + * The testResetPressuresDataPublishIntervalOverride function resets the override * of the pressure and occlusion data publish interval. * @details * Inputs : none @@ -459,12 +456,12 @@ /*********************************************************************//** * @brief - * The testSetDGPressureSensorOverride function overrides the value of the \n + * The testSetDGPressureSensorOverride function overrides the value of the * specified pressure sensor with a given value. * Inputs : none * Outputs : pressures[] - * @param sensor ID of pressure sensor to override for - * @param value override value for the given pressure sensor ID + * @param sensor pressure sensor ID + * @param value override value for pressure data * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetDGPressureSensorOverride( U32 sensor, F32 value ) @@ -491,7 +488,7 @@ * @details * Inputs : none * Outputs : pressures[] - * @param value ID of sensor to reset override pressure for + * @param sensor pressure sensor ID * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testResetDGPressureSensorOverride( U32 sensor )