Index: firmware/App/Drivers/PinchValve.c =================================================================== diff -u -r5a62968e832ffab29c33924c9aeecfedcbafb362 -r6c8401529a55424106923c83096a737871364705 --- firmware/App/Drivers/PinchValve.c (.../PinchValve.c) (revision 5a62968e832ffab29c33924c9aeecfedcbafb362) +++ firmware/App/Drivers/PinchValve.c (.../PinchValve.c) (revision 6c8401529a55424106923c83096a737871364705) @@ -196,16 +196,16 @@ static U16 commandOutputWord1[ NUM_OF_VALVES ]; static U16 commandOutputWord2[ NUM_OF_VALVES ]; static U16 commandOutputWord3[ NUM_OF_VALVES ]; +static U16 activityStatus[ NUM_OF_VALVES ]; +static U16 eventStatus[ NUM_OF_VALVES ]; static U08 commandSpiStatus[ NUM_OF_VALVES ]; static U08 commandErrorCount[ NUM_OF_VALVES ]; static U08 errorCountAtCommandStart[ NUM_OF_VALVES ]; static U08 enableResetValue[ NUM_OF_VALVES ]; static U32 executeStartTime[ NUM_OF_VALVES ]; -//static U32 statusPollStartMSCount[ NUM_OF_VALVES ]; - // ********** private function prototypes ********** static BOOL setPinchValveCommand( VALVE_T valve, PINCH_VALVE_COMMAND_T command ); @@ -221,11 +221,12 @@ static BOOL didPinchValveErrorCountChange( VALVE_T valve ); static BOOL arePinchValveWordCountsValid( VALVE_T valve ); -static U08 readPinchValveErrorCount( VALVE_T valve ); +static U08 readPinchValveErrorCount( VALVE_T valve ); static BOOL isValidPinchValve( VALVE_T valve ); -static BOOL isValidPinchValveCommand( PINCH_VALVE_COMMAND_T *command ); +static BOOL isValidPinchValveCommand( const PINCH_VALVE_COMMAND_T *command ); static void setSigned32CommandWords( PINCH_VALVE_COMMAND_T *command, S32 value ); -static S32 getSigned32OutputValue( VALVE_T valve ); +static S32 getSigned32OutputValue( VALVE_T valve ); +static void savePinchValveCommandOutput( VALVE_T valve ); /*********************************************************************//** * @brief @@ -258,12 +259,13 @@ commandOutputWord1[ valve ] = 0; commandOutputWord2[ valve ] = 0; commandOutputWord3[ valve ] = 0; + activityStatus[ valve ] = 0; + eventStatus[ valve ] = 0; commandSpiStatus[ valve ] = 0; commandErrorCount[ valve ] = 0; errorCountAtCommandStart[ valve ] = 0; enableResetValue[ valve ] = 0; executeStartTime[ valve ] = 0; - statusPollStartMSCount[ valve ] = 0; activeCommand[ valve ].cmdHeader = 0; activeCommand[ valve ].inputWord1 = 0; @@ -318,7 +320,6 @@ if ( TRUE == transmitPinchValveCommand( valve ) ) { executeStartTime[ valve ] = getMSTimerCount(); -// statusPollStartMSCount[ valve ] = executeStartTime[ valve ]; commandState[ valve ] = PINCH_VALVE_CMD_WAIT_DONE_STATE; } else @@ -331,13 +332,11 @@ case PINCH_VALVE_CMD_WAIT_DONE_STATE: if ( TRUE == didTimeout( executeStartTime[ valve ], PINCH_VALVE_COMMAND_TIMEOUT_MS ) ) { - //readPinchValveCommandResponse( valve ); // Varshini, I don't think we should read response if it times out. commandState[ valve ] = PINCH_VALVE_CMD_ERROR_STATE; } - else // if ( TRUE == didTimeout( statusPollStartMSCount[ valve ], PINCH_VALVE_STATUS_POLL_INTERVAL_MS ) ) + else { readPinchValveCommandResponse( valve ); -// statusPollStartMSCount[ valve ] = getMSTimerCount(); if ( ( TRUE == didPinchValveErrorCountChange( valve ) ) || ( TRUE == isPinchValveControllerFaultActive( valve ) ) ) { @@ -351,7 +350,6 @@ break; case PINCH_VALVE_CMD_READ_WORDS_STATE: - readPinchValveCommandResponse( valve ); // Varshini - do we have to read again? Looks like you already read response in prior state. if ( ( TRUE == didPinchValveErrorCountChange( valve ) ) || ( TRUE == isPinchValveControllerFaultActive( valve ) ) || @@ -361,7 +359,7 @@ } else { - // TODO - Varshini, I think we need to interpret/save output words (for Get commands) to static variables (e.g. currentValvePosition for a GetPosition command) + savePinchValveCommandOutput( valve ); clearPinchValveFpgaCommand( valve ); activeCommand[ valve ].cmdHeader = 0; commandFailed[ valve ] = FALSE; @@ -371,7 +369,6 @@ case PINCH_VALVE_CMD_ERROR_STATE: -// readPinchValveCommandResponse( valve ); clearPinchValveFpgaCommand( valve ); activeCommand[ valve ].cmdHeader = 0; commandFailed[ valve ] = TRUE; @@ -639,11 +636,11 @@ { activeCommand[ valve ] = command; - // if set position command, replace position value (words 1 and 2) with position given with command - if ( PINCH_VALVE_PMD_CMD_SET_POSITION == activeCommandArray[ valve ]->cmdHeader ) + if ( PINCH_VALVE_PMD_CMD_SET_POSITION == activeCommand[ valve ].cmdHeader ) { setSigned32CommandWords( &activeCommand[ valve ], pendingValvePosition[ valve ] ); } + // reset command feedback before command is sent commandOutputWord1[ valve ] = 0; commandOutputWord2[ valve ] = 0; @@ -659,7 +656,6 @@ return result; } - /*********************************************************************//** * @brief * The writePinchValveCommandRegisters function writes the command header and @@ -859,7 +855,7 @@ *************************************************************************/ static BOOL arePinchValveWordCountsValid( VALVE_T valve ) { - U08 expectedTransmitCount = (U08)( activeCommand[ valve ].inputWordCount + 1U ); + U08 expectedTransmitCount = (U08)( activeCommand[ valve ].inputWordCount + 1 ); U08 transmittedCount = (U08)( ( commandSpiStatus[ valve ] & PINCH_VALVE_SPI_TX_COUNT_MASK ) >> PINCH_VALVE_SPI_TX_COUNT_SHIFT ); U08 receivedCount = (U08)( ( commandSpiStatus[ valve ] & PINCH_VALVE_SPI_RX_COUNT_MASK ) >> PINCH_VALVE_SPI_RX_COUNT_SHIFT ); @@ -912,7 +908,7 @@ * @param command Pointer to command record to validate. * @return TRUE if the request is valid. *************************************************************************/ -static BOOL isValidPinchValveCommand( PINCH_VALVE_COMMAND_T *command ) +static BOOL isValidPinchValveCommand( const PINCH_VALVE_COMMAND_T *command ); { BOOL result = FALSE; @@ -962,4 +958,39 @@ return (S32)rawValue; } +/*********************************************************************//** +* @brief +* The savePinchValveCommandOutput 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 +*************************************************************************/ +static void savePinchValveCommandOutput( VALVE_T valve ) +{ + if ( TRUE == isValidPinchValve( valve ) ) + { + switch ( activeCommand[ valve ].cmdHeader ) + { + case PINCH_VALVE_PMD_CMD_GET_ACTIVITY_STATUS: + activityStatus[ valve ] = commandOutputWord1[ valve ]; + break; + + case PINCH_VALVE_PMD_CMD_GET_EVENT_STATUS: + eventStatus[ valve ] = commandOutputWord1[ valve ]; + break; + + case PINCH_VALVE_PMD_CMD_GET_ACTUAL_POSITION: + currentValvePosition[ valve ] = getSigned32OutputValue( valve ); + break; + + default: + // Check with Sean TODO later + break; + } + } +} /**@}*/ Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -r8345f0415ce34f2f47afcbf613a00216769f51c6 -r6c8401529a55424106923c83096a737871364705 --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 8345f0415ce34f2f47afcbf613a00216769f51c6) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 6c8401529a55424106923c83096a737871364705) @@ -25,6 +25,7 @@ #include "TDDefs.h" #include "Timers.h" #include "TubeSetInstall.h" +#include "TxParams.h" /** * @addtogroup TubeSetInstall