Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -rf6b78d1fe6741043de38707211710ab0e8a08483 -r28643ed284d6e6c61c15df02d62f49577a38cce4 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision f6b78d1fe6741043de38707211710ab0e8a08483) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 28643ed284d6e6c61c15df02d62f49577a38cce4) @@ -14,30 +14,31 @@ * @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 ) +<<<<<<< HEAD #define DATA_PUBLISH_COUNTER_START_COUNT 7 ///< Data publish counter start count. /// Defined states for the air trap controller state machine. @@ -55,31 +56,49 @@ static AIR_TRAP_STATE_T airTrapControllerState; ///< Current state of air trap controller state machine. static U32 airTrapDataPublicationTimerCounter; ///< Used to schedule air trap data publication to CAN bus. +======= + +/// 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. + +>>>>>>> cc-vectorcast2 /// 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; @@ -351,6 +370,7 @@ result = AIR_TRAP_VALVE_CLOSED_STATE; } + return result; } @@ -525,4 +545,4 @@ return result; } -/**@}*/ +/**@}*/