/************************************************************************** * * 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_VBF_PWM_PULL_IN_MS ( 3 * MS_PER_SECOND ) ///< FPGA VBf PWM pull in in milliseconds. #define FPGA_VBF_PWM_LOW 9999 ///< FPGA VBf PWM low. #define FPGA_VBF_PWM_PERIOD 16666 ///< FPGA VBf PWM period. // 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_CP1_PARKED_BIT 0x04 ///< Concentrate pump 1 parked status bit mask. #define FPGA_CP2_PARKED_BIT 0x10 ///< Concentrate pump 2 parked status bit mask. #define FPGA_CP1_PARK_FAULT_BIT 0x08 ///< Concentrate pump 1 park fault status bit mask. #define FPGA_CP2_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. /// 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 U32 fpgaPnPressure; ///< Reg 264. Pn/PHo MPM pressure sensor RAW pressure data U32 fpgaPnTemp; ///< Reg 268. Pn/PHo MPM pressure sensor RAW temperature data U08 fpgaPnReadCnt; ///< Reg 272. Pn/PHo Counter for good I2C transmission b/w FPGA and sensor U08 fpgaPnErrorCnt; ///< Reg 273. Pn/PHo Counter for bad I2C transmission b/w FPGA and sensor U32 fpgaPCbPressure; ///< Reg 274. PCb/PDB MPM pressure sensor RAW pressure data U32 fpgaPCbTemp; ///< Reg 278. PCb/PDB MPM pressure sensor RAW temperature data U08 fpgaPCbReadCnt; ///< Reg 282. PCb/PDB Counter for good I2C transmission b/w FPGA and sensor U08 fpgaPCbErrorCnt; ///< Reg 283. PCb/PDB Counter for bad I2C transmission b/w FPGA and sensor U32 fpgaPDsPressure; ///< Reg 284. PDs MPM pressure sensor RAW pressure data U32 fpgaPDsTemp; ///< Reg 288. PDs MPM pressure sensor RAW temperature data U08 fpgaPDsReadCnt; ///< Reg 292. PDs Counter for good I2C transmission b/w FPGA and sensor U08 fpgaPDsErrorCnt; ///< Reg 293. PDs Counter for bad I2C transmission b/w FPGA and sensor U32 fpgaPDfPressure; ///< Reg 294. PDf MPM pressure sensor RAW pressure data U32 fpgaPDfTemp; ///< Reg 298. PDf MPM pressure sensor RAW temperature data U08 fpgaPDfReadCnt; ///< Reg 302. PDf Counter for good I2C transmission b/w FPGA and sensor U08 fpgaPDfErrorCnt; ///< Reg 303. PDf Counter for bad I2C transmission b/w FPGA and sensor U32 fpgaPtmPressure; ///< Reg 304. Ptm MPM pressure sensor RAW pressure data U32 fpgaPtmTemp; ///< Reg 308. Ptm MPM pressure sensor RAW temperature data U08 fpgaPtmReadCnt; ///< Reg 312. Ptm Counter for good I2C transmission b/w FPGA and sensor U08 fpgaPtmErrorCnt; ///< Reg 313. Ptm Counter for bad I2C transmission b/w FPGA and sensor U16 fpgaCD1DataOut; ///< Reg 314. Data read from Conductivity Sensor 1 register U16 fpgaCD1Cond; ///< Reg 316. CD1 conductivity U16 fpgaCD1Temp; ///< Reg 318. CD1 Temperature U08 fpgaCD1ReadCnt; ///< Reg 320. CD1 successful read count U08 fpgaCD1ErrorCnt; ///< Reg 321. CD1 error read count U16 fpgaCD2DataOut; ///< Reg 322. Data read from Conductivity Sensor 2 register U16 fpgaCD2Cond; ///< Reg 324. CD2 conductivity U16 fpgaCD2Temp; ///< Reg 326. CD2 Temperature U08 fpgaCD2ReadCnt; ///< Reg 328. CD2 successful read count U08 fpgaCD2ErrorCnt; ///< Reg 329. CD2 error read count U16 fpgaCD3DataOut; ///< Reg 330. Data read from Conductivity Sensor 3 register U16 fpgaCD3Cond; ///< Reg 332. CD3 conductivity U16 fpgaCD3Temp; ///< Reg 334. CD3 Temperature U08 fpgaCD3ReadCnt; ///< Reg 336. CD3 successful read count U08 fpgaCD3ErrorCnt; ///< Reg 337. CD3 error read count U16 fpgaCD4DataOut; ///< Reg 338. 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 } 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 U08 fpgaBCValveControl; ///< Reg 86. Balancing Chamber Valves Control Registers U08 fpgaBCValvePWMControl; ///< Reg 87. Balancing Chamber Valves PWM control U08 fpgaUFValveControl; ///< Reg 88. Ultra filtration Valves Control Registers U08 fpgaUFValvePWMControl; ///< Reg 89. Ultra filtration Valves PWM control U08 fpgaConSensTD12Control; ///< Reg 90. Conductivity/Temperature Sensors 1 & 2 Control registers U08 fpgaConSensTD34Control; ///< Reg 91. Conductivity/Temperature Sensors 3 & 4 Control registers U16 fpgaConSensTD12_Addrs; ///< Reg 92. CDTD 1&2 Initialization Address register U16 fpgaConSensTD12_Data_In; ///< Reg 94. CDTD 1&2 Initialization data register U16 fpgaConSensTD34_Addrs; ///< Reg 96. CDTD 3&4 Initialization Address register U16 fpgaConSensTD34_Data_In; ///< Reg 98. CDTD 3&4 Initialization data register U16 fpgaRemoteUpdate_Write; ///< Reg 100.Register for Remote update used by SW. U16 fpgaDGPSpeed; ///< Reg 102. DGP Speed/RPM Control U08 fpgaDGPControl; ///< Reg 104. DGP Control U08 fpgaSDPControl; ///< Reg 105. SDP Control U16 fpgaSDPSpeed; ///< Reg 106. SDP Speed/RPM Control U16 fpgaCPASpeed; ///< Reg 108. Acid Concentrate Pump Speed/RPM Control U08 fpgaCPAControl; ///< Reg 110. Acid Concentrate Pump Control U08 fpgaCPBControl; ///< Reg 111. BiCarb Concentrate Pump Control U16 fpgaCPBSpeed; ///< Reg 112. BiCarb Concentrate Pump Speed/RPM Control U08 fpgaBloodLeakSensorTest; ///< Reg 114. Blood leak sensor test U08 fpgaBloodLeakUARTControl; ///< Reg 115. Blood leak sensor UART control U08 fpgaBloodLeakFIFOTx; ///< Reg 116. Blood leak sensor FIFO transmit 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..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 setFPGADialysateOutPumpSpeed function sets the speed period for * dialysate out pump (SDP). * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaSDPSpeed * @param speed The dialysate out pump speed period * @return none *************************************************************************/ void setFPGADialysateOutPumpSpeed( U16 speed ) { fpgaActuatorSetPoints.fpgaSDPSpeed = speed; } /*********************************************************************//** * @brief * The setFPGADialysateInPumpSpeed function sets the speed period for * dialysate In pump (DGP). * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDGPSpeed * @param speed The dialysate In pump speed period * @return none *************************************************************************/ void setFPGADialysateInPumpSpeed( U16 speed ) { fpgaActuatorSetPoints.fpgaDGPSpeed = speed; } /*********************************************************************//** * @brief * The setFPGADialysateOutPumpControl function sets the controls for * dialysate out pump (SDP). bit definitions To be defined(TBD) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaSDPControl * @param control The dialysate out pump controls * @return none *************************************************************************/ void setFPGADialysateOutPumpControl( U08 control ) { fpgaActuatorSetPoints.fpgaSDPControl = control; } /*********************************************************************//** * @brief * The setFPGADialysateInPumpControl function sets the controls for * dialysate In pump (DGP). bit definitions To be defined(TBD) * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDGPControl * @param control The dialysate In pump controls * @return none *************************************************************************/ void setFPGADialysateInPumpControl( 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 CP2. * @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 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 input for write operations. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD12_Data_In * @param data The conductivity sensor CD12 Data * @return none *************************************************************************/ void setFPGACD12Data( U16 data ) { fpgaActuatorSetPoints.fpgaConSensTD12_Data_In = data; } /*********************************************************************//** * @brief * The setFPGACD34Data function sets the conductivity sensor * CD34 data input for write operations. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensTD34_Data_In * @param data The conductivity sensor CD34 Data * @return none *************************************************************************/ void setFPGACD34Data( U16 data ) { fpgaActuatorSetPoints.fpgaConSensTD34_Data_In = data; } /*********************************************************************//** * @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 getFPGADialysateOutPumpControl 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 0-2: TBD * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaSDPControl * @return Dialysate Out pump control status bit *************************************************************************/ U08 getFPGADialysateOutPumpControl( void ) { return fpgaActuatorSetPoints.fpgaSDPControl; } /*********************************************************************//** * @brief * The getFPGADialysateInPumpControl 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 0-2: TBD * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.fpgaDGPControl * @return Dialysate Inlet pump control status bit *************************************************************************/ U08 getFPGADialysateInPumpControl( void ) { return fpgaActuatorSetPoints.fpgaDGPControl; } /*********************************************************************//** * @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 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 I2C 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 *************************************************************************/ U32 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 *************************************************************************/ U32 getFPGAPnRawTemperature( void ) { return fpgaSensorReadings.fpgaPnTemp; } /*********************************************************************//** * @brief * The getFPGAPCbReadCount function gets Bibag pressure sensor counter of * good I2C 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 *************************************************************************/ U32 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 *************************************************************************/ U32 getFPGAPCbRawTemperature( void ) { return fpgaSensorReadings.fpgaPCbTemp; } /*********************************************************************//** * @brief * The getFPGAPDsReadCount function gets spent dialysate pressure sensor counter of * good I2C 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 *************************************************************************/ U32 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 *************************************************************************/ U32 getFPGAPDsRawTemperature( void ) { return fpgaSensorReadings.fpgaPDsTemp; } /*********************************************************************//** * @brief * The getFPGAPDfReadCount function gets fresh dialysate pressure sensor counter of * good I2C 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 *************************************************************************/ U32 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 *************************************************************************/ U32 getFPGAPDfRawTemperature( void ) { return fpgaSensorReadings.fpgaPDfTemp; } /*********************************************************************//** * @brief * The getFPGAPtmReadCount function gets transmembrane pressure sensor counter of * good I2C 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 *************************************************************************/ U32 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 *************************************************************************/ U32 getFPGAPtmRawTemperature( void ) { return fpgaSensorReadings.fpgaPtmTemp; } /*********************************************************************//** * @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 *************************************************************************/ U16 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 *************************************************************************/ U16 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 *************************************************************************/ U16 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 *************************************************************************/ U16 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 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 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; } /**@}*/