Index: firmware/App/Controllers/Valves.h =================================================================== diff -u -r4a5f3c9dfe803562a40aeea3bbc9fc3be0d1e26d -re13152777df58456a873789fbfc3f889813109c9 --- firmware/App/Controllers/Valves.h (.../Valves.h) (revision 4a5f3c9dfe803562a40aeea3bbc9fc3be0d1e26d) +++ firmware/App/Controllers/Valves.h (.../Valves.h) (revision e13152777df58456a873789fbfc3f889813109c9) @@ -1,47 +1,116 @@ -/* - * Valves.h - * - * Created on: Aug 7, 2020 - * Author: fw - */ +/************************************************************************** +* +* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file Valves.h +* +* @author (last) Dara Navaei +* @date (last) 08-Oct-2020 +* +* @author (original) Dara Navaei +* @date (original) 07-Aug-2020 +* +***************************************************************************/ + #ifndef _VALVES_H_ #define _VALVES_H_ #include "Common.h" +/** + * @defgroup Valves Valves + * @brief Valves module + * Driver that runs the valves in HD. The driver can home the valves + * as well as setting a position. + * + * @addtogroup Valves + * @{ + */ + +// ********** public definitions ********** + +/// Valves positions typedef enum valveStatesNames { - VALVE_STATE_POS_A_INSERT_EJECT = 0, - VALVE_STATE_POS_B_OPEN, - VALVE_STATE_POS_C_CLOSE, - NUM_OF_VALVE_STATES, -} VALVE_STATE_NAMES_T; + VALVE_POSITION_NOT_IN_POSITION = 0, ///< Valve position is unknown (cannot be used as a command) + VALVE_POSITION_A_INSERT_EJECT, ///< Position A, Insert/Eject (current position or commanded) + VALVE_POSITION_B_OPEN, ///< Position B, Open (current position or commanded) + VALVE_POSITION_C_CLOSE, ///< Position C, Close (current position or commanded) + NUM_OF_VALVE_POSITIONS, ///< Number of valve positions +} VALVE_POSITION_T; -typedef enum valveNames +/// 3 way valves names +typedef enum valvesNames { - VDI = 0, - VDO, - VBA, - VBV, - VAT, - NUM_OF_VALVES -} VALVES_T; + VDI = 0, ///< Valve Dialyzer Inlet + VDO, ///< Valve Dialyzer Outlet + VBA, ///< Valve Blood Arterial + VBV, ///< Valve Blood Venous + NUM_OF_VALVES ///< Number of valves +} VALVE_T; +#pragma pack(push, 1) +/// HD valves broadcast data +typedef struct +{ + U32 valveID; ///< Valve ID + U32 state; ///< Current state of the state machine + U32 currentPosID; ///< Current position in enum + S16 currentPos; ///< Current position in counts + S16 nextPos; ///< Next position in counts + F32 current; ///< Current of the valves + S16 posC; ///< Calculated Position C + S16 posA; ///< Calculated Position A + S16 posB; ///< Calculated Position B + U32 pwm; ///< Valve PWM in the bypass mode + U32 airTrapValve; ///< Air trap valve status + +} HD_VALVE_DATA_T; +#pragma pack(pop) + +/// HD valves PWM override payload +typedef struct +{ + BOOL reset; ///< Reset flag + U32 valve; ///< Valve ID + U32 pwm; ///< Valve PWM + U32 direction; ///< Valve direction +} OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T; + +// ********** public function prototypes ********* + void initValves( void ); SELF_TEST_STATUS_T execValvesSelfTest( void ); void execValves( void ); -BOOL homeDialyzerInletValve( void ); +BOOL homeValve( VALVE_T valve ); -BOOL homeDialyzerOutletValve( void ); +BOOL setValvePosition( VALVE_T valve, VALVE_POSITION_T position ); -BOOL homeBloodArterialValve( void ); +VALVE_POSITION_T getValvePosition( VALVE_T valve ); -BOOL homeBloodVenousValve( void ); +void setValveAirTrap( OPN_CLS_STATE_T state ); -BOOL homeBloodTrapValve( void ); +OPN_CLS_STATE_T getValveAirTrapStatus( void ); +BOOL testSetValvesDataPublishInterval( U32 value ); + +BOOL testResetValvesDataPublishInterval( void ); + +BOOL testSetValvesPositionOverride( U32 valve, U32 position ); + +BOOL testResetValvesPositionOverride( U32 valve ); + +BOOL testSetValvePWMOverride( U32 valve, U32 pwm, U32 direction ); + +BOOL testResetValvePWMOverride( U32 valve ); + +/**@}*/ + #endif