Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r22e7af9d984aeb680b8ddb444757bf59c2e09c15 -r2db157fa0b39912cdf03e39c5ff3090c300ff32c --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 22e7af9d984aeb680b8ddb444757bf59c2e09c15) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 2db157fa0b39912cdf03e39c5ff3090c300ff32c) @@ -59,15 +59,30 @@ static AIR_PUMP_STATE_T handleAirPumpOffState( void ); static AIR_PUMP_STATE_T handleAirPumpOnState ( void ); static void publishAirPumpData( void ); +static void setAirPumpMotor( AIR_PUMP_MOTOR_STATE_T state ); - +/*********************************************************************//** + * @brief + * The initAirPump function initializes the valve driver. + * @details Inputs: none + * @details Outputs: currentAirPumpState, currentAirPumpMotorState + * @return none + *************************************************************************/ void initAirPump(void) { currentAirPumpMotorState = AIR_PUMP_MOTOR_OFF; - currentAirPumpState = AIR_PUMP_STATE_START; + currentAirPumpState = AIR_PUMP_STATE_INIT; } +/*********************************************************************//** + * @brief + * The setAirPumpMotor function sets the air pump Pin. + * @details Inputs: AIR_PUMP_GPIO_PIN, hetPORT1 + * @details Outputs: none + * @param state HIGH/LOW for the air pump pin. + * @return none. + *************************************************************************/ static void setAirPumpMotor( AIR_PUMP_MOTOR_STATE_T state ) { if ( state < NUM_OF_AIR_PUMP_MOTOR_STATES ) @@ -76,10 +91,17 @@ } else { - // hard fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_AIR_PUMP_INVALID_MOTOR_STATE_SELECTED, (U32)state ) } } +/*********************************************************************//** + * @brief + * The setAirPumpState function sets the current air pump state machine state. + * @details Inputs: currentAirPumpState + * @details Outputs: currentAirPumpState + * @return none + *************************************************************************/ void setAirPumpState( AIR_PUMP_STATE_T state ) { if ( state < NUM_OF_AIR_PUMP_STATES ) @@ -88,20 +110,34 @@ } else { - // hard fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_AIR_PUMP_INVALID_STATE, (U32)state ) } } +/*********************************************************************//** + * @brief + * The getAirPumpState function returns the current air pump state machine. + * @details Inputs: currentAirPumpState + * @details Outputs: currentAirPumpState + * @return current state of the air pump state machine. + *************************************************************************/ AIR_PUMP_STATE_T getAirPumpState( void ) { return currentAirPumpState; } +/*********************************************************************//** + * @brief + * The execAirPumpController function executes the air pump state machine. + * @details Inputs: currentAirPumpState + * @details Outputs: currentAirPumpState + * @return none + *************************************************************************/ void execAirPumpController( void ) { switch( currentAirPumpState ) { - case AIR_PUMP_STATE_START: + case AIR_PUMP_STATE_INIT: currentAirPumpState = handleAirPumpStartState(); break; @@ -114,32 +150,61 @@ break; default: - //hard fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_AIR_PUMP_INVALID_STATE, (U32)state ) break; } publishAirPumpData(); } +/*********************************************************************//** + * @brief + * The handleAirPumpStartState function starts the air pump state machine. + * @details Inputs: none + * @details Outputs: none + * @return next state of the air pump state machine + *************************************************************************/ static AIR_PUMP_STATE_T handleAirPumpStartState( void ) { AIR_PUMP_STATE_T state = AIR_PUMP_STATE_OFF; return state; } +/*********************************************************************//** + * @brief + * The handleAirPumpOffState function stops the air pump + * @details Inputs: none + * @details Outputs: none + * @return next state of the air pump state machine + *************************************************************************/ static AIR_PUMP_STATE_T handleAirPumpOffState( void ) { AIR_PUMP_STATE_T state = AIR_PUMP_STATE_OFF; setAirPumpMotor( AIR_PUMP_MOTOR_OFF ); return state; } +/*********************************************************************//** + * @brief + * The handleAirPumpOnState function starts the air pump + * @details Inputs: none + * @details Outputs: none + * @return next state of the air pump state machine + *************************************************************************/ static AIR_PUMP_STATE_T handleAirPumpOnState( void ) { AIR_PUMP_STATE_T state = AIR_PUMP_STATE_ON; setAirPumpMotor( AIR_PUMP_MOTOR_ON ); return state; } +/*********************************************************************//** + * @brief + * The publishAirPumpData function constructs and sends the air pump data + * broadcast message. + * @details Inputs: currentAirPumpState + * @details Outputs: data + * @return none + *************************************************************************/ static void publishAirPumpData( void ) { if (++airPumpDataPublicationTimerCounter >= getU32OverrideValue( &airPumpDataPublishInterval ) ) @@ -204,7 +269,14 @@ return result; } - +/*********************************************************************//** + * @brief + * The testSetAirPump function sets the Air Pump state. + * @details Inputs: none + * @details Outputs: currentAirPumpState + * @param state, the air pump state to be set to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ BOOL testSetAirPump( U32 state ) { BOOL result = FALSE;