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; Index: firmware/App/Controllers/AirPump.h =================================================================== diff -u -r4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5 -r2db157fa0b39912cdf03e39c5ff3090c300ff32c --- firmware/App/Controllers/AirPump.h (.../AirPump.h) (revision 4bcafe45ae40939d6b3471f4ccca7e2b4fa7c0f5) +++ firmware/App/Controllers/AirPump.h (.../AirPump.h) (revision 2db157fa0b39912cdf03e39c5ff3090c300ff32c) @@ -33,24 +33,22 @@ /// Payload record structure for air pump data broadcast message typedef struct { - U32 airPumpStateStatus; - U32 airPumpMotorStatus; + U32 airPumpStateStatus; ///< Air Pump state status } AIR_PUMP_PAYLOAD_T; /// Enumeration of air pump states. typedef enum AirPumpControllerStates { - AIR_PUMP_STATE_OFF= 0, ///< Air Pump Off + AIR_PUMP_STATE_INIT = 0, ///< Air Pump Init + AIR_PUMP_STATE_OFF, ///< Air Pump Off AIR_PUMP_STATE_ON, ///< Air Pump On - AIR_PUMP_STATE_START, NUM_OF_AIR_PUMP_STATES, } AIR_PUMP_STATE_T; // ********** public function prototypes ********** void initAirPump(void); - void execAirPumpController(void); void setAirPumpState( AIR_PUMP_STATE_T state ); AIR_PUMP_STATE_T getAirPumpState( void ); Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -re482c9636c0e359386156d21a5518d59e727eb39 -r2db157fa0b39912cdf03e39c5ff3090c300ff32c --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision e482c9636c0e359386156d21a5518d59e727eb39) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 2db157fa0b39912cdf03e39c5ff3090c300ff32c) @@ -176,6 +176,8 @@ SW_FAULT_ID_BLOOD_LEAK_INVALID_EMB_MODE_CMD_SELECTED, // 145 SW_FAULT_ID_INVALID_FPGA_ERROR_GROUP_SELECTED, SW_FAULT_ID_HD_SYRINGE_NOT_PRELOADED, + SW_FAULT_ID_HD_AIR_PUMP_INVALID_STATE, + SW_FAULT_ID_HD_AIR_PUMP_INVALID_MOTOR_STATE_SELECTED, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T;