/************************************************************************** * * Copyright (c) 2019-2020 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 FPGA.h * * @author (last) Sean Nash * @date (last) 14-Oct-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #ifndef __FPGA_H__ #define __FPGA_H__ #include "HDCommon.h" #include "Interrupts.h" /** * @defgroup FPGA FPGA * @brief FPGA service module. * The FPGA module manages communication between the HD and the FPGA via UART. * This module is driven by the Priority Task via calls to two FPGA executive functions: * 1) an incoming executive manages the states of the state machine that deal with responses and data received from the FPGA * 2) an outgoing executive manages transmission of write and read commands to the FPGA. * This module first reads the header record that includes the FPGA ID and revision and * verifies the FPGA ID to check FPGA communication. It then initializes and configures the ADCs and * various other sensors that are interfaced via the FPGA. Then, it essentially enters an infinite loop * where a bulk write command updates actuator set points and a bulk read command retrieves the latest sensor readings. * * @addtogroup FPGA * @{ */ // ********** public definitions ********** // ********** public function prototypes ********** void initFPGA( void ); void execFPGAIn( void ); void execFPGAOut( void ); SELF_TEST_STATUS_T execFPGATest( void ); void execFPGAClockSpeedTest( void ); void signalFPGAReceiptCompleted( void ); void signalFPGATransmitCompleted( void ); void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ); U16 getFPGATemperature( void ); F32 getFPGAVcc( void ); F32 getFPGAVccAux( void ); F32 getFPGAVpvn( void ); void setAlarmAudioState( U32 state, U32 volumeLevel, U32 volumeDivider ); F32 getFPGABloodFlowSignalStrength( void ); F32 getFPGADialysateFlowSignalStrength( void ); F32 getFPGABloodFlow( void ); U08 getFPGABloodFlowMeterStatus( void ); U08 getFPGABloodFlowFastPacketReadCounter( void ); U08 getFPGABloodFlowSlowPacketReadCounter( void ); U08 getFPGABloodFlowStatusPacketReadCounter( void ); U08 getFPGABloodFlowErrorCounter( void ); F32 getFPGADialysateFlow( void ); U08 getFPGADialysateFlowMeterStatus( void ); U08 getFPGADialysateFlowFastPacketReadCounter( void ); U08 getFPGADialysateFlowSlowPacketReadCounter( void ); U08 getFPGADialysateFlowStatusPacketReadCounter( void ); U08 getFPGADialysateFlowErrorCounter( void ); U16 getFPGABloodPumpHallSensorCount( void ); U08 getFPGABloodPumpHallSensorStatus( void ); U16 getFPGADialInPumpHallSensorCount( void ); U08 getFPGADialInPumpHallSensorStatus( void ); U16 getFPGADialOutPumpHallSensorCount( void ); U08 getFPGADialOutPumpHallSensorStatus( void ); U32 getFPGAArterialPressure( void ); U08 getFPGAArterialPressureReadCounter( void ); U08 getFPGAArterialPressureErrorCounter( void ); U16 getFPGAVenousPressure( void ); U16 getFPGAVenousPressureTemperature( void ); U08 getFPGAVenousPressureReadCounter( void ); U16 getFPGABloodPumpOcclusion( void ); U08 getFPGABloodPumpOcclusionReadCounter( void ); U08 getFPGABloodPumpOcclusionErrorCounter( void ); void setFPGASyringePumpControlFlags( U08 bitFlags ); void setFPGASyringePumpADCandDACControlFlags( U08 bitFlags ); void setFPGASyringePumpDACOutputLevel( U16 counts ); void setFPGASyringePumpStepToggleTime( U32 microSeconds ); U08 getFPGASyringePumpStatus( void ); U08 getFPGASyringePumpADCReadCounter( void ); U08 getFPGASyringePumpADCandDACStatus( void ); U08 getFPGASyringePumpEncoderStatus( void ); U32 getFPGASyringePumpEncoderPosition( void ); U16 getFPGASyringePumpADCChannel0( void ); U16 getFPGASyringePumpADCChannel1( void ); U16 getFPGASyringePumpADCChannel2( void ); U16 getFPGASyringePumpADCChannel3( void ); U16 getFPGATimerCount( void ); void getFPGAAccelAxes( S16 *x, S16 *y, S16 *z ); void getFPGAAccelMaxes( S16 *xm, S16*ym, S16*zm ); void getFPGAAccelStatus( U16 *cnt, U16 *accelFPGAFaultReg ); F32 getFPGABackupAlarmAudioCurrent( void ); void getFPGAAirTrapLevels( BOOL *airAtLower, BOOL *airAtUpper ); void setFPGASensorTest( U08 sensorTest ); OPN_CLS_STATE_T getFPGADoorState( void ); void setFPGAValvesControlMode( U16 bits ); U16 getFPGAValvesStatus( void ); BOOL noFPGAFluidLeakDetected( void ); BOOL noFPGABloodLeakDetected( void ); BOOL FPGABloodLeakZeroDetected( void ); void setFPGABloodLeakZero( void ); void clearFPGABloodLeakZero( void ); void setFPGABloodLeakSelfTest( void ); void clearFPGABloodLeakSelfTest( void ); BOOL noFPGABubbleDetected( U32 bubble ); void setFPGABubbleSelfTest( U32 bubble ); void clearFPGABubbleSelfTest( U32 bubble ); void setFPGAValveDialyzerInletPosition( S16 setPoint ); S16 getFPGAValveDialyzerInletPosition( void ); U16 getFPGAValveDialyzerInletCurrentCounts( void ); void setFPGAValveDialyzerOutletPosition( S16 setPoint ); S16 getFPGAValveDialyzerOutletPosition( void ); U16 getFPGAValveDialyzerOutletCurrentCounts( void ); void setFPGAValveBloodVenousPosition( S16 setPoint ); S16 getFPGAValveBloodVenousPosition( void ); U16 getFPGAValveBloodVenousCurrentCounts( void ); void setFPGAValveBloodArterialPosition( S16 setPoint ); S16 getFPGAValveBloodArterialPosition( void ); U16 getFPGAValveBloodArterialCurrentCounts( void ); U16 getFPGABoardTemperature( void ); U32 getFPGAPBAADCTemperature( void ); U16 getFPGAInletFan1TogglePeriod( void ); U16 getFPGAFrontDoorStatus( void ); U16 getFPGAPumpTrackSwitchStatus( void ); // The PWM functions are only used during debugging #ifdef DEBUG_ENABLED void setFPGAValveDialyzerInletPWM( U16 count ); U16 getFPGAValveDialyzerInletPWM( void ); void setFPGAValveDialyzerOutletPWM( U16 count ); U16 getFPGAValveDialyzerOutletPWM( void ); void setFPGAValveBloodVenousPWM( U16 count ); U16 getFPGAValveBloodVenousPWM( void ); void setFPGAValveBloodArterialPWM( U16 count ); U16 getFPGAValveBloodArterialPWM( void ); #endif /**@}*/ #endif