Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r7bb46513e0563ac58f769f654ac67ae694f369ad -r17261d704df24e2cbb33f544af053d67262a9e28 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 7bb46513e0563ac58f769f654ac67ae694f369ad) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 17261d704df24e2cbb33f544af053d67262a9e28) @@ -38,18 +38,18 @@ #define VALVES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Valves data publish interval. #define DATA_PUBLISH_COUNTER_START_COUNT 13 ///< Valves data publish start counter. #define VALVE_TRANSITION_MIN_TGT_DELTA 50 ///< Minimum encoder position delta from target position to end transition state. -#define VALVE_HOME_MIN_POS_CHG 3 ///< Minimum encoder position change to indicate a home operation is still moving toward edge. -#define VALVE_HOME_BACK_OFF_EDGE 3 ///< Encoder counts to back off of detected edge position. -#define MAX_HOME_FULL_TRAVEL_DIFF 10U ///< Maximum allowed difference in full travel encoder counts between expected and measured during home operation. +//#define VALVE_HOME_MIN_POS_CHG 3 ///< Minimum encoder position change to indicate a home operation is still moving toward edge. +//#define VALVE_HOME_BACK_OFF_EDGE 3 ///< Encoder counts to back off of detected edge position. +//#define MAX_HOME_FULL_TRAVEL_DIFF 10U ///< Maximum allowed difference in full travel encoder counts between expected and measured during home operation. #define VALVE_TRANSITION_TIMEOUT_MS ( 3 * MS_PER_SECOND ) ///< Valves transition time out in ms. #define VALVE_HOMING_TIMEOUT_MS ( 15 * MS_PER_SECOND ) ///< Valves homing time out in ms. -#define HOMING_EDGE_DETECTION_TIMEOUT_MS ( 0.5 * MS_PER_SECOND ) ///< Valves homing edge detection timeout in milliseconds. -#define VALVE_FORCE_HOME TRUE ///< Force valve to home even if already homed. -#define ZERO_ENC_DEBOUNCE_THRESHOLD_CNT 5 ///< Valves zero encoder debounce threshold count. -#define ZERO_ENC_DEBOUNCE_TIMEOUT_MS ( 0.25 * MS_PER_SECOND ) ///< Valves zero encoder debounce timeout in milliseconds. -#define VALVE_OFFEST_FROM_EDG_CNT 296 ///< Valves offset from the edge. -#define POS_C_FROM_ZERO_CNT VALVE_OFFEST_FROM_EDG_CNT ///< Position C from zero position in counts. -#define POS_D_PARTIAL_CLOSE_FROM_ZERO_CNT ( POS_C_FROM_ZERO_CNT + 32 ) ///< Position D partial close from zero position in counts. +//#define HOMING_EDGE_DETECTION_TIMEOUT_MS ( 0.5 * MS_PER_SECOND ) ///< Valves homing edge detection timeout in milliseconds. +//#define VALVE_FORCE_HOME TRUE ///< Force valve to home even if already homed. +//#define ZERO_ENC_DEBOUNCE_THRESHOLD_CNT 5 ///< Valves zero encoder debounce threshold count. +//#define ZERO_ENC_DEBOUNCE_TIMEOUT_MS ( 0.25 * MS_PER_SECOND ) ///< Valves zero encoder debounce timeout in milliseconds. +//#define VALVE_OFFEST_FROM_EDG_CNT 296 ///< Valves offset from the edge. +//#define POS_C_FROM_ZERO_CNT VALVE_OFFEST_FROM_EDG_CNT ///< Position C from zero position in counts. +//#define POS_D_PARTIAL_CLOSE_FROM_ZERO_CNT ( POS_C_FROM_ZERO_CNT + 32 ) ///< Position D partial close from zero position in counts. /// Valve status structure typedef struct Index: firmware/App/Drivers/PinchValve.c =================================================================== diff -u -r7bb46513e0563ac58f769f654ac67ae694f369ad -r17261d704df24e2cbb33f544af053d67262a9e28 --- firmware/App/Drivers/PinchValve.c (.../PinchValve.c) (revision 7bb46513e0563ac58f769f654ac67ae694f369ad) +++ firmware/App/Drivers/PinchValve.c (.../PinchValve.c) (revision 17261d704df24e2cbb33f544af053d67262a9e28) @@ -135,6 +135,8 @@ typedef enum pinchValvePositionCommandIndexes { PINCH_VALVE_POSITION_CMD_RESET_EVENT_STATUS = 0, ///< Pinch valve position command reset event status + PINCH_VALVE_HOME_CMD_SET_VELOCITY, ///< Pinch valve position command set velocity + PINCH_VALVE_HOME_CMD_UPDATE, PINCH_VALVE_POSITION_CMD_SET_POSITION, ///< Pinch valve position command set position PINCH_VALVE_POSITION_CMD_UPDATE, ///< Pinch valve position command update PINCH_VALVE_POSITION_CMD_GET_ACTIVITY_STATUS, ///< Pinch valve position command get activity status @@ -196,6 +198,8 @@ static PINCH_VALVE_COMMAND_T positionCommands[ NUM_OF_PINCH_VALVE_POSITION_COMMANDS ] = { { PINCH_VALVE_PMD_CMD_RESET_EVENT_STATUS, PINCH_VALVE_RESET_EVENT_STATUS_VALUE, 0, 0, 1, 0, TRUE }, // Clears event bits before position movement + { PINCH_VALVE_PMD_CMD_SET_VELOCITY, 0, 0, 0, 2, 0, TRUE }, // Sets the velocity used to move to positions + { PINCH_VALVE_PMD_CMD_UPDATE, 0, 0, 0, 0, 0, TRUE }, // Starts movement to the calculated position A. { PINCH_VALVE_PMD_CMD_SET_POSITION, 0, 0, 0, 2, 0, TRUE }, // Writes the requested target encoder position { PINCH_VALVE_PMD_CMD_UPDATE, 0, 0, 0, 0, 0, TRUE }, // Starts movement to the requested position { PINCH_VALVE_PMD_CMD_GET_ACTIVITY_STATUS, 0, 0, 0, 0, 1, FALSE }, // Reads activity status after movement starts @@ -349,7 +353,7 @@ /*********************************************************************//** * @brief -* The execPinchValveCommand function executes the low-level FPGA command +* The execPinchValveCommand function executes the low level FPGA command * state machine. * @details \b Inputs: commandState[], activeCommand[], commandSpiStatus[], * commandErrorCount[], errorCountAtCommandStart[], executeStartTime[], @@ -484,14 +488,13 @@ /*********************************************************************//** * @brief -* The homePinchValve function starts the common homing command sequence. -* @note homingCommands[] is shared by H1 and H19. Only the FPGA register set -* changes according to the selected valve. -* @details \b Inputs: valve, commandState[],pendingValveHomeRequest[], +* The homePinchValve function requests the homing command sequence for the +* selected pinch valve. +* @details \b Inputs: valve, pendingValveHomeRequest[], * pendingValvePositionRequest[] -* @details \b Outputs: +* @details \b Outputs: commandFailed[], enableResetValue[] * @param valve H1_VALV or H19_VALV. -* @return TRUE if accepted, FALSE otherwise. +* @return TRUE if the homing request is accepted, FALSE otherwise. *************************************************************************/ BOOL homePinchValve( VALVE_T valve ) { @@ -511,12 +514,16 @@ /*********************************************************************//** * @brief -* The setPinchValvePosition function starts a raw position command sequence. -* @details \b Inputs: -* @details \b Outputs: +* The setPinchValvePosition function requests movement to the selected +* stored pinch valve position. +* @details \b Inputs: valve, position, pendingValveHomeRequest[], +* pendingValvePositionRequest[], valvePositions[] +* @details \b Outputs: pendingValvePosition[], +* pendingValvePositionRequest[], pendingValveHomeRequest[], +* commandFailed[] * @param valve H1_VALV or H19_VALV. -* @param position Signed destination position. -* @return TRUE if accepted, FALSE otherwise. +* @param position Requested stored valve position +* @return TRUE if the position request is accepted, FALSE otherwise. *************************************************************************/ BOOL setPinchValvePosition( VALVE_T valve, VALVE_POSITION_T position ) { @@ -536,11 +543,12 @@ /*********************************************************************//** * @brief -* The getPinchValvePosition function returns the latest actual position. -* @details \b Inputs: currentValvePosition +* The getPinchValvePosition function returns the latest actual encoder +* position for the selected pinch valve. +* @details \b Inputs: valve, currentValvePosition[] * @details \b Outputs: none * @param valve H1_VALV or H19_VALV. -* @return Latest signed position, or 0 for an invalid valve. +* @return Latest signed encoder position, or 0 for an invalid valve. *************************************************************************/ S32 getPinchValvePosition( VALVE_T valve ) { @@ -559,10 +567,10 @@ * The setPinchValveEnableReset function sets the enable and reset * register for the selected valve. * @details \b Inputs: valve, enable, reset -* @details \b Outputs: +* @details \b Outputs: enableResetValue[] * @param valve H1_VALV or H19_VALV. -* @param enable TRUE to enable the controller. -* @param reset TRUE to assert the reset bit. +* @param enable TRUE to enable the pinch valve controller. +* @param reset TRUE to assert the pinch valve controller reset. * @return none *************************************************************************/ void setPinchValveEnableReset( VALVE_T valve, BOOL enable, BOOL reset ) @@ -604,10 +612,12 @@ /*********************************************************************//** * @brief -* The isPinchValveBusy function indicates whether a command is active. -* @details \b Inputs: functionState, commandState +* The isPinchValveBusy function checks whether the selected pinch valve is +* executing or waiting for a command. +* @details \b Inputs: valve, functionState[], commandState[] * @details \b Outputs: none -* @return TRUE if the driver is busy, FALSE otherwise. +* @param valve H1_VALV or H19_VALV. +* @return TRUE if the valve is busy or invalid, FALSE otherwise. *************************************************************************/ BOOL isPinchValveBusy( VALVE_T valve ) { @@ -628,10 +638,12 @@ /*********************************************************************//** * @brief -* The isPinchValveHomed function indicates whether a command is active. -* @details \b Inputs: functionState, commandState +* The isPinchValveHomed function checks whether homed valve positions have +* been stored for the selected pinch valve. +* @details \b Inputs: valve, valvePositions[] * @details \b Outputs: none -* @return TRUE if the driver is busy, FALSE otherwise. +* @param valve H1_VALV or H19_VALV. +* @return TRUE if the selected valve has a stored Position A, FALSE otherwise. *************************************************************************/ BOOL isPinchValveHomed( VALVE_T valve ) { @@ -647,10 +659,17 @@ /*********************************************************************//** * @brief -* The execPinchValveFunction function executes the IDLE, SEND, and -* WAIT state machine. -* @details \b Inputs: functionState, commandState -* @details \b Outputs: functionState, commandState, commandResult +* The execPinchValveFunction function executes the homing and +* position sequence state machine. +* @details \b Inputs: functionState[], commandState[], +* pendingValveHomeRequest[], pendingValvePositionRequest[], +* pendingValvePosition[], commandFailed[], activeCommandArray[], +* activeCommandCount[], activeCommandIndex[] +* @details \b Outputs: functionState[],pendingValveHomeRequest[], +* pendingValvePositionRequest[],commandFailed[], homingInProgress[], +* positionInProgress[], +* activeCommandArray[], activeCommandCount[], activeCommandIndex[], +* positionCommands[] * @return none *************************************************************************/ void execPinchValveFunction( void ) @@ -762,12 +781,15 @@ /*********************************************************************//** * @brief -* The setPinchValveCommand function requests execution -* @details \b Inputs: activeCommand[] -* @details \b Outputs: pendingValvePosition[], command -* @param valve ID of valve to send a command to. -* @param command command record describing command to send to the given valve -* @return TRUE if the request was accepted, FALSE otherwise. +* The setPinchValveCommand function loads the selected command into the +* command state machine. +* @details \b Inputs: valve, command, commandState[] +* @details \b Outputs: activeCommand[], commandOutputWord1[], +* commandOutputWord2[], commandOutputWord3[], commandSpiStatus[], +* commandErrorCount[], commandFailed[], commandState[] +* @param valve H1_VALV or H19_VALV.. +* @param command Pinch valve command to execute +* @return TRUE if the command is accepted, FALSE otherwise.. *************************************************************************/ static BOOL setPinchValveCommand( VALVE_T valve, PINCH_VALVE_COMMAND_T command ) { @@ -797,11 +819,11 @@ /*********************************************************************//** * @brief -* The writePinchValveCommandRegisters function writes the command header and -* input words through the FpgaTD interface. -* @details \b Inputs: activeValve, activeCommand -* @details \b Outputs: FPGA command header and input registers -* @return TRUE if successful, FALSE if not +* The writePinchValveCommandRegisters function writes the active command +* header, input words and FPGA command byte. +* @details \b Inputs: valve, activeCommand[] +* @details \b Outputs: fpgaCommandValue[] +* @return TRUE if the command registers are written, FALSE otherwise. *************************************************************************/ static BOOL writePinchValveCommandRegisters( VALVE_T valve ) { @@ -834,11 +856,12 @@ /*********************************************************************//** * @brief -* The transmitPinchValveCommand function builds and writes the FPGA command -* byte. -* @details \b Inputs: activeValve, activeCommand -* @details \b Outputs: FPGA command register -* @return TRUE if the command byte was valid and written. +* The transmitPinchValveCommand function starts the active FPGA command +* transaction. +* @details \b Inputs: valve, fpgaCommandValue[] +* @details \b Outputs: none +* @param valve H1_VALV or H19_VALV. +* @return TRUE if the FPGA start command is written, FALSE otherwise. *************************************************************************/ static BOOL transmitPinchValveCommand( VALVE_T valve ) { @@ -866,10 +889,12 @@ /*********************************************************************//** * @brief -* The readPinchValveCommandResponse function reads the active valve response -* through the FpgaTD interface. -* @details \b Inputs: activeValve, FPGA response registers -* @details \b Outputs: currentResponse +* The readPinchValveCommandResponse function reads the command output words +* for the selected pinch valve. +* @details \b Inputs: valve +* @details \b Outputs: commandOutputWord1[], commandOutputWord2[], +* commandOutputWord3[] +* @param valve H1_VALV or H19_VALV. * @return none *************************************************************************/ static void readPinchValveCommandResponse( VALVE_T valve ) @@ -892,8 +917,9 @@ * @brief * The clearPinchValveFpgaCommand function clears the active valve FPGA command * register. -* @details \b Inputs: fpgaCommandValue[] -* @details \b Outputs: none +* @details \b Inputs: valve +* @details \b Outputs: fpgaCommandValue[] +* @param valve H1_VALV or H19_VALV. * @return none *************************************************************************/ static void clearPinchValveFpgaCommand( VALVE_T valve ) @@ -914,14 +940,14 @@ /*********************************************************************//** * @brief -* The setPinchValveFpgaCommandBytePinchValveFpgaCommandByte function builds the FPGA command byte. -* @details The transmit count includes the command header, so one is added to -* the number of input words. -* @details \b Inputs: command, +* The setPinchValveFpgaCommandByte function builds the FPGA command byte +* from the command word counts and write only setting. +* @details \b Inputs: command->inputWordCount,command->outputWordCount, +* command->writeOnly * @details \b Outputs: fpgaCommand -* @param command Pinch valve command request. -* @param fpgaCommand Destination for the built FPGA command byte. -* @return TRUE if the word counts are valid. +* @param command Pointer to the pinch valve command. +* @param fpgaCommand Pointer to the generated FPGA command byte. +* @return TRUE if the command byte is generated, FALSE otherwise. *************************************************************************/ static BOOL setPinchValveFpgaCommandByte( const PINCH_VALVE_COMMAND_T *command, U08 *fpgaCommand ) { @@ -954,10 +980,10 @@ /*********************************************************************//** * @brief -* The isPinchValveCommandDone function checks the SPI command-done bit. -* @details \b Inputs: -* @details \b Outputs: -* @return TRUE if the FPGA transaction is complete. +* The isPinchValveCommandDone function checks the SPI command done bit. +* @details \b Inputs: commandSpiStatus[] +* @details \b Outputs: none +* @return TRUE if the command done bit is set, FALSE otherwise. *************************************************************************/ static BOOL isPinchValveCommandDone( VALVE_T valve ) { @@ -968,9 +994,9 @@ * @brief * The isPinchValveControllerFaultActive function checks the controller fault * status bit. -* @details \b Inputs: commandSpiStatus +* @details \b Inputs: commandSpiStatus[] * @details \b Outputs: none -* @return TRUE if the controller fault bit is active. +* @return TRUE if the controller fault bit is set, FALSE otherwise *************************************************************************/ static BOOL isPinchValveControllerFaultActive( VALVE_T valve ) { @@ -979,11 +1005,11 @@ /*********************************************************************//** * @brief -* The didPinchValveErrorCountChange function checks whether the active -* transaction incremented the invalid-command counter. +* The didPinchValveErrorCountChange function checks whether the FPGA command +* error count changed during the active transaction. * @details \b Inputs: commandErrorCount[] * @details \b Outputs: none -* @return TRUE if the error count changed. +* @return TRUE if the error count changed, FALSE otherwise. *************************************************************************/ static BOOL didPinchValveErrorCountChange( VALVE_T valve ) { @@ -992,11 +1018,12 @@ /*********************************************************************//** * @brief -* The arePinchValveWordCountsValid function verifies the FPGA-reported -* transmitted and received word counts. +* The arePinchValveWordCountsValid function verifies the FPGA reported +* transmit and receive word counts. * @details \b Inputs: currentResponse.spiCmdStatus, activeCommand * @details \b Outputs: none -* @return TRUE if reported counts match the command. +* @param valve H1_VALV or H19_VALV. +* @return TRUE if the reported word counts are valid, FALSE otherwise. *************************************************************************/ static BOOL arePinchValveWordCountsValid( VALVE_T valve ) { @@ -1026,10 +1053,10 @@ /*********************************************************************//** * @brief -* The readPinchValveErrorCount function returns the current error count for +* The readPinchValveErrorCount function reads the current error count for * the selected valve. -* @details \b Inputs: H1_VALV, H19_VALV -* @details \b Outputs: result +* @details \b Inputs: valve +* @details \b Outputs: none * @param valve H1_VALV or H19_VALV. * @return Current error count, or 0 for an invalid valve. *************************************************************************/ @@ -1051,11 +1078,11 @@ /*********************************************************************//** * @brief -* The isValidPinchValve function validates a valve ID. +* The isValidPinchValve function validates the selected valve ID. * @details \b Inputs: valve * @details \b Outputs: none * @param valve Valve to validate. -* @return TRUE if the valve is H1 or H19. +* @return TRUE for H1_VALV or H19_VALV, FALSE otherwise. *************************************************************************/ static BOOL isValidPinchValve( VALVE_T valve ) { @@ -1064,11 +1091,13 @@ /*********************************************************************//** * @brief -* The isValidPinchValveCommand function validates a generic command request. -* @details \b Inputs: command +* The isValidPinchValveCommand function validates the command pointer and +* command word counts. +* @details \b Inputs: command, command->inputWordCount, +* command->outputWordCount * @details \b Outputs: none -* @param command Pointer to command record to validate. -* @return TRUE if the request is valid. +* @param command Pointer to the pinch valve command. +* @return TRUE if the command is valid, FALSE otherwise. *************************************************************************/ static BOOL isValidPinchValveCommand( const PINCH_VALVE_COMMAND_T *command ) { @@ -1090,10 +1119,12 @@ /*********************************************************************//** * @brief -* The setSigned32CommandWords function stores a signed 32-bit value. -* @details \b Inputs: rawValue -* @details \b Outputs: imputWord1, inputWord2 -* @param command Command to update. +* The setSigned32CommandWords function stores a signed 32 bit value in two +* 16 bit command input words. +* @details \b Inputs: command, value +* @details \b Outputs: command->inputWord1, command->inputWord2 +* @param command Pointer to the command to update. +* @param value Signed 32 bit value to store. * @return none *************************************************************************/ static void setSigned32CommandWords( PINCH_VALVE_COMMAND_T *command, S32 value ) @@ -1110,10 +1141,12 @@ /*********************************************************************//** * @brief -* The getSigned32ResponseValue function combines two PMD output words. -* @details \b Inputs:rawValue +* The getSigned32OutputValue function combines two 16 bit command output +* words into a signed 32 bit value. +* @details \b Inputs: valve, commandOutputWord1[], commandOutputWord2[] * @details \b Outputs: none -* @return Signed 32-bit value. +* * @param valve H1_VALV or H19_VALV. +* @return Signed 32 bit command output value. *************************************************************************/ static S32 getSigned32OutputValue( VALVE_T valve ) { @@ -1126,12 +1159,13 @@ /*********************************************************************//** * @brief -* The processPinchValveCommandOutput function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The processPinchValveCommandOutput function processes the active command +* response and determines the next low level command state. +* @details \b Inputs: valve, activeCommand[], activeCommandIndex[], +* commandOutputWord1[], commandOutputWord2[], commandOutputWord3[], +* motionStartTime[], homingInProgress[], valvePositions[] +* @details \b Outputs: motionStartTime[], activityStatus[], eventStatus[], +* currentValvePosition[], valvePositions[] * @param valve H1_VALV or H19_VALV. * @return next pinch valve command state *************************************************************************/ @@ -1247,12 +1281,10 @@ /*********************************************************************//** * @brief -* The isPinchValveCommandOutput function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The clearActivePinchValveCommand function clears the active command record +* for the selected pinch valve. +* @details \b Inputs: valve +* @details \b Outputs: activeCommand[] * @param valve H1_VALV or H19_VALV. * @return none *************************************************************************/ @@ -1272,12 +1304,10 @@ /*********************************************************************//** * @brief -* The clearPinchValveCommandRegisters function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The clearPinchValveCommandRegisters function clears the selected pinch +* valve FPGA command registers. +* @details \b Inputs: valve +* @details \b Outputs: fpgaCommandValue[] * @param valve H1_VALV or H19_VALV. * @return none *************************************************************************/ @@ -1307,12 +1337,12 @@ /*********************************************************************//** * @brief -* The resetPinchValveFunctionSequence function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The resetPinchValveFunctionSequence function resets the active homing or +* position command sequence for the selected pinch valve. +* @details \b Inputs: valve +* @details \b Outputs: activeCommandArray[], activeCommandCount[], +* activeCommandIndex[], homingInProgress[], positionInProgress[], +* functionState[] * @param valve H1_VALV or H19_VALV. * @return none *************************************************************************/ @@ -1331,62 +1361,67 @@ /*********************************************************************//** * @brief -* The isPinchValveMotionComplete function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition -* @param valve H1_VALV or H19_VALV. -* @return none +* The isPinchValveMotionComplete function checks the event status +* motion complete bit +* @details \b Inputs: status +* @details \b Outputs: none +* @param status of event status value. +* @return TRUE if motion is complete, FALSE otherwise. *************************************************************************/ static BOOL isPinchValveMotionComplete( U16 status ) { - return ( 0 != ( status & PINCH_VALVE_EVENT_MOTION_COMPLETE_MASK ) ); + BOOL result; + + result = ( 0 != ( status & PINCH_VALVE_EVENT_MOTION_COMPLETE_MASK ) ); + + return result; } /*********************************************************************//** * @brief -* The isPinchValveMotionComplete function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition -* @param valve H1_VALV or H19_VALV. -* @return none +* The isPinchValveMotionError function checks the PMD event status +* motion error bit. +* @details \b Inputs: status +* @details \b Outputs: none +* @param status of event status value. +* @return TRUE if a motion error is active, FALSE otherwise. *************************************************************************/ static BOOL isPinchValveMotionError( U16 status ) { - return ( 0 != ( status & PINCH_VALVE_EVENT_MOTION_ERROR_MASK ) ); + BOOL result; + + result = ( 0 != ( status & PINCH_VALVE_EVENT_MOTION_ERROR_MASK ) ); + + return result; } /*********************************************************************//** * @brief -* The isPinchValveMotionComplete function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition -* @param valve H1_VALV or H19_VALV. -* @return none +* The isValidPinchValvePosition function validates the selected stored valve +* position. +* @details \b Inputs: position +* @details \b Outputs: none +* @param position Valve position ID to validate. +* @return TRUE for Position A, B, or C, FALSE otherwise. *************************************************************************/ static BOOL isValidPinchValvePosition( VALVE_POSITION_T position ) { - return ( ( position > VALVE_POSITION_NOT_IN_POSITION ) && ( position < NUM_OF_VALVE_POSITIONS ) ); + BOOL result; + + result = ( ( position > VALVE_POSITION_NOT_IN_POSITION ) && ( position < NUM_OF_VALVE_POSITIONS ) ); + + return result; } /*********************************************************************//** * @brief -* The isPinchValveMotionComplete function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The getPinchValveStoredPosition function returns the stored encoder count +* for the selected pinch valve position. +* @details \b Inputs: valve, position, valvePositions[] +* @details \b Outputs: none * @param valve H1_VALV or H19_VALV. -* @return none +* @param position Stored valve position to read. +* @return Stored signed encoder position, or 0 for invalid input. *************************************************************************/ S32 getPinchValveStoredPosition( VALVE_T valve, VALVE_POSITION_T position ) { @@ -1402,14 +1437,13 @@ /*********************************************************************//** * @brief -* The isPinchValveMotionComplete function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The movePinchValveToStoredPosition function requests movement to a stored +* pinch valve position. +* @details \b Inputs: valve, position +* @details \b Outputs: none * @param valve H1_VALV or H19_VALV. -* @return none +* @param position Stored valve position to command. +* @return TRUE if the movement request is accepted, FALSE otherwise *************************************************************************/ BOOL movePinchValveToStoredPosition( VALVE_T valve, VALVE_POSITION_T position ) { @@ -1425,14 +1459,12 @@ /*********************************************************************//** * @brief -* The isPinchValveMotionComplete function stores output data returned by -* Get Activity Status, Get Event Status, and Get Actual Position commands. -* @details \b Inputs: activeCommand, commandOutputWord1, -* commandOutputWord2, commandOutputWord3 -* @details \b Outputs: activityStatus, eventStatus, -* currentValvePosition +* The isPinchValveCommandResponseReady function checks whether the FPGA +* command response is complete and contains the expected output words. +* @details \b Inputs: commandSpiStatus[], activeCommand[] +* @details \b Outputs: none * @param valve H1_VALV or H19_VALV. -* @return none +* @return TRUE if the command response is ready, FALSE otherwise. *************************************************************************/ static BOOL isPinchValveCommandResponseReady( VALVE_T valve ) {