/************************************************************************** * * Copyright (c) 2024-2026 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 FpgaDD.c * * @author (last) Varshini Nagabooshanam * @date (last) 27-Jan-2026 * * @author (original) Vinayakam Mani * @date (original) 26-Aug-2024 * ***************************************************************************/ #include "string.h" // for memset(), memcpy() #include "gio.h" // hal headers #include "sci.h" #include "sys_dma.h" #include "Comm.h" #include "Compatible.h" #include "FPGA.h" #include "Messaging.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "Timers.h" #include "Utilities.h" /** * @addtogroup FpgaDD * @{ */ // ********** private definitions ********** #define FPGA_EXPECTED_ID 0x04 ///< FPGA expected ID. #define MAX_COMM_ERROR_RETRIES 5 ///< Maximum number of communication error retries #define FPGA_ENABLE_VALVES_CONTROL 0x0000 ///< FPGA enable valves control. #define FPGA_ENABLE_BC_VALVES_CONTROL 0x00 ///< FPGA enable Balancing chamber valves control. #define FPGA_ENABLE_SPARE_VALVES_CNTRL 0x00 ///< FPGA enable spared valves control. #define FPGA_D17_RESET_BIT 0x01 ///< Conductivity Sensor D17 reset bit mask. #define FPGA_D17_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor D17 Initialization enable bit mask. #define FPGA_D17_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor D17 write enable bit mask. #define FPGA_D17_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor D17 read enable bit mask. #define FPGA_D74_RESET_BIT 0x10 ///< Conductivity Sensor D74 reset bit mask. #define FPGA_D74_INIT_ENABLE_BIT 0x20 ///< Conductivity Sensor D74 Initialization enable bit mask. #define FPGA_D74_WR_ENABLE_BIT 0x40 ///< Conductivity Sensor D74 write enable bit mask. #define FPGA_D74_RD_ENABLE_BIT 0x80 ///< Conductivity Sensor D74 read enable bit mask. #define FPGA_D27_RESET_BIT 0x01 ///< Conductivity Sensor D27 reset bit mask. #define FPGA_D27_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor D27 Initialization enable bit mask. #define FPGA_D27_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor D27 write enable bit mask. #define FPGA_D27_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor D27 read enable bit mask. #define FPGA_D29_RESET_BIT 0x10 ///< Conductivity Sensor D29 reset bit mask. #define FPGA_D29_INIT_ENABLE_BIT 0x20 ///< Conductivity Sensor D29 Initialization enable bit mask. #define FPGA_D29_WR_ENABLE_BIT 0x40 ///< Conductivity Sensor D29 write enable bit mask. #define FPGA_D29_RD_ENABLE_BIT 0x80 ///< Conductivity Sensor D29 read enable bit mask. #define FPGA_D43_RESET_BIT 0x01 ///< Conductivity Sensor D43 reset bit mask. #define FPGA_D43_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor D43 Initialization enable bit mask. #define FPGA_D43_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor D43 write enable bit mask. #define FPGA_D43_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor D43 read enable bit mask. // Assuming all valves are ON/OFF based control ( No PWM control used) #define FPGA_ENABLE_VALVES_PWM 0x0000 ///< FPGA enable valves PWM. #define FPGA_ENABLE_BC_VALVES_PWM 0x00 ///< FPGA enable Balancing chamber valves PWM. #define FPGA_ENABLE_UF_VALVES_PWM 0x00 ///< FPGA enable Ultrafiltration valves PWM. #define FPGA_ADC_AUTO_READ_ENABLE 0x11 ///< FPGA internal ADC auto read enable. #define CONCENTRATE_CAP_SWITCH_MASK 0x10 ///< Concentrate cap switch bit mask. #define FPGA_CONC_PUMP_FAULT_BITS 0x03 ///< Concentrate pump fault bits mask. #define UF_PUMP_FAULT_SHIFT 0x02 ///< Shift UF pump fault while reading, to account other dosing pumps fault. #define FPGA_UF_PUMP_FAULT_BIT 0x00 ///< UF pump fault bit mask. #define FPGA_UF_PUMP_PARKED_BIT 0x01 ///< UF pump parked status bit mask. #define FPGA_UF_PUMP_PARK_FAULT_BIT 0x02 ///< UF pump park fault status bit mask. #define FPGA_D11_PUMP_PARKED_BIT 0x04 ///< Acid Concentrate pump parked status bit mask. #define FPGA_D10_PUMP_PARKED_BIT 0x10 ///< Bicarb Concentrate pump parked status bit mask. #define FPGA_D11_PUMP_PARK_FAULT_BIT 0x08 ///< Acid Concentrate pump park fault status bit mask. #define FPGA_D10_PUMP_PARK_FAULT_BIT 0x20 ///< Bicarb Concentrate pump park fault status bit mask. #define FPGA_CONC_PUMP_PARK_COMMAND 0x80 ///< Park command bit for the concentrate pumps. #define FPGA_POWER_OUT_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< FPGA power out timeout in milliseconds. #define FPGA_D12_PUMP_ERROR_BIT 0x01 ///< Fresh dialysate pump error bit mask. #define FPGA_D48_PUMP_ERROR_BIT 0x02 ///< Spent dialysate pump error bit mask. #define FPGA_D6_FLOATER_LEVEL_BIT 0x07 ///< Floater level bit mask. #define FPGA_D5_HEATER_CNTRL_BIT 0x01 ///< FPGA GIO D5 heater control bit mask #define FPGA_D5_HEATER_PWM_ENABLE_BIT 0x02 ///< FPGA D5 PWM based heater control bit mask #define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. #define MAX_FPGA_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< FPGA comm failures window #define MAX_FPGA_COMM_FAILURES 3 ///< FPGA maximum comm failures per MAX_FPGA_COMM_FAILURES_WINDOW_MS #define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up #define FPGA_CONDUCTIVITY_RESET_BIT 0x01 ///< Conductivity Sensor reset bit mask. #define FPGA_CONDUCTIVITY_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor initialization enable bit mask. #define FPGA_CONDUCTIVITY_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor write enable bit mask. #define FPGA_CONDUCTIVITY_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor read enable bit mask. #define FPGA_D42_BLOOD_LEAK_STATUS_MASK 0x04 ///< Bit mask for blood leak detector. #define FPGA_D42_BLOOD_LEAK_ST_BIT_INDEX 2 ///< Bit index for the blood leak self test status bit. #define MAX_PUMP_SPEED 3000.0F ///< Maxon controller pump maximum speed #define PUMP_SPEED_OFFSET 168.7F ///< Speed Scale adjustment intercept factor #define PUMP_SPEED_FULL_SCALE 3187.0F ///< Speed scale adjustment slope factor #pragma pack(push,1) /// FPGA header struct. typedef struct { U08 fpgaId; ///< Reg 0. FPGA ID code. Checked against expected value at power up to verify basic FPGA communication and operation U08 fpgaRevMinor; ///< Reg 1. FPGA revision (minor) being reported U08 fpgaRevMajor; ///< Reg 2. FPGA revision (major) being reported U08 fpgaRevLab; ///< Reg 3. FPGA revision (lab) being reported } FPGA_HEADER_T; // read only on FPGA /// FPGA sensor readings struct. typedef struct { U16 fpgaCompatibilityRev; ///< Reg 512. Compatibility revision U16 fpgaTimerCountMS; ///< Reg 514. Internal FPGA timer count in milliseconds U16 fpgaRemoteUpdateRead; ///< Reg 516. FPGA Remote Update Read ( copy contents from remote update write) U08 fpgaIOErrorCntProcessor; ///< Reg 518. Number of errors in Microprocessor UART interface U08 fpgaIOErrorCntPC; ///< Reg 519. Number of errors in PC UART interface U16 fpgaD9PresPressure; ///< Reg 520. D9 MPM pressure sensor RAW pressure data U16 fpgaD9PresTemp; ///< Reg 522. D9 MPM pressure sensor RAW temperature data U16 fpgaD66PresPressure; ///< Reg 524. D66 MPM pressure sensor RAW pressure data U16 fpgaD66PresTemp; ///< Reg 526. D66 MPM pressure sensor RAW temperature data U16 fpgaD51PresPressure; ///< Reg 528. D51 MPM pressure sensor RAW pressure data U16 fpgaD51PresTemp; ///< Reg 530. D51 MPM pressure sensor RAW temperature data U16 fpgaD18PresPressure; ///< Reg 532. D18 MPM pressure sensor RAW pressure data U16 fpgaD18PresTemp; ///< Reg 534. D18 MPM pressure sensor RAW temperature data U16 fpgaD41PresPressure; ///< Reg 536. D41 MPM pressure sensor RAW pressure data U16 fpgaD41PresTemp; ///< Reg 538. D41 MPM pressure sensor RAW temperature data U16 fpgaD63LevelSensor; ///< Reg 540. Upper level Sensor U16 fpgaD46LevelSensor; ///< Reg 542. Level Sensor 2 U08 fpgaHallSensInputs; ///< Reg 544. Hall sensor Inputs U08 fpgaD42TxFIFOCnt; ///< Reg 545. Blood leak sensor transmit FIFO count U16 fpgaD42RxErrorCnt; ///< Reg 546. Blood leak sensor Receive error count U16 fpgaD42RxFIFOCnt; ///< Reg 548. Blood leak sensor Receive FIFO count U08 fpgaD42RxFIFODataOut; ///< Reg 550. Blood leak sensor Receive data U08 fpgaD42PulseStatus; ///< Reg 551. Blood leak sensor status U16 fpgaValveStates; ///< Reg 552. Valve status read U16 fpgaValvePWMEnableStates; ///< Reg 554. Valve PWM Enable status read U08 fpgaValveBCStates; ///< Reg 556. Balancing chamber Valves states U08 fpgaValveBCPWMStates; ///< Reg 557. Balancing Chamber Valve PWM states U08 fpgaValveSpStates; ///< Reg 558. DD Spare Valves states U08 fpgaValveSpPWMStates; ///< Reg 559. Spare Valves PWM states U08 fpgaD11_D10_PumpFault; ///< Reg 560. Concentrate pump fault register for D11_Pump and D10_Pump U08 fpgaD78D1D4D50ErrorCounter; ///< Reg 561. Count of each incomplete seq of reads from RTD ADC. U16 fpga_UnUsed_1; ///< Reg 562. Concentrate pump D11_Pump hall sensor pulse width U16 fpga_UnUsed_2; ///< Reg 564. Concentrate pump D10_Pump hall sensor pulse width U32 fpgaD78Temp; ///< Reg 566. Outlet heat exchanger temperature U32 fpgaD1Temp; ///< Reg 570. Inlet heat exchanger temperature U32 fpgaD4Temp; ///< Reg 574. Hydraulics primary heater temperature U32 fpgaD50Temp; ///< Reg 578. Trimmer heater temperature U16 fpgaD98LevelSensor; ///< Reg 582. Lower level Sensor U16 fpgaD12MeasuredSpeed; ///< Reg 584. Fresh dialysate pump measured speed U16 fpgaD48MeasuredSpeed; ///< Reg 586. Spent dialysate pump measured speed U08 fpgaRTDReadCnt; ///< Reg 588. Read count for all RTD sensors U08 fpgaD12D48PumpStatus; ///< Reg 589. Dialysate pumps Error status U16 fpgaD12CurrentFeedback; ///< Reg 590. Fresh dialysate pump current feedback U16 fpgaD48CurrentFeedback; ///< Reg 592. Spent dialysate pump current feedback U08 fpgaD12HallStatus; ///< Reg 594. Fresh dialysate pump hall sensor direction status U08 fpgaD48HallStatus; ///< Reg 595. Spent dialysate pump hall sensor direction status U08 fpgaD6FloaterStatus; ///< Reg 596. Floater 1 level sensor status U08 fpgaFloater2Status; ///< Reg 597. Floater 2 level sensor status U16 fpgaD11PumpStepCountStatus; ///< Reg 598. Acid concentrate pump revolution down count status U16 fpgaD10PumpStepCountStatus; ///< Reg 600. Bicarb concentrate pump revolution down count status U16 fpgaAdcTemp; ///< Reg 602. TBD U16 fpgaAdcVccInt; ///< Reg 604. TBD U16 fpgaAdcVccAux; ///< Reg 606. TBD U16 fpgaAdcVpVn; ///< Reg 608. TBD U16 fpgaD12PumpSpeedFeedback; ///< Reg 610. D12 Pump speed feedback U16 fpgaD48PumpSpeedFeedback; ///< Reg 612. D48 Pump Speed feedback U16 fpga_UnUsed_3; ///< Reg 614. UF D76_Pump hall sensor pulse width U16 fpgaD76PumpStepCountStatus; ///< Reg 616. UF pump revolution down count status U08 fpgaD76PumpFault; ///< Reg 618: UF pump fault U08 fpga_UnUsed_4; ///< Reg 619: Not used S16 pressureP46; ///< Reg 620. P46 pressure data. U16 temperatureP46; ///< Reg 622. P46 temperature data. S16 pressureM3; ///< Reg 624. M3 pressure data. U16 temperatureM3; ///< Reg 626. M3 temperature data. S16 pressureP8; ///< Reg 628. P8 pressure data. U16 temperatureP8; ///< Reg 630. P8 temperature data. S16 pressureP13; ///< Reg 632. P13 pressure data. U16 temperatureP13; ///< Reg 634. P13 temperature data. S16 pressureP17; ///< Reg 636. P17 pressure data. U16 temperatureP17; ///< Reg 638. P17 temperature data. U16 p40PumpTachCount; ///< Reg 640. P40 pump tachometer counter. U08 p25LevelSwitch; ///< Reg 642. P25 level switch. U08 fpga_UnUsed_5; ///< Reg 643. Reserved. U16 flowRateP7; ///< Reg 644. P7 flow sensor rate. U16 flowTempP7; ///< Reg 646. P7 flow sensor temperature. U16 p12PumpTachCount; ///< Reg 648. P12 pump tachometer counter. U16 d79SpeedPulseWidth; ///< Reg 650. D79 pusle width feedback. U16 flowIntTempP7; ///< Reg 652. P7 flow sensor internal temperature. U08 valveIOControlReadback; ///< Reg 654. IO Valve control bits read back. U08 valveFPControlReadback; ///< Reg 655. FP Valve control enable read back. U08 valveIOPWMEnableReadback; ///< Reg 656. IO Valve PWM enable read back. U08 valveFPPWMEnableReadback; ///< Reg 657. FP Valve PWM enable read back. U16 p12PumpPWMReadback; ///< Reg 658. P12 pump PWM read back. U16 p40PumpPWMReadback; ///< Reg 660. P40 pump PWM read back. U08 p7flowReadCount; ///< Reg 662. P7 Flow sensor read counter. U08 p7flowErrorCount; ///< Reg 663. P7 Flow sensor error counter. U16 fpgaD87PresPressure; ///< Reg 664. D87 MPM pressure sensor RAW pressure data U16 fpgaD87PresTemp; ///< Reg 666. D87 MPM pressure sensor RAW temperature data U32 fpgaD99Temp; ///< Reg 668. D99 temperature sensor U32 fpga_UnUsed_6; ///< Reg 672. Reserved. U32 fpga_UnUsed_7; ///< Reg 676. Reserved. U08 ad7124errcnt; ///< Reg 680. Counter which increments when an invalid transaction happen between FPGA and AD7124. U08 ad7124readcnt; ///< Reg 681. Counter which increments when a valid transaction happens between FPGA and AD7124. U16 flowRateP16; ///< Reg 682. P16 flow sensor rate. U16 flowTempP16; ///< Reg 684. P16 flow sensor temperature. U16 flowIntTempP16; ///< Reg 686. P16 flow sensor internal temperature. U08 p16flowReadCount; ///< Reg 688. P16 Flow sensor read counter. U08 p16flowErrorCount; ///< Reg 689. P16 Flow sensor error counter. U32 d11HallSense; ///< Reg 690. D11 Pump hall sensor optical sensor interface pulse width. U32 d10HallSense; ///< Reg 694. D10 Pump hall sensor optical sensor interface pulse width. U32 d76HallSense; ///< Reg 698. D76 Pump hall sensor optical sensor interface pulse width. U32 d16CondCalData; ///< Reg 702. D16 Cal Word - Holds current word being read from cal memory. U32 d16CondCond; ///< Reg 706. D16 Conductivity Measurement. U32 d16CondTemp; ///< Reg 710. D16 Temperature Measurement. U08 d16CondCondReadCount; ///< Reg 714. D16 Conductivity successful read count. U08 d16CondCondErrorCount; ///< Reg 715. D16 Conductivity unsuccessful error count. U08 d16CondTempReadCount; ///< Reg 716. D16 Temperature successful read count. U08 d16CondTempErrorCount; ///< Reg 717. D16 Temperature unsuccessful error count. U08 d16CondMemCounter; ///< Reg 718. D16 Cal memory counter that keeps track of which cal word. U08 d74CondMemCounter; ///< Reg 719. D74 Cal memory counter that keeps track of which cal word. U32 d74CondCalData; ///< Reg 720. D74 Cal Word - Holds current word being read from cal memory. U32 d74CondCond; ///< Reg 724. D74 Conductivity Measurement. U32 d74CondTemp; ///< Reg 728. D74 Temperature Measurement. U08 d74CondCondReadCount; ///< Reg 732. D74 Conductivity successful read count. U08 d74CondCondErrorCount; ///< Reg 733. D74 Conductivity unsuccessful error count. U08 d74CondTempReadCount; ///< Reg 734. D74 Temperature successful read count. U08 d74CondTempErrorCount; ///< Reg 735. D74 Temperature unsuccessful error count. U32 d27CondCalData; ///< Reg 736. D27 Cal Word - Holds current word being read from cal memory. U32 d27CondCond; ///< Reg 740. D27 Conductivity Measurement. U32 d27CondTemp; ///< Reg 744. D27 Temperature Measurement. U08 d27CondCondReadCount; ///< Reg 748. D27 Conductivity successful read count. U08 d27CondCondErrorCount; ///< Reg 749. D27 Conductivity unsuccessful error count. U08 d27CondTempReadCount; ///< Reg 750. D27 Temperature successful read count. U08 d27CondTempErrorCount; ///< Reg 751. D27 Temperature unsuccessful error count. U08 d27CondMemCounter; ///< Reg 752. D27 Cal memory counter that keeps track of which cal word. U08 d29CondMemCounter; ///< Reg 753. D29 Cal memory counter that keeps track of which cal word. U32 d29CondCalData; ///< Reg 754. D29 Cal Word - Holds current word being read from cal memory. U32 d29CondCond; ///< Reg 758. D29 Conductivity Measurement. U32 d29CondTemp; ///< Reg 762. D29 Temperature Measurement. U08 d29CondCondReadCount; ///< Reg 766. D29 Conductivity successful read count. U08 d29CondCondErrorCount; ///< Reg 767. D29 Conductivity unsuccessful error count. U08 d29CondTempReadCount; ///< Reg 768. D29 Temperature successful read count. U08 d29CondTempErrorCount; ///< Reg 769. D29 Temperature unsuccessful error count. U32 d43CondCalData; ///< Reg 770. D43 Cal Word - Holds current word being read from cal memory. U32 d43CondCond; ///< Reg 774. D43 Conductivity Measurement. U32 d43CondTemp; ///< Reg 778. D43 Temperature Measurement. U08 d43CondCondReadCount; ///< Reg 782. D43 Conductivity successful read count. U08 d43CondCondErrorCount; ///< Reg 783. D43 Conductivity unsuccessful error count. U08 d43CondTempReadCount; ///< Reg 784. D43 Temperature successful read count. U08 d43CondTempErrorCount; ///< Reg 785. D43 Temperature unsuccessful error count. U08 d43CondMemCounter; ///< Reg 786. D43 Cal memory counter that keeps track of which cal word. U08 p9CondMemCounter; ///< Reg 787. P9 Cal memory counter that keeps track of which cal word. U32 p9CondCalData; ///< Reg 788. P9 Cal Word - Holds current word being read from cal memory. U32 p9CondCond; ///< Reg 792. P9 Conductivity Measurement. U32 p9CondTemp; ///< Reg 796. P9 Temperature Measurement. U08 p9CondCondReadCount; ///< Reg 800. P9 Conductivity successful read count. U08 p9CondCondErrorCount; ///< Reg 801. P9 Conductivity unsuccessful error count. U08 p9CondTempReadCount; ///< Reg 802. P9 Temperature successful read count. U08 p9CondTempErrorCount; ///< Reg 803. P9 Temperature unsuccessful error count. U32 p18CondCalData; ///< Reg 804. P18 Cal Word - Holds current word being read from cal memory. U32 p18CondCond; ///< Reg 808. P18 Conductivity Measurement. U32 p18CondTemp; ///< Reg 812. P18 Temperature Measurement. U08 p18CondCondReadCount; ///< Reg 816. P18 Conductivity successful read count. U08 p18CondCondErrorCount; ///< Reg 817. P18 Conductivity unsuccessful error count. U08 p18CondTempReadCount; ///< Reg 818. P18 Temperature successful read count. U08 p18CondTempErrorCount; ///< Reg 819. P18 Temperature unsuccessful error count. U08 p18CondMemCounter; ///< Reg 820. P18 Cal memory counter that keeps track of which cal word. } DD_FPGA_SENSORS_T; typedef struct { U16 fpgaValveControl; ///< Reg 04. Valve control register U16 fpgaValvePWMEnable; ///< Reg 06. Valve PWM enable U16 fpgaDDValvePWMLow; ///< Reg 08. DD valves PWM low. (VDR) U16 fpgaDDValvePWMPeriod; ///< Reg 10. DD valves PWM period (VDR) U16 fpgaDDValvePWMPullin; ///< Reg 12. DD valves pull in (VDR) U08 fpgaBCValveControl; ///< Reg 14. Balancing Chamber Valves Control Registers U08 fpgaBCValvePWMControl; ///< Reg 15. Balancing Chamber Valves PWM control U08 fpgaDDSpareValveControl; ///< Reg 16. Spare Valves Control Registers U08 fpgaDDSpareValvePWMControl; ///< Reg 17. Spare Valves PWM control U16 fpgaRemoteUpdate_Write; ///< Reg 18. Register for Remote update used by SW. U16 fpgaD12PumpSpeed; ///< Reg 20. D48 Speed/RPM Control U08 fpgaD12PumpControl; ///< Reg 22. DGP Control U08 fpgaD48PumpControl; ///< Reg 23. SDP Control U16 fpgaD48PumpSpeed; ///< Reg 24. SDP Speed/RPM Control U08 fpgaD11PumpControl; ///< Reg 28. Acid Concentrate Pump Control U08 fpgaD10PumpControl; ///< Reg 29. BiCarb Concentrate Pump Control U08 fpgaD42SensorTest; ///< Reg 32. Blood leak sensor test U08 fpgaD42UARTControl; ///< Reg 33. Blood leak sensor UART control U08 fpgaD42FIFOTx; ///< Reg 34. Blood leak sensor FIFO transmit control U08 fpgaD5HeaterPWMControl; ///< Reg 35. Primary heater PWM control U08 fpgaD45HeaterPWMControl; ///< Reg 36. Trimmer heater PWM control U08 fpgaD79PWMPumpCtl; ///< Reg 37. Rinse pump PWM control U16 fpgaVBCPWMLow; ///< Reg 38. VBC PWM low ( Balancing chamber valves) U16 fpgaVBCPWMPeriod; ///< Reg 40. VBC PWM period U16 fpgaVBCPWMPullIn; ///< Reg 42. VBC PWM pull in U16 fpgaVSPPWMLow; ///< Reg 44. VSP PWM low ( Spare valves ) U16 fpgaVSPPWMPeriod; ///< Reg 46. VSP PWM period U16 fpgaVSPPWMPullIn; ///< Reg 48. VSP PWM pull in U16 fpgaD11PumpRevCount; ///< Reg 50. Acid Concentrate pump revolution count U16 fpgaD10PumpRevCount; ///< Reg 52. Bicarb Concentrate pump revolution count U08 fpgaADCControl; ///< Reg 54. FPGA internal ADC Control register for debugging U08 fpgaGPIOControl; ///< Reg 55. FPGA GPIO control interface U16 fpgaACRelayPWMLow; ///< Reg 56. Length of time in 10us resoultion that PWM output stays low. U16 fpgaACRelayPWMPeriod; ///< Reg 58. PWM period for AC relay/heater. U16 reserved1; ///< Reg 60. Reserved U16 fpgaD76PumpRevCount; ///< Reg 62. UF pump revolution count U08 fpgaD76PumpControl; ///< Reg 64. UF Pump Control U08 reserved2; ///< Reg 65. Reserved U08 valveIOControl; ///< Reg 66. IO Valve control register. U08 valveFPControl; ///< Reg 67. FP Valve control register. U16 descalePumpSpeed; ///< Reg 68. Descaler pump speed register. U08 descalePumpControl; ///< Reg 70. Descaler pump control register. U08 p12PumpControl; ///< Reg 71. P12 pump control register. U16 valveIOFPPWMLow; ///< Reg 72. Valve VWi PWM low pulse period in 0.1 uSec. U16 valveIOFPPWMPeriod; ///< Reg 74. Valve VWi PWM full period in 0.1 uSec. U16 valveIOFPPWMPullIn; ///< Reg 76. Valve PWM high pulse period when valve is on in 0.1 uSec. U16 p12PumpPWMDutyCyclePct; ///< Reg 78. P12 pump PWM duty cycle in percentage. U16 p40PumpPWMDutyCyclePct; ///< Reg 80. P40 pump PWM duty cycle in percentage. U08 p40PumpControl; ///< Reg 82. P40 pump control register. U08 reserved3; ///< Reg 83. Reserved. U08 flowControlp7; ///< Reg 84. P7 AVS Romer flow sensor control register. U08 flowAddressp7; ///< Reg 85. P7 AVS Romer flow sensor I2C slave address register. U08 valveIOPWMEnable; ///< Reg 86. Valve IO PWM enable register. U08 valveFPPWMEnable; ///< Reg 87. Valve FP PWM enable register. U08 flowControlp16; ///< Reg 88. P16 AVS Romer flow sensor control register. U08 flowAddressp16; ///< Reg 89. P16 AVS Romer flow sensor I2C slave address register. U08 reserved4; ///< Reg 90. Reserved. U32 fpgaD11PumpSpeed; ///< Reg 92. Acid Concentrate Pump Speed/RPM Control U32 fpgaD10PumpSpeed; ///< Reg 94. BiCarb Concentrate Pump Speed/RPM Control U32 fpgaD76PumpSpeed; ///< Reg 96. UF Pump Speed/RPM Control } FPGA_ACTUATORS_T; #pragma pack(pop) // ********** private data ********** static FPGA_HEADER_T fpgaHeader; ///< FPGA header structure. static DD_FPGA_SENSORS_T fpgaSensorReadings; ///< DD FPGA sensors structure. static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< FPGA actuator set points structure. // ********** private function prototypes ********** static U16 getFPGATimerCount( void ); /*********************************************************************//** * @brief * The initFPGADD function initializes the DD FPGA unit. * @details \b Inputs: none * @details \b Outputs: FPGA unit initialized. * @return none *************************************************************************/ void initFPGADD( void ) { // Initialize fpga driver initFPGA( (U08*)&fpgaHeader, (U08*)&fpgaSensorReadings, (U08*)&fpgaActuatorSetPoints, sizeof(FPGA_HEADER_T), sizeof(DD_FPGA_SENSORS_T), sizeof(FPGA_ACTUATORS_T) ); // initialize fpga data structures memset( &fpgaHeader, 0, sizeof( FPGA_HEADER_T ) ); memset( &fpgaSensorReadings, 0, sizeof( DD_FPGA_SENSORS_T ) ); memset( &fpgaActuatorSetPoints, 0, sizeof( FPGA_ACTUATORS_T ) ); // Set the valve control mode and default state of valve fpgaActuatorSetPoints.fpgaValveControl = FPGA_ENABLE_VALVES_CONTROL; fpgaActuatorSetPoints.fpgaValvePWMEnable = FPGA_ENABLE_VALVES_PWM; fpgaActuatorSetPoints.fpgaBCValveControl = FPGA_ENABLE_BC_VALVES_CONTROL; fpgaActuatorSetPoints.fpgaBCValvePWMControl = FPGA_ENABLE_BC_VALVES_PWM; fpgaActuatorSetPoints.fpgaDDSpareValveControl = FPGA_ENABLE_SPARE_VALVES_CNTRL; fpgaActuatorSetPoints.fpgaDDSpareValvePWMControl = FPGA_ENABLE_UF_VALVES_PWM; fpgaActuatorSetPoints.fpgaADCControl = FPGA_ADC_AUTO_READ_ENABLE; // initialize FPGA clock speed error time windowed count initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES_WINDOW_MS); } /*********************************************************************//** * @brief * The execFPGATest function executes the FPGA self-test. * @details \b Inputs: fpgaHeader * @details \b Outputs: none * @details \b Alarm: ALARM_ID_DD_FPGA_POST_TEST_FAILED when FPGA compatibility failed and/or * wrong FPGA header seen. * @return passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execFPGATest( void ) { SELF_TEST_STATUS_T result; // check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { // Check FPGA compatibility w/ firmware if ( DD_FPGA_COMPATIBILITY_REV == fpgaSensorReadings.fpgaCompatibilityRev ) { result = SELF_TEST_STATUS_PASSED; } else { result = SELF_TEST_STATUS_FAILED; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_POST_TEST_FAILED, (U32)DD_FPGA_COMPATIBILITY_REV, (U32)fpgaSensorReadings.fpgaCompatibilityRev ) } } else { result = SELF_TEST_STATUS_FAILED; SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) } return result; } /*********************************************************************//** * @brief * The execFPGAClockSpeedTest function verifies the processor clock speed * against the FPGA clock. * @details \b Inputs: time windowed error count for FPGA clock speed alarm * @details \b Outputs: none * @details \b Alarm: ALARM_ID_DD_FPGA_CLOCK_SPEED_CHECK_FAILURE when clock speed * mismatch seen. * @warning: It may be necessary to comment out the following code to prevent * the alarm from occurring while debugging. * @return: none *************************************************************************/ void execFPGAClockSpeedTest( void ) { static U16 currentFPGATimerCount_ms = 0; static U32 currentTimerCount_ms = 0; U16 const newFPGATimerCount_ms = getFPGATimerCount(); U32 const newTimerCount_ms = getMSTimerCount(); U32 const diffFPGATimerCount = (U32)u16DiffWithWrap( currentFPGATimerCount_ms, newFPGATimerCount_ms ); U32 const diffTimerCount = u32DiffWithWrap( currentTimerCount_ms, newTimerCount_ms ); if ( getCurrentOperationMode() != DD_MODE_INIT ) { if ( abs( diffFPGATimerCount - diffTimerCount ) > PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE ) { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR ) ) { //TODO : Enable alarm later //SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); } } } currentFPGATimerCount_ms = newFPGATimerCount_ms; currentTimerCount_ms = newTimerCount_ms; } /*********************************************************************//** * @brief * The setFPGADDValveStates function sets the DD valve states with a 16-bit * set of states - one bit per valve, with a 1 meaning "energized" and a 0 * meaning "de-energized". The bit positions for these bit states are as follows: * 0 - D53Valve.\n * 1 - D52Valve.\n * 2 - D8Valve.\n * 3 - D54Valve.\n * 4 - D14Valve.\n * 5 - D65Valve.\n * 6 - D64Valve.\n * 7 - D31Valve.\n * 8 - D34Valve.\n * 9 - D35Valve.\n * 10 - D40Valve.\n * 11 - D47Valve.\n * 12 - D3Valve.\n * 13 - M4Valve.\n * 14..15 - reserved or unused. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaValveControl * @param valveStates bit mask for the various valve states * @return none *************************************************************************/ void setFPGADDValveStates( U16 valveStates ) { fpgaActuatorSetPoints.fpgaValveControl = valveStates; } /*********************************************************************//** * @brief * The setFPGABCValveStates function sets the DD balancing chamber valve states with a * 8-bit set of states - one bit per valve, with a 1 meaning "energized" and a 0 * meaning "de-energized". The bit positions for these bit states are as follows: * 0 - D23.\n * 1 - D19.\n * 2 - D25.\n * 3 - D21.\n * 4 - D24.\n * 5 - D20.\n * 6 - D26.\n * 7 - D22.\n * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaBCValveControl * @param valveStates bit mask for the balancing chamber valve states * @return none *************************************************************************/ void setFPGABCValveStates( U08 valveStates ) { fpgaActuatorSetPoints.fpgaBCValveControl = valveStates; } /*********************************************************************//** * @brief * The setFPGASpareValveStates function sets the DD spare valve states with a * 8-bit set of states - one bit per valve, with a 1 meaning "energized" and a 0 * meaning "de-energized". The bit positions for these bit states are as follows: * 0 - Not used.\n * 1 - Not used.\n * 2 - Not used.\n * 3 - Not used.\n * 4..7 - Unused or reserved.\n * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDDSpareValveControl * @param valveStates bit mask for the spare valve states * @return none *************************************************************************/ void setFPGASpareValveStates( U08 valveStates ) { fpgaActuatorSetPoints.fpgaDDSpareValveControl = valveStates; } /*********************************************************************//** * @brief * The setFPGAValveDDPWMEnable function sets the DD valve PWM states with * * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled" * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaValvePWMEnable * @param valvePWMStates bit mask for requested valve states. * @return none *************************************************************************/ void setFPGAValveDDPWMEnable( U16 valvePWMStates ) { fpgaActuatorSetPoints.fpgaValvePWMEnable = valvePWMStates; } /*********************************************************************//** * @brief * The getFPGAValveDDPWMEnable function gets the DD valve pwm states with * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaValvePWMEnableStates * @return none *************************************************************************/ U16 getFPGAValveDDPWMEnable( void ) { return fpgaSensorReadings.fpgaValvePWMEnableStates; } /*********************************************************************//** * @brief * The setFPGAValveDDPWMPullIn function sets the DD valves Pull-in "strike" * period where PWM is at 100% in 1ms resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDDValvePWMPullin * @param valvePWMPullIn Pull-in period in 1ms resolution. * @return none *************************************************************************/ void setFPGAValveDDPWMPullIn( U16 valvePWMPullIn ) { fpgaActuatorSetPoints.fpgaDDValvePWMPullin = valvePWMPullIn; } /*********************************************************************//** * @brief * The setFPGAValveDDPWMLow function sets the DD valves "low" * period where PWM is at 0% in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDDValvePWMLow * @param valvePWMLow low period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveDDPWMLow( U16 valvePWMLow ) { fpgaActuatorSetPoints.fpgaDDValvePWMLow = valvePWMLow; } /*********************************************************************//** * @brief * The setFPGAValveDDPWMPeriod function sets the DD valves pwm * period in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDDValvePWMPeriod * @param valvePWMPeriod period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveDDPWMPeriod( U16 valvePWMPeriod ) { fpgaActuatorSetPoints.fpgaDDValvePWMPeriod = valvePWMPeriod; } /*********************************************************************//** * @brief * The setFPGAValveBCPWMEnable function sets the BC valve PWM states with * * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled" * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaBCValvePWMControl * @param valvePWMStates bit mask for requested valve states. * @return none *************************************************************************/ void setFPGAValveBCPWMEnable( U08 valvePWMStates ) { fpgaActuatorSetPoints.fpgaBCValvePWMControl = valvePWMStates; } /*********************************************************************//** * @brief * The getFPGAValveBCPWMEnable function gets the BC valve pwm states with * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaValveBCPWMStates * @return none *************************************************************************/ U08 getFPGAValveBCPWMEnable( void ) { return fpgaSensorReadings.fpgaValveBCPWMStates; } /*********************************************************************//** * @brief * The setFPGAValveBCPWMPullIn function sets the BC valves Pull-in "strike" * period where PWM is at 100% in 1ms resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaVBCPWMPullin * @param valvePWMPullIn Pull-in period in 1ms resolution. * @return none *************************************************************************/ void setFPGAValveBCPWMPullIn( U16 valvePWMPullIn ) { fpgaActuatorSetPoints.fpgaVBCPWMPullIn = valvePWMPullIn; } /*********************************************************************//** * @brief * The setFPGAValveBCPWMLow function sets the BC valves "low" * period where PWM is at 0% in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaVBCPWMLow * @param valvePWMLow low period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveBCPWMLow( U16 valvePWMLow ) { fpgaActuatorSetPoints.fpgaVBCPWMLow = valvePWMLow; } /*********************************************************************//** * @brief * The setFPGAValveBCPWMPeriod function sets the BC valves pwm * period in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaVBCPWMPeriod * @param valvePWMPeriod period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveBCPWMPeriod( U16 valvePWMPeriod ) { fpgaActuatorSetPoints.fpgaVBCPWMPeriod = valvePWMPeriod; } /*********************************************************************//** * @brief * The setFPGAValveSPPWMEnable function sets the Spare valve PWM states with * * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled" * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDDSpareValvePWMControl * @param valvePWMStates bit mask for requested valve states. * @return none *************************************************************************/ void setFPGAValveSPPWMEnable( U08 valvePWMStates ) { fpgaActuatorSetPoints.fpgaDDSpareValvePWMControl = valvePWMStates; } /*********************************************************************//** * @brief * The getFPGAValveSPPWMEnable function gets the Spare valve pwm states with * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaValveSpPWMStates * @return none *************************************************************************/ U08 getFPGAValveSPPWMEnable( void ) { return fpgaSensorReadings.fpgaValveSpPWMStates; } /*********************************************************************//** * @brief * The setFPGAValveSPPWMPullIn function sets the Spare valves Pull-in "strike" * period where PWM is at 100% in 1ms resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaVSPPWMPullIn * @param valvePWMPullIn Pull-in period in 1ms resolution. * @return none *************************************************************************/ void setFPGAValveSPPWMPullIn( U16 valvePWMPullIn ) { fpgaActuatorSetPoints.fpgaVSPPWMPullIn = valvePWMPullIn; } /*********************************************************************//** * @brief * The setFPGAValveSPPWMLow function sets the Spare valves "low" * period where PWM is at 0% in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaVSPPWMLow * @param valvePWMLow low period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveSPPWMLow( U16 valvePWMLow ) { fpgaActuatorSetPoints.fpgaVSPPWMLow = valvePWMLow; } /*********************************************************************//** * @brief * The setFPGAValveSPPWMPeriod function sets the Spare valves pwm * period in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaVSPPWMPeriod * @param valvePWMPeriod period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveSPPWMPeriod( U16 valvePWMPeriod ) { fpgaActuatorSetPoints.fpgaVSPPWMPeriod = valvePWMPeriod; } /*********************************************************************//** * @brief * The setFPGAD48PumpSpeed function sets the speed for the * spent dialysate pump (SDP). * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD48PumpSpeed * @param speed The spent dialysate pump speed * @return none *************************************************************************/ void setFPGAD48PumpSpeed( U16 speed ) { #ifdef __MAXON_SPEED_UPDATE__ { U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); fpgaActuatorSetPoints.fpgaD48PumpSpeed = currentSpeed; } #else { fpgaActuatorSetPoints.fpgaD48PumpSpeed = speed; } #endif } /*********************************************************************//** * @brief * The setFPGAD12PumpSpeed function sets the speed for the * fresh dialysate pump (DGP). * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD12PumpSpeed * @param speed The fresh dialysate pump speed * @return none *************************************************************************/ void setFPGAD12PumpSpeed( U16 speed ) { #ifdef __MAXON_SPEED_UPDATE__ { U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); fpgaActuatorSetPoints.fpgaD12PumpSpeed = currentSpeed; } #else { fpgaActuatorSetPoints.fpgaD12PumpSpeed = speed; } #endif } /*********************************************************************//** * @brief * The setFPGAD48PumpControl function sets the controls for * dialysate out pump (D48). * bit 7: Reserved * bit 6: Reserved * bit 5: Reserved * bit 4: Reserved * bit 3: Reserved * bit 1-2: Reserved * bit 0: Run (1), stop (0) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD48PumpControl * @param control The dialysate out pump controls * @return none *************************************************************************/ void setFPGAD48PumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaD48PumpControl = control; } /*********************************************************************//** * @brief * The setFPGAD12PumpControl function sets the controls for * De gassing pump (D12). * bit 7: Reserved * bit 6: Reserved * bit 5: Reserved * bit 4: Reserved * bit 3: Reserved * bit 1-2: Reserved * bit 0: Run (1), stop (0) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD12PumpControl * @param control The dialysate In pump controls * @return none *************************************************************************/ void setFPGAD12PumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaD12PumpControl = control; } /*********************************************************************//** * @brief * The setFPGAD11PumpSetStepSpeed function sets the step speed period for * concentrate pump D11_Pump. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD11PumpSpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ void setFPGAD11PumpSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaD11PumpSpeed = stepSpeed; } /*********************************************************************//** * @brief * The setFPGAD10PumpSetStepSpeed function sets the step speed period for * concentrate pump D10_Pump. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD10PumpSpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ void setFPGAD10PumpSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaD10PumpSpeed = stepSpeed; } /*********************************************************************//** * @brief * The setFPGAD76PumpSetStepSpeed function sets the step speed period for * UF D76_Pump. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpSpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ void setFPGAD76PumpSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaD76PumpSpeed = stepSpeed; } /*********************************************************************//** * @brief * The setFPGAD11PumpControl function sets the DVT concentrate pump 1 * (acid pump) control mode. * bit 7: Park (set in different function) * bit 6: nSleep * bit 5: nReset * bit 4: nEnable * bit 3: Direction (1=Fwd, 0=Rev) * bit 0-2: Microstepping resolution * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD11PumpControl * @param control Concentrate pump control set * @return none *************************************************************************/ void setFPGAD11PumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaD11PumpControl &= FPGA_CONC_PUMP_PARK_COMMAND; // preserve msb (park command bit) fpgaActuatorSetPoints.fpgaD11PumpControl |= control; } /*********************************************************************//** * @brief * The setFPGAD10PumpControl function sets the DVT concentrate pump 2 * (bicarb pump) control mode. * bit 7: Park (set in different function) * bit 6: nSleep * bit 5: nReset * bit 4: nEnable * bit 3: Direction (1=Fwd, 0=Rev) * bit 0-2: Microstepping resolution * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD10PumpControl * @param control Concentrate pump control set * @return none *************************************************************************/ void setFPGAD10PumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaD10PumpControl &= FPGA_CONC_PUMP_PARK_COMMAND; // preserve msb (park command bit) fpgaActuatorSetPoints.fpgaD10PumpControl |= control; } /*********************************************************************//** * @brief * The setFPGAD76PumpControl function sets the UF pump * (D76 pump) control mode. * bit 7: Park (set in different function) * bit 6: nSleep * bit 5: nReset * bit 4: nEnable * bit 3: Direction (1=Fwd, 0=Rev) * bit 0-2: Microstepping resolution * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpControl * @param control UF pump control set * @return none *************************************************************************/ void setFPGAD76PumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaD76PumpControl &= FPGA_CONC_PUMP_PARK_COMMAND; // preserve msb (park command bit) fpgaActuatorSetPoints.fpgaD76PumpControl |= control; } /*********************************************************************//** * @brief * The setFPGAD11PumpParkCmd function sets the DVT concentrate pump 1 * (acid pump) park command bit. * bit 7: Park command bit * bit 0-6: Other pump control bits (set in different function) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD11PumpControl * @param Park command bit set * @return none *************************************************************************/ void setFPGAD11PumpParkCmd( void ) { fpgaActuatorSetPoints.fpgaD11PumpControl |= FPGA_CONC_PUMP_PARK_COMMAND; // this bit must be cleared after next transmit to prevent continuous park commands } /*********************************************************************//** * @brief * The setFPGAD10PumpParkCmd function sets the DVT concentrate pump 2 * (bicarb pump) park command bit. * bit 7: Park command bit * bit 0-6: Other pump control bits (set in different function) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD10PumpControl * @param Park command bit set * @return none *************************************************************************/ void setFPGAD10PumpParkCmd( void ) { fpgaActuatorSetPoints.fpgaD10PumpControl |= FPGA_CONC_PUMP_PARK_COMMAND; // this bit must be cleared after next transmit to prevent continuous park commands } /*********************************************************************//** * @brief * The setFPGAD76PumpParkCmd function sets the Ultrafiltration pump * (D76 pump) park command bit. * bit 7: Park command bit * bit 0-6: Other pump control bits (set in different function) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpControl * @param Park command bit set * @return none *************************************************************************/ void setFPGAD76PumpParkCmd( void ) { fpgaActuatorSetPoints.fpgaD76PumpControl |= FPGA_CONC_PUMP_PARK_COMMAND; // this bit must be cleared after next transmit to prevent continuous park commands } /*********************************************************************//** * @brief * The setFPGAD5HeaterPWMControl function sets the primary heater * PWM input. * @details \b Inputs: none * @details \b Outputs: fpgaD5HeaterPWMControl * @param control the PWM dutycycle to control the heater * @return none *************************************************************************/ void setFPGAD5HeaterPWMControl( U08 control ) { fpgaActuatorSetPoints.fpgaD5HeaterPWMControl = control; } /*********************************************************************//** * @brief * The setFPGAD45HeaterPWMControl function sets the trimmer heater * PWM input. * @details \b Inputs: none * @details \b Outputs: fpgaD45HeaterPWMControl * @param control the PWM dutycycle to control the heater * @return none *************************************************************************/ void setFPGAD45HeaterPWMControl( U08 control ) { fpgaActuatorSetPoints.fpgaD45HeaterPWMControl = control; } /*********************************************************************//** * @brief * The setFPGAD11PumpRevolutionCount function sets the Acid concentrate * pump revolution count. * @details \b Inputs: none * @details \b Outputs: fpgaD11PumpRevCount * @param count the number of revolution to be rotated for the pump. * @return none *************************************************************************/ void setFPGAD11PumpRevolutionCount( U16 count ) { fpgaActuatorSetPoints.fpgaD11PumpRevCount = count; } /*********************************************************************//** * @brief * The setFPGAD10PumpRevolutionCount function sets the Bicarb concentrate * pump revolution count. * @details \b Inputs: none * @details \b Outputs: fpgaD10PumpRevCount * @param count the number of revolution to be rotated for the pump. * @return none *************************************************************************/ void setFPGAD10PumpRevolutionCount( U16 count ) { fpgaActuatorSetPoints.fpgaD10PumpRevCount = count; } /*********************************************************************//** * @brief * The setFPGAD76PumpRevolutionCount function sets the UltraFilteration * pump revolution count. * @details \b Inputs: none * @details \b Outputs: fpgaD76PumpRevCount * @param count the number of revolution to be rotated for the pump. * @return none *************************************************************************/ void setFPGAD76PumpRevolutionCount( U16 count ) { fpgaActuatorSetPoints.fpgaD76PumpRevCount = count; } /*********************************************************************//** * @brief * The setFPGAD5HeaterOnOffControl function sets the primary heater * On/Off control. * @details \b Inputs: none * @details \b Outputs: fpgaGPIOControl * @param flag Turn heater ON when true, otherwise not. * @return none *************************************************************************/ void setFPGAD5HeaterOnOffControl( BOOL flag ) { if ( TRUE == flag) { fpgaActuatorSetPoints.fpgaGPIOControl |= FPGA_D5_HEATER_CNTRL_BIT; } else { fpgaActuatorSetPoints.fpgaGPIOControl &= ~FPGA_D5_HEATER_CNTRL_BIT; } } /*********************************************************************//** * @brief * The setFPGAD5HeaterPWMEnableControl function sets whether the primary heater * control based out of On/OFF (0) or PWM based control (1). * @details \b Inputs: none * @details \b Outputs: fpgaGPIOControl * @param enable PWM based heater control when true, otherwise On/Off Control. * @return none *************************************************************************/ void setFPGAD5HeaterPWMEnableControl( BOOL enable ) { if ( TRUE == enable) { fpgaActuatorSetPoints.fpgaGPIOControl |= FPGA_D5_HEATER_PWM_ENABLE_BIT; } else { fpgaActuatorSetPoints.fpgaGPIOControl &= ~FPGA_D5_HEATER_PWM_ENABLE_BIT; } } /*********************************************************************//** * @brief * The setFPGAD5HeaterPWMLowState function sets the PWM low period( Off time) * for AC heater. * @details \b Inputs: none * @details \b Outputs: fpgaACRelayPWMLow * @param count the number of count that PWM stays low for the AC relay/heater. * @return none *************************************************************************/ void setFPGAD5HeaterPWMLowState( U16 count ) { fpgaActuatorSetPoints.fpgaACRelayPWMLow = count; } /*********************************************************************//** * @brief * The setFPGAD5HeaterPWMPeriod function sets the PWM period( On and Off time) * for AC heater. * @details \b Inputs: none * @details \b Outputs: fpgaACRelayPWMPeriod * @param period the total period of PWM cycle ( On and Off time). * @return none *************************************************************************/ void setFPGAD5HeaterPWMPeriod( U16 period ) { fpgaActuatorSetPoints.fpgaACRelayPWMPeriod = period; } /*********************************************************************//** * @brief * The getFPGAVersions function gets the FPGA version numbers. * @details \b Inputs: fpgaHeader * @details \b Outputs: none * @return none *************************************************************************/ void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) { *Id = fpgaHeader.fpgaId; *Maj = fpgaHeader.fpgaRevMajor; *Min = fpgaHeader.fpgaRevMinor; *Lab = fpgaHeader.fpgaRevLab; } /*********************************************************************//** * @brief * The getFPGAD48PumpControl function gets the status of the * dialysate out pump control status bits. * bit 7: TBD * bit 6: TBD * bit 5: TBD * bit 4: TBD * bit 3: TBD * bit 1-2: TBD * bit 0: Run (1), stop (0) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD48PumpControl * @return Dialysate Out pump control status bit *************************************************************************/ U08 getFPGAD48PumpControl( void ) { return fpgaActuatorSetPoints.fpgaD48PumpControl; } /*********************************************************************//** * @brief * The getFPGAD12PumpControl function gets the status of the * dialysate Inlet pump control status bits. * bit 7: TBD * bit 6: TBD * bit 5: TBD * bit 4: TBD * bit 3: TBD * bit 1-2: TBD * bit 0: Run (1), stop (0) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD12PumpControl * @return Dialysate Inlet pump control status bit *************************************************************************/ U08 getFPGAD12PumpControl( void ) { return fpgaActuatorSetPoints.fpgaD12PumpControl; } /*********************************************************************//** * @brief * The getFPGAD48PumpSpeed function gets the spent dialysate * pump speed. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD48MeasuredSpeed * @return Spent dialysate pump measured speed. *************************************************************************/ U16 getFPGAD48PumpSpeed( void ) { return fpgaSensorReadings.fpgaD48MeasuredSpeed; } /*********************************************************************//** * @brief * The getFPGAD12PumpSpeed function gets the fresh dialysate * pump speed. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD12MeasuredSpeed * @return fresh dialysate pump measured speed. *************************************************************************/ U16 getFPGAD12PumpSpeed( void ) { return fpgaSensorReadings.fpgaD12MeasuredSpeed; } /*********************************************************************//** * @brief * The getFPGAD12PumpErrorStatus function gets the fresh dialysate * pump error status. * bit 7-2: TBD * bit 1 : spent dialysate pump error (1), no error(0) * bit 0 : fresh dialysate pump error (1), no error(0) * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD12D48PumpStatus * @return fresh dialysate pump error status. *************************************************************************/ BOOL getFPGAD12PumpErrorStatus( void ) { U08 mask = fpgaSensorReadings.fpgaD12D48PumpStatus & FPGA_D12_PUMP_ERROR_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD48PumpErrorStatus function gets the spent dialysate * pump error status. * bit 7-2: TBD * bit 1 : spent dialysate pump error (1), no error(0) * bit 0 : fresh dialysate pump error (1), no error(0) * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD12D48PumpStatus * @return spent dialysate pump error status. *************************************************************************/ BOOL getFPGAD48PumpErrorStatus( void ) { U08 mask = fpgaSensorReadings.fpgaD12D48PumpStatus & FPGA_D48_PUMP_ERROR_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD12PumpCurrentFeedback function gets the fresh dialysate * pump current consumption. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD12CurrentFeedback * @return fresh dialysate pump measured current. *************************************************************************/ U16 getFPGAD12PumpCurrentFeedback( void ) { return fpgaSensorReadings.fpgaD12CurrentFeedback; } /*********************************************************************//** * @brief * The getFPGAD48PumpCurrentFeedback function gets the spent dialysate * pump current consumption. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD48CurrentFeedback * @return spent dialysate pump measured current. *************************************************************************/ U16 getFPGAD48PumpCurrentFeedback( void ) { return fpgaSensorReadings.fpgaD48CurrentFeedback; } /*********************************************************************//** * @brief * The getFPGAD12PumpHallDirectionStatus function gets the fresh dialysate * pump hall sensor based direction error status. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD12HallStatus * @return fresh dialysate pump hall sensor based direction status. *************************************************************************/ U08 getFPGAD12PumpHallDirectionStatus( void ) { return fpgaSensorReadings.fpgaD12HallStatus; } /*********************************************************************//** * @brief * The getFPGAD48PumpHallDirectionStatus function gets the spent dialysate * pump hall sensor based direction error status. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaD48HallStatus * @return spent dialysate pump hall sensor based direction status. *************************************************************************/ U08 getFPGAD48PumpHallDirectionStatus( void ) { return fpgaSensorReadings.fpgaD48HallStatus; } /*********************************************************************//** * @brief * The getFPGAD11PumpControlStatus function gets the status of the * acid pump control status bits. * bit 7: Park (set in different function) * bit 6: nSleep * bit 5: nReset * bit 4: nEnable * bit 3: Direction (1=Fwd, 0=Rev) * bit 0-2: Microstepping resolution * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD11PumpControl * @return Acid pump control status bit *************************************************************************/ U08 getFPGAD11PumpControlStatus( void ) { return fpgaActuatorSetPoints.fpgaD11PumpControl; } /*********************************************************************//** * @brief * The getFPGAD10PumpControlStatus function gets the DVT concentrate pump 2 * (bicarb pump) control mode. * bit 7: Park (set in different function) * bit 6: nSleep * bit 5: nReset * bit 4: nEnable * bit 3: Direction (1=Fwd, 0=Rev) * bit 0-2: Microstepping resolution * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD10PumpControl * @return Bicarb pump control status bit *************************************************************************/ U08 getFPGAD10PumpControlStatus( void ) { return fpgaActuatorSetPoints.fpgaD10PumpControl; } /*********************************************************************//** * @brief * The getFPGAD76PumpControlStatus function gets the Ultrafilteration pump * (D76 pump) control mode. * bit 7: Park (set in different function) * bit 6: nSleep * bit 5: nReset * bit 4: nEnable * bit 3: Direction (1=Fwd, 0=Rev) * bit 0-2: Microstepping resolution * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpControl * @return UF pump control status bit *************************************************************************/ U08 getFPGAD76PumpControlStatus( void ) { return fpgaActuatorSetPoints.fpgaD76PumpControl; } /*********************************************************************//** * @brief * The getFPGAUFPumpFault function gets UF pumps fault * reported by FGPA. * @details \b Inputs: fpgaSensorReadings.fpgaD76PumpFault * @details \b Outputs: none * @return Latest UF pumps fault value *************************************************************************/ U08 getFPGAUFPumpFault( void ) { return ( ( fpgaSensorReadings.fpgaD76PumpFault & FPGA_UF_PUMP_FAULT_BIT ) << UF_PUMP_FAULT_SHIFT ); } /*********************************************************************//** * @brief * The getFPGAD76PumpIsParked function gets whether the UF pump is currently * parked. * @details \b Inputs: fpgaSensorReadings.fpgaD76PumpFault * @details \b Outputs: none * @return TRUE if UF pump is parked, FALSE if not *************************************************************************/ BOOL getFPGAD76PumpIsParked( void ) { U08 mask = fpgaSensorReadings.fpgaD76PumpFault & FPGA_UF_PUMP_PARKED_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD76PumpParkFault function gets whether the UF pump park command * has faulted. * @details \b Inputs: fpgaSensorReadings.fpgaD76PumpFault * @details \b Outputs: none * @return TRUE if UF pump park command faulted, FALSE if not *************************************************************************/ BOOL getFPGAD76PumpParkFault( void ) { U08 mask = fpgaSensorReadings.fpgaD76PumpFault & FPGA_UF_PUMP_PARK_FAULT_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAConcentratePumpsFault function gets concentrate pumps fault * reported by FGPA. * @details \b Inputs: fpgaSensorReadings.fpgaD11_D10_PumpFault * @details \b Outputs: none * @return Latest concentrate pumps fault value *************************************************************************/ U08 getFPGAConcentratePumpsFault( void ) { return fpgaSensorReadings.fpgaD11_D10_PumpFault & FPGA_CONC_PUMP_FAULT_BITS; } /*********************************************************************//** * @brief * The getFPGAD11PumpIsParked function gets whether the acid pump is currently * parked. * @details \b Inputs: fpgaSensorReadings.fpgaD11_D10_PumpFault * @details \b Outputs: none * @return TRUE if acid pump is parked, FALSE if not *************************************************************************/ BOOL getFPGAD11PumpIsParked( void ) { U08 mask = fpgaSensorReadings.fpgaD11_D10_PumpFault & FPGA_D11_PUMP_PARKED_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD10PumpIsParked function gets whether the bicarb pump is currently * parked. * @details \b Inputs: fpgaSensorReadings.fpgaD11_D10_PumpFault * @details \b Outputs: none * @return TRUE if bicarb pump is parked, FALSE if not *************************************************************************/ BOOL getFPGAD10PumpIsParked( void ) { U08 mask = fpgaSensorReadings.fpgaD11_D10_PumpFault & FPGA_D10_PUMP_PARKED_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD11PumpParkFault function gets whether the acid pump park command * has faulted. * @details \b Inputs: fpgaSensorReadings.fpgaD11_D10_PumpFault * @details \b Outputs: none * @return TRUE if acid pump park command faulted, FALSE if not *************************************************************************/ BOOL getFPGAD11PumpParkFault( void ) { U08 mask = fpgaSensorReadings.fpgaD11_D10_PumpFault & FPGA_D11_PUMP_PARK_FAULT_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD10PumpParkFault function gets whether the bicarb pump park command * has faulted. * @details \b Inputs: fpgaSensorReadings.fpgaD11_D10_PumpFault * @details \b Outputs: none * @return TRUE if bicarb pump park command faulted, FALSE if not *************************************************************************/ BOOL getFPGAD10PumpParkFault( void ) { U08 mask = fpgaSensorReadings.fpgaD11_D10_PumpFault & FPGA_D10_PUMP_PARK_FAULT_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAD11PumpHallSensePulseWidth function gets concentrate pump D11_Pump * hall sense pulse width. * @details \b Inputs: fpgaSensorReadings.fpgaD11PumpHallSense * @details \b Outputs: none * @return concentrate pump D11_Pump hall sense pulse width *************************************************************************/ U16 getFPGAD11PumpHallSensePulseWidth( void ) { return fpgaSensorReadings.d11HallSense; } /*********************************************************************//** * @brief * The getFPGAD10PumpHallSensePulseWidth function gets concentrate pump D10_Pump * hall sense pulse width. * @details \b Inputs: fpgaSensorReadings.fpgaD10PumpHallSense * @details \b Outputs: none * @return concentrate pump D10_Pump hall sense pulse width *************************************************************************/ U16 getFPGAD10PumpHallSensePulseWidth( void ) { return fpgaSensorReadings.d10HallSense; } /*********************************************************************//** * @brief * The getFPGAD76PumpHallSensePulseWidth function gets UF pump D76_Pump * hall sense pulse width. * @details \b Inputs: fpgaSensorReadings.fpgaD76PumpHallSense * @details \b Outputs: none * @return ultrafiltration pump D76_Pump hall sense pulse width *************************************************************************/ U16 getFPGAD76PumpHallSensePulseWidth( void ) { return fpgaSensorReadings.d76HallSense; } /*********************************************************************//** * @brief * The getFPGADDValveStates function gets the latest sensed valve states. * See setFPGADDValveStates for valve state bit positions. * @details \b Inputs: fpgaSensorReadings.fpgaValveStates * @details \b Outputs: none * @return last valve states reading *************************************************************************/ U16 getFPGADDValveStates( void ) { return fpgaSensorReadings.fpgaValveStates; } /*********************************************************************//** * @brief * The getFPGAValveBCStates function gets the latest sensed balancing * chamber valve states. * See setFPGABCValveStates for BC valve state bit positions. * @details \b Inputs: fpgaSensorReadings.fpgaValveBCStates * @details \b Outputs: none * @return last balancing chamber valve states reading *************************************************************************/ U08 getFPGAValveBCStates( void ) { return fpgaSensorReadings.fpgaValveBCStates; } /*********************************************************************//** * @brief * The getFPGAValveSpStates function gets the latest sensed spare * valve states. * See setFPGAUFValveStates for Spare valve state bit positions. * @details \b Inputs: fpgaSensorReadings.fpgaValveSpStates * @details \b Outputs: none * @return last spare valve states reading *************************************************************************/ U08 getFPGAValveSpStates( void ) { return fpgaSensorReadings.fpgaValveSpStates; } /*********************************************************************//** * @brief * The getFPGAD9PresRawPressure function gets hydraulics outlet pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaD9PresPressure * @details \b Outputs: none * @return Latest hydraulics outlet pressure sensor raw pressure data *************************************************************************/ U16 getFPGAD9PresRawPressure( void ) { return fpgaSensorReadings.fpgaD9PresPressure; } /*********************************************************************//** * @brief * The getFPGAD9PresRawTemperature function gets hydraulics outlet pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaD9PresTemp * @details \b Outputs: none * @return Latest hydraulics outlet pressure sensor raw temperature data *************************************************************************/ U16 getFPGAD9PresRawTemperature( void ) { return fpgaSensorReadings.fpgaD9PresTemp; } /*********************************************************************//** * @brief * The getFPGAD66PresRawPressure function gets Bibag pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaD66PresPressure * @details \b Outputs: none * @return Latest Bibag pressure sensor raw pressure data *************************************************************************/ U16 getFPGAD66PresRawPressure( void ) { return fpgaSensorReadings.fpgaD66PresPressure; } /*********************************************************************//** * @brief * The getFPGAD66PresRawTemperature function gets Bibag pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaD66PresTemp * @details \b Outputs: none * @return Latest Bibag pressure sensor raw temperature data *************************************************************************/ U16 getFPGAD66PresRawTemperature( void ) { return fpgaSensorReadings.fpgaD66PresTemp; } /*********************************************************************//** * @brief * The getFPGAD51PresRawPressure function gets spent dialysate pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaD51PresPressure * @details \b Outputs: none * @return Latest spent dialysate pressure sensor raw pressure data *************************************************************************/ U16 getFPGAD51PresRawPressure( void ) { return fpgaSensorReadings.fpgaD51PresPressure; } /*********************************************************************//** * @brief * The getFPGAD51PresRawTemperature function gets spent dialysate pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaD51PresTemp * @details \b Outputs: none * @return Latest spent dialysate pressure sensor raw temperature data *************************************************************************/ U16 getFPGAD51PresRawTemperature( void ) { return fpgaSensorReadings.fpgaD51PresTemp; } /*********************************************************************//** * @brief * The getFPGAD18PresRawPressure function gets fresh dialysate pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaD18PresPressure * @details \b Outputs: none * @return Latest fresh dialysate pressure sensor raw pressure data *************************************************************************/ U16 getFPGAD18PresRawPressure( void ) { return fpgaSensorReadings.fpgaD18PresPressure; } /*********************************************************************//** * @brief * The getFPGAD18PresRawTemperature function gets fresh dialysate pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaD18PresTemp * @details \b Outputs: none * @return Latest fresh dialysate pressure sensor raw temperature data *************************************************************************/ U16 getFPGAD18PresRawTemperature( void ) { return fpgaSensorReadings.fpgaD18PresTemp; } /*********************************************************************//** * @brief * The getFPGAD41PresRawPressure function gets transmembrane pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaD41PresPressure * @details \b Outputs: none * @return Latest transmembrane pressure sensor raw pressure data *************************************************************************/ U16 getFPGAD41PresRawPressure( void ) { return fpgaSensorReadings.fpgaD41PresPressure; } /*********************************************************************//** * @brief * The getFPGAD41PresRawTemperature function gets transmembrane pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaD41PresTemp * @details \b Outputs: none * @return Latest transmembrane pressure sensor raw temperature data *************************************************************************/ U16 getFPGAD41PresRawTemperature( void ) { return fpgaSensorReadings.fpgaD41PresTemp; } /*********************************************************************//** * @brief * The getFPGAD87PresRawPressure function gets fresh dialysate post ultrafilter * pressure sensor raw pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaD87PresPressure * @details \b Outputs: none * @return Fresh dialysate post ultrafilter pressure sensor raw pressure data *************************************************************************/ U16 getFPGAD87PresRawPressure( void ) { return fpgaSensorReadings.fpgaD87PresPressure; } /*********************************************************************//** * @brief * The getFPGAD87PresRawTemperature function gets fresh dialysate post ultrafilter * pressure sensor raw temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaD87PresTemp * @details \b Outputs: none * @return Fresh dialysate post ultrafilter pressure sensor raw temperature data *************************************************************************/ U16 getFPGAD87PresRawTemperature( void ) { return fpgaSensorReadings.fpgaD87PresTemp; } /*********************************************************************//** * @brief * The getFPGAD63LevelSensor function gets the latest FPGA D63 upper level * sensor reading. * @details \b Inputs: fpgaSensorReadings.fpgaD63LevelSensor * @details \b Outputs: none * @return last FPGA D63 upper level sensor reading *************************************************************************/ U16 getFPGAD63LevelSensor( void ) { return fpgaSensorReadings.fpgaD63LevelSensor; } /*********************************************************************//** * @brief * The getFPGAD98LevelSensor function gets the latest FPGA D98 lower level * sensor reading. * @details \b Inputs: fpgaSensorReadings.fpgaD98LevelSensor * @details \b Outputs: none * @return last FPGA D98 lower level sensor reading *************************************************************************/ U16 getFPGAD98LevelSensor( void ) { return fpgaSensorReadings.fpgaD98LevelSensor; } /*********************************************************************//** * @brief * The getFPGAD46LevelSensor function gets the latest FPGA level sensor 2 * reading. * @details \b Inputs: fpgaSensorReadings.fpgaD46LevelSensor * @details \b Outputs: none * @return last FPGA level sensor2 reading *************************************************************************/ U16 getFPGAD46LevelSensor( void ) { return fpgaSensorReadings.fpgaD46LevelSensor; } /*********************************************************************//** * @brief * The getFPGAD6LevelStatus function gets the latest FPGA floater D6 level * reading. * @details \b Inputs: fpgaSensorReadings.fpgaD6FloaterStatus * @details \b Outputs: none * @return last FPGA floater D6 level reading *************************************************************************/ U08 getFPGAD6LevelStatus( void ) { return ( fpgaSensorReadings.fpgaD6FloaterStatus & FPGA_D6_FLOATER_LEVEL_BIT ); } /*********************************************************************//** * @brief * The getFPGAFloater2Status function gets the latest FPGA floater 2 level * reading. * @details \b Inputs: fpgaSensorReadings.fpgaFloater2Status * @details \b Outputs: none * @return last FPGA floater 2 level reading *************************************************************************/ U08 getFPGAFloater2Status( void ) { return fpgaSensorReadings.fpgaFloater2Status; } /*********************************************************************//** * @brief * The getFPGATimerCount function gets the latest FPGA timer millisecond count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return last FPGA timer count *************************************************************************/ static U16 getFPGATimerCount( void ) { return fpgaSensorReadings.fpgaTimerCountMS; } /*********************************************************************//** * @brief * The getFPGAD1Temp function gets the inlet heat exchanger * temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return inlet heat exchanger temperature *************************************************************************/ U32 getFPGAD1Temp( void ) { return fpgaSensorReadings.fpgaD1Temp; } /*********************************************************************//** * @brief * The getFPGAD78Temp function gets the outlet heat exchanger * temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return outlet heat exchanger temperature *************************************************************************/ U32 getFPGAD78Temp( void ) { return fpgaSensorReadings.fpgaD78Temp; } /*********************************************************************//** * @brief * The getFPGAD4Temp function gets the hydraulics primary * heater temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return hydraulics primary heater temperature *************************************************************************/ U32 getFPGAD4Temp( void ) { return fpgaSensorReadings.fpgaD4Temp; } /*********************************************************************//** * @brief * The getFPGAD50Temp function gets the trimmer heater temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return trimmer heater temperature *************************************************************************/ U32 getFPGAD50Temp( void ) { return fpgaSensorReadings.fpgaD50Temp; } /*********************************************************************//** * @brief * The getFPGAD99Temp function gets the fresh dialysate temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return Fresh dialysate temperature *************************************************************************/ U32 getFPGAD99Temp( void ) { return fpgaSensorReadings.fpgaD99Temp; } /*********************************************************************//** * @brief * The getFPGARTDReadCount function gets the RTD sensors group read count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return RTD read count *************************************************************************/ U08 getFPGARTDReadCount( void ) { return fpgaSensorReadings.fpgaRTDReadCnt; } /*********************************************************************//** * @brief * The getFPGARTDCountErrorCycles function gets the FPGA incomplete sequences * of reads from RTD ADC. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return count of in-complete sequences of reads from RTD ADC. *************************************************************************/ U08 getFPGARTDCountErrorCycles( void ) { return fpgaSensorReadings.fpgaD78D1D4D50ErrorCounter; } /*********************************************************************//** * @brief * The checkFPGACommFailure function increments the FPGA comm failure * windowed timer and returns whether or not the number of failures in * the window have been reached. * @details \b Inputs: none * @details \b Outputs: none * @return TRUE if windowed count exceeded, else false. *************************************************************************/ void checkFPGACommFailure( void ) { if ( getMSTimerCount() > MIN_POWER_ON_TIME_FOR_COMM_FAILS ) { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) { //TODO : Enable alarm later //SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) } } } /*********************************************************************//** * @brief * The getFPGAD11PumpRevolutionCountStatus function gets the current revolution of * acid concentrate pump (down counter). * @details \b Inputs: fpgaD11PumpStepCountStatus * @details \b Outputs: none * @return the current revolution of the acid concentrate pump *************************************************************************/ U16 getFPGAD11PumpRevolutionCountStatus( void ) { return fpgaSensorReadings.fpgaD11PumpStepCountStatus; } /*********************************************************************//** * @brief * The getFPGAD10PumpRevolutionCountStatus function gets the current revolution of * bicarb concentrate pump (down counter). * @details \b Inputs: fpgaD10PumpStepCountStatus * @details \b Outputs: none * @return the current revolution of the bicarb concentrate pump *************************************************************************/ U16 getFPGAD10PumpRevolutionCountStatus( void ) { return fpgaSensorReadings.fpgaD10PumpStepCountStatus; } /*********************************************************************//** * @brief * The getFPGAD76PumpRevolutionCountStatus function gets the current revolution of * UF pump (down counter) status. * @details \b Inputs: fpgaD76PumpStepCountStatus * @details \b Outputs: none * @return the current revolution of the UF pump *************************************************************************/ U16 getFPGAD76PumpRevolutionCountStatus( void ) { return fpgaSensorReadings.fpgaD76PumpStepCountStatus; } /*********************************************************************//** * @brief * The checkFPGAAFEOEFailure function increments the FPGA comm failure * windowed timer if an FE or OE error has occurred and returns whether * or not the number of failures in * the window have been reached. * @details \b Inputs: none * @details \b Outputs: none * @details \b Alarm: ALARM_ID_DD_FPGA_COMM_TIMEOUT when FPGA communication is * lost with the processor. * @return TRUE if windowed count exceeded, else false. *************************************************************************/ BOOL checkFPGAFEOEFailure( void ) { BOOL status = FALSE; BOOL FPGAFEOEError = getSci2FEOEError(); if ( TRUE == FPGAFEOEError) { if ( getMSTimerCount() > MIN_POWER_ON_TIME_FOR_COMM_FAILS ) { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) { //TODO : Enable alarm later //SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) status = TRUE; } } } return status; } // Blood leak functions /*********************************************************************//** * @brief * The getFPGABloodLeakStatus function returns the blood leak sensor's * blood detection status bit. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return blood leak sensor self test status bit *************************************************************************/ U08 getFPGABloodLeakStatus( void ) { U08 selfTestStatus = ( fpgaSensorReadings.fpgaD42PulseStatus & FPGA_D42_BLOOD_LEAK_STATUS_MASK ) >> FPGA_D42_BLOOD_LEAK_ST_BIT_INDEX; return selfTestStatus; } /*********************************************************************//** * @brief * The setFPGABloodLeakUARTControl function sets the blood leak sensor UART * control value. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints * @return none *************************************************************************/ void setFPGABloodLeakUARTControl( U08 value ) { fpgaActuatorSetPoints.fpgaD42UARTControl = value; } /*********************************************************************//** * @brief * The setFPGABloodLeakUARTTransmit function sets the blood leak sensor UART * transmit value. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints * @return none *************************************************************************/ void setFPGABloodLeakUARTTransmit( U08 value ) { fpgaActuatorSetPoints.fpgaD42FIFOTx = value; } /*********************************************************************//** * @brief * The getFPGABloodLeakTxFIFOCount function returns the blood leak transmit * FIFO count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return fpgaSensorReadings.fpgaD42TxFIFOCnt *************************************************************************/ U08 getFPGABloodLeakTxFIFOCount( void ) { return fpgaSensorReadings.fpgaD42TxFIFOCnt; } /*********************************************************************//** * @brief * The getFPGABloodLeakRxFIFOCount function returns the blood leak receive * FIFO count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return fpgaSensorReadings.fpgaD42RxFIFOCnt *************************************************************************/ U16 getFPGABloodLeakRxFIFOCount( void ) { return fpgaSensorReadings.fpgaD42RxFIFOCnt; } /*********************************************************************//** * @brief * The getFPGABloodLeakRxErrorCount function returns the blood leak receive * error count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return fpgaSensorReadings.fpgaD42RxErrorCnt *************************************************************************/ U08 getFPGABloodLeakRxErrorCount( void ) { return fpgaSensorReadings.fpgaD42RxErrorCnt; } /*********************************************************************//** * @brief * The getFPGABloodLeakRxFIFODataOut function returns the blood leak receive * FIFO data out. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return fpgaSensorReadings.fpgaD42RxFIFODataOut *************************************************************************/ U08 getFPGABloodLeakRxFIFODataOut( void ) { return fpgaSensorReadings.fpgaD42RxFIFODataOut; } /*********************************************************************//** * @brief * The setFPGAD79RinsePumpControl function sets the control bit of the rinse * pump to turn it on or off. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDDSpareValveControl * @return none *************************************************************************/ void setFPGAD79RinsePumpControl( U08 value ) { fpgaActuatorSetPoints.fpgaDDSpareValveControl &= value; } /*********************************************************************//** * @brief * The setFPGAD79RinsePumpPWMControl function sets the PWM value of the rinse * pump to turn it on or off. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaD79PWMPumpCtl * @return none *************************************************************************/ void setFPGAD79RinsePumpPWMControl( U08 value ) { fpgaActuatorSetPoints.fpgaD79PWMPumpCtl = value; } /*********************************************************************//** * @brief * The getFPGAD79RinsePumpPulseWidth function returns the 4-wire rinse pump * pulse width. * @details \b Inputs: d79SpeedPulseWidth * @details \b Outputs: none * @return fpgaSensorReadings.d79SpeedPulseWidth *************************************************************************/ U16 getFPGAD79RinsePumpPulseWidth( void ) { return fpgaSensorReadings.d79SpeedPulseWidth; } /*********************************************************************//** * @brief * The setFPGAFPValveStates function sets the FP valve states with an 8-bit * mask of states - one bit per valve, with a 1 meaning "energized" and a 0 * meaning "de-energized". The bit positions for these bit states are as follows: * 0 - P11.\n * 1 - P33.\n * 2 - P34.\n * 3 - P37.\n * 4 - P39.\n * 5 - P6.\n * 6:8 - Not used. \n * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveFPControl * @param valveStates bit mask for requested valve states * @return none *************************************************************************/ void setFPGAFPValveStates( U08 valveStates ) { fpgaActuatorSetPoints.valveFPControl = valveStates; } /*********************************************************************//** * @brief * The getFPGAFPValveStates function gets the FP valve commanded states with * an 8-bit mask representing the set of states with a 1 meaning "energized" * and a 0 meaning "de-energized". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.valveFPControlReadback * @return none *************************************************************************/ U08 getFPGAFPValveStates( void ) { return fpgaSensorReadings.valveFPControlReadback; } /*********************************************************************//** * @brief * The setFPGAIOValveStates function sets the IO valve states with an 8-bit * mask of states - one bit per valve, with a 1 meaning "energized" and a 0 * meaning "de-energized". The bit positions for these bit states are as follows: * 0 - M4_VALV.\n * 1 - M12_VALV.\n * 2:8 - Not used. \n * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveIOControl * @param valveStates bit mask for requested valve states * @return none *************************************************************************/ void setFPGAIOValveStates( U08 valveStates ) { fpgaActuatorSetPoints.valveIOControl = valveStates; } /*********************************************************************//** * @brief * The getFPGAIOValveStates function gets the IO valve commanded states with * an 8-bit mask representing the set of states with a 1 meaning "energized" * and a 0 meaning "de-energized". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.valveIOControlReadback * @return none *************************************************************************/ U08 getFPGAIOValveStates( void ) { return fpgaSensorReadings.valveIOControlReadback; } /*********************************************************************//** * @brief * The setFPGAValveIOPWMEnable function sets the IO valve PWM states with * * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled" * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveIOPWMEnable * @param valvePWMStates bit mask for requested valve states. * @return none *************************************************************************/ void setFPGAValveIOPWMEnable( U08 valvePWMStates ) { fpgaActuatorSetPoints.valveIOPWMEnable = valvePWMStates; } /*********************************************************************//** * @brief * The getFPGAValveIOPWMEnable function gets the IO valve pwm states with * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.valveIOPWMEnableReadback * @return none *************************************************************************/ U08 getFPGAValveIOPWMEnable( void ) { return fpgaSensorReadings.valveIOPWMEnableReadback; } /*********************************************************************//** * @brief * The setFPGAValveFPPWMEnable function sets the FP valve PWM states with * * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled" * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveFPPWMEnable * @param valvePWMStates bit mask for requested valve states. * @return none *************************************************************************/ void setFPGAValveFPPWMEnable( U08 valvePWMStates ) { fpgaActuatorSetPoints.valveFPPWMEnable = valvePWMStates; } /*********************************************************************//** * @brief * The getFPGAValveFPPWMEnable function gets the FP valve pwm states with * an 8-bit mask representing the set of states with a 1 meaning "enabled" * and a 0 meaning "disabled". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.valveFPPWMEnableReadback * @return none *************************************************************************/ U08 getFPGAValveFPPWMEnable( void ) { return fpgaSensorReadings.valveFPPWMEnableReadback; } /*********************************************************************//** * @brief * The setFPGAValveIOFPPWMPullIn function sets the IO & FP valves Pull-in "strike" * period where PWM is at 100% in 1ms resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveIOFPPWMPullIn * @param valvePWMPullIn Pull-in period in 1ms resolution. * @return none *************************************************************************/ void setFPGAValveIOFPPWMPullIn( U16 valvePWMPullIn ) { fpgaActuatorSetPoints.valveIOFPPWMPullIn = valvePWMPullIn; } /*********************************************************************//** * @brief * The setFPGAValveIOFPPWMLow function sets the IO & FP valves "low" * period where PWM is at 0% in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveIOFPPWMLow * @param valvePWMLow low period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveIOFPPWMLow( U16 valvePWMLow ) { fpgaActuatorSetPoints.valveIOFPPWMLow = valvePWMLow; } /*********************************************************************//** * @brief * The setFPGAValveIOFPPWMPeriod function sets the IO & FP valves pwm * period in 0.1us resolution. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveIOFPPWMPeriod * @param valvePWMPeriod period in 0.1us resolution. * @return none *************************************************************************/ void setFPGAValveIOFPPWMPeriod( U16 valvePWMPeriod ) { fpgaActuatorSetPoints.valveIOFPPWMPeriod = valvePWMPeriod; } /*********************************************************************//** * @brief * The setFPGAP12PumpEnable function enables or disables the P12 pump. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.p12PumpControl * @param enable flag indicating whether to enable or disable the P12 pump. * @return none *************************************************************************/ void setFPGAP12PumpEnable( BOOL enable ) { fpgaActuatorSetPoints.p12PumpControl = ( TRUE == enable ? 0x1 : 0x0 ); } /*********************************************************************//** * @brief * The setFPGAP12PumpPWM function sets the P12 pump PWM duty cycle. * The higher the PWM duty cycle (0..500), the faster the pump will go. * @note PWM values < 5% or > 95% will cause pump to stop so effective * range is actually 25..475. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.p12PumpPWMDutyCyclePct * @param pwm PWM duty cycle magnitude * @return none *************************************************************************/ void setFPGAP12PumpPWM( U16 pwm ) { fpgaActuatorSetPoints.p12PumpPWMDutyCyclePct = pwm; } /*********************************************************************//** * @brief * The getFPGAP12PumpPWM function gets a read back from FPGA of RO pump PWM * duty cycle. * @details \b Inputs: fpgaSensorReadings.roPumpPWMReadback * @details \b Outputs: none * @return measured speed (RPM) of the RO pump *************************************************************************/ U16 getFPGAP12PumpPWM( void ) { return fpgaSensorReadings.p12PumpPWMReadback; } /*********************************************************************//** * @brief * The getFPGAP12PumpTachCount function gets the running 16-bit tachometer count * from the P12 pump hall sensor. * @details \b Inputs: fpgaSensorReadings.p12PumpTachCount * @details \b Outputs: none * @return P12 pump tachometer count *************************************************************************/ U16 getFPGAP12PumpTachCount( void ) { return fpgaSensorReadings.p12PumpTachCount; } /*********************************************************************//** * @brief * The setFPGAP24Enabled function sets the heater enable on or off. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.p24Control * @param enable Flag indicating whether to enable or disable the P24 heater. * @return none *************************************************************************/ void setFPGAP24Enabled( BOOL enable ) { return; } /*********************************************************************//** * @brief * The setFPGAP24PWM function sets the P24 heater PWM duty cycle. * The higher the PWM duty cycle (0..500), the faster the pump will go. * @note PWM values < 5% or > 95% will cause heater to go off so effective * range is actually 25..475. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.p24PWMDutyCyclePct * @param pwm PWM duty cycle magnitude * @return none *************************************************************************/ void setFPGAP24PWM( U16 pwm ) { return; } /*********************************************************************//** * @brief * The getFPGAP46RawPressure function gets the P46 pressure reading. * @details \b Inputs: fpgaSensorReadings.pressureP46 * @details \b Outputs: none * @return P46 pressure *************************************************************************/ S16 getFPGAP46RawPressure( void ) { return fpgaSensorReadings.pressureP46; } /*********************************************************************//** * @brief * The getFPGAP46RawTemperature function gets the P46 sensor temperature reading. * @details \b Inputs: fpgaSensorReadings.temperatureP46 * @details \b Outputs: none * @return P46 sensor temperature *************************************************************************/ S16 getFPGAP46RawTemperature( void ) { return fpgaSensorReadings.temperatureP46; } /*********************************************************************//** * @brief * The getFPGAM3RawPressure function gets the M3 pressure reading. * @details \b Inputs: fpgaSensorReadings.pressureM3 * @details \b Outputs: none * @return M3 pressure *************************************************************************/ S16 getFPGAM3RawPressure( void ) { return fpgaSensorReadings.pressureM3; } /*********************************************************************//** * @brief * The getFPGAM3RawTemperature function gets the M3 sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperatureM3 * @details \b Outputs: none * @return M3 sensor temperature *************************************************************************/ S16 getFPGAM3RawTemperature( void ) { return fpgaSensorReadings.temperatureM3; } /*********************************************************************//** * @brief * The getFPGAP8RawPressure function gets the P8 pressure reading. * @details \b Inputs: fpgaSensorReadings.pressureP8 * @details \b Outputs: none * @return P8 pressure *************************************************************************/ S16 getFPGAP8RawPressure( void ) { return fpgaSensorReadings.pressureP8; } /*********************************************************************//** * @brief * The getFPGAP8RawTemperature function gets the P8 sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperatureP8 * @details \b Outputs: none * @return P8 sensor temperature *************************************************************************/ S16 getFPGAP8RawTemperature( void ) { return fpgaSensorReadings.temperatureP8; } /*********************************************************************//** * @brief * The getFPGAP13RawPressure function gets the P13 pressure reading. * @details \b Inputs: fpgaSensorReadings.pressureP13 * @details \b Outputs: none * @return P13 pressure *************************************************************************/ S16 getFPGAP13RawPressure( void ) { return fpgaSensorReadings.pressureP13; } /*********************************************************************//** * @brief * The getFPGAP13RawTemperature function gets the P13 sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperatureP13 * @details \b Outputs: none * @return P13 sensor temperature *************************************************************************/ S16 getFPGAP13RawTemperature( void ) { return fpgaSensorReadings.temperatureP13; } /*********************************************************************//** * @brief * The getFPGAP17RawPressure function gets the P17 pressure reading. * @details \b Inputs: fpgaSensorReadings.pressureP17 * @details \b Outputs: none * @return P17 pressure *************************************************************************/ S16 getFPGAP17RawPressure( void ) { return fpgaSensorReadings.pressureP17; } /*********************************************************************//** * @brief * The getFPGAP17RawTemperature function gets the P17 sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperatureP17 * @details \b Outputs: none * @return P17 sensor temperature *************************************************************************/ S16 getFPGAP17RawTemperature( void ) { return fpgaSensorReadings.temperatureP17; } /*********************************************************************//** * @brief * The getFPGAP25FloaterState function gets the P25 floater level state. * @details \b Inputs: fpgaSensorReadings.levelSwitch * @details \b Outputs: none * @return P25 floater level state *************************************************************************/ U08 getFPGAP25FloaterState( void ) { return fpgaSensorReadings.p25LevelSwitch; } /*********************************************************************//** * @brief * The getFPGAFlowFMP function gets the P16 flow rate (in mL/min). * @details \b Inputs: fpgaSensorReadings.flowRateP16 * @details \b Outputs: none * @return P16 flow rate (in mL/min) *************************************************************************/ U16 getFPGAFlowP16( void ) { return fpgaSensorReadings.flowRateP16; } /*********************************************************************//** * @brief * The getFPGAFlowP16Temp function gets the P16 flow sensor temperature, the * temperature of the fluid flowing through the sensor. * @details \b Inputs: fpgaSensorReadings.flowTempP16 * @details \b Outputs: none * @return P16 fluid temperature *************************************************************************/ U16 getFPGAFlowP16Temp( void ) { return fpgaSensorReadings.flowTempP16; } /*********************************************************************//** * @brief * The getFPGAFlowP16InternalTemp function gets the P16 flow sensor * internal temperature. * @details \b Inputs: fpgaSensorReadings.flowIntTempP16 * @details \b Outputs: none * @return P16 internal temperature *************************************************************************/ U16 getFPGAFlowP16InternalTemp( void ) { return fpgaSensorReadings.flowIntTempP16; } /*********************************************************************//** * @brief * The getFPGAFlowP7 function gets the P7 flow rate (in mL/min). * @details \b Inputs: fpgaSensorReadings.flowRateP7 * @details \b Outputs: none * @return P7 flow rate (in mL/min) *************************************************************************/ U16 getFPGAFlowP7( void ) { return fpgaSensorReadings.flowRateP7; } /*********************************************************************//** * @brief * The getFPGAFlowP7Temp function gets the P7 flow sensor temperature, the * temperature of the fluid flowing through the sensor. * @details \b Inputs: fpgaSensorReadings.flowTempP7 * @details \b Outputs: none * @return P7 fluid temperature *************************************************************************/ U16 getFPGAFlowP7Temp( void ) { return fpgaSensorReadings.flowTempP7; } /*********************************************************************//** * @brief * The getFPGAFlowP7InternalTemp function gets the P7 flow sensor * internal temperature. * @details \b Inputs: fpgaSensorReadings.flowIntTempP7 * @details \b Outputs: none * @return P7 internal temperature *************************************************************************/ U16 getFPGAFlowP7InternalTemp( void ) { return fpgaSensorReadings.flowIntTempP7; } /*********************************************************************//** * @brief * The setFPGAP40PumpEnable function enables or disables the P40 pump. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.p40PumpControl * @param enable flag indicating whether to enable or disable the P40 pump. * @return none *************************************************************************/ void setFPGAP40PumpEnable( BOOL enable ) { fpgaActuatorSetPoints.p40PumpControl = ( TRUE == enable ? 0x1 : 0x0 ); } /*********************************************************************//** * @brief * The setFPGAP40PumpPWM function sets the P40 pump PWM duty cycle. * The higher the PWM duty cycle (0..500), the faster the pump will go. * @note PWM values < 5% or > 95% will cause pump to stop so effective * range is actually 25..475. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.p40PumpPWMDutyCyclePct * @param pwm PWM duty cycle magnitude * @return none *************************************************************************/ void setFPGAP40PumpPWM( U16 pwm ) { fpgaActuatorSetPoints.p40PumpPWMDutyCyclePct = pwm; } /*********************************************************************//** * @brief * The getFPGAP12PumpPWM function gets a read back from FPGA of RO pump PWM * duty cycle. * @details \b Inputs: fpgaSensorReadings.p40PumpPWMReadback * @details \b Outputs: none * @return measured speed (RPM) of the P40 pump *************************************************************************/ U16 getFPGAP40PumpPWM( void ) { return fpgaSensorReadings.p40PumpPWMReadback; } /*********************************************************************//** * @brief * The getFPGAP12PumpTachCount function gets the running 16-bit tachometer count * from the P40 pump hall sensor. * @details \b Inputs: fpgaSensorReadings.p40PumpTachCount * @details \b Outputs: none * @return P40 pump tachometer count *************************************************************************/ U16 getFPGAP40PumpTachCount( void ) { return fpgaSensorReadings.p40PumpTachCount; } /**@}*/