Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rb9300084966f27ebd166962121c5217f5cd30eb0 -rf9a866abfc44db38c01cb795fea894cce1042eec --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision b9300084966f27ebd166962121c5217f5cd30eb0) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision f9a866abfc44db38c01cb795fea894cce1042eec) @@ -7,8 +7,8 @@ * * @file FPGA.c * -* @author (last) Dara Navaei -* @date (last) 20-Jun-2022 +* @author (last) Dong Nguyen +* @date (last) 27-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -138,18 +138,18 @@ { U08 errorCountProcessor; ///< Reg 256. TBD. U08 errorCountPC; ///< Reg 257. TBD. - U08 bloodFlowMeterDataPktCount; ///< Reg 258. Blood flow sensor data packet count. - U08 bloodFlowMeterSlowPktCounts; ///< Reg 259. Blood flow sensor slow data packet count. - F32 bloodFlowLast; ///< Reg 260. Blood flow rate data. - U08 bloodFlowMeterDeviceStatus; ///< Reg 264. Blood flow sensor status. - U08 bloodFlowMeterResponse; ///< Reg 265. TBD. - U08 dialysateFlowMeterDataPktCount; ///< Reg 266. Dialysate flow sensor data packet count. - U08 dialysateFlowMeterSlowPckCounts; ///< Reg 267. Dialysate flow sensor slow data packet count. - F32 dialysateFlowLast; ///< Reg 268. Dialysate flow rate data. - U08 dialysateFlowMeterDeviceStatus; ///< Reg 272. Dialysate flow sensor status. - U08 dialysateFlowMeterResponse; ///< Reg 273. TBD. - U08 bloodFlowMeterErrorCount; ///< Reg 274. Blood flow sensor error count. - U08 dialysateFlowMeterErrorCount; ///< Reg 275. Dialysate flow sensor error count. + U08 reserved1; ///< Reg 258. Reserved. + U08 reserved2; ///< Reg 259. Reserved. + F32 reserved3; ///< Reg 260. Reserved. + U08 reserved4; ///< Reg 264. Reserved. + U08 reserved5; ///< Reg 265. Reserved. + U08 reserved6; ///< Reg 266. Reserved. + U08 reserved7; ///< Reg 267. Reserved. + F32 reserved8; ///< Reg 268. Reserved. + U08 reserved9; ///< Reg 272. Reserved. + U08 reserved10; ///< Reg 273. Reserved. + U08 reserved11; ///< Reg 274. Reserved. + U08 reserved12; ///< Reg 275. Reserved. U16 bloodOcclusionData; ///< Reg 276. Blood pump occlusion sensor data. U08 bloodOcclusionReadCount; ///< Reg 278. Blood pump occlusion sensor read count. U08 bloodOcclusionErrorCount; ///< Reg 279. Blood pump occlusion sensor error count. @@ -164,9 +164,9 @@ U08 dialInPumpHallSensorStatus; ///< Reg 291. Dialysate inlet pump hall sensor status. U32 adc1Channel0; ///< Reg 292. ADC1 channel 0 data. U32 adc1Channel1; ///< Reg 296. ADC1 channel 1 data. - U32 bloodFlowSoundSpeedData; ///< Reg 300. Blood flow sensor - sound speed data. - U32 bloodFlowAccFlowData; ///< Reg 304. Blood flow sensor - accumulated flow data. - F32 bloodFlowSignalStrength; ///< Reg 308. Blood flow sensor - signal strength. + U32 reserved13; ///< Reg 300. Reserved. + U32 reserved14; ///< Reg 304. Reserved. + F32 reserved15; ///< Reg 308. Reserved. U08 adc1SequenceCount; ///< Reg 312. ADC1 round robin channel sequence count. U08 adc1ErrorCount; ///< Reg 313. ADC1 error count. U16 accelX; ///< Reg 314. Accelerometer X axis data. @@ -183,9 +183,9 @@ U08 dialOutPumpSensorStatus; ///< Reg 335. Dialysate outlet pump hall sensor status. U16 dialInPumpHallSensorCount; ///< Reg 336. Dialysate inlet pump hall sensor count. U16 dialOutPumpHallSensorCount; ///< Reg 338. Dialysate outlet pump hall sensor count. - U32 dialysateFlowSoundSpeedData; ///< Reg 340. Dialysate flow sensor - sound speed data. - U32 dialysateFlowAccFlowData; ///< Reg 344. Dialysate flow sensor - accumulated flow data. - F32 dialysateFlowSignalStrength; ///< Reg 348. Dialysate flow sensor - signal strength. + U32 reserved16; ///< Reg 340. Reserved. + U32 reserved17; ///< Reg 344. Reserved. + F32 reserved18; ///< Reg 348. Reserved. U16 fan1PulseTime; ///< Reg 352. Fan 1 pulse time in 2.5 uSec resolution. 0xFFFF if fan RPM < 500 RPM. U16 fan2PUlseTime; ///< Reg 354. Fan 2 pulse time in 2.5 uSec resolution. 0xFFFF if fan RPM < 500 RPM. U16 fpgaGPIO; ///< Reg 356. FPGA GPIO register. @@ -227,15 +227,15 @@ U08 V4EncError; ///< Reg 423. Pinch valve V4 encoder error counter. U08 ADACounter; ///< Reg 424. ADA bubble counter. U08 ADVCounter; ///< Reg 425. ADV bubble counter. - U08 ZLeakCounter; ///< Reg 426. Blood leak zero status counter. - U08 BLeakCounter; ///< Reg 427. Blood leak counter. - U08 PBoErrorCount; ///< Reg 428. PBo error count. - U08 bloodLeakZeroedStatus; ///< Reg 429. Blood leak and sensor zeored status. - U16 bloodLeakDetectSetPoint; ///< Reg 430. Blood leak stored set point value. - U16 bloodLeakDetectLevel; ///< Reg 432. Blood leak detection stored level value. - U16 bloodLeakStCount; ///< Reg 434. Blood leak St Count. - U16 bloodLeakLEDIntensity; ///< Reg 436. Blood leak LED intensity. - U16 bloodLeakRdCounter; ///< Reg 438. Blood leak register counter. + U08 reserved19; ///< Reg 426. Reserved. + U08 reserved20; ///< Reg 427. Reserved. + U08 VenousErrorCounter; ///< Reg 428. Venous error counter. + U08 reserved21; ///< Reg 429. Reserved. + U16 reserved22; ///< Reg 430. Reserved. + U16 reserved23; ///< Reg 432. Reserved. + U16 reserved24; ///< Reg 434. Reserved. + U16 reserved25; ///< Reg 436. Reserved. + U16 reserved26; ///< Reg 438. Reserved. U16 arterialPressure; ///< Reg 440. Arterial pressure sensor. U16 arterialPressureTemperature; ///< Reg 442. Arterial pressure sensor temperature. U08 arterialPressureReadCount; ///< Reg 444. Arterial pressure sensor read count. @@ -245,8 +245,7 @@ U16 bloodLeakRxFIFOCount; ///< Reg 448. Blood leak receive FIFO count. U08 bloodLeakRxFIFODataOut; ///< Reg 450. Blood leak receive FIFO data out. U08 dummyByte; ///< Reg 451. Dummy byte to meet the even of the data. - U08 bloodLeakSelfTestErrorCounter; ///< Reg 452. Blood leak self test error counter. - U08 bloodLeakZeroErrorCounter; ///< Reg 453. Blood leak zero error counter. + U16 fpgaCompatibilityRev; ///< Reg 452. Compatibility revisions } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -291,7 +290,7 @@ U16 fpgaVAux11Voltage; ///< Reg 534. Aux. voltage 11. F32 bloodFlowSoundSpeed; ///< Reg 536. Blood flow sound speed. F32 bloodFlowAccFlow; ///< Reg 540. Blood flow accumulated flow. - F32 bloodFlowSignalStrength; ///< Reg 544. Blood flow signal strength. + F32 reserved15; ///< Reg 544. Reserved. F32 dialysateInFlowSoundSpeed; ///< Reg 548. Dialysate inlet flow sound speed. F32 dialysateInFlowAccFlow; ///< Reg 552. Dialysate inlet flow accumulated flow. F32 dialysateInFlowSignalStrength; ///< Reg 556. Dialysate inlet flow signal strength. @@ -931,25 +930,18 @@ { SELF_TEST_STATUS_T result; - // Check FPGA reported correct ID + // check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { // Check FPGA compatibility w/ firmware - if ( fpgaHeader.fpgaRevMajor > MIN_HD_FPGA_MAJOR ) + if ( HD_FPGA_COMPATIBILITY_REV == fpgaSensorReadings.fpgaCompatibilityRev ) { result = SELF_TEST_STATUS_PASSED; } else { - if ( fpgaHeader.fpgaRev >= MIN_HD_FPGA_MINOR ) - { - result = SELF_TEST_STATUS_PASSED; - } - else - { - result = SELF_TEST_STATUS_FAILED; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaRevMajor, (U32)fpgaHeader.fpgaRev ) - } + result = SELF_TEST_STATUS_FAILED; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_POST_TEST_FAILED, (U32)HD_FPGA_COMPATIBILITY_REV, (U32)fpgaSensorReadings.fpgaCompatibilityRev ) } } else @@ -977,11 +969,14 @@ U32 const diffFPGATimerCount = (U32)u16DiffWithWrap( currentFPGATimerCount_ms, newFPGATimerCount_ms ); U32 const diffTimerCount = u32DiffWithWrap( currentTimerCount_ms, newTimerCount_ms ); - if ( getCurrentOperationMode() > MODE_INIT ) + if ( getCurrentOperationMode() != MODE_INIT ) { if ( abs( diffFPGATimerCount - diffTimerCount ) > PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); + } } } @@ -1288,108 +1283,6 @@ /*********************************************************************//** * @brief - * The getFPGABloodFlowSignalStrength function gets the latest blood flow - * signal strength reading. - * @details Inputs: fpgaSensorReadings2 - * @details Outputs: none - * @return last blood flow signal strength reading - *************************************************************************/ -F32 getFPGABloodFlowSignalStrength( void ) -{ - return fpgaSensorReadings.bloodFlowSignalStrength; -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlowSignalStrength function gets the latest dialysate - * flow signal strength reading. - * @details Inputs: fpgaSensorReadings2 - * @details Outputs: none - * @return last dialysate flow signal strength reading - *************************************************************************/ -F32 getFPGADialysateFlowSignalStrength( void ) -{ - return fpgaSensorReadings.dialysateFlowSignalStrength; -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlow function gets the latest dialysate flow reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last dialysate flow reading - *************************************************************************/ -F32 getFPGADialysateFlow( void ) -{ - return fpgaSensorReadings.dialysateFlowLast; -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlowMeterStatus function gets the dialysate flow meter status. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current dialysate flow meter status - *************************************************************************/ -U08 getFPGADialysateFlowMeterStatus( void ) -{ - return fpgaSensorReadings.dialysateFlowMeterDeviceStatus; -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlowFastPacketReadCounter function gets the dialysate - * flow meter fast packet read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current dialysate flow meter fast packet read counter - *************************************************************************/ -U08 getFPGADialysateFlowFastPacketReadCounter( void ) -{ - return fpgaSensorReadings.dialysateFlowMeterDataPktCount; -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlowSlowPacketReadCounter function gets the dialysate - * flow meter slow packet read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current dialysate flow meter slow packet read counter - *************************************************************************/ -U08 getFPGADialysateFlowSlowPacketReadCounter( void ) -{ - return ( fpgaSensorReadings.dialysateFlowMeterSlowPckCounts & MASK_OFF_NIBBLE_LSB ) >> SHIFT_BITS_BY_4; -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlowStatusPacketReadCounter function gets the dialysate - * flow meter status packet read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current dialysate flow meter status packet read counter - *************************************************************************/ -U08 getFPGADialysateFlowStatusPacketReadCounter( void ) -{ - return ( fpgaSensorReadings.dialysateFlowMeterSlowPckCounts & MASK_OFF_NIBBLE_MSB ); -} - -/*********************************************************************//** - * @brief - * The getFPGADialysateFlowErrorCounter function gets the dialysate flow meter - * error counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current dialysate flow meter error counter - *************************************************************************/ -U08 getFPGADialysateFlowErrorCounter( void ) -{ - return fpgaSensorReadings.dialysateFlowMeterErrorCount; -} - -/*********************************************************************//** - * @brief * The getFPGABloodPumpHallSensorCount function gets the latest blood pump * hall sensor count. Count is a 16 bit free running counter. If counter is * counting up, indicates motor is running in forward direction. If counter is @@ -1657,6 +1550,19 @@ /*********************************************************************//** * @brief + * The getFPGAVenousPressureErrorCounter function gets the latest venous pressure + * sensor error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last venous pressure sensor error counter + *************************************************************************/ +U08 getFPGAVenousPressureErrorCounter( void ) +{ + return fpgaSensorReadings.VenousErrorCounter; +} + +/*********************************************************************//** + * @brief * The setFPGASyringePumpControlFlags function sets the syringe pump control * register per given bit flags. * @details Inputs: none @@ -1974,87 +1880,6 @@ /*********************************************************************//** * @brief - * The noFPGABloodLeakDetected function returns TRUE if no blood leak has been - * detected and FALSE if a blood leak has been detected. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return noFPGABloodLeakDetected - *************************************************************************/ -BOOL noFPGABloodLeakDetected( void ) -{ - U16 noFPGABloodLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_STATUS_MASK; - - return ( 0 == noFPGABloodLeakDetected ? TRUE : FALSE ); -} - -/*********************************************************************//** - * @brief - * The setFPGABloodLeakZero function sets the Blood Leak detector into - * zeroing mode via the FPGA. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints - * @return none - *************************************************************************/ -void setFPGABloodLeakZero( void ) -{ - fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_BLOOD_LEAK_ZERO_CMD; -} - -/*********************************************************************//** - * @brief - * The clearFPGABloodLeakZero function clears the Blood Leak detector from - * zeroing mode via the FPGA. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return none - *************************************************************************/ -void clearFPGABloodLeakZero( void ) -{ - fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_BLOOD_LEAK_ZERO_CMD; -} - -/*********************************************************************//** - * @brief - * The setFPGABloodLeakSelfTest function sets the Blood Leak detector into - * self-test mode via the FPGA. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints - * @return: none - *************************************************************************/ -void setFPGABloodLeakSelfTest( void ) -{ - fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_BLOOD_LEAK_SELF_TEST_CMD; -} - -/*********************************************************************//** - * @brief - * The clearFPGABloodLeakSelfTest function clears the Blood Leak detector from - * self-test mode via the FPGA. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return none - *************************************************************************/ -void clearFPGABloodLeakSelfTest( void ) -{ - fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_BLOOD_LEAK_SELF_TEST_CMD; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakZeroStatus function returns the blood leak sensor's - * zero status bit. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return blood leak sensor zero status bit - *************************************************************************/ -U08 getFPGABloodLeakZeroStatus( void ) -{ - U08 zeroStatus = (U08)( ( fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_ZERO_STATE_MASK ) >> FPAG_BLOOD_LEAK_ZERO_BIT_INDEX ); - return zeroStatus; -} - -/*********************************************************************//** - * @brief * The getFPGABloodLeakStatus function returns the blood leak sensor's * blood detection status bit. * @details Inputs: fpgaSensorReadings @@ -2095,105 +1920,6 @@ /*********************************************************************//** * @brief - * The getFPGABloodLeakZeroStatusCounter function returns the blood leak - * zero status counter - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.ZLeakCounter - *************************************************************************/ -U08 getFPGABloodLeakZeroStatusCounter( void ) -{ - return fpgaSensorReadings.ZLeakCounter; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakCounter function returns the blood leak counter. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.BLeakCounter - *************************************************************************/ -U08 getFPGABloodLeakCounter( void ) -{ - return fpgaSensorReadings.BLeakCounter; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakZeroedStatus function returns the blood leak zeroed status. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakZeroedStatus - *************************************************************************/ -U08 getFPGABloodLeakZeroedStatus( void ) -{ - return fpgaSensorReadings.bloodLeakZeroedStatus; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakDetectSetPoint function returns the blood leak detect - * set point. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodDetectSetPoint - *************************************************************************/ -U16 getFPGABloodLeakDetectSetPoint( void ) -{ - return fpgaSensorReadings.bloodLeakDetectSetPoint; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakDetectLevel function returns the blood leak detect level. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodDetectLevel - *************************************************************************/ -U16 getFPGABloodLeakDetectLevel( void ) -{ - return fpgaSensorReadings.bloodLeakDetectLevel; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakStCount function returns the blood leak st count. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodStCount - *************************************************************************/ -U16 getFPGABloodLeakStCount( void ) -{ - return fpgaSensorReadings.bloodLeakStCount; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakLEDIntensity function returns the blood leak LED intensity. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLEDIntensity - *************************************************************************/ -U16 getFPGABloodLeakLEDIntensity( void ) -{ - return fpgaSensorReadings.bloodLeakLEDIntensity; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakRegisterCounter function returns the blood leak register - * counter. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodRdCounter - *************************************************************************/ -U16 getFPGABloodLeakRegisterCounter( void ) -{ - return fpgaSensorReadings.bloodLeakRdCounter; -} - -/*********************************************************************//** - * @brief * The getFPGABloodLeakTxFIFOCount function returns the blood leak transmit * FIFO count. * @details Inputs: none @@ -2246,32 +1972,6 @@ /*********************************************************************//** * @brief - * The getFPGABloodLeakSelfTestErrorCounter function returns the blood leak - * self test error counter. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakSelfTestErrorCounter - *************************************************************************/ -U08 getFPGABloodLeakSelfTestErrorCounter( void ) -{ - return fpgaSensorReadings.bloodLeakSelfTestErrorCounter; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakZeroErrorCounter function returns the blood leak - * zero error counter. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakZeroErrorCounter - *************************************************************************/ -U08 getFPGABloodLeakZeroErrorCounter( void ) -{ - return fpgaSensorReadings.bloodLeakZeroErrorCounter; -} - -/*********************************************************************//** - * @brief * The noFPGABubbleDetected function returns TRUE if no air bubble has been * detected and FALSE if an air bubble has been detected. * @details Inputs: fpgaSensorReadings