/************************************************************************** * * Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file GLXferPump.c * * @author (last) Sean * @date (last) 17-Sep-2024 * * @author (original) Sean * @date (original) 17-Sep-2024 * ***************************************************************************/ #include "AlarmMgmtTD.h" #include "GLXferPump.h" #include "GPIO.h" #include "Messaging.h" /** * @addtogroup GLXferPump * @{ */ // ********** private definitions ********** // ********** private data ********** static AIR_PUMP_MOTOR_STATE_T currentAirPumpMotorState; ///< Current air pump motor state (on/off). // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initGasLiqXferPumpDriver function initializes the gas/liquid transfer * pump driver unit. * @details \b Inputs: none * @details \b Outputs: currentAirPumpMotorState * @return none *************************************************************************/ void initGasLiqXferPumpDriver(void) { currentAirPumpMotorState = AIR_PUMP_MOTOR_OFF; setAirPumpMotorSignal( (PIN_SIGNAL_STATE_T)currentAirPumpMotorState ); } /*********************************************************************//** * @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. * @details \b Inputs: none * @details \b Outputs: currentAirPumpMotorState * @param state State to set the air pump motor (on/off). * @return none. *************************************************************************/ void setAirPumpMotorState( AIR_PUMP_MOTOR_STATE_T state ) { 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 ( 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; } } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_AIR_PUMP_INVALID_MOTOR_STATE_SELECTED, (U32)state ) } } /*********************************************************************//** * @brief * The getAirPumpMotorState function gets the current state of the air pump * motor. * @details \b Inputs: currentAirPumpMotorState * @details \b Outputs: none * @return Current on/off state of the air pump motor. *************************************************************************/ AIR_PUMP_MOTOR_STATE_T getAirPumpMotorState( void ) { return currentAirPumpMotorState; } /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /*********************************************************************//** * @brief * The testSetAirPump function sets the air pump to a given state (on/off). * @details \b Inputs: none * @details \b Outputs: currentAirPumpState * @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 *************************************************************************/ BOOL testSetAirPump( MESSAGE_T *message ) { BOOL result = FALSE; // Verify tester has logged in with TD and override type is valid if ( TRUE == isTestingActivated() ) { U32 state; memcpy( &state, message->payload, sizeof(U32) ); result = TRUE; if ( state < NUM_OF_AIR_PUMP_MOTOR_STATES ) { setAirPumpMotorState( (AIR_PUMP_MOTOR_STATE_T)state ); result = TRUE; } } return result; } /**@}*/