/************************************************************************** * * Copyright (c) 2026-2026 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 PinchValve.c * * @author (last) Varshini Nagabooshanam * @date (last) 08-Jul-2026 * * @author (original) Varshini Nagabooshanam * @date (original) 08-Jul-2026 * ***************************************************************************/ #include "FpgaTD.h" #include "PinchValve.h" #include "RotaryValve.h" #include "Timers.h" #include "Utilities.h" /** * @addtogroup PinchValve * @{ */ // ********** private definitions ********** #define PINCH_VALVE_STATUS_POLL_INTERVAL_MS 10 ///< FPGA status polling interval in (ms). #define PINCH_VALVE_COMMAND_TIMEOUT_MS 1000 ///< Maximum FPGA command execution time. #define PINCH_VALVE_FPGA_CMD_START_BIT_MASK 0x01 ///< Bit 0 starts a command transaction. (TODO: To change the comments later) #define PINCH_VALVE_FPGA_CMD_WRITE_ONLY_BIT_MASK 0x02 ///< Bit 1 selects a write-only command. #define PINCH_VALVE_FPGA_CMD_TX_COUNT_SHIFT 2 ///< Bits 4-2 contain transmit word count. #define PINCH_VALVE_FPGA_CMD_RX_COUNT_SHIFT 5 ///< Bits 7-5 contain receive word count. #define PINCH_VALVE_FPGA_CMD_WORD_COUNT_MASK 0x07 ///< Three-bit FPGA word-count mask. #define PINCH_VALVE_SPI_DONE_BIT_MASK 0x01 ///< SPI command completed. #define PINCH_VALVE_SPI_TX_COUNT_MASK 0x0E ///< SPI status bits 3-1: transmitted words. #define PINCH_VALVE_SPI_TX_COUNT_SHIFT 1 #define PINCH_VALVE_SPI_RX_COUNT_MASK 0x30 ///< SPI status bits 5-4: received words. #define PINCH_VALVE_SPI_RX_COUNT_SHIFT 4 #define PINCH_VALVE_SPI_CONTROLLER_FAULT_BIT_MASK 0x40 ///< SPI status bit 6: controller fault. #define PINCH_VALVE_ENABLE_BIT_MASK 0x01 ///< Enable controller. #define PINCH_VALVE_RESET_BIT_MASK 0x02 ///< Reset controller. /// Pinch Valve driver function state machine. typedef enum pinchValveFunctionStates { PINCH_VALVE_FUNCTION_IDLE_STATE = 0, ///< Waiting for a new command request. PINCH_VALVE_FUNCTION_SEND_STATE, ///< Starts the low level command state machine. PINCH_VALVE_FUNCTION_WAIT_STATE ///< Waits for command completion or error. } PINCH_VALVE_FUNCTION_STATE_T; /// Low level FPGA command state machine. typedef enum pinchValveCommandStates { PINCH_VALVE_CMD_IDLE_STATE = 0, ///< No FPGA command is active. PINCH_VALVE_CMD_SET_CMD_STATE, ///< Writes header and input words. PINCH_VALVE_CMD_XMIT_CMD_STATE, ///< Writes FPGA command byte. PINCH_VALVE_CMD_WAIT_DONE_STATE, ///< Polls command-done status. PINCH_VALVE_CMD_READ_WORDS_STATE, ///< Reads response words and counters. PINCH_VALVE_CMD_ERROR_STATE, ///< Command failed. PINCH_VALVE_CMD_READY_STATE ///< Command completed successfully. } PINCH_VALVE_CMD_STATE_T; // ********** private data ********** static PINCH_VALVE_FUNCTION_STATE_T functionState; ///< Current function state. static PINCH_VALVE_CMD_STATE_T commandState; ///< Current command state. static VALVE_T activeValve; ///< Valve executing the current command. static PINCH_VALVE_COMMAND_T pendingCommand; ///< Command waiting to be started. static PINCH_VALVE_COMMAND_T activeCommand; ///< Command currently being executed. static PINCH_VALVE_RESPONSE_T currentResponse; ///< Response for the active command. static PINCH_VALVE_RESPONSE_T lastResponse[ NUM_OF_VALVES ]; ///< Last response for each valve. static PINCH_VALVE_CMD_RESULT_T commandResult; ///< Latest driver result. static U08 enableResetValue[ NUM_OF_VALVES ]; ///< Last enable/reset value written per valve. static U08 errorCountAtCommandStart; ///< Error counter captured before command start. static U32 executeStartTime; ///< Execute transaction start time. static U32 statusPollStartMSCount; ///< Status polling interval start time. // ********** private function prototypes ********** static void handlePinchValveFunction( void ); static void handlePinchValveCommand( void ); static void writePinchValveCommandRegisters( void ); static BOOL transmitPinchValveCommand( void ); static void readPinchValveCommandResponse( void ); static void clearPinchValveFpgaCommand( void ); static BOOL buildPinchValveFpgaCommandByte( const PINCH_VALVE_COMMAND_T *command, U08 *fpgaCommand ); static BOOL isPinchValveCommandDone( void ); static BOOL isPinchValveControllerFaultActive( void ); static BOOL didPinchValveErrorCountChange( void ); static BOOL arePinchValveWordCountsValid( void ); static U08 readPinchValveErrorCount( VALVE_T valve ); static BOOL isValidPinchValve( VALVE_T valve ); static BOOL isValidPinchValveCommand( const PINCH_VALVE_COMMAND_T *command ); static void clearPinchValveResponse( PINCH_VALVE_RESPONSE_T *response ); /*********************************************************************//** * @brief * The initPinchValveDriver function initializes the pinch valve * communication driver. * @details \b Inputs: none * @details \b Outputs: PinchValve driver unit is initialized * @return none *************************************************************************/ void initPinchValveDriver( void ) { U32 valve; functionState = PINCH_VALVE_FUNCTION_IDLE_STATE; commandState = PINCH_VALVE_CMD_IDLE_STATE; activeValve = H1_VALV; commandResult = PINCH_VALVE_CMD_RESULT_IDLE; pendingCommand.cmdHeader = 0; pendingCommand.inputWord1 = 0; pendingCommand.inputWord2 = 0; pendingCommand.inputWord3 = 0; pendingCommand.inputWordCount = 0; pendingCommand.outputWordCount = 0; pendingCommand.writeOnly = FALSE; activeCommand = pendingCommand; clearPinchValveResponse( ¤tResponse ); for ( valve = FIRST_VALVE; valve < NUM_OF_VALVES; valve++ ) { clearPinchValveResponse( &lastResponse[ valve ] ); enableResetValue[ valve ] = 0; } errorCountAtCommandStart = 0; executeStartTime = 0; statusPollStartMSCount = 0; clearPinchValveFpgaCommand(); } /*********************************************************************//** * @brief * The execPinchValveDriver function executes the function and command state * machines. * TODO: All Inputs and Outputs will be changed later * @details \b Inputs: PinchValve private data and FPGA response data * @details \b Outputs: PinchValve private data and FPGA command data * @return none *************************************************************************/ void execPinchValveDriver( void ) { //TODO: Need to fix this handlePinchValveCommand(); handlePinchValveFunction(); } /*********************************************************************//** * @brief * The setPinchValveCommand function requests execution of one generic * Magellan command. * @details \b Inputs: valve, command * @details \b Outputs: pendingCommand, functionState, commandResult * @param valve H1_VALV or H19_VALV. * @param command Command header, input words, word counts, and transaction type. * @return TRUE if the request was accepted, FALSE otherwise. *************************************************************************/ BOOL setPinchValveCommand( VALVE_T valve, const PINCH_VALVE_COMMAND_T *command ) { BOOL result = FALSE; if ( ( TRUE == isValidPinchValve( valve ) ) && ( TRUE == isValidPinchValveCommand( command ) ) && ( PINCH_VALVE_FUNCTION_IDLE_STATE == functionState ) && ( PINCH_VALVE_CMD_IDLE_STATE == commandState ) ) { activeValve = valve; pendingCommand = *command; commandResult = PINCH_VALVE_CMD_RESULT_BUSY; functionState = PINCH_VALVE_FUNCTION_SEND_STATE; result = TRUE; } return result; } /*********************************************************************//** * @brief * 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[] * @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 ) { U08 value = 0; if ( TRUE == enable ) { value |= PINCH_VALVE_ENABLE_BIT_MASK; } if ( TRUE == reset ) { value |= PINCH_VALVE_RESET_BIT_MASK; } if ( H1_VALV == valve ) { enableResetValue[ H1_VALV ] = value; setH1EnableReset( value ); } else if ( H19_VALV == valve ) { enableResetValue[ H19_VALV ] = value; setH19EnableReset( value ); } else { // TODO: Check with Sean and update later (Invalid valve. The caller can verify the valve before calling) } } /*********************************************************************//** * @brief * The getPinchValveEnableReset function returns the last enable/reset value * written for the selected valve. * @details \b Inputs: enableResetValue[] * @details \b Outputs: none * @param valve H1_VALV or H19_VALV. * @return Last enable/reset value, or 0 for an invalid valve. *************************************************************************/ U08 getPinchValveEnableReset( VALVE_T valve ) { U08 result = 0; if ( TRUE == isValidPinchValve( valve ) ) { result = enableResetValue[ valve ]; } return result; } /*********************************************************************//** * @brief * The isPinchValveBusy function indicates whether a command is active. * @details \b Inputs: functionState, commandState * @details \b Outputs: none * @return TRUE if the driver is busy, FALSE otherwise. *************************************************************************/ BOOL isPinchValveBusy( void ) { return ( ( PINCH_VALVE_FUNCTION_IDLE_STATE != functionState ) || ( PINCH_VALVE_CMD_IDLE_STATE != commandState ) ); } /*********************************************************************//** * @brief * The getPinchValveCommandResult function returns the latest command result. * @details \b Inputs: commandResult * @details \b Outputs: none * @return Latest driver command result. *************************************************************************/ PINCH_VALVE_CMD_RESULT_T getPinchValveCommandResult( void ) { return commandResult; } /*********************************************************************//** * @brief * The getPinchValveResponse function returns the last response for a valve. * @details \b Inputs: lastResponse[] * @details \b Outputs: response * @param valve H1_VALV or H19_VALV. * @param response Destination for the response data. * @return TRUE if the response was returned, FALSE otherwise. *************************************************************************/ BOOL getPinchValveResponse( VALVE_T valve, PINCH_VALVE_RESPONSE_T *response ) { BOOL result = FALSE; if ( ( TRUE == isValidPinchValve( valve ) ) && ( response != 0 ) ) { *response = lastResponse[ valve ]; result = TRUE; } return result; } /*********************************************************************//** * @brief * The handlePinchValveFunction function executes the high level * IDLE, SEND, and WAIT state machine. * @details \b Inputs: functionState, commandState * @details \b Outputs: functionState, commandState, commandResult * @return none *************************************************************************/ static void handlePinchValveFunction( void ) { switch ( functionState ) { case PINCH_VALVE_FUNCTION_IDLE_STATE: { // TODO: Check with Sean and update later break; } case PINCH_VALVE_FUNCTION_SEND_STATE: { activeCommand = pendingCommand; clearPinchValveResponse( ¤tResponse ); commandState = PINCH_VALVE_CMD_SET_CMD_STATE; functionState = PINCH_VALVE_FUNCTION_WAIT_STATE; break; } case PINCH_VALVE_FUNCTION_WAIT_STATE: { if ( PINCH_VALVE_CMD_READY_STATE == commandState ) { clearPinchValveFpgaCommand(); lastResponse[ activeValve ] = currentResponse; commandResult = PINCH_VALVE_CMD_RESULT_COMPLETE; commandState = PINCH_VALVE_CMD_IDLE_STATE; functionState = PINCH_VALVE_FUNCTION_IDLE_STATE; } else if ( PINCH_VALVE_CMD_ERROR_STATE == commandState ) { clearPinchValveFpgaCommand(); lastResponse[ activeValve ] = currentResponse; commandResult = PINCH_VALVE_CMD_RESULT_ERROR; commandState = PINCH_VALVE_CMD_IDLE_STATE; functionState = PINCH_VALVE_FUNCTION_IDLE_STATE; } else { //TODO: Check with Sean and update later (The command state machine is still executing) } break; } default: { clearPinchValveFpgaCommand(); commandResult = PINCH_VALVE_CMD_RESULT_ERROR; commandState = PINCH_VALVE_CMD_IDLE_STATE; functionState = PINCH_VALVE_FUNCTION_IDLE_STATE; break; } } } /*********************************************************************//** * @brief * The handlePinchValveCommand function executes one FPGA command * transaction. * @details \b Inputs: activeCommand, activeValve, FPGA response data * @details \b Outputs: FPGA command data, currentResponse, commandState * @return none *************************************************************************/ static void handlePinchValveCommand( void ) { switch ( commandState ) { case PINCH_VALVE_CMD_IDLE_STATE: { break; } case PINCH_VALVE_CMD_SET_CMD_STATE: { writePinchValveCommandRegisters(); if ( PINCH_VALVE_CMD_ERROR_STATE != commandState ) { errorCountAtCommandStart = readPinchValveErrorCount( activeValve ); commandState = PINCH_VALVE_CMD_XMIT_CMD_STATE; } break; } case PINCH_VALVE_CMD_XMIT_CMD_STATE: { if ( TRUE == transmitPinchValveCommand() ) { executeStartTime = getMSTimerCount(); statusPollStartMSCount = executeStartTime; commandState = PINCH_VALVE_CMD_WAIT_DONE_STATE; } else { commandState = PINCH_VALVE_CMD_ERROR_STATE; } break; } case PINCH_VALVE_CMD_WAIT_DONE_STATE: { if ( TRUE == didTimeout( executeStartTime, PINCH_VALVE_COMMAND_TIMEOUT_MS ) ) { readPinchValveCommandResponse(); commandState = PINCH_VALVE_CMD_ERROR_STATE; } else if ( TRUE == didTimeout( statusPollStartMSCount, PINCH_VALVE_STATUS_POLL_INTERVAL_MS ) ) { readPinchValveCommandResponse(); statusPollStartMSCount = getMSTimerCount(); if ( ( TRUE == didPinchValveErrorCountChange() ) || ( TRUE == isPinchValveControllerFaultActive() ) ) { commandState = PINCH_VALVE_CMD_ERROR_STATE; } else if ( TRUE == isPinchValveCommandDone() ) { commandState = PINCH_VALVE_CMD_READ_WORDS_STATE; } else { // TODO: Remove later (FPGA command is still executing) } } else { // TODO: Remove later (Wait for the next polling interval) } break; } case PINCH_VALVE_CMD_READ_WORDS_STATE: { readPinchValveCommandResponse(); if ( ( TRUE == didPinchValveErrorCountChange() ) || ( TRUE == isPinchValveControllerFaultActive() ) || ( FALSE == arePinchValveWordCountsValid() ) ) { commandState = PINCH_VALVE_CMD_ERROR_STATE; } else { commandState = PINCH_VALVE_CMD_READY_STATE; } break; } case PINCH_VALVE_CMD_ERROR_STATE: { // TODO: Check with Sean and update later break; } case PINCH_VALVE_CMD_READY_STATE: { // TODO: Check with Sean and update later break; } default: { commandState = PINCH_VALVE_CMD_ERROR_STATE; break; } } } /*********************************************************************//** * @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 none *************************************************************************/ static void writePinchValveCommandRegisters( void ) { if ( H1_VALV == activeValve ) { setH1CmdHeader( activeCommand.cmdHeader ); setH1InputWord1( activeCommand.inputWord1 ); setH1InputWord2( activeCommand.inputWord2 ); setH1InputWord3( activeCommand.inputWord3 ); } else if ( H19_VALV == activeValve ) { setH19CmdHeader( activeCommand.cmdHeader ); setH19InputWord1( activeCommand.inputWord1 ); setH19InputWord2( activeCommand.inputWord2 ); setH19InputWord3( activeCommand.inputWord3 ); } else { commandState = PINCH_VALVE_CMD_ERROR_STATE; } } /*********************************************************************//** * @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. *************************************************************************/ static BOOL transmitPinchValveCommand( void ) { BOOL result = FALSE; U08 fpgaCommand; if ( TRUE == buildPinchValveFpgaCommandByte( &activeCommand, &fpgaCommand ) ) { if ( H1_VALV == activeValve ) { setH1FPGACmd( fpgaCommand ); result = TRUE; } else if ( H19_VALV == activeValve ) { setH19FPGACmd( fpgaCommand ); result = TRUE; } else { //TODO: Check with Sean and remove later } } return result; } /*********************************************************************//** * @brief * The readPinchValveCommandResponse function reads the active valve response * through the FpgaTD interface. * @details \b Inputs: activeValve, FPGA response registers * @details \b Outputs: currentResponse * @return none *************************************************************************/ static void readPinchValveCommandResponse( void ) { if ( H1_VALV == activeValve ) { currentResponse.spiCmdStatus = getH1SPICmdStatus(); currentResponse.readCount = getH1ReadCount(); currentResponse.errorCount = getH1ErrorCount(); currentResponse.outputWord1 = getH1OutputWord1(); currentResponse.outputWord2 = getH1OutputWord2(); currentResponse.outputWord3 = getH1OutputWord3(); } else if ( H19_VALV == activeValve ) { currentResponse.spiCmdStatus = getH19SPICmdStatus(); currentResponse.readCount = getH19ReadCount(); currentResponse.errorCount = getH19ErrorCount(); currentResponse.outputWord1 = getH19OutputWord1(); currentResponse.outputWord2 = getH19OutputWord2(); currentResponse.outputWord3 = getH19OutputWord3(); } else { clearPinchValveResponse( ¤tResponse ); } } /*********************************************************************//** * @brief * The clearPinchValveFpgaCommand function clears the active valve FPGA command * register. * @details \b Inputs: activeValve * @details \b Outputs: FPGA command register * @return none *************************************************************************/ static void clearPinchValveFpgaCommand( void ) { if ( H1_VALV == activeValve ) { setH1FPGACmd( 0 ); } else if ( H19_VALV == activeValve ) { setH19FPGACmd( 0 ); } else { //TODO: Check with Sean and Update } } /*********************************************************************//** * @brief * The buildPinchValveFpgaCommandByte 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 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. *************************************************************************/ static BOOL buildPinchValveFpgaCommandByte( const PINCH_VALVE_COMMAND_T *command, U08 *fpgaCommand ) { BOOL result = FALSE; if ( ( command != 0 ) && ( fpgaCommand != 0 ) ) { U08 transmitWordCount = (U08)( command->inputWordCount + 1 ); if ( ( command->inputWordCount <= PINCH_VALVE_MAX_INPUT_WORDS ) && ( command->outputWordCount <= PINCH_VALVE_MAX_OUTPUT_WORDS ) && ( transmitWordCount <= 4 ) ) { *fpgaCommand = PINCH_VALVE_FPGA_CMD_START_BIT_MASK; if ( TRUE == command->writeOnly ) { *fpgaCommand |= PINCH_VALVE_FPGA_CMD_WRITE_ONLY_BIT_MASK; } *fpgaCommand |= (U08)( ( transmitWordCount & PINCH_VALVE_FPGA_CMD_WORD_COUNT_MASK ) << PINCH_VALVE_FPGA_CMD_TX_COUNT_SHIFT ); *fpgaCommand |= (U08)( ( command->outputWordCount & PINCH_VALVE_FPGA_CMD_WORD_COUNT_MASK ) << PINCH_VALVE_FPGA_CMD_RX_COUNT_SHIFT ); result = TRUE; } } return result; } /*********************************************************************//** * @brief * The isPinchValveCommandDone function checks the SPI command-done bit. * @details \b Inputs: currentResponse * @details \b Outputs: none * @return TRUE if the FPGA transaction is complete. *************************************************************************/ static BOOL isPinchValveCommandDone( void ) { return ( ( currentResponse.spiCmdStatus & PINCH_VALVE_SPI_DONE_BIT_MASK ) != 0 ); } /*********************************************************************//** * @brief * The isPinchValveControllerFaultActive function checks the controller fault * status bit. * @details \b Inputs: currentResponse * @details \b Outputs: none * @return TRUE if the controller fault bit is active. *************************************************************************/ static BOOL isPinchValveControllerFaultActive( void ) { return ( ( currentResponse.spiCmdStatus & PINCH_VALVE_SPI_CONTROLLER_FAULT_BIT_MASK ) != 0 ); } /*********************************************************************//** * @brief * The didPinchValveErrorCountChange function checks whether the active * transaction incremented the invalid-command counter. * @details \b Inputs: errorCountAtCommandStart, currentResponse.errorCount * @details \b Outputs: none * @return TRUE if the error count changed. *************************************************************************/ static BOOL didPinchValveErrorCountChange( void ) { return ( currentResponse.errorCount != errorCountAtCommandStart ); } /*********************************************************************//** * @brief * The arePinchValveWordCountsValid function verifies the FPGA-reported * transmitted and received word counts. * @details \b Inputs: currentResponse.spiCmdStatus, activeCommand * @details \b Outputs: none * @return TRUE if reported counts match the command. *************************************************************************/ static BOOL arePinchValveWordCountsValid( void ) { U08 expectedTransmitCount = (U08)( activeCommand.inputWordCount + 1 ); U08 transmittedCount = (U08)( ( currentResponse.spiCmdStatus & PINCH_VALVE_SPI_TX_COUNT_MASK ) >> PINCH_VALVE_SPI_TX_COUNT_SHIFT ); U08 receivedCount = (U08)( ( currentResponse.spiCmdStatus & PINCH_VALVE_SPI_RX_COUNT_MASK ) >> PINCH_VALVE_SPI_RX_COUNT_SHIFT ); return ( ( transmittedCount == expectedTransmitCount ) && ( receivedCount == activeCommand.outputWordCount ) ); } /*********************************************************************//** * @brief * The readPinchValveErrorCount function returns the current error count for * the selected valve. * @details \b Inputs: FPGA response registers * @details \b Outputs: none * @param valve H1_VALV or H19_VALV. * @return Current error count, or 0 for an invalid valve. *************************************************************************/ static U08 readPinchValveErrorCount( VALVE_T valve ) { U08 result = 0; if ( H1_VALV == valve ) { result = getH1ErrorCount(); } else if ( H19_VALV == valve ) { result = getH19ErrorCount(); } else { // TODO: Check with Sean and Remove later ( Invalid valve ) } return result; } /*********************************************************************//** * @brief * The isValidPinchValve function validates a valve ID. * @details \b Inputs: valve * @details \b Outputs: none * @param valve Valve to validate. * @return TRUE if the valve is H1 or H19. *************************************************************************/ static BOOL isValidPinchValve( VALVE_T valve ) { return ( ( H1_VALV == valve ) || ( H19_VALV == valve ) ); } /*********************************************************************//** * @brief * The isValidPinchValveCommand function validates a generic command request. * @details \b Inputs: command * @details \b Outputs: none * @param command Command to validate. * @return TRUE if the request is valid. *************************************************************************/ static BOOL isValidPinchValveCommand( const PINCH_VALVE_COMMAND_T *command ) { BOOL result = FALSE; if ( command != 0 ) { if ( ( command->inputWordCount <= PINCH_VALVE_MAX_INPUT_WORDS ) && ( command->outputWordCount <= PINCH_VALVE_MAX_OUTPUT_WORDS ) ) { result = TRUE; } } return result; } /*********************************************************************//** * @brief * The clearPinchValveResponse function clears a response structure. * @details \b Inputs: response * @details \b Outputs: response * @param response Response structure to clear. * @return none *************************************************************************/ static void clearPinchValveResponse( PINCH_VALVE_RESPONSE_T *response ) { if ( response != 0 ) { response->outputWord1 = 0; response->outputWord2 = 0; response->outputWord3 = 0; response->spiCmdStatus = 0; response->readCount = 0; response->errorCount = 0; } } /**@}*/