Index: firmware/App/Drivers/PinchValve.h =================================================================== diff -u -r9565d9627edc032a2c6414a38f38f14c62e3ec87 -r078ab958e0cac18c5b8a5cc2f9d22710ac52aa1e --- firmware/App/Drivers/PinchValve.h (.../PinchValve.h) (revision 9565d9627edc032a2c6414a38f38f14c62e3ec87) +++ firmware/App/Drivers/PinchValve.h (.../PinchValve.h) (revision 078ab958e0cac18c5b8a5cc2f9d22710ac52aa1e) @@ -18,52 +18,71 @@ #ifndef __PINCHVALVE_H__ #define __PINCHVALVE_H__ -#ifndef __PINCH_VALVE_H__ -#define __PINCH_VALVE_H__ - #include "TDCommon.h" +#include "RotaryValve.h" /** - * @defgroup PinchValve PinchValve - * @brief Magellan pinch valve driver for H1 and H19. + * @defgroup PinchValve PinchValve + * @brief pinch valve communication driver. + * This driver sends one generic command at a time through the FPGA + * interface. High level functions such as homing and movement to positions + * A, B, and C belong in the controller layer. * - * The PinchValve unit provides a command execution state machine for the - * Magellan based pinch valve interface. FPGA register access is handled by - * FpgaTD. - * - * @addtogroup PinchValve - * @{ + * @addtogroup PinchValve + * @{ */ // ********** public definitions ********** +#define PINCH_VALVE_MAX_INPUT_WORDS 3U ///< Maximum number of command input words. +#define PINCH_VALVE_MAX_OUTPUT_WORDS 3U ///< Maximum number of command output words. +/// Pinch valve command request. +typedef struct +{ + U16 cmdHeader; ///< Command header. + U16 inputWord1; ///< Input word 1. + U16 inputWord2; ///< Input word 2. + U16 inputWord3; ///< Input word 3. + U08 inputWordCount; ///< Number of valid input words, excluding the command header. + U08 outputWordCount; ///< Number of output words expected. + BOOL writeOnly; ///< TRUE for a write-only command. +} PINCH_VALVE_COMMAND_T; -// PMD IC command codes. -#define PINCH_VALVE_PMD_CMD_SET_PROFILE_MODE 0x00A0 -#define PINCH_VALVE_PMD_CMD_RESET_EVENT_STATUS 0x0034 -#define PINCH_VALVE_PMD_CMD_SET_VELOCITY 0x0011 -#define PINCH_VALVE_PMD_CMD_SET_POSITION 0x0010 -#define PINCH_VALVE_PMD_CMD_UPDATE 0x001A -#define PINCH_VALVE_PMD_CMD_GET_ACTIVITY_STATUS 0x00A6 -#define PINCH_VALVE_PMD_CMD_GET_EVENT_STATUS 0x0031 -#define PINCH_VALVE_PMD_CMD_GET_ACTUAL_POSITION 0x0037 -#define PINCH_VALVE_PMD_CMD_SET_ACTUAL_POSITION 0x004D -#define PINCH_VALVE_PMD_CMD_SET_OPERATING_MODE 0x0065 +/// Pinch valve command response. +typedef struct +{ + U16 outputWord1; ///< Output word 1. + U16 outputWord2; ///< Output word 2. + U16 outputWord3; ///< Output word 3. + U08 spiCmdStatus; ///< FPGA SPI command status. + U08 readCount; ///< FPGA read count. + U08 errorCount; ///< FPGA invalid command error count. +} PINCH_VALVE_RESPONSE_T; +/// Pinch valve driver command result. +typedef enum pinchValveCommandResults +{ + PINCH_VALVE_CMD_RESULT_IDLE = 0, ///< No command has been requested. + PINCH_VALVE_CMD_RESULT_BUSY, ///< Command is executing. + PINCH_VALVE_CMD_RESULT_COMPLETE, ///< Command completed successfully. + PINCH_VALVE_CMD_RESULT_ERROR ///< Command failed. +} PINCH_VALVE_CMD_RESULT_T; + // ********** public function prototypes ********** -void initPinchValve( void ); -void execPinchValve( void ); +void initPinchValveDriver( void ); +void execPinchValveDriver( void ); -BOOL startPinchValveHome( PINCH_VALVE_ID_T valve ); -BOOL startPinchValveMove( PINCH_VALVE_ID_T valve, S32 targetPosition ); -BOOL startPinchValveReadStatus( PINCH_VALVE_ID_T valve ); +BOOL setPinchValveCommand( VALVE_T valve, const PINCH_VALVE_COMMAND_T *command ); -PINCH_VALVE_STATE_T getPinchValveState( void ); +void setPinchValveEnableReset( VALVE_T valve, BOOL enable, BOOL reset ); +U08 getPinchValveEnableReset( VALVE_T valve ); + +BOOL isPinchValveBusy( void ); PINCH_VALVE_CMD_RESULT_T getPinchValveCommandResult( void ); -void getPinchValveResponse( PINCH_VALVE_RESPONSE_T *response ); +BOOL getPinchValveResponse( VALVE_T valve, PINCH_VALVE_RESPONSE_T *response ); -U16 getPinchValveLastOutputWord3( void ); +/**@}*/ #endif