Index: firmware/App/Controllers/Valves.h =================================================================== diff -u -rf64e547824dbb2ade04b700b319d92206f7d0b6d -r8e7158d8231435496fcf1d5649e51babf859ccc7 --- firmware/App/Controllers/Valves.h (.../Valves.h) (revision f64e547824dbb2ade04b700b319d92206f7d0b6d) +++ firmware/App/Controllers/Valves.h (.../Valves.h) (revision 8e7158d8231435496fcf1d5649e51babf859ccc7) @@ -1,10 +1,21 @@ -/* - * Valves.h - * - * Created on: Aug 7, 2020 - * Author: fw - */ +/************************************************************************** +* +* Copyright (c) 2019-2021 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) Sean Nash +* @date (last) 14-Oct-2020 +* +* @author (original) Dara Navaei +* @date (original) 07-Aug-2020 +* +***************************************************************************/ + #ifndef _VALVES_H_ #define _VALVES_H_ @@ -13,39 +24,63 @@ /** * @defgroup Valves Valves * @brief Valves module - * Driver that runs the valves in HD. + * 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_POSITION_NOT_IN_POSITION = 0, - VALVE_POSITION_A_INSERT_EJECT, - VALVE_POSITION_B_OPEN, - VALVE_POSITION_C_CLOSE, - NUM_OF_VALVE_POSITIONS, + 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, - NUM_OF_VALVES + 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; -typedef enum valveBloodTrap +#pragma pack(push, 1) +/// HD valves broadcast data +typedef struct { - ENERGIZE = 0, - DEENERGIZE, - NUM_OF_STATES -} VALVE_BLOOD_TRAP_STATE_T; + 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 ); @@ -54,14 +89,28 @@ void execValves( void ); -BOOL homeValve( VALVE_T valve ); //TODO does it need to return bool? +BOOL homeValve( VALVE_T valve ); -BOOL setValvePosition( VALVE_T valve, VALVE_POSITION_T position ); //TODO does it need to return bool? +BOOL setValvePosition( VALVE_T valve, VALVE_POSITION_T position ); -S16 getValvePosition( VALVE_T valve ); +VALVE_POSITION_T getValvePosition( VALVE_T valve ); -BOOL setValveBloodTrap( VALVE_BLOOD_TRAP_STATE_T state ); +void setValveAirTrap( OPN_CLS_STATE_T state ); +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