Index: firmware/App/Controllers/Ejector.c =================================================================== diff -u -rfdb7ee915da2741dc200fef1b624b7f383f4db85 -r8749beb3f7bed2f9d7fcd2c6916496ea300d9f9d --- firmware/App/Controllers/Ejector.c (.../Ejector.c) (revision fdb7ee915da2741dc200fef1b624b7f383f4db85) +++ firmware/App/Controllers/Ejector.c (.../Ejector.c) (revision 8749beb3f7bed2f9d7fcd2c6916496ea300d9f9d) @@ -60,17 +60,19 @@ static BOOL ejectorHomeRequested; ///< Flag indicating that ejector home operation is requested. static BOOL ejectorRetractRequested; ///< Flag indicating that ejector retract operation is requested. static BOOL ejectorExtendRequested; ///< Flag indicating that ejector extend operation is requested. +static BOOL ejectorAbortRequested; ///< Flag indicating that ejector abort operation in requested. // ********** private function prototypes ********** static EJECTOR_STATE_T handleEjectorStartState( void ); static EJECTOR_STATE_T handleEjectorHomingState( void ); -static EJECTOR_STATE_T handleEjectorRetractedState ( void ); -static EJECTOR_STATE_T handleEjectorExtendedState ( void ); -static EJECTOR_STATE_T handleEjectorRetractingState ( void ); -static EJECTOR_STATE_T handleEjectorExtendingState ( void ); +static EJECTOR_STATE_T handleEjectorRetractedState( void ); +static EJECTOR_STATE_T handleEjectorExtendedState( void ); +static EJECTOR_STATE_T handleEjectorRetractingState( void ); +static EJECTOR_STATE_T handleEjectorExtendingState( void ); static EJECTOR_STATE_T handleEjectorRetractBackoffState( void ); static EJECTOR_STATE_T handleEjectorDirChangeStopState( void ); +static EJECTOR_STATE_T handleEjectorAbortState( void ); static void resetEjectorFlags( void ); static void publishEjectorData( void ); @@ -103,14 +105,15 @@ * The resetEjectorFlags function resets the ejector flags to FALSE. * @details \b Inputs: none * @details \b Outputs: ejectorHomeRequested, ejectorRetractRequested, - * ejectorExtendRequested + * ejectorExtendRequested, ejectorAbortRequested * @return none *************************************************************************/ static void resetEjectorFlags( void ) { ejectorHomeRequested = FALSE; ejectorRetractRequested = FALSE; ejectorExtendRequested = FALSE; + ejectorAbortRequested = FALSE; } /*********************************************************************//** @@ -175,6 +178,20 @@ /*********************************************************************//** * @brief + * The extendEjector function requests an ejector extend operation. + * @details \b Inputs: currentEjectorState + * @details \b Outputs: ejectorExtendRequested + * @return TRUE if extend command accepted, FALSE if not + *************************************************************************/ +void abortEjector( void ) +{ + setEjectorMotorSpeed( EJECTOR_OFF_MOTOR_SPEED_RPM ); + // Set the flag to TRUE regardless of where the ejector is at + ejectorAbortRequested = TRUE; +} + +/*********************************************************************//** + * @brief * The getEjectorState function returns the current ejector control state machine. * @details \b Inputs: currentEjectorState * @details \b Outputs: none @@ -229,11 +246,21 @@ currentEjectorState = handleEjectorDirChangeStopState(); break; + case EJECTOR_STATE_ABORT: + currentEjectorState = handleEjectorAbortState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_TD_EJECTOR_INVALID_STATE, (U32)currentEjectorState ) break; } + if ( TRUE == ejectorAbortRequested ) + { + // If abort has been called, set it to abort state no matter where we are at. + currentEjectorState = EJECTOR_STATE_ABORT; + } + // reset request flags after processing ejector control state machine (they expire) resetEjectorFlags(); @@ -416,6 +443,13 @@ return state; } +static EJECTOR_STATE_T handleEjectorAbortState( void ) +{ + EJECTOR_STATE_T state = EJECTOR_STATE_ABORT; + + return state; +} + /*********************************************************************//** * @brief * The publishEjectorData function constructs and sends the air pump data