Index: firmware/App/Services/FPGA.h =================================================================== diff -u -reb877ae36c28eb83553ee11ccccf42e2c4a5b4d2 -rc72332b4674a895aed7d56ca37ee5230548da3f6 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision eb877ae36c28eb83553ee11ccccf42e2c4a5b4d2) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision c72332b4674a895aed7d56ca37ee5230548da3f6) @@ -1,38 +1,190 @@ -/************************************************************************** - * - * Copyright (c) 2019-2019 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 - * - * @date 21-Oct-2019 - * @author S. Nash - * - * @brief header file for FPGA Interface service. - * - **************************************************************************/ +/************************************************************************** +* +* Copyright (c) 2019-2022 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) Dara Navaei +* @date (last) 07-May-2022 +* +* @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 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 getFPGADVTArterialPressure( void ); +U16 getFPGADVTArterialTemperature( void ); +U08 getFPGADVTArterialPressureReadCounter( void ); +U08 getFPGATDVTArterialPressureErrorCounter( 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 ); + +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 ); + +void setFPGABloodLeakUARTControl( U08 value ); +void setFPGABloodLeakUARTTransmit( U08 value ); +U08 getFPGABloodLeakZeroStatusCounter( void ); +U08 getFPGABloodLeakCounter( void ); +U08 getFPGABloodLeakZeroedStatus( void ); +U16 getFPGABloodLeakDetectSetPoint( void ); +U16 getFPGABloodLeakDetectLevel( void ); +U16 getFPGABloodLeakStCount( void ); +U16 getFPGABloodLeakLEDIntensity( void ); +U16 getFPGABloodLeakRegisterCounter( void ); +U08 getFPGABloodLeakTxFIFOCount( void ); +U16 getFPGABloodLeakRxFIFOCount( void ); +U08 getFPGABloodLeakRxErrorCount( void ); +U08 getFPGABloodLeakRxFIFODataOut( void ); +U08 getFPGABloodLeakSelfTestErrorCounter( void ); +U08 getFPGABloodLeakZeroErrorCounter( 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 + +/**@}*/ -#ifndef __FPGA_H__ -#define __FPGA_H__ - -#include "Common.h" -#include "Interrupts.h" - -// ********** public definitions ********** - -// ********** public function prototypes ********** - -void initFPGA( void ); -void execFPGAIn( void ); -void execFPGAOut( void ); -SELF_TEST_STATUS_T execFPGATest( void ); - -void signalFPGAReceiptCompleted( void ); -void signalFPGATransmitCompleted( void ); - -U16 getFPGAStatus( void ); -void setFPGAControl( U16 ctrl ); - #endif