Index: firmware/App/Drivers/PinchValve.c =================================================================== diff -u -r6ad57767b87b8e691c6cbb728b56efabe8a28e8e -r7bb46513e0563ac58f769f654ac67ae694f369ad --- firmware/App/Drivers/PinchValve.c (.../PinchValve.c) (revision 6ad57767b87b8e691c6cbb728b56efabe8a28e8e) +++ firmware/App/Drivers/PinchValve.c (.../PinchValve.c) (revision 7bb46513e0563ac58f769f654ac67ae694f369ad) @@ -28,26 +28,26 @@ // ********** private definitions ********** -#define PINCH_VALVE_COMMAND_TIMEOUT_MS 1000 ///< Maximum FPGA command execution time in milliseconds. -#define PINCH_VALVE_MOTION_TIMEOUT_MS 10000 ///< Maximum allowed valve motion time in milliseconds +#define PINCH_VALVE_COMMAND_TIMEOUT_MS 1000 ///< Maximum FPGA command execution time in milliseconds. +#define PINCH_VALVE_MOTION_TIMEOUT_MS 10000 ///< Maximum allowed valve motion time in milliseconds -#define PINCH_VALVE_HOME_OFFSET 1300 ///< Offset (in encoder counts) from end of travel edge to set position B and C. +#define PINCH_VALVE_HOME_OFFSET 1300 ///< Offset (in encoder counts) from end of travel edge to set position B and C. -#define PINCH_VALVE_FPGA_CMD_START_BIT_MASK 0x01 ///< FPGA command register bit 0 used to start a command transaction -#define PINCH_VALVE_FPGA_CMD_WRITE_ONLY_BIT_MASK 0x02 ///< FPGA command register bit 1 indicating a write only command. -#define PINCH_VALVE_FPGA_CMD_TX_COUNT_SHIFT 2 ///< Bit shift for the FPGA command transmit word count field -#define PINCH_VALVE_FPGA_CMD_RX_COUNT_SHIFT 5 ///< Bit shift for the FPGA command receive word count field. -#define PINCH_VALVE_FPGA_CMD_WORD_COUNT_MASK 0x07 ///< Three bit mask used for FPGA transmit and receive word counts +#define PINCH_VALVE_FPGA_CMD_START_BIT_MASK 0x01 ///< FPGA command register bit 0 used to start a command transaction +#define PINCH_VALVE_FPGA_CMD_WRITE_ONLY_BIT_MASK 0x02 ///< FPGA command register bit 1 indicating a write only command. +#define PINCH_VALVE_FPGA_CMD_TX_COUNT_SHIFT 2 ///< Bit shift for the FPGA command transmit word count field +#define PINCH_VALVE_FPGA_CMD_RX_COUNT_SHIFT 5 ///< Bit shift for the FPGA command receive word count field. +#define PINCH_VALVE_FPGA_CMD_WORD_COUNT_MASK 0x07 ///< Three bit mask used for FPGA transmit and receive word counts -#define PINCH_VALVE_SPI_DONE_BIT_MASK 0x01 ///< SPI status bit 0 indicating command completion -#define PINCH_VALVE_SPI_TX_COUNT_MASK 0x0E ///< SPI status mask for the transmitted word count -#define PINCH_VALVE_SPI_TX_COUNT_SHIFT 1 ///< Bit shift for the SPI transmitted word count -#define PINCH_VALVE_SPI_RX_COUNT_MASK 0x30 ///< SPI status mask for the received-word count. -#define PINCH_VALVE_SPI_RX_COUNT_SHIFT 4 ///< Bit shift for the SPI received word count -#define PINCH_VALVE_SPI_CONTROLLER_FAULT_BIT_MASK 0x40 ///< SPI status bit 6 indicating a controller fault. +#define PINCH_VALVE_SPI_DONE_BIT_MASK 0x01 ///< SPI status bit 0 indicating command completion +#define PINCH_VALVE_SPI_TX_COUNT_MASK 0x0E ///< SPI status mask for the transmitted word count +#define PINCH_VALVE_SPI_TX_COUNT_SHIFT 1 ///< Bit shift for the SPI transmitted word count +#define PINCH_VALVE_SPI_RX_COUNT_MASK 0x30 ///< SPI status mask for the received-word count. +#define PINCH_VALVE_SPI_RX_COUNT_SHIFT 4 ///< Bit shift for the SPI received word count +#define PINCH_VALVE_SPI_CONTROLLER_FAULT_BIT_MASK 0x40 ///< SPI status bit 6 indicating a controller fault. -#define PINCH_VALVE_ENABLE_BIT_MASK 0x01 ///< Value used to enable normal pinch valve controller -#define PINCH_VALVE_RESET_BIT_MASK 0x02 ///< Bit mask used to reset the pinch valve controller. +#define PINCH_VALVE_ENABLE_BIT_MASK 0x01 ///< Value used to enable normal pinch valve controller +#define PINCH_VALVE_RESET_BIT_MASK 0x02 ///< Bit mask used to reset the pinch valve controller. #define PINCH_VALVE_MAX_INPUT_WORDS 3 ///< Maximum number of command input words, excluding the command header. #define PINCH_VALVE_MAX_OUTPUT_WORDS 3 ///< Maximum number of command output words. @@ -73,8 +73,8 @@ static const S32 H19_HOMING_VELOCITY_SECOND = -3342; ///< Second H19 homing movement velocity ( Reverse Direction ) static const S32 POSITION_VELOCITY = 50000; ///< Velocity used for normal stored position movement -#define PINCH_VALVE_EVENT_MOTION_COMPLETE_MASK 0x0001 ///< Event Status bit 0: motion complete. -#define PINCH_VALVE_EVENT_MOTION_ERROR_MASK 0x0010 ///< Event Status bit 4: motion error. +#define PINCH_VALVE_EVENT_MOTION_COMPLETE_MASK 0x0001 ///< Event Status bit 0: motion complete. +#define PINCH_VALVE_EVENT_MOTION_ERROR_MASK 0x0010 ///< Event Status bit 4: motion error. /// Pinch valve function state machine. typedef enum pinchValveFunctionStates @@ -261,7 +261,6 @@ static void setSigned32CommandWords( PINCH_VALVE_COMMAND_T *command, S32 value ); static S32 getSigned32OutputValue( VALVE_T valve ); -//Added Temporary to hardware need to check with SEAN later TODO static void clearActivePinchValveCommand( VALVE_T valve ); static void clearPinchValveCommandRegisters( VALVE_T valve ); static void resetPinchValveFunctionSequence( VALVE_T valve ); @@ -352,9 +351,13 @@ * @brief * The execPinchValveCommand function executes the low-level FPGA command * state machine. -* @details \b Inputs: activeCommand, activeValve, -* @details \b Outputs: currentResponse, commandState, -* and commandResult +* @details \b Inputs: commandState[], activeCommand[], commandSpiStatus[], +* commandErrorCount[], errorCountAtCommandStart[], executeStartTime[], +* fpgaCommandValue[] +* @details \b Outputs: commandState[], commandFailed[], +* commandOutputWord1[], commandOutputWord2[], commandOutputWord3[], +* commandSpiStatus[], commandErrorCount[], errorCountAtCommandStart[], +* executeStartTime[], fpgaCommandValue[], activeCommand[] * @return none *************************************************************************/ void execPinchValveCommand( void ) @@ -466,14 +469,14 @@ clearPinchValveCommandRegisters( valve ); clearActivePinchValveCommand( valve ); commandFailed[ valve ] = TRUE; - commandState[ valve ] = PINCH_VALVE_CMD_IDLE_STATE; + commandState[ valve ] = PINCH_VALVE_CMD_IDLE_STATE; break; default: clearPinchValveCommandRegisters( valve ); clearActivePinchValveCommand( valve ); commandFailed[ valve ] = TRUE; - commandState[ valve ] = PINCH_VALVE_CMD_IDLE_STATE; + commandState[ valve ] = PINCH_VALVE_CMD_IDLE_STATE; break; } } @@ -484,7 +487,8 @@ * 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: +* @details \b Inputs: valve, commandState[],pendingValveHomeRequest[], +* pendingValvePositionRequest[] * @details \b Outputs: * @param valve H1_VALV or H19_VALV. * @return TRUE if accepted, FALSE otherwise. @@ -508,7 +512,6 @@ /*********************************************************************//** * @brief * The setPinchValvePosition function starts a raw position command sequence. -* //TODO: Need too fix the code f * @details \b Inputs: * @details \b Outputs: * @param valve H1_VALV or H19_VALV. @@ -556,12 +559,11 @@ * The setPinchValveEnableReset function sets the enable and reset * register for the selected valve. * @details \b Inputs: valve, enable, reset -* @details \b Outputs: FPGA enable/reset register, enableResetValue[] +* @details \b Outputs: * @param valve H1_VALV or H19_VALV. * @param enable TRUE to enable the controller. * @param reset TRUE to assert the reset bit. * @return none -* *************************************************************************/ void setPinchValveEnableReset( VALVE_T valve, BOOL enable, BOOL reset ) { @@ -761,8 +763,8 @@ /*********************************************************************//** * @brief * The setPinchValveCommand function requests execution -* @details \b Inputs: valve, command -* @details \b Outputs: pendingCommand, functionState, commandResult +* @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. @@ -890,8 +892,8 @@ * @brief * The clearPinchValveFpgaCommand function clears the active valve FPGA command * register. -* @details \b Inputs: activeValve -* @details \b Outputs: FPGA command register +* @details \b Inputs: fpgaCommandValue[] +* @details \b Outputs: none * @return none *************************************************************************/ static void clearPinchValveFpgaCommand( VALVE_T valve ) @@ -915,7 +917,7 @@ * 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 +* @details \b Inputs: command, * @details \b Outputs: fpgaCommand * @param command Pinch valve command request. * @param fpgaCommand Destination for the built FPGA command byte. @@ -966,7 +968,7 @@ * @brief * The isPinchValveControllerFaultActive function checks the controller fault * status bit. -* @details \b Inputs: currentResponse +* @details \b Inputs: commandSpiStatus * @details \b Outputs: none * @return TRUE if the controller fault bit is active. *************************************************************************/ @@ -979,7 +981,7 @@ * @brief * The didPinchValveErrorCountChange function checks whether the active * transaction incremented the invalid-command counter. -* @details \b Inputs: errorCountAtCommandStart, currentResponse.errorCount +* @details \b Inputs: commandErrorCount[] * @details \b Outputs: none * @return TRUE if the error count changed. *************************************************************************/ @@ -1026,8 +1028,8 @@ * @brief * The readPinchValveErrorCount function returns the current error count for * the selected valve. -* @details \b Inputs: -* @details \b Outputs: none +* @details \b Inputs: H1_VALV, H19_VALV +* @details \b Outputs: result * @param valve H1_VALV or H19_VALV. * @return Current error count, or 0 for an invalid valve. *************************************************************************/ @@ -1089,8 +1091,8 @@ /*********************************************************************//** * @brief * The setSigned32CommandWords function stores a signed 32-bit value. -* @details \b Inputs: value -* @details \b Outputs: +* @details \b Inputs: rawValue +* @details \b Outputs: imputWord1, inputWord2 * @param command Command to update. * @return none *************************************************************************/ @@ -1109,7 +1111,7 @@ /*********************************************************************//** * @brief * The getSigned32ResponseValue function combines two PMD output words. -* @details \b Inputs: +* @details \b Inputs:rawValue * @details \b Outputs: none * @return Signed 32-bit value. *************************************************************************/ @@ -1177,7 +1179,6 @@ break; default: - // Check with Sean TODO later break; } @@ -1244,8 +1245,6 @@ return result; } -//TODO Temporary code from here - /*********************************************************************//** * @brief * The isPinchValveCommandOutput function stores output data returned by @@ -1306,8 +1305,6 @@ } } - - /*********************************************************************//** * @brief * The resetPinchValveFunctionSequence function stores output data returned by @@ -1364,9 +1361,6 @@ return ( 0 != ( status & PINCH_VALVE_EVENT_MOTION_ERROR_MASK ) ); } - -//Temporary code this is adding to store position functions - /*********************************************************************//** * @brief * The isPinchValveMotionComplete function stores output data returned by