Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r22293ecac97c3f374f90bb20e3c4cc03fbd27f9d -r2de8bd54fe7ce6557115820251069611b49aa0ab --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 22293ecac97c3f374f90bb20e3c4cc03fbd27f9d) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 2de8bd54fe7ce6557115820251069611b49aa0ab) @@ -17,10 +17,10 @@ #include // Used for fabs() functions -#include "AlarmMgmt.h" +#include "AlarmMgmtTD.h" #include "BloodFlow.h" #include "CpldInterface.h" -#include "FPGA.h" +#include "FpgaTD.h" #include "Messaging.h" #include "ModeTreatment.h" #include "OperationModes.h" @@ -295,6 +295,7 @@ static BOOL checkVolumeVsSafetyVolume( BOOL stopPump, F32 pctMargin ); static BOOL checkForStall( BOOL stopPump ); static void publishSyringePumpData( void ); +static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ); /*********************************************************************//** * @brief @@ -524,11 +525,11 @@ { if ( HEPARIN_STATE_INITIAL_BOLUS == heparinDeliveryState ) { - sendTreatmentLogEventData( HEPARIN_BOLUS_END_EVENT, syringePumpSetRate, 0.0 ); +// sendTreatmentLogEventData( HEPARIN_BOLUS_END_EVENT, syringePumpSetRate, 0.0 ); } else { - sendTreatmentLogEventData( HEPARIN_STOP_PAUSE_EVENT, syringePumpSetRate, 0.0 ); +// sendTreatmentLogEventData( HEPARIN_STOP_PAUSE_EVENT, syringePumpSetRate, 0.0 ); } heparinDeliveryState = HEPARIN_STATE_STOPPED; syringePumpSetRate = 0.0; @@ -672,7 +673,7 @@ else { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) #endif { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_TD_SYRINGE_INVALID_BOLUS_CMD, syringePumpSetRate ) @@ -709,7 +710,7 @@ else { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_ENABLE_VALUE ) #endif { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, (F32)SW_FAULT_ID_TD_SYRINGE_INVALID_CONT_CMD, flowRate ) @@ -1061,12 +1062,12 @@ static void execSyringePumpMonitor( void ) { // Check if a new calibration is available - if ( TRUE == isNewCalibrationRecordAvailable() ) - { +// if ( TRUE == isNewCalibrationRecordAvailable() ) +// { // Get the new calibration data and check its validity - getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), - 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); - } +// getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), +// 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); +// } S32 encPosition = getFPGASyringePumpEncoderPosition(); @@ -1079,19 +1080,19 @@ // Get latest ADC data and convert to V syringePumpMeasHome.data = ( (F32)getFPGASyringePumpADCChannel2() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_DISABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP ) != SW_CONFIG_DISABLE_VALUE ) { syringePumpMeasSyringeDetectionSwitch.data = 0.0; // if syringe pump disabled, always report no detection } - else +// else #endif { syringePumpMeasSyringeDetectionSwitch.data = ( (F32)getFPGASyringePumpADCChannel1() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; } // Handle syringe detect alarm management #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { F32 bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); @@ -1140,7 +1141,7 @@ calcMeasRate(); #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { // Get measured direction @@ -1162,7 +1163,7 @@ if ( ( FALSE == syringePumpDACVrefWriteInProgress ) && ( getCurrentOperationMode() > MODE_INIT ) ) { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { checkFPGAPersistentAlarms( FPGA_PERS_ERROR_SYRINGE_PUMP_ADC, getSyringePumpADCReadCounter() ); @@ -1264,12 +1265,13 @@ SELF_TEST_STATUS_T execSyringePumpSelfTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + BOOL calStatus = FALSE; // Read/check force sensor calibration - BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), - 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); +// BOOL calStatus = getNVRecord2Driver( GET_CAL_HEPARIN_FORCE_SENSOR, (U08*)&forceSensorCalRecord, sizeof( TD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T ), +// 0, ALARM_ID_TD_HEPARIN_FORCE_SENSOR_INVALID_CAL_RECORD ); #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { if ( TRUE == calStatus ) @@ -1328,7 +1330,7 @@ if ( ( syringePumpStopLastPosition != getSyringePumpPosition() ) && ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_SYRINGE_PUMP_OFF_ERROR ) ) ) { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { activateAlarmNoData( ALARM_ID_TD_SYRINGE_PUMP_NOT_STOPPED_ERROR ); @@ -1368,13 +1370,13 @@ else if ( TRUE == syringePumpBolusRequested ) { heparinDeliveryState = HEPARIN_STATE_INITIAL_BOLUS; - sendTreatmentLogEventData( HEPARIN_BOLUS_START_EVENT, 0.0, syringePumpSetRate ); +// sendTreatmentLogEventData( HEPARIN_BOLUS_START_EVENT, 0.0, syringePumpSetRate ); result = SYRINGE_PUMP_HEP_BOLUS_STATE; } else if ( TRUE == syringePumpContinuousRequested ) { heparinDeliveryState = HEPARIN_STATE_DISPENSING; - sendTreatmentLogEventData( HEPARIN_START_RESUME_EVENT, 0.0, syringePumpSetRate ); +// sendTreatmentLogEventData( HEPARIN_START_RESUME_EVENT, 0.0, syringePumpSetRate ); result = SYRINGE_PUMP_HEP_CONTINUOUS_STATE; } else if ( ( TRUE == syringePumpDACVrefSetRequested ) || @@ -1574,7 +1576,7 @@ else { #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { SET_ALARM_WITH_2_F32_DATA( ALARM_ID_TD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM, syringeVol, txVolume ); @@ -1822,7 +1824,7 @@ BOOL result = stopPump; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { // Check direction if rate >= minimum for alarm @@ -1991,7 +1993,7 @@ BOOL result = stopPump; #ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SYRINGE_PUMP_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif { F32 rate = getSyringePumpMeasRate(); @@ -2221,6 +2223,26 @@ } } +/*********************************************************************//** + * @brief + * The sendHeparinCommandResponse function constructs a Heparin command response + * to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Heparin command response msg constructed and queued. + * @param accepted flag indicating whether request was accepted + * @param rejReason rejection reason code + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason ) +{ + BOOL result; + UI_RESPONSE_PAYLOAD_T payload; + payload.accepted = accepted; + payload.rejectionReason = rejReason; + result = sendMessage( MSG_ID_TD_HEPARIN_PAUSE_RESUME_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&payload), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + return result; +} /************************************************************************* * TEST SUPPORT FUNCTIONS Index: firmware/App/Services/FpgaTD.c =================================================================== diff -u -r395522dffef1348e176564925656012f529c1910 -r2de8bd54fe7ce6557115820251069611b49aa0ab --- firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 395522dffef1348e176564925656012f529c1910) +++ firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 2de8bd54fe7ce6557115820251069611b49aa0ab) @@ -165,6 +165,14 @@ U32 baroTemperature; ///< Reg 372. Baro temperature value in counts. U08 baroReadCount; ///< Reg 376. Baro read count. U08 baroErrorCount; ///< Reg 377. Baro error count. + U08 syrPumpStatus; ///< Reg 380. Syringe pump status register. + U08 syrPumpADCReadCounter; ///< Reg 381. Syringe pump ADC read counter. + U08 syrPumpADCandDACStatus; ///< Reg 382. Syringe pump ADC and DAC status register. + U08 syrPumpEncoderStatus; ///< Reg 383. Syringe pump encoder status register. + U32 syrPumpEncPosition; ///< Reg 384. Syringe pump encoder position + U16 syrPumpAdcDataReadCh0; ///< Reg 388. Syringe pump ADC channel 0 register (10 bit). + U16 syrPumpAdcDataReadCh1; ///< Reg 390. Syringe pump ADC channel 1 register (10 bit). + U16 syrPumpAdcDataReadCh2; ///< Reg 392. Syringe pump ADC channel 2 register (10 bit). } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -1316,4 +1324,169 @@ } } +/*********************************************************************//** + * @brief + * The setFPGASyringePumpControlFlags function sets the syringe pump control + * register per given bit flags. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @param bitFlags control bit settings for syringe pump + * @return none + *************************************************************************/ +void setFPGASyringePumpControlFlags( U08 bitFlags ) +{ + fpgaActuatorSetPoints.syrPumpControl = bitFlags; +} + +/*********************************************************************//** + * @brief + * The setFPGASyringePumpADCandDACControlFlags function sets the syringe pump + * ADC/DAC control register per given bit flags. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @param bitFlags ADC/DAC control bit settings for syringe pump + * @return none + *************************************************************************/ +void setFPGASyringePumpADCandDACControlFlags( U08 bitFlags ) +{ + fpgaActuatorSetPoints.syrPumpDACControl = bitFlags; +} + +/*********************************************************************//** + * @brief + * The setFPGASyringePumpDACOutputLevel function sets the syringe pump force + * sensor DAC output level register to a given value. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @param counts level to set syringe pump force sensor DAC to + * @return none + *************************************************************************/ +void setFPGASyringePumpDACOutputLevel( U16 counts ) +{ + fpgaActuatorSetPoints.syrPumpDACData = counts; +} + +/*********************************************************************//** + * @brief + * The setFPGASyringePumpStepToggleTime function sets the syringe pump stepper + * toggle time register to a given period (in uSec). + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints + * @param microSeconds toggle the stepper motor at this time interval to set pump speed + * @return none + *************************************************************************/ +void setFPGASyringePumpStepToggleTime( U32 microSeconds ) +{ + fpgaActuatorSetPoints.syrPumpSpeed = microSeconds; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpStatus function gets the latest syringe pump status + * register reading. Bit 0 indicates a fault. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump status reading + *************************************************************************/ +U08 getFPGASyringePumpStatus( void ) +{ + return fpgaSensorReadings.syrPumpStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCReadCounter function gets the latest syringe pump + * 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 + *************************************************************************/ +U08 getFPGASyringePumpADCReadCounter( void ) +{ + return fpgaSensorReadings.syrPumpADCReadCounter; +} + +/*********************************************************************//** + * @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 + *************************************************************************/ +U08 getFPGASyringePumpADCandDACStatus( void ) +{ + return fpgaSensorReadings.syrPumpADCandDACStatus; +} + +/*********************************************************************//** + * @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 + *************************************************************************/ +U08 getFPGASyringePumpEncoderStatus( void ) +{ + return fpgaSensorReadings.syrPumpEncoderStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpEncoderPosition function gets the latest syringe pump + * encoder position reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump encoder position reading + *************************************************************************/ +U32 getFPGASyringePumpEncoderPosition( void ) +{ + return fpgaSensorReadings.syrPumpEncPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel0 function gets the latest syringe pump ADC + * channel 0 register reading (syringe pump force sensor). + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 0 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel0( void ) +{ + return fpgaSensorReadings.syrPumpAdcDataReadCh0; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel1 function gets the latest syringe pump ADC + * channel 1 register reading (syringe detection switch). + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 1 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel1( void ) +{ + return fpgaSensorReadings.syrPumpAdcDataReadCh1; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel2 function gets the latest syringe pump ADC + * channel 2 register reading (syringe pump home position sensor). + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 2 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel2( void ) +{ + return fpgaSensorReadings.syrPumpAdcDataReadCh2; +} + /**@}*/ Index: firmware/App/Services/FpgaTD.h =================================================================== diff -u -r395522dffef1348e176564925656012f529c1910 -r2de8bd54fe7ce6557115820251069611b49aa0ab --- firmware/App/Services/FpgaTD.h (.../FpgaTD.h) (revision 395522dffef1348e176564925656012f529c1910) +++ firmware/App/Services/FpgaTD.h (.../FpgaTD.h) (revision 2de8bd54fe7ce6557115820251069611b49aa0ab) @@ -150,6 +150,19 @@ U32 getFPGAEjectorRetractOpticalSensor( void ); U32 getFPGAEjectorEngageOpticalSensor( void ); +void setFPGASyringePumpControlFlags( U08 bitFlags ); +void setFPGASyringePumpADCandDACControlFlags( U08 bitFlags ); +void setFPGASyringePumpDACOutputLevel( U16 counts ); +void setFPGASyringePumpStepToggleTime( U32 microSeconds ); +U08 getFPGASyringePumpStatus( void ); +U08 getFPGASyringePumpADCReadCounter( void ); +U08 getFPGASyringePumpADCandDACStatus( void ); +U08 getFPGASyringePumpEncoderStatus( void ); +U32 getFPGASyringePumpEncoderPosition( void ); +U16 getFPGASyringePumpADCChannel0( void ); +U16 getFPGASyringePumpADCChannel1( void ); +U16 getFPGASyringePumpADCChannel2( void ); + /**@}*/ #endif