Index: firmware/App/Drivers/PeristalticPump.c =================================================================== diff -u -r036a75d76ab01912646a480b935d97187a231a19 -r52e1d4487a69a1ef0475321084527c0ba86c0892 --- firmware/App/Drivers/PeristalticPump.c (.../PeristalticPump.c) (revision 036a75d76ab01912646a480b935d97187a231a19) +++ firmware/App/Drivers/PeristalticPump.c (.../PeristalticPump.c) (revision 52e1d4487a69a1ef0475321084527c0ba86c0892) @@ -38,6 +38,10 @@ #define H4_HZ_TO_RPM(h) ((h) * H4_HZ_TO_RPM_SCALAR) ///< Blood pump Hz to RPM conversion macro. #define H4_ZERO_SPEED_PERIOD 0xFFFF ///< Blood pump period reported when pump is stopped. +#define H4_HOME_SPEED_RPM 400 ///< Blood pump set speed for rotor homing operation. + +#define H6_STATUS_HOME_BIT_POS 0x1 ///< Bit position in H6 status register that indicates whether rotor is in home position. + // ********** private data ********** static S32 pumpSetSpeedRPM; ///< Current set speed for the pump (in RPM). Negative indicates reverse direction. @@ -64,7 +68,6 @@ pumpMeasSpeedRPM.override = OVERRIDE_RESET; setH4Direction( MOTOR_DIR_FORWARD ); - resetH4HomeRequest(); setH4SetSpeed( 0 ); setH4Enabled( TRUE ); } @@ -102,11 +105,11 @@ pumpMeasSpeedRPM.data = 0.0F; } - // clear home command if previously requested - if ( TRUE == pumpHomeRequested ) + // monitor home command status if in progress, stop pump if rotor in home position + if ( ( TRUE == pumpHomeRequested ) && ( TRUE == isPeristalticPumpHome() ) ) { pumpHomeRequested = FALSE; - resetH4HomeRequest(); + setPeristalticPumpSetSpeed( 0 ); } } @@ -115,12 +118,36 @@ * The cmdPeristalticPumpHome function initiates a pump home operation. * @details \b Inputs: none * @details \b Outputs: pumpHomeRequested, FPGA + * @return TRUE if home operation is initiated, FALSE if not + *************************************************************************/ +BOOL cmdPeristalticPumpHome( void ) +{ + BOOL result = FALSE; + + if ( ( 0 == pumpSetSpeedRPM ) && ( pumpHomeRequested != TRUE ) ) + { + result = TRUE; + pumpHomeRequested = TRUE; + setPeristalticPumpSetSpeed( H4_HOME_SPEED_RPM ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The isPeristalticPumpHome function determines whether the rotor is currently + * in the home position. + * @details \b Inputs: FPGA + * @details \b Outputs: none * @return none *************************************************************************/ -void cmdPeristalticPumpHome( void ) +BOOL isPeristalticPumpHome( void ) { - pumpHomeRequested = TRUE; - homeH4(); + U08 status = getH6Status() & H6_STATUS_HOME_BIT_POS; + BOOL result = ( status != 0 ? TRUE : FALSE ); + + return result; } /*********************************************************************//**