Index: firmware/App/Drivers/GLXferPump.c =================================================================== diff -u -r87d705fcf977af12b7b034735fa5867f2daea2b9 -r285b5d82539c96524c93703d52a66fff76fb64fc --- firmware/App/Drivers/GLXferPump.c (.../GLXferPump.c) (revision 87d705fcf977af12b7b034735fa5867f2daea2b9) +++ firmware/App/Drivers/GLXferPump.c (.../GLXferPump.c) (revision 285b5d82539c96524c93703d52a66fff76fb64fc) @@ -16,6 +16,7 @@ ***************************************************************************/ #include "AlarmMgmtTD.h" +#include "FpgaTD.h" #include "GLXferPump.h" #include "GPIO.h" #include "Messaging.h" @@ -29,7 +30,7 @@ // ********** private data ********** -static AIR_PUMP_MOTOR_STATE_T currentAirPumpMotorState; ///< Current air pump motor state (on/off). +static U08 currentAirPumpMotorPowerLevel; ///< Current air pump motor state: 0=off, 1..255=power level. // ********** private function prototypes ********** @@ -38,53 +39,47 @@ * The initGasLiqXferPumpDriver function initializes the gas/liquid transfer * pump driver unit. * @details \b Inputs: none - * @details \b Outputs: currentAirPumpMotorState + * @details \b Outputs: currentAirPumpMotorPowerLevel * @return none *************************************************************************/ void initGasLiqXferPumpDriver(void) { - currentAirPumpMotorState = AIR_PUMP_MOTOR_OFF; - setAirPumpMotorSignal( (PIN_SIGNAL_STATE_T)currentAirPumpMotorState ); + currentAirPumpMotorPowerLevel = AIR_PUMP_MOTOR_OFF; + setAirPumpMotorPowerLevel( currentAirPumpMotorPowerLevel ); } /*********************************************************************//** * @brief - * The setAirPumpMotorState function sets the air pump motor state to on or off. - * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if invalid state given. + * The setAirPumpMotorPower function sets the air pump motor to the given + * power level. + * @details \b Message \b Sent: MSG_ID_TD_EVENT if changing air pump power level. * @details \b Inputs: none - * @details \b Outputs: currentAirPumpMotorState - * @param state State to set the air pump motor (on/off). + * @details \b Outputs: currentAirPumpMotorPowerLevel + * @param power Power level for air pump (0=off, 1..255=lower to higher power level). * @return none. *************************************************************************/ -void setAirPumpMotorState( AIR_PUMP_MOTOR_STATE_T state ) +void setAirPumpMotorPower( U08 power ) { - if ( state < NUM_OF_AIR_PUMP_MOTOR_STATES ) + // if state is changing, set the air pump to the given on/off state and send event + if ( power != currentAirPumpMotorPowerLevel ) { - // if state is changing, set the air pump to the given on/off state and send event - if ( state != currentAirPumpMotorState ) - { - SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_PUMP_ON_OFF, (U32)currentAirPumpMotorState, (U32)state ); - setAirPumpMotorSignal( (PIN_SIGNAL_STATE_T)state ); - currentAirPumpMotorState = state; - } + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_PUMP_ON_OFF, (U32)currentAirPumpMotorPowerLevel, (U32)power ); + setAirPumpMotorPowerLevel( power ); + currentAirPumpMotorPowerLevel = power; } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_TD_AIR_PUMP_INVALID_STATE, (U32)state ) - } } /*********************************************************************//** * @brief - * The getAirPumpMotorState function gets the current state of the air pump - * motor. - * @details \b Inputs: currentAirPumpMotorState + * The getAirPumpMotorState function gets the current set power level of the + * air pump motor. + * @details \b Inputs: currentAirPumpMotorPowerLevel * @details \b Outputs: none - * @return Current on/off state of the air pump motor. + * @return Current set power level of the air pump motor. *************************************************************************/ -AIR_PUMP_MOTOR_STATE_T getAirPumpMotorState( void ) +U08 getAirPumpMotorPower( void ) { - return currentAirPumpMotorState; + return currentAirPumpMotorPowerLevel; } @@ -97,7 +92,7 @@ * @brief * The testSetAirPump function sets the air pump to a given state (on/off). * @details \b Inputs: none - * @details \b Outputs: currentAirPumpState + * @details \b Outputs: currentAirPumpMotorPowerLevel * @param message set message from Dialin which includes the state to set * the air pump to. * @return TRUE if set request is successful, FALSE if not @@ -112,12 +107,12 @@ // Verify payload length is valid if ( sizeof( U32 ) == message->hdr.payloadLen ) { - U32 state; + U32 power; - memcpy( &state, message->payload, sizeof(U32) ); - if ( state < NUM_OF_AIR_PUMP_MOTOR_STATES ) + memcpy( &power, message->payload, sizeof(U32) ); + if ( power <= AIR_PUMP_MOTOR_MAX_PWM ) { - setAirPumpMotorState( (AIR_PUMP_MOTOR_STATE_T)state ); + setAirPumpMotorPower( (U08)power ); result = TRUE; } }