Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r911f6526ec3ba03ba0131681c7fb371c0abda6bb -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 911f6526ec3ba03ba0131681c7fb371c0abda6bb) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) @@ -51,7 +51,7 @@ #define FPGA_HEADER_START_ADDR 0x0000 ///< Start address for FPGA header data. #define FPGA_BULK_READ_START_ADDR 0x0100 ///< Start address for FPGA continuous priority reads. -#define FPGA_BULK_WRITE_START_ADDR 0x000C ///< Start address for FPGA continuous priority writes. +#define FPGA_BULK_WRITE_START_ADDR 0x000B ///< Start address for FPGA continuous priority writes. #define FPGA_BULK_ASYNC_READ_START_ADDR 0x0200 ///< Start address for FPGA async reads. #define FPGA_WRITE_CMD_BUFFER_LEN (FPGA_PAGE_SIZE+8) ///< FPGA write command buffer byte length. @@ -81,6 +81,10 @@ #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_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. + // FPGA Sensors Record #pragma pack(push,1) /// Record structure for FPGA header read. @@ -96,8 +100,6 @@ U08 flowDAQ1Cmd; ///< Reg 8. Command passed to flow DAQ #1. U08 flowDAQ2Cmd; ///< Reg 9. Command passed to flow DAQ #2. U08 accelCmd; ///< Reg 10. Command passed to accelerometer. - U08 fpgaSensorTest; ///< Reg 11. Blood leak and bubble detector sensor test register. - U16 fpgaPIDControl; ///< Reg 12. Valve PID enables. } FPGA_HEADER_T; // Read only on FPGA /// Record structure for FPGA continuous priority reads. @@ -189,6 +191,7 @@ /// Record structure for FPGA continuous priority writes. typedef struct // TODO - add all actuator set points to this structure per FPGA register map { + U08 fpgaSensorTest; ///< Reg 11. Blood leak and bubble detector sensor test register. U16 fpgaPIDControl; ///< Reg 12. Valve PID enables. S16 VBASetPoint; ///< Reg 14. VBA pinch valve is commanded to this set point position. S16 VBVSetPoint; ///< Reg 16. VBV pinch valve is commanded to this set point position. @@ -1141,6 +1144,30 @@ /*********************************************************************//** * @brief + * The getFPGABloodFlowMeterStatus function gets the blood flow meter status. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter status + *************************************************************************/ +U08 getFPGABloodFlowMeterStatus( void ) +{ + return fpgaSensorReadings.bloodFlowMeterDeviceStatus; +} + +/*********************************************************************//** + * @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 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 @@ -1376,6 +1403,79 @@ /*********************************************************************//** * @brief + * The getFPGAArterialAirBubbleStatus function gets the latest arterial air + * bubble detector status. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return TRUE if air bubble is detected, otherwise FALSE + *************************************************************************/ +BOOL getFPGAArterialAirBubbleStatus( void ) +{ + U16 const status = fpgaSensorReadings.fpgaGPIO & FPGA_ADA_INPUT_STATUS_MASK; + + return ( 0 == status ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief + * The getFPGAVenousAirBubbleStatus function gets the latest venous air + * bubble detector status. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return TRUE if air bubble is detected, otherwise FALSE + *************************************************************************/ +BOOL getFPGAVenousAirBubbleStatus( void ) +{ + U16 const status = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_INPUT_STATUS_MASK; + + return ( 0 == status ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief + * The setFPGASensorTest function sets the sensor test output. + * @details Inputs: fpgaActuatorSetPoints + * @details Outputs: fpgaActuatorSetPoints + * @param sensorTest + * @return none + *************************************************************************/ +void setFPGASensorTest( U08 sensorTest ) +{ + fpgaActuatorSetPoints.fpgaSensorTest = sensorTest; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodLeakDetectorStatus function gets the latest blood leak + * detector status. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return TRUE if blood leak is detected, otherwise FALSE + *************************************************************************/ +BOOL getFPGABloodLeakDetectorStatus( void ) +{ + U16 const status = fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_STATUS_MASK; + + return ( 0 == status ? FALSE : TRUE ); +} + +/*********************************************************************//** + * @brief + * The getDoorState function gets the current state of door switch. + * @details Inputs: none + * @details Outputs: none + * @return current door state + *************************************************************************/ +OPN_CLS_STATE_T getFPGADoorState( void ) +{ + // TODO: Get actual door state from FPGA or GPIO + BOOL const status = 0x0; + + return ( 0 == status ? STATE_CLOSED : STATE_OPEN ); +} + +/*********************************************************************//** + * @brief * The setFPGAValvesControlMode function sets the valves control mode. * @details Inputs: fpgaActuatorSetPoints * @details Outputs: fpgaActuatorSetPoints