/************************************************************************** * * Copyright (c) 2024-2024 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) Vinayakam Mani * @date (last) 05-Aug-2024 * * @author (original) Vinayakam Mani * @date (original) 05-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 0x02 ///< FPGA expected ID. #define MAX_COMM_ERROR_RETRIES 5 ///< Maximum number of communication error retries #define DRAIN_PUMP_DAC_SHIFT_BITS 4 ///< Drain pump DAC shift bits. #define FPGA_FLUIDLEAK_STATE_MASK 0x0004 ///< Bit mask for fluid leak detector. //TODO : Define the default values for the Valves ( 0: Deenergized, 1 : Energized) on power up. #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_UF_VALVES_CONTROL 0x00 ///< FPGA enable Balancing Chamber valves control. #define FPGA_CD1_RESET_BIT 0x01 ///< Conductivity Sensor CD1 reset bit mask. #define FPGA_CD1_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor CD1 Initialization enable bit mask. #define FPGA_CD1_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor CD1 write enable bit mask. #define FPGA_CD1_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor CD1 read enable bit mask. #define FPGA_CD2_RESET_BIT 0x10 ///< Conductivity Sensor CD2 reset bit mask. #define FPGA_CD2_INIT_ENABLE_BIT 0x20 ///< Conductivity Sensor CD2 Initialization enable bit mask. #define FPGA_CD2_WR_ENABLE_BIT 0x40 ///< Conductivity Sensor CD2 write enable bit mask. #define FPGA_CD2_RD_ENABLE_BIT 0x80 ///< Conductivity Sensor CD2 read enable bit mask. #define FPGA_CD3_RESET_BIT 0x01 ///< Conductivity Sensor CD3 reset bit mask. #define FPGA_CD3_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor CD3 Initialization enable bit mask. #define FPGA_CD3_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor CD3 write enable bit mask. #define FPGA_CD3_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor CD3 read enable bit mask. #define FPGA_CD4_RESET_BIT 0x10 ///< Conductivity Sensor CD4 reset bit mask. #define FPGA_CD4_INIT_ENABLE_BIT 0x20 ///< Conductivity Sensor CD4 Initialization enable bit mask. #define FPGA_CD4_WR_ENABLE_BIT 0x40 ///< Conductivity Sensor CD4 write enable bit mask. #define FPGA_CD4_RD_ENABLE_BIT 0x80 ///< Conductivity Sensor CD4 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 CONCENTRATE_CAP_SWITCH_MASK 0x10 ///< Concentrate cap switch bit mask. #define FPGA_CONC_PUMP_FAULT_BITS 0x03 ///< Concentrate pump fault bits mask. #define FPGA_CPA_PARKED_BIT 0x04 ///< Concentrate pump 1 parked status bit mask. #define FPGA_CPB_PARKED_BIT 0x10 ///< Concentrate pump 2 parked status bit mask. #define FPGA_CPA_PARK_FAULT_BIT 0x08 ///< Concentrate pump 1 park fault status bit mask. #define FPGA_CPB_PARK_FAULT_BIT 0x20 ///< Concentrate pump 2 park fault status bit mask. #define FPGA_CONC_PUMP_PARK_COMMAND 0x80 ///< Park command bit for the concentrate pumps. #define FPGA_THD_CONTROL_COMMAND 0X01 ///< FPGA THd control command. #define FPGA_POWER_OUT_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< FPGA power out timeout in milliseconds. #define FPGA_GPIO_POWER_STATUS_PIN 7 ///< FPGA GPIO power status pin. #define FPGA_READ_V3_START_BYTE_NUM 256 ///< FPGA V3 read sensors start byte number. #define FPGA_READ_V3_END_BYTE_NUM 430 ///< FPGA V3 read sensors end byte number. #define FPGA_DGP_PUMP_ERROR_BIT 0x01 ///< Fresh dialysate pump error bit mask. #define FPGA_SDP_PUMP_ERROR_BIT 0x02 ///< Spent dialysate pump error bit mask. /// FPGA size of V3 read bytes. #define FPGA_SIZE_OF_V3_READ_BYTES ( FPGA_READ_V3_END_BYTE_NUM - FPGA_READ_V3_START_BYTE_NUM ) #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 #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 256. Compatibility revision U16 fpgaTimerCountMS; ///< Reg 258. Internal FPGA timer count in milliseconds U16 fpgaRemoteUpdateRead; ///< Reg 260. FPGA Remote Update Read ( copy contents from remote update write) U08 fpgaIOErrorCntProcessor; ///< Reg 262. Number of errors in Microprocessor UART interface U08 fpgaIOErrorCntPC; ///< Reg 263. Number of errors in PC UART interface U16 fpgaPnPressure; ///< Reg 264. Pn/PHo MPM pressure sensor RAW pressure data U16 fpgaPnTemp; ///< Reg 266. Pn/PHo MPM pressure sensor RAW temperature data U08 fpgaPnReadCnt; ///< Reg 268. Pn/PHo Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPnErrorCnt; ///< Reg 229. Pn/PHo Counter for bad SPI transmission b/w FPGA and sensor U16 fpgaPCbPressure; ///< Reg 270. PCb/PDB MPM pressure sensor RAW pressure data U16 fpgaPCbTemp; ///< Reg 272. PCb/PDB MPM pressure sensor RAW temperature data U08 fpgaPCbReadCnt; ///< Reg 274. PCb/PDB Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPCbErrorCnt; ///< Reg 275. PCb/PDB Counter for bad SPI transmission b/w FPGA and sensor U16 fpgaPDsPressure; ///< Reg 276. PDs MPM pressure sensor RAW pressure data U16 fpgaPDsTemp; ///< Reg 278. PDs MPM pressure sensor RAW temperature data U08 fpgaPDsReadCnt; ///< Reg 280. PDs Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPDsErrorCnt; ///< Reg 281. PDs Counter for bad SPI transmission b/w FPGA and sensor U16 fpgaPDfPressure; ///< Reg 282. PDf MPM pressure sensor RAW pressure data U16 fpgaPDfTemp; ///< Reg 284. PDf MPM pressure sensor RAW temperature data U08 fpgaPDfReadCnt; ///< Reg 286. PDf Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPDfErrorCnt; ///< Reg 287. PDf Counter for bad SPI transmission b/w FPGA and sensor U16 fpgaPtmPressure; ///< Reg 288. Ptm MPM pressure sensor RAW pressure data U16 fpgaPtmTemp; ///< Reg 290. Ptm MPM pressure sensor RAW temperature data U08 fpgaPtmReadCnt; ///< Reg 292. Ptm Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPtmErrorCnt; ///< Reg 293. Ptm Counter for bad SPI transmission b/w FPGA and sensor U16 fpgaPRiPressure; ///< Reg 294. PRi MPM pressure sensor RAW pressure data U16 fpgaPRiTemp; ///< Reg 296. PRi MPM pressure sensor RAW temperature data U08 fpgaPRiReadCnt; ///< Reg 298. PRi Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPRiErrorCnt; ///< Reg 299. Pri Counter for bad SPI transmission b/w FPGA and sensor U16 fpgaPRoPressure; ///< Reg 300. PRo MPM pressure sensor RAW pressure data U16 fpgaPRoTemp; ///< Reg 302. PRo MPM pressure sensor RAW temperature data U08 fpgaPRoReadCnt; ///< Reg 304. PRo Counter for good SPI transmission b/w FPGA and sensor U08 fpgaPRoErrorCnt; ///< Reg 305. PRo Counter for bad SPI transmission b/w FPGA and sensor U32 fpgaCD1DataOut; ///< Reg 306. Data read from Conductivity Sensor 1 register U16 fpgaCD1Cond; ///< Reg 310. CD1 conductivity U16 fpgaCD1Temp; ///< Reg 312. CD1 Temperature U08 fpgaCD1ReadCnt; ///< Reg 314. CD1 successful read count U08 fpgaCD1ErrorCnt; ///< Reg 315. CD1 error read count U32 fpgaCD2DataOut; ///< Reg 316. Data read from Conductivity Sensor 2 register U16 fpgaCD2Cond; ///< Reg 320. CD2 conductivity U16 fpgaCD2Temp; ///< Reg 322. CD2 Temperature U08 fpgaCD2ReadCnt; ///< Reg 324. CD2 successful read count U08 fpgaCD2ErrorCnt; ///< Reg 325. CD2 error read count U32 fpgaCD3DataOut; ///< Reg 326. Data read from Conductivity Sensor 3 register U16 fpgaCD3Cond; ///< Reg 330. CD3 conductivity U16 fpgaCD3Temp; ///< Reg 332. CD3 Temperature U08 fpgaCD3ReadCnt; ///< Reg 334. CD3 successful read count U08 fpgaCD3ErrorCnt; ///< Reg 335. CD3 error read count U32 fpgaCD4DataOut; ///< Reg 336. Data read from Conductivity Sensor 4 register U16 fpgaCD4Cond; ///< Reg 340. CD4 conductivity U16 fpgaCD4Temp; ///< Reg 342. CD4 Temperature U08 fpgaCD4ReadCnt; ///< Reg 344. CD4 successful read count U08 fpgaCD4ErrorCnt; ///< Reg 345. CD4 error read count U16 fpgaLevelSensor1; ///< Reg 346. Level Sensor 1 U16 fpgaLevelSensor2; ///< Reg 348. Level Sensor 2 U08 fpgaHallSensInputs; ///< Reg 350. Hall sensor Inputs U08 fpgaBldTxFIFOCnt; ///< Reg 351. Blood leak sensor transmit FIFO count U16 fpgaBldRxErrorCnt; ///< Reg 352. Blood leak sensor Receive error count U16 fpgaBldRxFIFOCnt; ///< Reg 354. Blood leak sensor Receive FIFO count U08 fpgaBldRxFIFODataOut; ///< Reg 356. Blood leak sensor Receive data U08 fpgaBldPulseStatus; ///< Reg 357. Blood leak sensor status U16 fpgaValveStates; ///< Reg 358. Valve status read U16 fpgaValvePWMEnableStates; ///< Reg 360. Valve PWM Enable status read U08 fpgaValveBCStates; ///< Reg 362. Balancing chamber Valves states U08 fpgaValveBCPWMStates; ///< Reg 363. Balancing Chamber Valve PWM states U08 fpgaValveUFStates; ///< Reg 364. Ultrafiltration Valves states U08 fpgaValveUFPWMStates; ///< Reg 365. Ultrafiltration Valves PWM states U08 fpgaCPACPBFault; ///< Reg 366. Concentrate pump fault register for CPA and CPB U16 fpgaCPAHallSense; ///< Reg 367. Concentrate pump CPA hall sensor pulse width U16 fpgaCPBHallSense; ///< Reg 369. Concentrate pump CPB hall sensor pulse width F32 fpgaTax1Temp; ///< Reg 371. Inlet heat exchanger temperature F32 fpgaTH2Temp; ///< Reg 375. Inlet heat exchanger temperature F32 fpgaTH1Temp; ///< Reg 379. Hydraulics primary heater temperature F32 fpgaTH3Temp; ///< Reg 383. Trimmer heater temperature U08 fpgaRTDReadCnt; ///< Reg 387. Read count for all RTD sensors U08 fpgaBaroReadCount; ///< Reg 388. Barometric sensor read count U08 fpgaBaroErrorCount; ///< Reg 389. Barometric sensor error count U16 fpgaBaroManufacInfo; ///< Reg 390. Barometric sensor manufacturing information U16 fpgaBaroPROMCoeff1; ///< Reg 392. Barometric sensor PROM coefficient 1 U16 fpgaBaroPROMCoeff2; ///< Reg 394. Barometric sensor PROM coefficient 2 U16 fpgaBaroPROMCoeff3; ///< Reg 396. Barometric sensor PROM coefficient 3 U16 fpgaBaroPROMCoeff4; ///< Reg 398. Barometric sensor PROM coefficient 4 U16 fpgaBaroPROMCoeff5; ///< Reg 400. Barometric sensor PROM coefficient 5 U16 fpgaBaroPROMCoeff6; ///< Reg 402. Barometric sensor PROM coefficient 6 U16 fpgaBaroPROMCRC; ///< Reg 404. Barometric sensor PROM CRC U32 fpgaBaroPressure; ///< Reg 406. Barometric sensor pressure value U32 fpgaBaroTemperature; ///< Reg 410. Barometric sensor temperature sensor U16 fpgaDGPMeasuredSpeed; ///< Reg 414. Fresh dialysate pump measured speed U16 fpgaSDPMeasuredSpeed; ///< Reg 416. Spent dialysate pump measured speed U08 fpgaDGPSDPPumpStatus; ///< Reg 418. Dialysate pumps Error status U16 fpgaDGPCurrentFeedback; ///< Reg 419. Fresh dialysate pump current feedback U16 fpgaSDPCurrentFeedback; ///< Reg 421. Spent dialysate pump current feedback U08 fpgaDGPHallStatus; ///< Reg 423. Fresh dialysate pump hall sensor direction status U08 fpgaSDPHallStatus; ///< Reg 424. Spent dialysate pump hall sensor direction status U08 fpgaFloater1Status; ///< Reg 425. Floater 1 level sensor status U08 fpgaFloater2Status; ///< Reg 426. Floater 2 level sensor status } DD_FPGA_SENSORS_T; typedef struct { U16 fpgaValveControl; ///< Reg 04. Valve control register U16 fpgaValvePWMEnable; ///< Reg 06. Valve PWM enable U16 fpgaVDrPWMLow; ///< Reg 08. VDr PWM low. VDo-> VDr. U16 fpgaVDrPWMPeriod; ///< Reg 10. VDr PWM period U16 fpgaVDrPWMPullin; ///< Reg 12. VDr PWM pull in U16 fpgaVTDWMLow; ///< Reg 14. VTD PWM low U16 fpgaVTDPWMPeriod; ///< Reg 16. VTD PWM period U16 fpgaVTDPWMPullin; ///< Reg 18. VTD PWM pull in U16 fpgaVHBPWMLow; ///< Reg 20. VHB PWM low U16 fpgaVHBPWMPeriod; ///< Reg 22. VHB PWM period U16 fpgaVHBPWMPullin; ///< Reg 24. VHB PWM pull in U16 fpgaVrpPWMLow; ///< Reg 26. Vrp PWM low U16 fpgaVrpPWMPeriod; ///< Reg 28. Vrp PWM period U16 fpgaVrpPWMPullin; ///< Reg 30. Vrp PWM pull in U16 fpgaVHoPWMLow; ///< Reg 32. VHo PWM low U16 fpgaVHoPWMPeriod; ///< Reg 34. VHo PWM period U16 fpgaVHoPWMPullin; ///< Reg 36. VHo PWM pull in U16 fpgaVDB1PWMLow; ///< Reg 38. VDB1 PWM low U16 fpgaVDB1PWMPeriod; ///< Reg 40. VDB1 PWM period U16 fpgaVDB1PWMPullin; ///< Reg 42. VDB1 PWM pull in U16 fpgaVP1PWMLow; ///< Reg 44. VP1 PWM low U16 fpgaVP1PWMPeriod; ///< Reg 46. VP1 PWM period U16 fpgaVP1PWMPullin; ///< Reg 48. VP1 PWM pull in U16 fpgaVPTPWMLow; ///< Reg 50. VPT PWM Low U16 fpgaVPTPWMPeriod; ///< Reg 52. VPT PWM period U16 fpgaVPTPWMPullin; ///< Reg 54. VPT PWM pull in U16 fpgaVDB2PWMLow; ///< Reg 56. VDB2 PWM low U16 fpgaVDB2PWMPeriod; ///< Reg 58. VDB2 PWM period U16 fpgaVDB2PWMPullin; ///< Reg 60. VDB2 PWM pull in U16 fpgaVDiPWMLow; ///< Reg 62. VDi PWM low U16 fpgaVDiPWMPeriod; ///< Reg 64. VDi PWM period U16 fpgaVDiPWMPullin; ///< Reg 66. VDi PWM pull in U16 fpgaVDoPWMLow; ///< Reg 68. VDo PWM low U16 fpgaVDoPWMPeriod; ///< Reg 70. VDo PWM period U16 fpgaVDoPWMPullin; ///< Reg 72. VDo PWM pull in U16 fpgaVP2PWMLow; ///< Reg 74. VP2 PWM low U16 fpgaVP2PWMPeriod; ///< Reg 76. VP2 PWM period U16 fpgaVP2PWMPullin; ///< Reg 78. VP2 PWM pull in U16 fpgaVHiPWMLow; ///< Reg 80. VHi PWM low U16 fpgaVHiPWMPeriod; ///< Reg 82. VHi PWM period U16 fpgaVHiPWMPullin; ///< Reg 84. VHi PWM pull in U16 fpgaVWiPWMLow; ///< Reg 86. VWi PWM low U16 fpgaVWiPWMPeriod; ///< Reg 88. VWi PWM period U16 fpgaVWiPWMPullin; ///< Reg 90. VWi PWM pull in U08 fpgaBCValveControl; ///< Reg 92. Balancing Chamber Valves Control Registers U08 fpgaBCValvePWMControl; ///< Reg 93. Balancing Chamber Valves PWM control U08 fpgaUFValveControl; ///< Reg 94. Ultra filtration Valves Control Registers U08 fpgaUFValvePWMControl; ///< Reg 95. Ultra filtration Valves PWM control U08 fpgaConSensTD12Control; ///< Reg 96. Conductivity/Temperature Sensors 1 & 2 Control registers U08 fpgaConSensTD34Control; ///< Reg 97. Conductivity/Temperature Sensors 3 & 4 Control registers U16 fpgaConSensTD12_Addrs; ///< Reg 98. CDTD 1&2 Initialization Address register U32 fpgaConSensTD12_Data_In; ///< Reg 100. CDTD 1&2 Initialization data register U16 fpgaConSensTD34_Addrs; ///< Reg 104. CDTD 3&4 Initialization Address register U32 fpgaConSensTD34_Data_In; ///< Reg 106. CDTD 3&4 Initialization data register U16 fpgaRemoteUpdate_Write; ///< Reg 110.Register for Remote update used by SW. U16 fpgaDGPSpeed; ///< Reg 112. DGP Speed/RPM Control U08 fpgaDGPControl; ///< Reg 114. DGP Control U08 fpgaSDPControl; ///< Reg 115. SDP Control U16 fpgaSDPSpeed; ///< Reg 116. SDP Speed/RPM Control U16 fpgaCPASpeed; ///< Reg 118. Acid Concentrate Pump Speed/RPM Control U08 fpgaCPAControl; ///< Reg 120. Acid Concentrate Pump Control U08 fpgaCPBControl; ///< Reg 121. BiCarb Concentrate Pump Control U16 fpgaCPBSpeed; ///< Reg 122. BiCarb Concentrate Pump Speed/RPM Control U08 fpgaBloodLeakSensorTest; ///< Reg 124. Blood leak sensor test U08 fpgaBloodLeakUARTControl; ///< Reg 125. Blood leak sensor UART control U08 fpgaBloodLeakFIFOTx; ///< Reg 126. Blood leak sensor FIFO transmit control U08 fpgaPrimaryHeaterPWMControl; ///< Reg 127. Primary heater PWM control U08 fpgaTrimmerHeaterPWMControl; ///< Reg 128. Trimmer heater PWM 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 THd control register to 0x1 to make sure its ADC is running //fpgaActuatorSetPoints.fpgaTHdControlReg = FPGA_THD_CONTROL_COMMAND; // 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.fpgaUFValveControl = FPGA_ENABLE_UF_VALVES_CONTROL; fpgaActuatorSetPoints.fpgaUFValvePWMControl = FPGA_ENABLE_UF_VALVES_PWM; // 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 ) ) { 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 setFPGAValveStates 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 - VDr/VDo.\n * 1 - VTD.\n * 2 - VHB.\n * 3 - Vrp.\n * 4 - VHo.\n * 5 - VDB1.\n * 6 - VP1.\n * 7 - VPT.\n * 8 - VDB2.\n * 9 - VDi.\n * 10 - VDo.\n * 11 - VP2.\n * 12 - VHi.\n * 13 - VWi.\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 setFPGAValveStates( 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 - V1.\n * 1 - V2.\n * 2 - V3.\n * 3 - V4.\n * 4 - V5.\n * 5 - V6.\n * 6 - V7.\n * 7 - V8.\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 setFPGAUFValveStates function sets the DD ultrafiltration 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 - UFi1.\n * 1 - UFi2.\n * 2 - UFo1.\n * 3 - UFo2.\n * 4..7 - Unused or reserved.\n * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaUFValveControl * @param valveStates bit mask for the balancing chamber valve states * @return none *************************************************************************/ void setFPGAUFValveStates( U08 valveStates ) { fpgaActuatorSetPoints.fpgaUFValveControl = valveStates; } /*********************************************************************//** * @brief * The setFPGASpentDialysatePumpSpeed function sets the speed for the * spent dialysate pump (SDP). * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaSDPSpeed * @param speed The spent dialysate pump speed * @return none *************************************************************************/ void setFPGASpentDialysatePumpSpeed( U16 speed ) { fpgaActuatorSetPoints.fpgaSDPSpeed = speed; } /*********************************************************************//** * @brief * The setFPGAFreshDialysatePumpSpeed function sets the speed for the * fresh dialysate pump (DGP). * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDGPSpeed * @param speed The fresh dialysate pump speed * @return none *************************************************************************/ void setFPGAFreshDialysatePumpSpeed( U16 speed ) { fpgaActuatorSetPoints.fpgaDGPSpeed = speed; } /*********************************************************************//** * @brief * The setFPGASpentDialysatePumpControl function sets the controls for * dialysate out pump (SDP). * 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.fpgaSDPControl * @param control The dialysate out pump controls * @return none *************************************************************************/ void setFPGASpentDialysatePumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaSDPControl = control; } /*********************************************************************//** * @brief * The setFPGAFreshDialysatePumpControl function sets the controls for * dialysate In pump (DGP). * 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.fpgaDGPControl * @param control The dialysate In pump controls * @return none *************************************************************************/ void setFPGAFreshDialysatePumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaDGPControl = control; } /*********************************************************************//** * @brief * The setFPGAAcidPumpSetStepSpeed function sets the step speed period for * concentrate pump CPA. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaCPASpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ void setFPGAAcidPumpSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaCPASpeed = stepSpeed; } /*********************************************************************//** * @brief * The setFPGABicarbSetStepSpeed function sets the step speed period for * concentrate pump CPB. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaCPBSpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ void setFPGABicarbSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaCPBSpeed = stepSpeed; } /*********************************************************************//** * @brief * The setFPGAAcidPumpControl 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.fpgaCPAControl * @param control Concentrate pump control set * @return none *************************************************************************/ void setFPGAAcidPumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaCPAControl &= FPGA_CONC_PUMP_PARK_COMMAND; // preserve msb (park command bit) fpgaActuatorSetPoints.fpgaCPAControl |= control; } /*********************************************************************//** * @brief * The setFPGABicarbPumpControl 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.fpgaCPBControl * @param control Concentrate pump control set * @return none *************************************************************************/ void setFPGABicarbPumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaCPBControl &= FPGA_CONC_PUMP_PARK_COMMAND; // preserve msb (park command bit) fpgaActuatorSetPoints.fpgaCPBControl |= control; } /*********************************************************************//** * @brief * The setFPGAAcidPumpParkCmd 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.fpgaCPAControl * @param Park command bit set * @return none *************************************************************************/ void setFPGAAcidPumpParkCmd( void ) { fpgaActuatorSetPoints.fpgaCPAControl |= FPGA_CONC_PUMP_PARK_COMMAND; // this bit must be cleared after next transmit to prevent continuous park commands } /*********************************************************************//** * @brief * The setFPGABicarbPumpParkCmd 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.fpgaCPBControl * @param Park command bit set * @return none *************************************************************************/ void setFPGABicarbPumpParkCmd( void ) { fpgaActuatorSetPoints.fpgaCPBControl |= FPGA_CONC_PUMP_PARK_COMMAND; // this bit must be cleared after next transmit to prevent continuous park commands } /*********************************************************************//** * @brief * The setFPGACD1Reset function resets the FPGA Conductivity * Sensor CD1. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void setFPGACD1Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD1_RESET_BIT; } /*********************************************************************//** * @brief * The clearFPGACD1Reset function clears the reset of FPGA Conductivity * Sensor CD1. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD1Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD1_RESET_BIT; } /*********************************************************************//** * @brief * The setFPGACD1InitEnable function enables the FPGA Conductivity * Sensor CD1 initialzation procedure. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void setFPGACD1InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD1_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD1InitEnable function clears the init process of FPGA Conductivity * Sensor CD1. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD1InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD1_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD1WriteEnable function enables the FPGA Conductivity * Sensor CD1 write transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @warning: The address (setFPGACD12Address) and data (setFPGACD12Data) register * must be populated before invoking this write enable function to initiate * write transaction with the sensor. * @return none *************************************************************************/ void setFPGACD1WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD1_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD1WriteEnable function clears the write enable of FPGA Conductivity * Sensor CD1. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD1WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD1_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD1ReadEnable function enables the FPGA Conductivity * Sensor CD1 read transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @warning: The address (setFPGACD12Address) register must be populated * before invoking this read enable function to initiate read transaction * with the sensor. * @return none *************************************************************************/ void setFPGACD1ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD1_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD1ReadEnable function clears the read enable of FPGA Conductivity * Sensor CD1. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD1ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD1_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD2Reset function resets the FPGA Conductivity * Sensor CD2. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void setFPGACD2Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD2_RESET_BIT; } /*********************************************************************//** * @brief * The clearFPGACD2Reset function clears the reset of FPGA Conductivity * Sensor CD2. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD2Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD2_RESET_BIT; } /*********************************************************************//** * @brief * The setFPGACD2InitEnable function enables the FPGA Conductivity * Sensor CD2 initialzation procedure. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void setFPGACD2InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD2_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD2InitEnable function clears the init process of FPGA Conductivity * Sensor CD2. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD2InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD2_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD2WriteEnable function enables the FPGA Conductivity * Sensor CD2 write transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @warning: The address (setFPGACD12Address) and data (setFPGACD12Data) register * must be populated before invoking this write enable function to initiate * write transaction with the sensor. * @return none *************************************************************************/ void setFPGACD2WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD2_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD2WriteEnable function clears the write enable of FPGA Conductivity * Sensor CD2. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD2WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD2_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD2ReadEnable function enables the FPGA Conductivity * Sensor CD2 read transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @warning: The address (setFPGACD12Address) register must be populated * before invoking this read enable function to initiate read transaction * with the sensor. * @return none *************************************************************************/ void setFPGACD2ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control |= FPGA_CD2_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD2ReadEnable function clears the read enable of FPGA Conductivity * Sensor CD2. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param none * @return none *************************************************************************/ void clearFPGACD2ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD12Control &= ~FPGA_CD2_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGCD3Reset function resets the FPGA Conductivity * Sensor CD3. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void setFPGACD3Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD3_RESET_BIT; } /*********************************************************************//** * @brief * The clearFPGACD3Reset function clears the reset of FPGA Conductivity * Sensor CD3. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD3Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD3_RESET_BIT; } /*********************************************************************//** * @brief * The setFPGACD3InitEnable function enables the FPGA Conductivity * Sensor CD3 initialzation procedure. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void setFPGACD3InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD3_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD3InitEnable function clears the init process of FPGA Conductivity * Sensor CD3. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD3InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD3_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD3WriteEnable function enables the FPGA Conductivity * Sensor CD3 write transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @warning: The address (setFPGACD12Address) and data (setFPGACD12Data) register * must be populated before invoking this write enable function to initiate * write transaction with the sensor. * @return none *************************************************************************/ void setFPGACD3WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD3_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD3WriteEnable function clears the write enable of FPGA Conductivity * Sensor CD3. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD3WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD3_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD3ReadEnable function enables the FPGA Conductivity * Sensor CD3 read transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @warning: The address (setFPGACD12Address) register must be populated * before invoking this read enable function to initiate read transaction * with the sensor. * @return none *************************************************************************/ void setFPGACD3ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD3_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD3ReadEnable function clears the read enable of FPGA Conductivity * Sensor CD3. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD3ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD3_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD4Reset function resets the FPGA Conductivity * Sensor CD4. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void setFPGACD4Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD4_RESET_BIT; } /*********************************************************************//** * @brief * The clearFPGACD4Reset function clears the reset of FPGA Conductivity * Sensor CD4. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD4Reset( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD4_RESET_BIT; } /*********************************************************************//** * @brief * The setFPGACD4InitEnable function enables the FPGA Conductivity * Sensor CD4 initialzation procedure. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void setFPGACD4InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD4_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD4InitEnable function clears the init process of FPGA Conductivity * Sensor CD4. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD4InitEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD4_INIT_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD4WriteEnable function enables the FPGA Conductivity * Sensor CD4 write transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @warning: The address (setFPGACD12Address) and data (setFPGACD12Data) register * must be populated before invoking this write enable function to initiate * write transaction with the sensor. * @return none *************************************************************************/ void setFPGACD4WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD4_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD4WriteEnable function clears the write enable of FPGA Conductivity * Sensor CD4. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD4WriteEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD4_WR_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFPGACD4ReadEnable function enables the FPGA Conductivity * Sensor CD4 read transaction. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @warning: The address (setFPGACD12Address) register must be populated * before invoking this read enable function to initiate read transaction * with the sensor. * @return none *************************************************************************/ void setFPGACD4ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control |= FPGA_CD4_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The clearFPGACD4ReadEnable function clears the read enable of FPGA Conductivity * Sensor CD4. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param none * @return none *************************************************************************/ void clearFPGACD4ReadEnable( void ) { fpgaActuatorSetPoints.fpgaConSensTD34Control &= ~FPGA_CD4_RD_ENABLE_BIT; } /*********************************************************************//** * @brief * The setFpgaCD12Control function sets the FPGA Conductivity * Sensor control register for CD1&2. * bit 7: Enables TD2 read transaction (1), address needed * bit 6: Enables TD2 write transaction (1), address and data needs to be set * bit 5: Enable TD2 Init procedure (1) * bit 4: reset TD2 Conduct sensor (1) * bit 3: Enables TD1 read transaction (1), address needed * bit 2: Enables TD1 write transaction (1), address and data needs to be set * bit 1: Enable TD1 Init procedure (1) * bit 0: reset TD1 Conduct sensor (1) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12Control * @param control Conductivity Sensor control set * @return none *************************************************************************/ void setFPGACD12Control( U08 control ) { fpgaActuatorSetPoints.fpgaConSensTD12Control = control; } /*********************************************************************//** * @brief * The setFpgaCD34Control function sets the FPGA Conductivity * Sensor control register for CD3&4. * bit 7: Enables TD4 read transaction (1), address needed * bit 6: Enables TD4 write transaction (1), address and data needs to be set * bit 5: Enable TD4 Init procedure (1) * bit 4: reset TD4 Conduct sensor (1) * bit 3: Enables TD3 read transaction (1), address needed * bit 2: Enables TD3 write transaction (1), address and data needs to be set * bit 1: Enable TD3 Init procedure (1) * bit 0: reset TD3 Conduct sensor (1) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34Control * @param control Conductivity sensor control set * @return none *************************************************************************/ void setFPGACD34Control( U08 control ) { fpgaActuatorSetPoints.fpgaConSensTD34Control = control; } /*********************************************************************//** * @brief * The setFPGACD12Address function sets the conductivity sensor * CD12 address register to perform read and write operations. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12_Addrs * @param address The conductivity sensor CD12 address * @return none *************************************************************************/ void setFPGACD12Address( U16 address ) { fpgaActuatorSetPoints.fpgaConSensTD12_Addrs = address; } /*********************************************************************//** * @brief * The setFPGACD34Address function sets the conductivity sensor * CD34 address register to perform read and write operations. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34_Addrs * @param address The conductivity sensor CD34 address * @return none *************************************************************************/ void setFPGACD34Address( U16 address ) { fpgaActuatorSetPoints.fpgaConSensTD34_Addrs = address; } /*********************************************************************//** * @brief * The setFPGACD12Data function sets the conductivity sensor * CD12 data outputfor write operations. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12_Data_In * @param data The conductivity sensor CD12 Data * @return none *************************************************************************/ void setFPGACD12Data( U32 data ) { fpgaActuatorSetPoints.fpgaConSensTD12_Data_In = data; } /*********************************************************************//** * @brief * The setFPGACD34Data function sets the conductivity sensor * CD34 data outputfor write operations. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34_Data_In * @param data The conductivity sensor CD34 Data * @return none *************************************************************************/ void setFPGACD34Data( U32 data ) { fpgaActuatorSetPoints.fpgaConSensTD34_Data_In = data; } /*********************************************************************//** * @brief * The setFPGAPrimaryHeaterPWMControl function sets the primary heater * PWM input. * @details \b Inputs: none * @details \b Outputs: fpgaPrimaryHeaterPWMControl * @param control the PWM dutycycle to control the heater * @return none *************************************************************************/ void setFPGAPrimaryHeaterPWMControl( U08 control ) { fpgaActuatorSetPoints.fpgaPrimaryHeaterPWMControl = control; } /*********************************************************************//** * @brief * The setFPGATrimmerHeaterPWMControl function sets the trimmer heater * PWM input. * @details \b Inputs: none * @details \b Outputs: fpgaTrimmerHeaterPWMControl * @param control the PWM dutycycle to control the heater * @return none *************************************************************************/ void setFPGATrimmerHeaterPWMControl( U08 control ) { fpgaActuatorSetPoints.fpgaTrimmerHeaterPWMControl = control; } /*********************************************************************//** * @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 getFPGASpentDialysatePumpControl 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.fpgaSDPControl * @return Dialysate Out pump control status bit *************************************************************************/ U08 getFPGASpentDialysatePumpControl( void ) { return fpgaActuatorSetPoints.fpgaSDPControl; } /*********************************************************************//** * @brief * The getFPGAFreshDialysatePumpControl 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.fpgaDGPControl * @return Dialysate Inlet pump control status bit *************************************************************************/ U08 getFPGAFreshDialysatePumpControl( void ) { return fpgaActuatorSetPoints.fpgaDGPControl; } /*********************************************************************//** * @brief * The getFPGASpentDialysatePumpSpeed function gets the spent dialysate * pump speed. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaSDPMeasuredSpeed * @return Spent dialysate pump measured speed. *************************************************************************/ U16 getFPGASpentDialysatePumpSpeed( void ) { return fpgaSensorReadings.fpgaSDPMeasuredSpeed; } /*********************************************************************//** * @brief * The getFPGAFreshDialysatePumpSpeed function gets the fresh dialysate * pump speed. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaDGPMeasuredSpeed * @return fresh dialysate pump measured speed. *************************************************************************/ U16 getFPGAFreshDialysatePumpSpeed( void ) { return fpgaSensorReadings.fpgaDGPMeasuredSpeed; } /*********************************************************************//** * @brief * The getFPGAFreshDialysatePumpErrorStatus 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.fpgaDGPSDPPumpStatus * @return fresh dialysate pump error status. *************************************************************************/ BOOL getFPGAFreshDialysatePumpErrorStatus( void ) { U08 mask = fpgaSensorReadings.fpgaDGPSDPPumpStatus & FPGA_DGP_PUMP_ERROR_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGASpentDialysatePumpErrorStatus 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.fpgaDGPSDPPumpStatus * @return spent dialysate pump error status. *************************************************************************/ BOOL getFPGASpentDialysatePumpErrorStatus( void ) { U08 mask = fpgaSensorReadings.fpgaDGPSDPPumpStatus & FPGA_SDP_PUMP_ERROR_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAFreshDialysatePumpCurrentFeedback function gets the fresh dialysate * pump current consumption. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaDGPCurrentFeedback * @return fresh dialysate pump measured current. *************************************************************************/ U16 getFPGAFreshDialysatePumpCurrentFeedback( void ) { return fpgaSensorReadings.fpgaDGPCurrentFeedback; } /*********************************************************************//** * @brief * The getFPGASpentDialysatePumpCurrentFeedback function gets the spent dialysate * pump current consumption. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaSDPCurrentFeedback * @return spent dialysate pump measured current. *************************************************************************/ U16 getFPGASpentDialysatePumpCurrentFeedback( void ) { return fpgaSensorReadings.fpgaSDPCurrentFeedback; } /*********************************************************************//** * @brief * The getFPGAFreshDialysatePumpHallDirectionStatus function gets the fresh dialysate * pump hall sensor based direction error status. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaDGPHallStatus * @return fresh dialysate pump hall sensor based direction status. *************************************************************************/ U08 getFPGAFreshDialysatePumpHallDirectionStatus( void ) { return fpgaSensorReadings.fpgaDGPHallStatus; } /*********************************************************************//** * @brief * The getFPGASpentDialysatePumpHallDirectionStatus function gets the spent dialysate * pump hall sensor based direction error status. * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.fpgaSDPHallStatus * @return spent dialysate pump hall sensor based direction status. *************************************************************************/ U08 getFPGASpentDialysatePumpHallDirectionStatus( void ) { return fpgaSensorReadings.fpgaSDPHallStatus; } /*********************************************************************//** * @brief * The getFPGAAcidPumpControlStatus 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.fpgaCPAControl * @return Acid pump control status bit *************************************************************************/ U08 getFPGAAcidPumpControlStatus( void ) { return fpgaActuatorSetPoints.fpgaCPAControl; } /*********************************************************************//** * @brief * The getFPGABicarbPumpControlStatus 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.fpgaCPBControl * @return Bicarb pump control status bit *************************************************************************/ U08 getFPGABicarbPumpControlStatus( void ) { return fpgaActuatorSetPoints.fpgaCPBControl; } /*********************************************************************//** * @brief * The getFPGAConcentratePumpsFault function gets concentrate pumps fault * reported by FGPA. * @details \b Inputs: fpgaSensorReadings.fpgaCPACPBFault * @details \b Outputs: none * @return Latest concentrate pumps fault value *************************************************************************/ U08 getFPGAConcentratePumpsFault( void ) { return fpgaSensorReadings.fpgaCPACPBFault & FPGA_CONC_PUMP_FAULT_BITS; } /*********************************************************************//** * @brief * The getFPGAAcidPumpIsParked function gets whether the acid pump is currently * parked. * @details \b Inputs: fpgaSensorReadings.fpgaCPACPBFault * @details \b Outputs: none * @return TRUE if acid pump is parked, FALSE if not *************************************************************************/ BOOL getFPGAAcidPumpIsParked( void ) { U08 mask = fpgaSensorReadings.fpgaCPACPBFault & FPGA_CPA_PARKED_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGABicarbPumpIsParked function gets whether the bicarb pump is currently * parked. * @details \b Inputs: fpgaSensorReadings.fpgaCPACPBFault * @details \b Outputs: none * @return TRUE if bicarb pump is parked, FALSE if not *************************************************************************/ BOOL getFPGABicarbPumpIsParked( void ) { U08 mask = fpgaSensorReadings.fpgaCPACPBFault & FPGA_CPB_PARKED_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGAAcidPumpParkFault function gets whether the acid pump park command * has faulted. * @details \b Inputs: fpgaSensorReadings.fpgaCPACPBFault * @details \b Outputs: none * @return TRUE if acid pump park command faulted, FALSE if not *************************************************************************/ BOOL getFPGAAcidPumpParkFault( void ) { U08 mask = fpgaSensorReadings.fpgaCPACPBFault & FPGA_CPA_PARK_FAULT_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGABicarbPumpParkFault function gets whether the bicarb pump park command * has faulted. * @details \b Inputs: fpgaSensorReadings.fpgaCPACPBFault * @details \b Outputs: none * @return TRUE if bicarb pump park command faulted, FALSE if not *************************************************************************/ BOOL getFPGABicarbPumpParkFault( void ) { U08 mask = fpgaSensorReadings.fpgaCPACPBFault & FPGA_CPB_PARK_FAULT_BIT; BOOL result = ( mask > 0 ? TRUE : FALSE ); return result; } /*********************************************************************//** * @brief * The getFPGACPAHallSensePulseWidth function gets concentrate pump CPA * hall sense pulse width. * @details \b Inputs: fpgaSensorReadings.fpgaCPAHallSense * @details \b Outputs: none * @return concentrate pump CPA hall sense pulse width *************************************************************************/ U16 getFPGACPAHallSensePulseWidth( void ) { return fpgaSensorReadings.fpgaCPAHallSense; } /*********************************************************************//** * @brief * The getFPGACPBHallSensePulseWidth function gets concentrate pump CPB * hall sense pulse width. * @details \b Inputs: fpgaSensorReadings.fpgaCPBHallSense * @details \b Outputs: none * @return concentrate pump CPB hall sense pulse width *************************************************************************/ U16 getFPGACPBHallSensePulseWidth( void ) { return fpgaSensorReadings.fpgaCPBHallSense; } /*********************************************************************//** * @brief * The getFPGAValveStates function gets the latest sensed valve states. * See setFPGAValveStates for valve state bit positions. * @details \b Inputs: fpgaSensorReadings.fpgaValveStates * @details \b Outputs: none * @return last valve states reading *************************************************************************/ U16 getFPGAValveStates( 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 getFPGAValveUFStates function gets the latest sensed ultrafiltration * valve states. * See setFPGAUFValveStates for UF valve state bit positions. * @details \b Inputs: fpgaSensorReadings.fpgaValveUFStates * @details \b Outputs: none * @return last ultrafiltration valve states reading *************************************************************************/ U08 getFPGAValveUFStates( void ) { return fpgaSensorReadings.fpgaValveUFStates; } /*********************************************************************//** * @brief * The getFPGAPnReadCount function gets hydraulics outlet pressure sensor counter of * good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPnReadCnt * @details \b Outputs: none * @return Latest hydraulics outlet Pressure sensor read count *************************************************************************/ U08 getFPGAPnReadCount( void ) { return fpgaSensorReadings.fpgaPnReadCnt; } /*********************************************************************//** * @brief * The getFPGAPnErrorCount function gets hydraulics outlet pressure sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPnErrorCnt * @details \b Outputs: none * @return Latest hydraulics outlet pressure sensor read error count *************************************************************************/ U08 getFPGAPnErrorCount( void ) { return fpgaSensorReadings.fpgaPnErrorCnt; } /*********************************************************************//** * @brief * The getFPGAPnRawPressure function gets hydraulics outlet pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPnPressure * @details \b Outputs: none * @return Latest hydraulics outlet pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPnRawPressure( void ) { return fpgaSensorReadings.fpgaPnPressure; } /*********************************************************************//** * @brief * The getFPGAPnRawTemperature function gets hydraulics outlet pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPnTemp * @details \b Outputs: none * @return Latest hydraulics outlet pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPnRawTemperature( void ) { return fpgaSensorReadings.fpgaPnTemp; } /*********************************************************************//** * @brief * The getFPGAPCbReadCount function gets Bibag pressure sensor counter of * good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPCbReadCnt * @details \b Outputs: none * @return Latest Bibag Pressure sensor read count *************************************************************************/ U08 getFPGAPCbReadCount( void ) { return fpgaSensorReadings.fpgaPCbReadCnt; } /*********************************************************************//** * @brief * The getFPGAPCbErrorCount function gets Bibag pressure sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPCbErrorCnt * @details \b Outputs: none * @return Latest Bibag pressure sensor read error count *************************************************************************/ U08 getFPGAPCbErrorCount( void ) { return fpgaSensorReadings.fpgaPCbErrorCnt; } /*********************************************************************//** * @brief * The getFPGAPCbRawPressure function gets Bibag pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPCbPressure * @details \b Outputs: none * @return Latest Bibag pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPCbRawPressure( void ) { return fpgaSensorReadings.fpgaPCbPressure; } /*********************************************************************//** * @brief * The getFPGAPCbRawTemperature function gets Bibag pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPCbTemp * @details \b Outputs: none * @return Latest Bibag pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPCbRawTemperature( void ) { return fpgaSensorReadings.fpgaPCbTemp; } /*********************************************************************//** * @brief * The getFPGAPDsReadCount function gets spent dialysate pressure sensor counter of * good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPDsReadCnt * @details \b Outputs: none * @return Latest spent dialysate Pressure sensor read count *************************************************************************/ U08 getFPGAPDsReadCount( void ) { return fpgaSensorReadings.fpgaPDsReadCnt; } /*********************************************************************//** * @brief * The getFPGAPDsErrorCount function gets spent dialysate pressure sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPDsErrorCnt * @details \b Outputs: none * @return Latest spent dialysate pressure sensor read error count *************************************************************************/ U08 getFPGAPDsErrorCount( void ) { return fpgaSensorReadings.fpgaPDsErrorCnt; } /*********************************************************************//** * @brief * The getFPGAPDsRawPressure function gets spent dialysate pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPDsPressure * @details \b Outputs: none * @return Latest spent dialysate pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPDsRawPressure( void ) { return fpgaSensorReadings.fpgaPDsPressure; } /*********************************************************************//** * @brief * The getFPGAPDsRawTemperature function gets spent dialysate pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPDsTemp * @details \b Outputs: none * @return Latest spent dialysate pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPDsRawTemperature( void ) { return fpgaSensorReadings.fpgaPDsTemp; } /*********************************************************************//** * @brief * The getFPGAPDfReadCount function gets fresh dialysate pressure sensor counter of * good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPDfReadCnt * @details \b Outputs: none * @return Latest fresh dialysate Pressure sensor read count *************************************************************************/ U08 getFPGAPDfReadCount( void ) { return fpgaSensorReadings.fpgaPDfReadCnt; } /*********************************************************************//** * @brief * The getFPGAPDfErrorCount function gets fresh dialysate pressure sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPDfErrorCnt * @details \b Outputs: none * @return Latest fresh dialysate pressure sensor read error count *************************************************************************/ U08 getFPGAPDfErrorCount( void ) { return fpgaSensorReadings.fpgaPDfErrorCnt; } /*********************************************************************//** * @brief * The getFPGAPDfRawPressure function gets fresh dialysate pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPDfPressure * @details \b Outputs: none * @return Latest fresh dialysate pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPDfRawPressure( void ) { return fpgaSensorReadings.fpgaPDfPressure; } /*********************************************************************//** * @brief * The getFPGAPDfRawTemperature function gets fresh dialysate pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPDfTemp * @details \b Outputs: none * @return Latest fresh dialysate pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPDfRawTemperature( void ) { return fpgaSensorReadings.fpgaPDfTemp; } /*********************************************************************//** * @brief * The getFPGAPtmReadCount function gets transmembrane pressure sensor counter of * good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPtmReadCnt * @details \b Outputs: none * @return Latest transmembrane Pressure sensor read count *************************************************************************/ U08 getFPGAPtmReadCount( void ) { return fpgaSensorReadings.fpgaPtmReadCnt; } /*********************************************************************//** * @brief * The getFPGAPtmErrorCount function gets transmembrane pressure sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPtmErrorCnt * @details \b Outputs: none * @return Latest transmembrane pressure sensor read error count *************************************************************************/ U08 getFPGAPtmErrorCount( void ) { return fpgaSensorReadings.fpgaPtmErrorCnt; } /*********************************************************************//** * @brief * The getFPGAPtmRawPressure function gets transmembrane pressure sensor raw * pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPtmPressure * @details \b Outputs: none * @return Latest transmembrane pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPtmRawPressure( void ) { return fpgaSensorReadings.fpgaPtmPressure; } /*********************************************************************//** * @brief * The getFPGAPtmRawTemperature function gets transmembrane pressure sensor raw * temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPtmTemp * @details \b Outputs: none * @return Latest transmembrane pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPtmRawTemperature( void ) { return fpgaSensorReadings.fpgaPtmTemp; } /*********************************************************************//** * @brief * The getFPGAPRiRawPressure function gets water inlet input pressure sensor * raw pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPRiPressure * @details \b Outputs: none * @return Latest water inlet input pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPRiRawPressure( void ) { return fpgaSensorReadings.fpgaPRiPressure; } /*********************************************************************//** * @brief * The getFPGAPRiRawTemperature function gets water inlet input pressure sensor * raw temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPRiTemp * @details \b Outputs: none * @return Latest water inlet input pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPRiRawTemperature( void ) { return fpgaSensorReadings.fpgaPRiTemp; } /*********************************************************************//** * @brief * The getFPGAPRiReadCount function gets water inlet input pressure sensor * counter of good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPRiReadCnt * @details \b Outputs: none * @return Latest water inlet input pressure sensor read count *************************************************************************/ U08 getFPGAPRiReadCount( void ) { return fpgaSensorReadings.fpgaPRiReadCnt; } /*********************************************************************//** * @brief * The getFPGAPRiErrorCount function gets water inlet input pressure * sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPRiErrorCnt * @details \b Outputs: none * @return Latest water inlet input pressure sensor read error count *************************************************************************/ U08 getFPGAPRiErrorCount( void ) { return fpgaSensorReadings.fpgaPRiErrorCnt; } /*********************************************************************//** * @brief * The getFPGAPRoRawPressure function gets water inlet output pressure sensor * raw pressure value. * @details \b Inputs: fpgaSensorReadings.fpgaPRoPressure * @details \b Outputs: none * @return Latest water inlet output pressure sensor raw pressure data *************************************************************************/ U16 getFPGAPRoRawPressure( void ) { return fpgaSensorReadings.fpgaPRoPressure; } /*********************************************************************//** * @brief * The getFPGAPRoRawTemperature function gets water inlet output pressure sensor * raw temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaPRoTemp * @details \b Outputs: none * @return Latest water inlet output pressure sensor raw temperature data *************************************************************************/ U16 getFPGAPRoRawTemperature( void ) { return fpgaSensorReadings.fpgaPRoTemp; } /*********************************************************************//** * @brief * The getFPGAPRoReadCount function gets water inlet output pressure sensor * counter of good SPI transmissions between FPGA and Sensor. * @details \b Inputs: fpgaSensorReadings.fpgaPRoReadCnt * @details \b Outputs: none * @return Latest water inlet output pressure sensor read count *************************************************************************/ U08 getFPGAPRoReadCount( void ) { return fpgaSensorReadings.fpgaPRoReadCnt; } /*********************************************************************//** * @brief * The getFPGAPRoErrorCount function gets water inlet output pressure * sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaPRoErrorCnt * @details \b Outputs: none * @return Latest water inlet output pressure sensor read error count *************************************************************************/ U08 getFPGAPRoErrorCount( void ) { return fpgaSensorReadings.fpgaPRoErrorCnt; } /*********************************************************************//** * @brief * The getFPGACD1ReadCount function gets CD1 conductivity sensor read count. * @details \b Inputs: fpgaSensorReadings.fpgaCD1ReadCnt * @details \b Outputs: none * @return Latest CD1 conductivity sensor read count *************************************************************************/ U08 getFPGACD1ReadCount( void ) { return fpgaSensorReadings.fpgaCD1ReadCnt; } /*********************************************************************//** * @brief * The getFPGACD1ErrorCount function gets CD1 conductivity sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaCD1ErrorCnt * @details \b Outputs: none * @return Latest CD1 conductivity sensor read error count *************************************************************************/ U08 getFPGACD1ErrorCount( void ) { return fpgaSensorReadings.fpgaCD1ErrorCnt; } /*********************************************************************//** * @brief * The getFPGACD1 function gets CD1 conductivity sensor value. * @details \b Inputs: fpgaSensorReadings.fpgaCD1 * @details \b Outputs: none * @return Latest CD1 conductivity sensor value *************************************************************************/ U16 getFPGACD1( void ) { return fpgaSensorReadings.fpgaCD1Cond; } /*********************************************************************//** * @brief * The getFPGACD1Temp function gets CD1 conductivity sensor temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaCD1Temp * @details \b Outputs: none * @return Latest CD1 conductivity sensor temperature value *************************************************************************/ U16 getFPGACD1Temp( void ) { return fpgaSensorReadings.fpgaCD1Temp; } /*********************************************************************//** * @brief * The getFPGACD1Data function gets CD1 conductivity sensor register value. * @details \b Inputs: fpgaSensorReadings.fpgaCD1DataOut * @details \b Outputs: none * @return Latest CD1 conductivity sensor register data value *************************************************************************/ U32 getFPGACD1Data( void ) { return fpgaSensorReadings.fpgaCD1DataOut; } /*********************************************************************//** * @brief * The getFPGACD2ReadCount function gets CD2 conductivity sensor read count. * @details \b Inputs: fpgaSensorReadings.fpgaCD2ReadCnt * @details \b Outputs: none * @return Latest CD2 conductivity sensor read count *************************************************************************/ U08 getFPGACD2ReadCount( void ) { return fpgaSensorReadings.fpgaCD2ReadCnt; } /*********************************************************************//** * @brief * The getFPGACD2ErrorCount function gets CD2 conductivity sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaCD2ErrorCnt * @details \b Outputs: none * @return Latest CD2 conductivity sensor read error count *************************************************************************/ U08 getFPGACD2ErrorCount( void ) { return fpgaSensorReadings.fpgaCD2ErrorCnt; } /*********************************************************************//** * @brief * The getFPGACD2 function gets CD2 conductivity sensor value. * @details \b Inputs: fpgaSensorReadings.fpgaCD2 * @details \b Outputs: none * @return Latest CD2 conductivity sensor value *************************************************************************/ U16 getFPGACD2( void ) { return fpgaSensorReadings.fpgaCD2Cond; } /*********************************************************************//** * @brief * The getFPGACD2Temp function gets CD2 conductivity sensor temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaCD2Temp * @details \b Outputs: none * @return Latest CD2 conductivity sensor temperature value *************************************************************************/ U16 getFPGACD2Temp( void ) { return fpgaSensorReadings.fpgaCD2Temp; } /*********************************************************************//** * @brief * The getFPGACD2Data function gets CD2 conductivity sensor register value. * @details \b Inputs: fpgaSensorReadings.fpgaCD2DataOut * @details \b Outputs: none * @return Latest CD2 conductivity sensor register data value *************************************************************************/ U32 getFPGACD2Data( void ) { return fpgaSensorReadings.fpgaCD2DataOut; } /*********************************************************************//** * @brief * The getFPGACD3ReadCount function gets CD3 conductivity sensor read count. * @details \b Inputs: fpgaSensorReadings.fpgaCD3ReadCnt * @details \b Outputs: none * @return Latest CD3 conductivity sensor read count *************************************************************************/ U08 getFPGACD3ReadCount( void ) { return fpgaSensorReadings.fpgaCD3ReadCnt; } /*********************************************************************//** * @brief * The getFPGACD3ErrorCount function gets CD3 conductivity sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaCD3ErrorCnt * @details \b Outputs: none * @return Latest CD3 conductivity sensor read error count *************************************************************************/ U08 getFPGACD3ErrorCount( void ) { return fpgaSensorReadings.fpgaCD3ErrorCnt; } /*********************************************************************//** * @brief * The getFPGACD3 function gets CD3 conductivity sensor value. * @details \b Inputs: fpgaSensorReadings.fpgaCD3 * @details \b Outputs: none * @return Latest CD3 conductivity sensor value *************************************************************************/ U16 getFPGACD3( void ) { return fpgaSensorReadings.fpgaCD3Cond; } /*********************************************************************//** * @brief * The getFPGACD3Temp function gets CD3 conductivity sensor temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaCD3Temp * @details \b Outputs: none * @return Latest CD3 conductivity sensor temperature value *************************************************************************/ U16 getFPGACD3Temp( void ) { return fpgaSensorReadings.fpgaCD3Temp; } /*********************************************************************//** * @brief * The getFPGACD3Data function gets CD3 conductivity sensor register value. * @details \b Inputs: fpgaSensorReadings.fpgaCD3DataOut * @details \b Outputs: none * @return Latest CD3 conductivity sensor register data value *************************************************************************/ U32 getFPGACD3Data( void ) { return fpgaSensorReadings.fpgaCD3DataOut; } /*********************************************************************//** * @brief * The getFPGACD4ReadCount function gets CD4 conductivity sensor read count. * @details \b Inputs: fpgaSensorReadings.fpgaCD4ReadCnt * @details \b Outputs: none * @return Latest CD4 conductivity sensor read count *************************************************************************/ U08 getFPGACD4ReadCount( void ) { return fpgaSensorReadings.fpgaCD4ReadCnt; } /*********************************************************************//** * @brief * The getFPGACD4ErrorCount function gets CD4 conductivity sensor error count. * @details \b Inputs: fpgaSensorReadings.fpgaCD4ErrorCnt * @details \b Outputs: none * @return Latest CD4 conductivity sensor read error count *************************************************************************/ U08 getFPGACD4ErrorCount( void ) { return fpgaSensorReadings.fpgaCD4ErrorCnt; } /*********************************************************************//** * @brief * The getFPGACD4 function gets CD4 conductivity sensor value. * @details \b Inputs: fpgaSensorReadings.fpgaCD4 * @details \b Outputs: none * @return Latest CD4 conductivity sensor value *************************************************************************/ U16 getFPGACD4( void ) { return fpgaSensorReadings.fpgaCD4Cond; } /*********************************************************************//** * @brief * The getFPGACD4Temp function gets CD4 conductivity sensor temperature value. * @details \b Inputs: fpgaSensorReadings.fpgaCD4Temp * @details \b Outputs: none * @return Latest CD4 conductivity sensor temperature value *************************************************************************/ U16 getFPGACD4Temp( void ) { return fpgaSensorReadings.fpgaCD4Temp; } /*********************************************************************//** * @brief * The getFPGACD4Data function gets CD4 conductivity sensor register value. * @details \b Inputs: fpgaSensorReadings.fpgaCD4DataOut * @details \b Outputs: none * @return Latest CD4 conductivity sensor register data value *************************************************************************/ U32 getFPGACD4Data( void ) { return fpgaSensorReadings.fpgaCD4DataOut; } /*********************************************************************//** * @brief * The getFPGALevelSensor1 function gets the latest FPGA level sensor 1 * reading. * @details \b Inputs: fpgaSensorReadings.fpgaLevelSensor1 * @details \b Outputs: none * @return last FPGA level sensor1 reading *************************************************************************/ U16 getFPGALevelSensor1( void ) { return fpgaSensorReadings.fpgaLevelSensor1; } /*********************************************************************//** * @brief * The getFPGALevelSensor2 function gets the latest FPGA level sensor 2 * reading. * @details \b Inputs: fpgaSensorReadings.fpgaLevelSensor2 * @details \b Outputs: none * @return last FPGA level sensor2 reading *************************************************************************/ U16 getFPGALevelSensor2( void ) { return fpgaSensorReadings.fpgaLevelSensor2; } /*********************************************************************//** * @brief * The getFPGAFloater1Status function gets the latest FPGA floater 1 level * reading. * @details \b Inputs: fpgaSensorReadings.fpgaFloater1Status * @details \b Outputs: none * @return last FPGA floater 1 level reading *************************************************************************/ U08 getFPGAFloater1Status( void ) { return fpgaSensorReadings.fpgaFloater1Status; } /*********************************************************************//** * @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 getFPGAInletHeatExchangerTemp function gets the inlet heat exchanger * temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return inlet heat exchanger temperature *************************************************************************/ U32 getFPGAInletHeatExchangerTemp( void ) { return fpgaSensorReadings.fpgaTax1Temp; } /*********************************************************************//** * @brief * The getFPGAOutletHeatExchangerTemp function gets the outlet heat exchanger * temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return outlet heat exchanger temperature *************************************************************************/ U32 getFPGAOutletHeatExchangerTemp( void ) { return fpgaSensorReadings.fpgaTH2Temp; } /*********************************************************************//** * @brief * The getFPGAHydraulicsPrimaryHeaterTemp function gets the hydraulics primary * heater temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return hydraulics primary heater temperature *************************************************************************/ U32 getFPGAHydraulicsPrimaryHeaterTemp( void ) { return fpgaSensorReadings.fpgaTH1Temp; } /*********************************************************************//** * @brief * The getFPGATrimmerHeaterTemp function gets the trimmer heater temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return trimmer heater temperature *************************************************************************/ U32 getFPGATrimmerHeaterTemp( void ) { return fpgaSensorReadings.fpgaTH3Temp; } /*********************************************************************//** * @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 getFPGABaroReadCount function gets the FPGA barometric sensor read count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor read count *************************************************************************/ U08 getFPGABaroReadCount( void ) { return fpgaSensorReadings.fpgaBaroReadCount; } /*********************************************************************//** * @brief * The getFPGABaroErrorCount function gets the FPGA barometric sensor error count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor error count *************************************************************************/ U08 getFPGABaroErrorCount( void ) { return fpgaSensorReadings.fpgaBaroErrorCount; } /*********************************************************************//** * @brief * The getFPGABaroMfgInfo function gets the FPGA barometric pressure * sensor manufacturing information. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor manufacturing information *************************************************************************/ U16 getFPGABaroMfgInfo( void ) { return fpgaSensorReadings.fpgaBaroManufacInfo; } /*********************************************************************//** * @brief * The getFPGABaroPressureSensitivity function gets the FPGA barometric pressure * sensor sensitivity. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor sensitivity *************************************************************************/ U16 getFPGABaroPressureSensitivity( void ) { return fpgaSensorReadings.fpgaBaroPROMCoeff1; } /*********************************************************************//** * @brief * The getFPGABaroPressureOffset function gets the FPGA barometric pressure * sensor offset. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor offset *************************************************************************/ U16 getFPGABaroPressureOffset( void ) { return fpgaSensorReadings.fpgaBaroPROMCoeff2; } /*********************************************************************//** * @brief * The getFPGABaroTempCoeffOfPressSensitvity function gets the FPGA barometric * pressure sensor temperature coefficient of pressure sensitivity. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor temperature coefficient of pressure sensitivity *************************************************************************/ U16 getFPGABaroTempCoeffOfPressSensitvity( void ) { return fpgaSensorReadings.fpgaBaroPROMCoeff3; } /*********************************************************************//** * @brief * The getFPGABaroTempCoeffOfPressOffset function gets the FPGA barometric * pressure sensor temperature coefficient of pressure offset. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor temperature coefficient of pressure offset *************************************************************************/ U16 getFPGABaroTempCoeffOfPressOffset( void ) { return fpgaSensorReadings.fpgaBaroPROMCoeff4; } /*********************************************************************//** * @brief * The getFPGABaroReferenceTemperature function gets the FPGA barometric pressure * sensor reference temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor reference temperature *************************************************************************/ U16 getFPGABaroReferenceTemperature( void ) { return fpgaSensorReadings.fpgaBaroPROMCoeff5; } /*********************************************************************//** * @brief * The getFPGABaroTempCoeffOfTemperature function gets the FPGA barometric pressure * sensor temperature coefficient of temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor temperature coefficient of temperature *************************************************************************/ U16 getFPGABaroTempCoeffOfTemperature( void ) { return fpgaSensorReadings.fpgaBaroPROMCoeff6; } /*********************************************************************//** * @brief * The getFPGABaroCoeffsCRC function gets the FPGA barometric pressure * sensor temperature coefficients' CRC. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor temperature coefficients' CRC *************************************************************************/ U16 getFPGABaroCoeffsCRC( void ) { return fpgaSensorReadings.fpgaBaroPROMCRC; } /*********************************************************************//** * @brief * The getFPGABaroPressure function gets the FPGA barometric pressure sensor * pressure. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor pressure *************************************************************************/ U32 getFPGABaroPressure( void ) { return ( fpgaSensorReadings.fpgaBaroPressure & MASK_OFF_U32_MSB ); } /*********************************************************************//** * @brief * The getFPGABaroTemperature function gets the FPGA barometric pressure sensor * temperature. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return barometric pressure sensor temperature *************************************************************************/ U32 getFPGABaroTemperature( void ) { return ( fpgaSensorReadings.fpgaBaroTemperature & MASK_OFF_U32_MSB ); } /*********************************************************************//** * @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 ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) } } } /*********************************************************************//** * @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 ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) status = TRUE; } } } return status; } /**@}*/