Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r838df450f09668adbd73e61fadbff8c81fe7926e -r6419179374edcd65da462de84e8aeaefb7e20320 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 838df450f09668adbd73e61fadbff8c81fe7926e) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6419179374edcd65da462de84e8aeaefb7e20320) @@ -7,8 +7,8 @@ * * @file FPGA.c * -* @author (last) Sean Nash -* @date (last) 14-Oct-2020 +* @author (last) Peman Montazemi +* @date (last) 15-Feb-2021 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -81,6 +81,7 @@ #define FPGA_AIRTRAP_LEVEL_LOW_MASK 0x0008 ///< Bit mask for air trap lower level sensor. #define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. +#define FPGA_FLUIDLEAK_STATE_MASK 0x0040 ///< Bit mask for fluid leak detector. #define FPGA_ADA_INPUT_STATUS_MASK 0x0001 ///< Bit mask for arterial air bubble detector input status. #define FPGA_ADV_INPUT_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. #define FPGA_BLOOD_LEAK_STATUS_MASK 0x1000 ///< Bit mask for blood leak detector status. @@ -103,7 +104,7 @@ } FPGA_HEADER_T; // Read only on FPGA /// Record structure for FPGA continuous priority reads. -typedef struct // TODO - add all sensor readings to this structure per FPGA register map +typedef struct { U08 errorCountProcessor; ///< Reg 256. TBD. U08 errorCountPC; ///< Reg 257. TBD. @@ -191,7 +192,7 @@ } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. -typedef struct // TODO - add all actuator set points to this structure per FPGA register map +typedef struct { U08 fpgaSensorTest; ///< Reg 11. Blood leak and bubble detector sensor test register. U16 fpgaPIDControl; ///< Reg 12. Valve PID enables. @@ -214,7 +215,7 @@ // TODO clean up the struct /// Record structure for FPGA async (as needed) reads. -typedef struct // TODO - add all sensor readings to this structure per FPGA register map +typedef struct { U16 fpgaDieTemp; ///< Reg 512. Internal FPGA die temperature. U16 fpgaADCVccVoltage; ///< Reg 514. Internal FPGA Vcc voltage. @@ -491,8 +492,6 @@ fpgaState = handleFPGAReceiveHeaderState(); break; - // TODO - sensor/ADC init/configuration states - case FPGA_STATE_RCV_ALL_SENSORS: fpgaState = handleFPGAReceiveAllSensorsState(); break; @@ -545,8 +544,6 @@ fpgaState = handleFPGAReadHeaderState(); break; - // TODO - sensor/ADC init/configuration states - case FPGA_STATE_WRITE_ALL_ACTUATORS: fpgaState = handleFPGAWriteAllActuatorsState(); break; @@ -1395,7 +1392,7 @@ /*********************************************************************//** * @brief * The getFPGASyringePumpStatus function gets the latest syringe pump status - * register reading. + * register reading. Bit 0 indicates a fault. * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump status reading @@ -1408,7 +1405,7 @@ /*********************************************************************//** * @brief * The getFPGASyringePumpADCReadCounter function gets the latest syringe pump - * ADC read counter. + * ADC read counter. Counter is 8-bit and rolls over when exceeding 255. * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump ADC read counter @@ -1422,6 +1419,9 @@ * @brief * The getFPGASyringePumpADCandDACStatus function gets the latest syringe pump * ADC/DAC status register reading. + * Bit 7 = DAC write and read-back done + * Bit 6 = I2C error on DAC data transfer + * Bit 0..5 = count of I2C errors, rolls over after 63 * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump ADC/DAC status reading @@ -1435,6 +1435,8 @@ * @brief * The getFPGASyringePumpEncoderStatus function gets the latest syringe pump * encoder status register reading. + * Bit 7 = direction (0=fwd, 1=rev) + * Bit 0..5 = direction error count (# of errors after power up, rolls over after 63) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump encoder status reading @@ -1460,7 +1462,7 @@ /*********************************************************************//** * @brief * The getFPGASyringePumpADCChannel0 function gets the latest syringe pump ADC - * channel 0 register reading. + * channel 0 register reading (syringe pump force sensor). * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump ADC channel 0 reading @@ -1473,7 +1475,7 @@ /*********************************************************************//** * @brief * The getFPGASyringePumpADCChannel1 function gets the latest syringe pump ADC - * channel 1 register reading. + * channel 1 register reading (syringe detection switch). * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump ADC channel 1 reading @@ -1486,7 +1488,7 @@ /*********************************************************************//** * @brief * The getFPGASyringePumpADCChannel2 function gets the latest syringe pump ADC - * channel 2 register reading. + * channel 2 register reading (syringe pump home position sensor). * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last syringe pump ADC channel 2 reading @@ -1680,6 +1682,21 @@ /*********************************************************************//** * @brief + * The noFluidLeakDetected function returns TRUE if no fluid leak has been + * detected (dry) and FALSE if a fluid leak has been detected (wet). + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return noFluidLeakDetected + *************************************************************************/ +BOOL noFPGAFluidLeakDetected( void ) +{ + U16 noFluidLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_FLUIDLEAK_STATE_MASK; + + return ( 0 == noFluidLeakDetected ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief * The setValveDialyzerInletPosition function sets the position of VDi * in counts * @details Inputs: fpgaActuatorSetPoints