/************************************************************************** * * 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 "FpgaTD.h" #include "GLXferPump.h" #include "GPIO.h" #include "Messaging.h" /** * @addtogroup GLXferPump * @{ */ // ********** private definitions ********** // ********** private data ********** static U08 currentAirPumpMotorPowerLevel; ///< Current air pump motor state: 0=off, 1..255=power level. // ********** private function prototypes ********** /*********************************************************************//** * @brief * The initGasLiqXferPumpDriver function initializes the gas/liquid transfer * pump driver unit. * @details \b Inputs: none * @details \b Outputs: currentAirPumpMotorPowerLevel * @return none *************************************************************************/ void initGasLiqXferPumpDriver(void) { currentAirPumpMotorPowerLevel = AIR_PUMP_MOTOR_OFF; setAirPumpMotorPowerLevel( currentAirPumpMotorPowerLevel ); } /*********************************************************************//** * @brief * 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: currentAirPumpMotorPowerLevel * @param power Power level for air pump (0=off, 1..255=lower to higher power level). * @return none. *************************************************************************/ void setAirPumpMotorPower( U08 power ) { // if state is changing, set the air pump to the given on/off state and send event if ( power != currentAirPumpMotorPowerLevel ) { SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_PUMP_ON_OFF, (U32)currentAirPumpMotorPowerLevel, (U32)power ); setAirPumpMotorPowerLevel( power ); currentAirPumpMotorPowerLevel = power; } } /*********************************************************************//** * @brief * The getAirPumpMotorState function gets the current set power level of the * air pump motor. * @details \b Inputs: currentAirPumpMotorPowerLevel * @details \b Outputs: none * @return Current set power level of the air pump motor. *************************************************************************/ U08 getAirPumpMotorPower( void ) { return currentAirPumpMotorPowerLevel; } /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /*********************************************************************//** * @brief * The testSetAirPump function sets the air pump to a given state (on/off). * @details \b Inputs: none * @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 *************************************************************************/ BOOL testSetAirPump( MESSAGE_T *message ) { BOOL result = FALSE; // Verify tester has logged in with TD and override type is valid if ( TRUE == isTestingActivated() ) { // Verify payload length is valid if ( sizeof( U32 ) == message->hdr.payloadLen ) { U32 power; memcpy( &power, message->payload, sizeof(U32) ); if ( power <= AIR_PUMP_MOTOR_MAX_PWM ) { setAirPumpMotorPower( (U08)power ); result = TRUE; } } } return result; } /**@}*/