Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r4a5f3c9dfe803562a40aeea3bbc9fc3be0d1e26d -rcb9bcb7376f09096f833ce59cfb9a71f43263315 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 4a5f3c9dfe803562a40aeea3bbc9fc3be0d1e26d) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision cb9bcb7376f09096f833ce59cfb9a71f43263315) @@ -170,10 +170,10 @@ typedef struct // TODO - add all actuator set points to this structure per FPGA register map { U16 fpgaPIDControl; ///< Reg 12. Valve PID enables. - U16 VBASetPoint; ///< Reg 14. VBA pinch valve is commanded to this set point position. - U16 VBVSetPoint; ///< Reg 16. VBV pinch valve is commanded to this set point position. - U16 VDiSetPoint; ///< Reg 18. VDi pinch valve is commanded to this set point position. - U16 VDoSetPoint; ///< Reg 20. VDo pinch valve is commanded to this set point position. + S16 VBASetPoint; ///< Reg 14. VBA pinch valve is commanded to this set point position. + S16 VBVSetPoint; ///< Reg 16. VBV pinch valve is commanded to this set point position. + S16 VDiSetPoint; ///< Reg 18. VDi pinch valve is commanded to this set point position. + S16 VDoSetPoint; ///< Reg 20. VDo pinch valve is commanded to this set point position. U16 VSpareSetPoint; ///< Reg 22. VSpare pinch valve is commanded to this set point position. U16 VBAPWMFixed; ///< Reg 24. VBA PWM set to fixed current by setting fixed PWM duty cycle. Range 750 to 4250. < 2500 is reverse direction. U16 VBVPWMFixed; ///< Reg 26. VBV PWM set to fixed current by setting fixed PWM duty cycle. Range 750 to 4250. < 2500 is reverse direction. @@ -1312,43 +1312,163 @@ *err = fpgaSensorReadings.accelFaultRegister; } -void enableValvesPIDControl( U16 enableBits ) +/*********************************************************************//** + * @brief + * The enableValvesPIDControl function enables the PID controller \n + * bit of the valves + * @details + * Inputs : fpgaActuatorSetPoints + * Outputs : fpgaActuatorSetPoints + * @param bits : The bits to enable the PID controller of a valve + * @return none + *************************************************************************/ +void enableValvesPIDControl( U16 bits ) { - fpgaActuatorSetPoints.fpgaPIDControl = 0xFF; + fpgaActuatorSetPoints.fpgaPIDControl = + fpgaActuatorSetPoints.fpgaPIDControl | bits; } -void setDialyzerInletValvePosition( U16 setPoint ) +/*********************************************************************//** + * @brief + * The enableValvesBypassControl function enables the bypass controller \n + * bit of the valves + * @details + * Inputs : fpgaActuatorSetPoints + * Outputs : fpgaActuatorSetPoints + * @param bits : The bits to enable the bypass controller of a valve + * @return none + *************************************************************************/ +void enableValvesBypassControl( U16 bits ) { + fpgaActuatorSetPoints.fpgaPIDControl = + fpgaActuatorSetPoints.fpgaPIDControl & bits; +} + +/*********************************************************************//** + * @brief + * The getValvesStatus function reads the status of the valves + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @return The status of the valves + *************************************************************************/ +U16 getValvesStatus( void ) +{ + return fpgaSensorReadings.valveStatus; +} + +/*********************************************************************//** + * @brief + * The setValveDialyzerInletPosition function sets the position of VDi \n + * in counts + * @details + * Inputs : fpgaActuatorSetPoints + * Outputs : fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setValveDialyzerInletPosition( S16 setPoint ) +{ fpgaActuatorSetPoints.VDiSetPoint = setPoint; } -S16 getDialyzerInletValvePosition( void ) + +/*********************************************************************//** + * @brief + * The getValveDialyzerInletPosition function reads the current position \n + * of VDi in counts + * @details + * Inputs : none + * Outputs : fpgaSensorReadings + * @return The current position of VDi + *************************************************************************/ +S16 getValveDialyzerInletPosition( void ) { return fpgaSensorReadings.VDiPosition; } -void setDialyzerOutletValvePosition( U16 setPoint ) +/*********************************************************************//** + * @brief + * The setValveDialyzerOutletPosition function sets the position of VDo \n + * in counts + * @details + * Inputs : fpgaActuatorSetPoints + * Outputs : fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setValveDialyzerOutletPosition( S16 setPoint ) { fpgaActuatorSetPoints.VDoSetPoint = setPoint; } -S16 getDialyzerOutletValvePosition( void ) + +/*********************************************************************//** + * @brief + * The getDialyzerOutletValvePosition function reads the current position \n + * of VDo in counts + * @details + * Inputs : none + * Outputs : fpgaSensorReadings + * @return The current position of VDo + *************************************************************************/ +S16 getValveDialyzerOutletPosition( void ) { return fpgaSensorReadings.VDoPosition; } -void setVenousBloodValvePosition( U16 setPoint ) +/*********************************************************************//** + * @brief + * The setValveBloodVenousPosition function sets the position of VBV \n + * in counts + * @details + * Inputs : fpgaActuatorSetPoints + * Outputs : fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setValveBloodVenousPosition( S16 setPoint ) { fpgaActuatorSetPoints.VBVSetPoint = setPoint; } -S16 getVenousBloodValvePoistion( void ) + +/*********************************************************************//** + * @brief + * The getValveBloodVenousPosition function reads the current position \n + * of VBV in counts + * @details + * Inputs : none + * Outputs : fpgaSensorReadings + * @return The current position of VBV + *************************************************************************/ +S16 getValveBloodVenousPosition( void ) { return fpgaSensorReadings.VBVPosition; } -void setArterialBloodValvePosition( U16 setPoint ) +/*********************************************************************//** + * @brief + * The setValveBloodArterialPosition function sets the position of VBA \n + * in counts + * @details + * Inputs : fpgaActuatorSetPoints + * Outputs : fpgaActuatorSetPoints + * @param setPoint : Next position of the valve in counts + * @return none + *************************************************************************/ +void setValveBloodArterialPosition( S16 setPoint ) { fpgaActuatorSetPoints.VBASetPoint = setPoint; } -S16 getArterialBloodValvePoistion( void ) + +/*********************************************************************//** + * @brief + * The getValveBloodArterialPosition function reads the current position \n + * of VBA in counts + * @details + * Inputs : none + * Outputs : fpgaSensorReadings + * @return The current position of VBA + *************************************************************************/ +S16 getValveBloodArterialPosition( void ) { return fpgaSensorReadings.VBAPosition; }