Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rc9e1a93ccd8cfbdc9737c8ffc9e6a3dbe9ba7c44 -r933a18d740285e70be9d00696ed0f5a5381bc8e4 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision c9e1a93ccd8cfbdc9737c8ffc9e6a3dbe9ba7c44) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 933a18d740285e70be9d00696ed0f5a5381bc8e4) @@ -8,7 +8,7 @@ * @file FPGA.c * * @author (last) Sean Nash -* @date (last) 09-Sep-2020 +* @date (last) 14-Oct-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -78,6 +78,9 @@ #define FPGA_ADC1_AUTO_READ_ENABLE 0x01 ///< Auto-read enable bit for ADC1 control register. +#define FPGA_AIRTRAP_LEVEL_LOW_MASK 0x0008 ///< Bit mask for air trap lower level sensor. +#define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. + // FPGA Sensors Record #pragma pack(push,1) /// Record structure for FPGA header read. @@ -164,6 +167,23 @@ U16 VDiPWMTarget; ///< Reg 374. PWM target duty cycle for VDi pinch valve. U16 VDoPWMTarget; ///< Reg 376. PWM target duty cycle for VDo pinch valve. U16 VSparePWMTarget; ///< Reg 378. PWM target duty cycle for Vspare pinch valve. + U16 SyringePumpStatus; ///< Reg 380. Syringe pump status register + U16 SyringePumpEncStatus; ///< Reg 382. Syringe pump encoder status + U32 SyringePumpEncPosition; ///< Reg 384. Syringe pump encoder position + U16 sPumpAdcDataReadChannel0; ///< Reg 388. + U16 sPumpAdcDataReadCh1; ///< Reg 390. + U16 sPumpAdcDataReadCh2; ///< Reg 392. + U16 sPumpAdcDataReadCh3; ///< Reg 394. + U16 VBASpeed; ///< Reg 396. VBA pinch valve speed (Register VAUX0) + U16 VBVSpeed; ///< Reg 398. VBV pinch valve speed (Register VAUX1) + U16 VBVCurrent; ///< Reg 400. VBV pinch valve current (Register VAUX2) + U16 VDoCurrent; ///< Reg 402. VDo pinch valve current (Register VAUX3) + U16 VBACurrent; ///< Reg 404. VBA pinch valve current (Register VAUX8) + U16 VDiSpeed; ///< Reg 406. VDi pinch valve current (Register VAUX9) + U16 VDoSpeed; ///< Reg 408. VDo pinch valve speed (Register VAUX10) + U16 VDiCurrent; ///< Reg 410. VDi pinch valve current (Register VAUX11) + U16 VSpareSpeed; ///< Reg 412. VSpare speed (Register VAUX5) + U16 VSpareCurrent; ///< Reg 414. VSpare current (Register VAUX13) } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -183,6 +203,7 @@ U08 AlarmControl; ///< Reg 34. Alarm (audio) control register. } FPGA_ACTUATORS_T; +// TODO clean up the struct /// Record structure for FPGA async (as needed) reads. typedef struct // TODO - add all sensor readings to this structure per FPGA register map { @@ -268,9 +289,8 @@ /*********************************************************************//** * @brief * The initFPGA function initializes the FPGA module. - * @details - * Inputs : none - * Outputs : FPGA module initialized. + * @details Inputs: none + * @details Outputs: FPGA module initialized. * @return none *************************************************************************/ void initFPGA( void ) @@ -379,9 +399,8 @@ * @brief * The resetFPGACommFlags function resets the various fpga comm flags and * counters. - * @details - * Inputs : none - * Outputs : fpga comm flags & counters reset + * @details Inputs: none + * @details Outputs: fpga comm flags & counters reset * @return none *************************************************************************/ static void resetFPGACommFlags( void ) @@ -399,9 +418,8 @@ * @brief * The signalFPGAReceiptCompleted function increments a counter to indicate * that another DMA receipt from the FPGA has completed. - * @details - * Inputs : none - * Outputs : fpgaReceiptCounter + * @details Inputs: none + * @details Outputs: fpgaReceiptCounter * @return none *************************************************************************/ void signalFPGAReceiptCompleted( void ) @@ -434,9 +452,8 @@ * @brief * The signalFPGATransmitCompleted function increments a counter to indicate * that another DMA transmit to the FPGA has completed. - * @details - * Inputs : none - * Outputs : fpgaReceiptCounter + * @details Inputs: none + * @details Outputs: fpgaReceiptCounter * @return none *************************************************************************/ void signalFPGATransmitCompleted( void ) @@ -447,9 +464,8 @@ /*********************************************************************//** * @brief * The execFPGA function manages incoming data exchanges with the FPGA. - * @details - * Inputs : fpgaState - * Outputs : fpgaState + * @details Inputs: fpgaState + * @details Outputs: fpgaState * @return none *************************************************************************/ void execFPGAIn( void ) @@ -506,9 +522,8 @@ /*********************************************************************//** * @brief * The execFPGAOut function manages outgoing data exchanges with the FPGA. - * @details - * Inputs : fpgaState - * Outputs : fpgaState + * @details Inputs: fpgaState + * @details Outputs: fpgaState * @return none *************************************************************************/ void execFPGAOut( void ) @@ -553,9 +568,8 @@ * @brief * The handleFPGAReadHeaderState function handles the FPGA state where * the read header registers command is sent to the FPGA. - * @details - * Inputs : none - * Outputs : read command sent to FPGA + * @details Inputs: none + * @details Outputs: read command sent to FPGA * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReadHeaderState( void ) @@ -585,9 +599,8 @@ * @brief * The handleFPGAReceiveHeaderState function handles the FPGA state * where the header registers read response should be ready to take in. - * @details - * Inputs : none - * Outputs : header register values updated + * @details Inputs: none + * @details Outputs: header register values updated * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveHeaderState( void ) @@ -637,9 +650,8 @@ * @brief * The handleFPGAWriteAllActuatorsState function handles the FPGA state * where the bulk write command is sent to the FPGA. - * @details - * Inputs : actuator set points - * Outputs : actuator set points sent to FPGA + * @details Inputs: actuator set points + * @details Outputs: actuator set points sent to FPGA * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAWriteAllActuatorsState( void ) @@ -686,9 +698,8 @@ * @brief * The handleFPGAReceiveAllSensorsState function handles the FPGA state * where the bulk read response should be ready to parse. - * @details - * Inputs : none - * Outputs : sensor values updated + * @details Inputs: none + * @details Outputs: sensor values updated * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveAllSensorsState( void ) @@ -749,9 +760,8 @@ * @brief * The handleFPGAReadAllSensorsAsyncState function handles the FPGA state where * the read async sensors command is sent to the FPGA. - * @details - * Inputs : none - * Outputs : read async sensors command sent to FPGA + * @details Inputs: none + * @details Outputs: read async sensors command sent to FPGA * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReadAllSensorsAsyncState( void ) @@ -781,9 +791,8 @@ * @brief * The handleFPGAReceiveAllSensorsAsyncState function handles the FPGA state * where the bulk async read response should be ready to parse. - * @details - * Inputs : none - * Outputs : async sensor values updated + * @details Inputs: none + * @details Outputs: async sensor values updated * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveAllSensorsAsyncState( void ) @@ -833,9 +842,8 @@ /*********************************************************************//** * @brief * The execFPGATest function executes the FPGA self-test. - * @details - * Inputs : fpgaHeader - * Outputs : none + * @details Inputs: fpgaHeader + * @details Outputs: none * @return passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execFPGATest( void ) @@ -862,11 +870,30 @@ /*********************************************************************//** * @brief + * The consumeUnexpectedData function checks to see if a byte is sitting in + * the SCI2 received data register. + * @details Inputs: fpgaHeader + * @details Outputs: none + * @return fpgaDiag + *************************************************************************/ +static void consumeUnexpectedData( void ) +{ + // clear any errors + sciRxError( scilinREG ); + + // if a byte is pending read, read it + if ( sciIsRxReady( scilinREG ) != 0 ) + { + sciReceiveByte( scilinREG ); + } +} + +/*********************************************************************//** + * @brief * The setupDMAForWriteCmd function sets the byte count for the next DMA * write command to the FPGA. - * @details - * Inputs : none - * Outputs : number of bytes for next FPGA write command is set + * @details Inputs: none + * @details Outputs: number of bytes for next FPGA write command is set * @param bytes2Transmit number of bytes to be transmitted via DMA to the FPGA * @return none *************************************************************************/ @@ -887,9 +914,8 @@ * @brief * The startDMAWriteCmd function initiates the DMA transmit for the next * DMA write command to the FPGA. - * @details - * Inputs : none - * Outputs : DMA write command to FPGA is initiated + * @details Inputs: none + * @details Outputs: DMA write command to FPGA is initiated * @return none *************************************************************************/ static void startDMAWriteCmd( void ) @@ -903,9 +929,8 @@ * @brief * The setupDMAForWriteResp function sets the expected byte count for the * next DMA write command response from the FPGA. - * @details - * Inputs : none - * Outputs : number of expected bytes for next FPGA write command response is set + * @details Inputs: none + * @details Outputs: number of expected bytes for next FPGA write command response is set * @param bytes2Receive number of bytes expected to be transmitted via DMA from the FPGA * @return none *************************************************************************/ @@ -926,9 +951,8 @@ * @brief * The startDMAReceiptOfWriteResp function initiates readiness of the DMA * receiver for the next DMA write command response from the FPGA. - * @details - * Inputs : none - * Outputs : DMA write command response is ready to be received from the FPGA + * @details Inputs: none + * @details Outputs: DMA write command response is ready to be received from the FPGA * @return none *************************************************************************/ static void startDMAReceiptOfWriteResp( void ) @@ -942,9 +966,8 @@ * @brief * The setupDMAForReadCmd function sets the byte count for the next DMA * read command to the FPGA. - * @details - * Inputs : none - * Outputs : number of bytes for next FPGA read command is set + * @details Inputs: none + * @details Outputs: number of bytes for next FPGA read command is set * @param bytes2Transmit number of bytes to be transmitted via DMA to the FPGA * @return none *************************************************************************/ @@ -965,9 +988,8 @@ * @brief * The startDMAReadCmd function initiates the DMA transmit for the next * DMA read command to the FPGA. - * @details - * Inputs : none - * Outputs : DMA read command to FPGA is initiated + * @details Inputs: none + * @details Outputs: DMA read command to FPGA is initiated * @return none *************************************************************************/ static void startDMAReadCmd( void ) @@ -981,9 +1003,8 @@ * @brief * The setupDMAForReadResp function sets the expected byte count for the * next DMA read command response from the FPGA. - * @details - * Inputs : none - * Outputs : number of expected bytes for next FPGA read command response is set + * @details Inputs: none + * @details Outputs: number of expected bytes for next FPGA read command response is set * @param bytes2Receive number of expected bytes to be transmitted via DMA from the FPGA * @return none *************************************************************************/ @@ -1004,9 +1025,8 @@ * @brief * The startDMAReceiptOfReadResp function initiates readiness of the DMA * receiver for the next DMA read command response from the FPGA. - * @details - * Inputs : none - * Outputs : DMA read command response is ready to be received from the FPGA + * @details Inputs: none + * @details Outputs: DMA read command response is ready to be received from the FPGA * @return none *************************************************************************/ static void startDMAReceiptOfReadResp( void ) @@ -1019,9 +1039,8 @@ /*********************************************************************//** * @brief * The getFPGAVersions function gets the fpga version numbers. - * @details - * Inputs : fpgaHeader - * Outputs : none + * @details Inputs: fpgaHeader + * @details Outputs: none * @return none *************************************************************************/ void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) @@ -1036,9 +1055,8 @@ * @brief * The getFPGABloodFlowSignalStrength function gets the latest blood flow * signal strength reading. - * @details - * Inputs : fpgaSensorReadings2 - * Outputs : none + * @details Inputs: fpgaSensorReadings2 + * @details Outputs: none * @return last blood flow signal strength reading *************************************************************************/ F32 getFPGABloodFlowSignalStrength( void ) @@ -1050,9 +1068,8 @@ * @brief * The getFPGADialysateFlowSignalStrength function gets the latest dialysate * flow signal strength reading. - * @details - * Inputs : fpgaSensorReadings2 - * Outputs : none + * @details Inputs: fpgaSensorReadings2 + * @details Outputs: none * @return last dialysate flow signal strength reading *************************************************************************/ F32 getFPGADialysateFlowSignalStrength( void ) @@ -1063,9 +1080,8 @@ /*********************************************************************//** * @brief * The getFPGABloodFlow function gets the latest blood flow reading. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last blood flow reading *************************************************************************/ F32 getFPGABloodFlow( void ) @@ -1076,9 +1092,8 @@ /*********************************************************************//** * @brief * The getFPGADialysateFlow function gets the latest dialysate flow reading. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate flow reading *************************************************************************/ F32 getFPGADialysateFlow( void ) @@ -1093,9 +1108,8 @@ * counting up, indicates motor is running in forward direction. If counter is * counting down, indicates motor is running in reverse direction. Counter will * wrap at 0/65535. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last blood pump hall sensor count reading. *************************************************************************/ U16 getFPGABloodPumpHallSensorCount( void ) @@ -1110,9 +1124,8 @@ * Bit 0 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) * Bit 1 - A direction error was detected in the current hall sensor phase * Bit 2 - A direction error was detected since the last read of this register - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last blood pump hall sensor status reading. *************************************************************************/ U08 getFPGABloodPumpHallSensorStatus( void ) @@ -1127,9 +1140,8 @@ * counting up, indicates motor is running in forward direction. If counter is * counting down, indicates motor is running in reverse direction. Counter will * wrap at 0/65535. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate inlet pump hall sensor count reading. *************************************************************************/ U16 getFPGADialInPumpHallSensorCount( void ) @@ -1144,9 +1156,8 @@ * Bit 0 - Derived direction of the dialyste inlet pump motor (0=Fwd, 1=Rev) * Bit 1 - A direction error was detected in the current hall sensor phase * Bit 2 - A direction error was detected since the last read of this register - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate inlet pump hall sensor status reading. *************************************************************************/ U08 getFPGADialInPumpHallSensorStatus( void ) @@ -1161,9 +1172,8 @@ * counting up, indicates motor is running in forward direction. If counter is * counting down, indicates motor is running in reverse direction. Counter will * wrap at 0/65535. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate outlet pump hall sensor count reading. *************************************************************************/ U16 getFPGADialOutPumpHallSensorCount( void ) @@ -1178,9 +1188,8 @@ * Bit 0 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) * Bit 1 - A direction error was detected in the current hall sensor phase * Bit 2 - A direction error was detected since the last read of this register - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate outlet pump hall sensor status reading. *************************************************************************/ U08 getFPGADialOutPumpHallSensorStatus( void ) @@ -1191,9 +1200,8 @@ /*********************************************************************//** * @brief * The getFPGABloodPumpOcclusion function gets the latest blood occlusion reading. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last blood occlusion reading *************************************************************************/ U16 getFPGABloodPumpOcclusion( void ) @@ -1205,9 +1213,8 @@ * @brief * The getFPGADialInPumpOcclusion function gets the latest dialysate * inlet occlusion reading. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate inlet occlusion reading *************************************************************************/ U16 getFPGADialInPumpOcclusion( void ) @@ -1219,9 +1226,8 @@ * @brief * The getFPGADialOutPumpOcclusion function gets the latest dialysate * outlet occlusion reading. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last dialysate outlet occlusion reading *************************************************************************/ U16 getFPGADialOutPumpOcclusion( void ) @@ -1235,9 +1241,8 @@ * High byte indicates alarm status for ADC channel. * Low 24-bits are channel reading. Subtract 2^23 from low 24 bits to get * signed channel reading. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last arterial pressure reading *************************************************************************/ U32 getFPGAArterialPressure( void ) @@ -1251,9 +1256,8 @@ * The high 2 bits are status bits: 00=ok, 01=cmd mode, 10=stale data, 11=diag * The low 14 bits are data. Zero is at 1638. Values above are positive, * below are negative. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @return last venous pressure reading *************************************************************************/ U16 getFPGAVenousPressure( void ) @@ -1265,9 +1269,8 @@ * @brief * The getFPGAAccelAxes function gets the accelerometer axis readings. * Axis readings are in ADC counts. 0.004 g per LSB. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @param x Populate this param with X axis reading * @param y Populate this param with Y axis reading * @param z Populate this param with Z axis reading @@ -1285,9 +1288,8 @@ * The getFPGAAccelMaxes function gets the maximum accelerometer axis readings. * from last FPGA read (every 10ms). * Axis readings are in ADC counts. 0.004 g per LSB. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @param x Populate this param with maximum X axis reading * @param y Populate this param with maximum Y axis reading * @param z Populate this param with maximum Z axis reading @@ -1304,9 +1306,8 @@ * @brief * The getFPGAAccelStatus function gets the accelerometer reading count * and error register values. - * @details - * Inputs : fpgaSensorReadings - * Outputs : none + * @details Inputs: fpgaSensorReadings + * @details Outputs: none * @param cnt Populate this param with latest sample counter value * @param err Populate this param with latest error * @return none @@ -1319,22 +1320,316 @@ /*********************************************************************//** * @brief - * The consumeUnexpectedData function checks to see if a byte is sitting in - * the SCI2 received data register. - * @details - * Inputs : fpgaHeader - * Outputs : none - * @return fpgaDiag + * The getFPGAAirTrapLevels function gets the latest air trap level sensor + * readings. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return none *************************************************************************/ -static void consumeUnexpectedData( void ) +void getFPGAAirTrapLevels( BOOL *airAtLower, BOOL *airAtUpper ) { - // clear any errors - sciRxError( scilinREG ); - // if a byte is pending read, read it - if ( sciIsRxReady( scilinREG ) != 0 ) - { - sciReceiveByte( scilinREG ); - } + U16 fpgaGPIO = fpgaSensorReadings.fpgaGPIO; + U16 lower = fpgaGPIO & FPGA_AIRTRAP_LEVEL_LOW_MASK; + U16 upper = fpgaGPIO & FPGA_AIRTRAP_LEVEL_HIGH_MASK; + + *airAtLower = ( 0 == lower ? FALSE : TRUE ); + *airAtUpper = ( 0 == upper ? FALSE : TRUE ); } -/**@}*/ +/*********************************************************************//** + * @brief + * The setFPGAValvesControlMode function sets the valves control mode. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param bits : The bits to enable the PID controller of a valve + * @return none + *************************************************************************/ +void setFPGAValvesControlMode( U16 bits ) +{ + fpgaActuatorSetPoints.fpgaPIDControl = bits; +} + +/*********************************************************************//** + * @brief + * The getValvesStatus function reads the status of the valves + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return The status of the valves + *************************************************************************/ +U16 getFPGAValvesStatus( void ) +{ + return fpgaSensorReadings.valveStatus; +} + +/*********************************************************************//** + * @brief + * The setValveDialyzerInletPosition function sets the position of VDi + * in counts + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setFPGAValveDialyzerInletPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VDiSetPoint = setPoint; +} + +/*********************************************************************//** + * @brief + * The getValveDialyzerInletPosition function reads the current position + * of VDi in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current position of VDi + *************************************************************************/ +S16 getFPGAValveDialyzerInletPosition( void ) +{ + return fpgaSensorReadings.VDiPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerInletCurrentCounts function reads the current \n + * of VDi in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current of VDi + *************************************************************************/ +U16 getFPGAValveDialyzerInletCurrentCounts( void ) +{ + return fpgaSensorReadings.VDiCurrent; +} + +#ifdef DEBUG_ENABLED +/*********************************************************************//** + * @brief + * The setFPGAValveDialyzerInletPWM function sets the PWM of VDI in counts. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param count which is the PWM of VDI in counts + * @return none + *************************************************************************/ +void setFPGAValveDialyzerInletPWM( U16 count ) +{ + fpgaActuatorSetPoints.VDiPWMFixed = count; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerInletPWM function reads the current PWM target + * of VDI. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current PWM of VDI + *************************************************************************/ +U16 getFPGAValveDialyzerInletPWM( void ) +{ + return fpgaSensorReadings.VDiPWMTarget; +} +#endif + +/*********************************************************************//** + * @brief + * The setFPGAValveDialyzerOutletPosition function sets the position of VDo + * in counts + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setFPGAValveDialyzerOutletPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VDoSetPoint = setPoint; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerOutletPosition function reads the current position + * of VDo in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current position of VDo + *************************************************************************/ +S16 getFPGAValveDialyzerOutletPosition( void ) +{ + return fpgaSensorReadings.VDoPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerOutletCurrentCounts function reads the current + * of VDo in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current of VDo + *************************************************************************/ +U16 getFPGAValveDialyzerOutletCurrentCounts( void ) +{ + return fpgaSensorReadings.VDoCurrent; +} + +#ifdef DEBUG_ENABLED +/*********************************************************************//** + * @brief + * The setFPGAValveDialyzerOutletPWM function sets the PWM of VDO in counts. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param count which is the PWM of VDO in counts + * @return none + *************************************************************************/ +void setFPGAValveDialyzerOutletPWM( U16 count ) +{ + fpgaActuatorSetPoints.VDoPWMFixed = count; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerOutletPWM function reads the current PWM target + * of VDO. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current PWM of VDO + *************************************************************************/ +U16 getFPGAValveDialyzerOutletPWM( void ) +{ + return fpgaSensorReadings.VDoPWMTarget; +} +#endif + +/*********************************************************************//** + * @brief + * The setValveBloodVenousPosition function sets the position of VBV + * in counts + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setFPGAValveBloodVenousPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VBVSetPoint = setPoint; +} + +/*********************************************************************//** + * @brief + * The getValveBloodVenousPosition function reads the current position + * of VBV in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current position of VBV + *************************************************************************/ +S16 getFPGAValveBloodVenousPosition( void ) +{ + return fpgaSensorReadings.VBVPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveBloodVenousCurrentCounts function reads the current + * of VBV in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current of VBV + *************************************************************************/ +U16 getFPGAValveBloodVenousCurrentCounts( void ) +{ + return fpgaSensorReadings.VBVCurrent; +} + +#ifdef DEBUG_ENABLED +/*********************************************************************//** + * @brief + * The setFPGAValveBloodVenousPWM function sets the PWM of VBV in counts. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param count which is the PWM of VBV in counts + * @return none + *************************************************************************/ +void setFPGAValveBloodVenousPWM( U16 count ) +{ + fpgaActuatorSetPoints.VBVPWMFixed = count; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveBloodVenousPWM function returns the PWM of VBV in counts. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: none + * @return returns the PWM of VBV in counts + *************************************************************************/ +U16 getFPGAValveBloodVenousPWM( void ) +{ + return fpgaSensorReadings.VBVPWMTarget; +} +#endif + +/*********************************************************************//** + * @brief + * The setValveBloodArterialPosition function sets the position of VBA + * in counts + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setFPGAValveBloodArterialPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VBASetPoint = setPoint; +} + +/*********************************************************************//** + * @brief + * The getValveBloodArterialPosition function reads the current position + * of VBA in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current position of VBA + *************************************************************************/ +S16 getFPGAValveBloodArterialPosition( void ) +{ + return fpgaSensorReadings.VBAPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveBloodArterialCurrentCounts function reads the current + * of VBA in counts + * @details Inputs: none + * @details Outputs: fpgaSensorReadings + * @return The current of VBA + *************************************************************************/ +U16 getFPGAValveBloodArterialCurrentCounts( void ) +{ + return fpgaSensorReadings.VBACurrent; +} + +#ifdef DEBUG_ENABLED +/*********************************************************************//** + * @brief + * The setFPGAValveBloodArterialPWM function sets a PWM for VBA in counts. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param count which is the PWM of VBA in counts + * @return none + *************************************************************************/ +void setFPGAValveBloodArterialPWM( U16 count ) +{ + fpgaActuatorSetPoints.VBAPWMFixed = count; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveBloodArterialPWM function returns the current PWM of + * VBA in counts. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current PWM of VBA in counts + *************************************************************************/ +U16 getFPGAValveBloodArterialPWM( void ) +{ + return fpgaSensorReadings.VBAPWMTarget; +} +#endif + +/**@}*/