Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r1fb58baf6e7e3d1f054b2a3634e233da7609dad9 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1fb58baf6e7e3d1f054b2a3634e233da7609dad9) @@ -8,7 +8,7 @@ * @file FPGA.c * * @author (last) Sean Nash -* @date (last) 09-Sep-2020 +* @date (last) 26-Jun-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -164,6 +164,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 +200,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 { @@ -1002,7 +1020,7 @@ /*********************************************************************//** * @brief - * The startDMAReceiptOfReadResp function initiates readiness of the DMA + * The startDMAReceiptOfReadResp function initiates readiness of the DMA \n * receiver for the next DMA read command response from the FPGA. * @details * Inputs : none @@ -1203,7 +1221,7 @@ /*********************************************************************//** * @brief - * The getFPGADialInPumpOcclusion function gets the latest dialysate + * The getFPGADialInPumpOcclusion function gets the latest dialysate \n * inlet occlusion reading. * @details * Inputs : fpgaSensorReadings @@ -1217,7 +1235,7 @@ /*********************************************************************//** * @brief - * The getFPGADialOutPumpOcclusion function gets the latest dialysate + * The getFPGADialOutPumpOcclusion function gets the latest dialysate \n * outlet occlusion reading. * @details * Inputs : fpgaSensorReadings @@ -1314,6 +1332,324 @@ /*********************************************************************//** * @brief + * The setFPGAValvesControlMode function sets the valves control mode. + * @details + * Inputs : fpgaActuatorSetPoints + * 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 + * Outputs : none + * @return The status of the valves + *************************************************************************/ +U16 getFPGAValvesStatus( 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 setFPGAValveDialyzerInletPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VDiSetPoint = setPoint; +} + +/*********************************************************************//** + * @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 getFPGAValveDialyzerInletPosition( void ) +{ + return fpgaSensorReadings.VDiPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerInletCurrentCounts function reads the current \n + * of VDi in counts + * @details + * Inputs : none + * 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 + * 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 + * Outputs: none + * @return current PWM of VDI + *************************************************************************/ +U16 getFPGAValveDialyzerInletPWM( void ) +{ + return fpgaSensorReadings.VDiPWMTarget; +} +#endif + +/*********************************************************************//** + * @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 setFPGAValveDialyzerOutletPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VDoSetPoint = setPoint; +} + +/*********************************************************************//** + * @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 getFPGAValveDialyzerOutletPosition( void ) +{ + return fpgaSensorReadings.VDoPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveDialyzerOutletCurrentCounts function reads the current \n + * of VDo in counts + * @details + * Inputs : none + * 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 + * 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 + * Outputs: none + * @return current PWM of VDO + *************************************************************************/ +U16 getFPGAValveDialyzerOutletPWM( void ) +{ + return fpgaSensorReadings.VDoPWMTarget; +} +#endif + +/*********************************************************************//** + * @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 setFPGAValveBloodVenousPosition( S16 setPoint ) +{ + fpgaActuatorSetPoints.VBVSetPoint = setPoint; +} + +/*********************************************************************//** + * @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 getFPGAValveBloodVenousPosition( void ) +{ + return fpgaSensorReadings.VBVPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveBloodVenousCurrentCounts function reads the current \n + * of VBV in counts + * @details + * Inputs : none + * 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 + * 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 + * 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 \n + * in counts + * @details + * Inputs : fpgaActuatorSetPoints + * 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 \n + * of VBA in counts + * @details + * Inputs : none + * Outputs : fpgaSensorReadings + * @return The current position of VBA + *************************************************************************/ +S16 getFPGAValveBloodArterialPosition( void ) +{ + return fpgaSensorReadings.VBAPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveBloodArterialCurrentCounts function reads the current \n + * of VBA in counts + * @details + * Inputs : none + * 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 + * 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 + * Outputs: none + * @return current PWM of VBA in counts + *************************************************************************/ +U16 getFPGAValveBloodArterialPWM( void ) +{ + return fpgaSensorReadings.VBAPWMTarget; +} +#endif + +/*********************************************************************//** + * @brief * The consumeUnexpectedData function checks to see if a byte is sitting in * the SCI2 received data register. * @details