Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r6c0750e3fad58595adcda4bcc26da0032daeff57 -r1240b612f790f931825aba86ec37f37eccce9336 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6c0750e3fad58595adcda4bcc26da0032daeff57) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 1240b612f790f931825aba86ec37f37eccce9336) @@ -20,8 +20,9 @@ #include "sci.h" #include "sys_dma.h" -#include "FPGA.h" #include "Comm.h" +#include "Compatible.h" +#include "FPGA.h" #include "SystemCommMessages.h" #include "Utilities.h" @@ -93,6 +94,12 @@ #define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x04 ///< Bit for arterial air bubble detector self-test command. #define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. +#define FPGA_PBO_TEMP_DIVISOR 2047.0 ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_GAIN 200.0 ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_OFFSET 50.0 ///< Used in conversion of PBo temperature reading to deg C. + +#define FPGA_ALARM_AUDIO_VOLUME_SHIFT 3 ///< Shift alarm audio volume 3 bits to left before writing to register. + // FPGA Sensors Record #pragma pack(push,1) /// Record structure for FPGA header read. @@ -526,9 +533,14 @@ } // If retries for commands exceeds limit, fault - if ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) + if ( ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) +#ifdef _RELEASE_ + || ( fpgaSensorReadings.errorCountProcessor > MAX_COMM_ERROR_RETRIES ) ) +#else + ) +#endif { - activateAlarmNoData( ALARM_ID_HD_FPGA_COMM_TIMEOUT ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_COMM_TIMEOUT, fpgaCommRetryCount, (U32)fpgaSensorReadings.errorCountProcessor ) } // Reset comm flags after processing incoming responses @@ -867,7 +879,23 @@ // Check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { - result = SELF_TEST_STATUS_PASSED; + // Check FPGA compatibility w/ firmware + if ( fpgaHeader.fpgaRevMajor > MIN_HD_FPGA_MAJOR ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + if ( ( MIN_HD_FPGA_MAJOR == fpgaHeader.fpgaRevMajor ) && ( 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 ) + } + } } else { @@ -1072,6 +1100,7 @@ * 1 - Low priority alarm tone (c e) * 2 - Medium priority alarm tone (c f# c) * 3 - High priority alarm tone (c f# c - c f#) + * 4 - Continuous test tone (e) * @param volumeLevel the level of attenuation to command (0..4) * 4 - 3 dB gain * 3 - 6 dB gain @@ -1080,25 +1109,24 @@ * 0 - 15 dB gain * @return none *************************************************************************/ -void setAlarmAudioState( ALARM_PRIORITY_T state, U32 volumeLevel ) +void setAlarmAudioState( U32 state, U32 volumeLevel ) { - if ( ( state < NUM_OF_ALARM_PRIORITIES ) && ( volumeLevel <= MAX_ALARM_VOLUME_ATTENUATION ) ) - { - U08 audioCmd = (U08)state; + U08 audioCmd = (U08)state; - audioCmd |= ( (U08)volumeLevel << 2 ); + audioCmd |= ( (U08)volumeLevel << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); + + if ( ( state <= NUM_OF_ALARM_PRIORITIES ) && ( volumeLevel <= MAX_ALARM_VOLUME_ATTENUATION ) ) + { fpgaActuatorSetPoints.alarmControl = audioCmd; } else { - U08 audioCmd = (U08)ALARM_PRIORITY_HIGH; - + // S/w fault to indicate issue w/ s/w + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_ALARM_AUDIO_PARAM, (U32)audioCmd ) // Set alarm audio to high priority, max volume for safety since s/w seems to be having trouble setting audio correctly - audioCmd |= ( (U08)MIN_ALARM_VOLUME_ATTENUATION << 2 ); + audioCmd = (U08)ALARM_PRIORITY_HIGH; + audioCmd |= ( (U08)MIN_ALARM_VOLUME_ATTENUATION << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); fpgaActuatorSetPoints.alarmControl = audioCmd; - // S/w fault to indicate issue w/ s/w - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_ALARM_AUDIO_PARAM, volumeLevel ) - } } @@ -1142,30 +1170,82 @@ /*********************************************************************//** * @brief - * The getFPGADialysateFlow function gets the latest dialysate flow reading. + * The getFPGABloodFlowMeterStatus function gets the blood flow meter status. * @details Inputs: fpgaSensorReadings * @details Outputs: none - * @return last dialysate flow reading + * @return current blood flow meter status *************************************************************************/ -F32 getFPGADialysateFlow( void ) +U08 getFPGABloodFlowMeterStatus( void ) { - return fpgaSensorReadings.dialysateFlowLast; + return fpgaSensorReadings.bloodFlowMeterDeviceStatus; } /*********************************************************************//** * @brief - * The getFPGABloodFlowMeterStatus function gets the blood flow meter status. + * The getFPGABloodFlowFastPacketReadCounter function gets the blood + * flow meter fast packet read counter. * @details Inputs: fpgaSensorReadings * @details Outputs: none - * @return current blood flow meter status + * @return current blood flow meter fast packet read counter *************************************************************************/ -U08 getFPGABloodFlowMeterStatus( void ) +U08 getFPGABloodFlowFastPacketReadCounter( void ) { - return fpgaSensorReadings.bloodFlowMeterDeviceStatus; + return fpgaSensorReadings.bloodFlowMeterDataPktCount; } /*********************************************************************//** * @brief + * The getFPGABloodFlowSlowPacketReadCounter function gets the blood + * flow meter slow packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter slow packet read counter + *************************************************************************/ +U08 getFPGABloodFlowSlowPacketReadCounter( void ) +{ + return ( fpgaSensorReadings.bloodFlowMeterSlowPktCounts & MASK_OFF_NIBBLE_LSB ) >> SHIFT_BITS_BY_4; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodFlowStatusPacketReadCounter function gets the blood + * flow meter status packet read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter status packet read counter + *************************************************************************/ +U08 getFPGABloodFlowStatusPacketReadCounter( void ) +{ + return ( fpgaSensorReadings.bloodFlowMeterSlowPktCounts & MASK_OFF_NIBBLE_MSB ); +} + +/*********************************************************************//** + * @brief + * The getFPGABloodFlowErrorCounter function gets the blood flow meter + * error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return current blood flow meter error counter + *************************************************************************/ +U08 getFPGABloodFlowErrorCounter( void ) +{ + return fpgaSensorReadings.bloodFlowMeterErrorCount; +} + +/*********************************************************************//** + * @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 @@ -1178,6 +1258,58 @@ /*********************************************************************//** * @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 @@ -1196,9 +1328,9 @@ * @brief * The getFPGABloodPumpHallSensorStatus function gets the latest blood pump * hall sensor status. - * Bit 0 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) - * Bit 1 - A direction error was detected in the current hall sensor phase - * Bit 2 - A direction error was detected since the last read of this register + * Bit 7 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) + * Bit 6 - Unused + * Bit 5-0 - Direction error count since power-up (rolls over) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last blood pump hall sensor status reading. @@ -1228,9 +1360,9 @@ * @brief * The getFPGADialInPumpHallSensorStatus function gets the latest dialysate inlet pump * hall sensor status. - * Bit 0 - Derived direction of the dialyste inlet pump motor (0=Fwd, 1=Rev) - * Bit 1 - A direction error was detected in the current hall sensor phase - * Bit 2 - A direction error was detected since the last read of this register + * Bit 7 - Derived direction of the dialysate inlet pump motor (0=Fwd, 1=Rev) + * Bit 6 - Unused + * Bit 5-0 - Direction error count since power-up (rolls over) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last dialysate inlet pump hall sensor status reading. @@ -1260,9 +1392,9 @@ * @brief * The getFPGADialOutPumpHallSensorStatus function gets the latest dialysate outlet pump * hall sensor status. - * Bit 0 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) - * Bit 1 - A direction error was detected in the current hall sensor phase - * Bit 2 - A direction error was detected since the last read of this register + * Bit 7 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) + * Bit 6 - Unused + * Bit 5-0 - Direction error count since power-up (rolls over) * @details Inputs: fpgaSensorReadings * @details Outputs: none * @return last dialysate outlet pump hall sensor status reading. @@ -1312,6 +1444,84 @@ /*********************************************************************//** * @brief + * The getFPGABloodPumpOcclusionReadCounter function gets the latest blood + * pump occlusion read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last blood pump occlusion read counter + *************************************************************************/ +U08 getFPGABloodPumpOcclusionReadCounter( void ) +{ + return fpgaSensorReadings.bloodOcclusionReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialInPumpOcclusionReadCounter function gets the latest dialysate + * inlet pump occlusion read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate inlet pump occlusion read counter + *************************************************************************/ +U08 getFPGADialInPumpOcclusionReadCounter( void ) +{ + return fpgaSensorReadings.dialysateInOcclusionReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialOutPumpOcclusionReadCounter function gets the latest dialysate + * outlet pump occlusion read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate outlet pump occlusion read counter + *************************************************************************/ +U08 getFPGADialOutPumpOcclusionReadCounter( void ) +{ + return fpgaSensorReadings.dialysateOutOcclusionReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGABloodPumpOcclusionErrorCounter function gets the latest blood + * pump occlusion error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last blood pump occlusion error counter + *************************************************************************/ +U08 getFPGABloodPumpOcclusionErrorCounter( void ) +{ + return fpgaSensorReadings.bloodOcclusionErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialInPumpOcclusionErrorCounter function gets the latest dialysate + * inlet pump occlusion error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate inlet pump occlusion error counter + *************************************************************************/ +U08 getFPGADialInPumpOcclusionErrorCounter( void ) +{ + return fpgaSensorReadings.dialysateInOcclusionErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGADialOutPumpOcclusionErrorCounter function gets the latest dialysate + * outlet pump occlusion error counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last dialysate outlet pump occlusion error counter + *************************************************************************/ +U08 getFPGADialOutPumpOcclusionErrorCounter( void ) +{ + return fpgaSensorReadings.dialysateOutOcclusionErrorCount; +} + +/*********************************************************************//** + * @brief * The getFPGAArterialPressure function gets the latest arterial pressure reading. * High byte indicates alarm status for ADC channel. * Low 24-bits are channel reading. Subtract 2^23 from low 24 bits to get @@ -1327,7 +1537,7 @@ /*********************************************************************//** * @brief - * The getFPGAVenousPressure function gets the venous arterial pressure reading. + * The getFPGAVenousPressure function gets the latest venous pressure reading. * The high 2 bits are status bits: 00=ok, 01=cmd mode, 10=stale data, 11=diag * The low 14 bits are data. Zero is at 1638. Values above are positive, * below are negative. @@ -1342,6 +1552,34 @@ /*********************************************************************//** * @brief + * The getFPGAVenousPressureTemperature function gets the latest venous pressure + * sensor temperature reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last venous pressure sensor temperature reading + *************************************************************************/ +F32 getFPGAVenousPressureTemperature( void ) +{ + F32 result = ( (F32)fpgaSensorReadings.venousTemperature / FPGA_PBO_TEMP_DIVISOR ) * FPGA_PBO_TEMP_GAIN - FPGA_PBO_TEMP_OFFSET; + + return result; +} + +/*********************************************************************//** + * @brief + * The getFPGAVenousPressureReadCounter function gets the latest venous pressure + * sensor read counter. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last venous pressure sensor read counter + *************************************************************************/ +U08 getFPGAVenousPressureReadCounter( void ) +{ + return fpgaSensorReadings.venousReadCounter; +} + +/*********************************************************************//** + * @brief * The setFPGASyringePumpControlFlags function sets the syringe pump control * register per given bit flags. * @details Inputs: none