Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r61716bc97ecca8af1ec560333844a8cf602eccb0 -r9d03872a4b47b119f8416e2f78c0f24f6fb525e5 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 61716bc97ecca8af1ec560333844a8cf602eccb0) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 9d03872a4b47b119f8416e2f78c0f24f6fb525e5) @@ -14,71 +14,71 @@ * @date (original) 16-Sep-2020 * ***************************************************************************/ - -#include "AirTrap.h" -#include "AlarmMgmt.h" + +#include "AirTrap.h" +#include "AlarmMgmt.h" #include "FPGA.h" -#include "ModeTreatmentParams.h" -#include "OperationModes.h" -#include "SystemCommMessages.h" +#include "ModeTreatmentParams.h" +#include "OperationModes.h" +#include "SystemCommMessages.h" #include "TaskGeneral.h" -#include "TaskPriority.h" -#include "Timers.h" - -/** - * @addtogroup AirTrap - * @{ - */ - -// ********** private definitions ********** +#include "TaskPriority.h" +#include "Timers.h" -/// Interval (ms/task time) at which the air trap data is published on the CAN bus. +/** + * @addtogroup AirTrap + * @{ + */ + +// ********** private definitions ********** + +/// Interval (ms/task time) at which the air trap data is published on the CAN bus. #define AIR_TRAP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) /// Persistence period for illegal level sensors fault. static const U32 AIR_TRAP_ILLEGAL_LEVELS_PERSISTENCE = ( MS_PER_SECOND * 2 / TASK_PRIORITY_INTERVAL ); /// Volume (in mL) of venous portion of blood circuit line. TODO - get actual volume from Systems. -#define VENOUS_LINE_VOLUME_ML ( 200.0 ) - -/// Defined states for the air trap controller state machine. -typedef enum AirTrap_States -{ - AIR_TRAP_INIT_STATE = 0, ///< Initialization state +#define VENOUS_LINE_VOLUME_ML ( 200.0 ) + +/// Defined states for the air trap controller state machine. +typedef enum AirTrap_States +{ + AIR_TRAP_INIT_STATE = 0, ///< Initialization state AIR_TRAP_MANUAL_CONTROL_STATE, ///< Manually control air trap valve state AIR_TRAP_VALVE_CLOSED_STATE, ///< Valve closed state - until air detected at lower level - AIR_TRAP_VALVE_OPEN_STATE, ///< Valve open state - until fluid detected at upper level - NUM_OF_AIR_TRAP_STATES ///< Number of air trap controller states -} AIR_TRAP_STATE_T; - -// ********** private data ********** - -static AIR_TRAP_STATE_T airTrapControllerState; ///< Current state of air trap controller state machine. -static U32 airTrapDataPublicationTimerCounter = 0; ///< Used to schedule air trap data publication to CAN bus. - + AIR_TRAP_VALVE_OPEN_STATE, ///< Valve open state - until fluid detected at upper level + NUM_OF_AIR_TRAP_STATES ///< Number of air trap controller states +} AIR_TRAP_STATE_T; + +// ********** private data ********** + +static AIR_TRAP_STATE_T airTrapControllerState; ///< Current state of air trap controller state machine. +static U32 airTrapDataPublicationTimerCounter = 0; ///< Used to schedule air trap data publication to CAN bus. + /// Interval (in ms) at which to publish air trap data to CAN bus. -static OVERRIDE_U32_T airTrapDataPublishInterval = { AIR_TRAP_DATA_PUB_INTERVAL, AIR_TRAP_DATA_PUB_INTERVAL, 0, 0 }; -static OVERRIDE_U32_T airTrapLevels[ NUM_OF_AIR_TRAP_LEVEL_SENSORS ]; ///< Detected air trap level for each level sensor. +static OVERRIDE_U32_T airTrapDataPublishInterval = { AIR_TRAP_DATA_PUB_INTERVAL, AIR_TRAP_DATA_PUB_INTERVAL, 0, 0 }; +static OVERRIDE_U32_T airTrapLevels[ NUM_OF_AIR_TRAP_LEVEL_SENSORS ]; ///< Detected air trap level for each level sensor. static BOOL pendingStartAirTrapController = FALSE; ///< Flag indicates an air trap controller start request is pending. static BOOL pendingStopAirTrapController = FALSE; ///< Flag indicates an air trap controller stop request is pending. static U32 fillStartTime = 0; ///< Time stamp for start of air trap fill. static U32 airTrapIllegalLevelSensorsCtr = 0; ///< Timer counter for illegal level sensor fault. - -// ********** private function prototypes ********** - -static AIR_TRAP_STATE_T handleAirTrapManualControlState( void ); -static AIR_TRAP_STATE_T handleAirTrapValveClosedState( void ); + +// ********** private function prototypes ********** + +static AIR_TRAP_STATE_T handleAirTrapManualControlState( void ); +static AIR_TRAP_STATE_T handleAirTrapValveClosedState( void ); static AIR_TRAP_STATE_T handleAirTrapValveOpenState( void ); -static void publishAirTrapData( void ); - -/*********************************************************************//** - * @brief - * The initAirTrap function initializes the Air Trap module. - * @details Inputs: none - * @details Outputs: Air Trap module initialized. - * @return none - *************************************************************************/ +static void publishAirTrapData( void ); + +/*********************************************************************//** + * @brief + * The initAirTrap function initializes the Air Trap module. + * @details Inputs: none + * @details Outputs: Air Trap module initialized. + * @return none + *************************************************************************/ void initAirTrap( void ) { U32 i; @@ -345,6 +345,7 @@ result = AIR_TRAP_VALVE_CLOSED_STATE; } + return result; } @@ -519,4 +520,4 @@ return result; } -/**@}*/ +/**@}*/