Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r711e8c1a6d5024fa7d013ae37e632f59dc2268fe -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 711e8c1a6d5024fa7d013ae37e632f59dc2268fe) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -128,8 +128,7 @@ signalDialOutPumpHardStop(); signalDialInPumpHardStop(); - // TODO: Enable when have syringe pump driver - // stopSyringePump(); + stopSyringePump(); // Send treatment log data to UI sendTreatmentLogData( &treatmentLogData ); @@ -240,8 +239,7 @@ if ( ( bolusVol > 0.0 ) || ( hepRate > 0.0 ) ) { - // TODO: Enable when have syringe pump driver - // retractSyringePump(); + retractSyringePump(); } } } @@ -296,18 +294,16 @@ { if ( FALSE == isCartridgeUnloaded() ) { - activateAlarmNoData( ALARM_ID_CARTRIDGE_REMOVAL_FAILURE ); + activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); } - // TODO: Enable when have syringe pump driver -// if ( TRUE == isSyringeDetected() ) -// { -// // TODO: alarm -// } + if ( TRUE == isSyringeDetected() ) + { + activateAlarmNoData( ALARM_ID_HD_SYRINGE_DETECTED ); + } - // TODO: Add checks for syringe removed if ( ( TRUE == isReservoirOneEmpty ) && ( TRUE == isReservoirTwoEmpty ) && - ( TRUE == isCartridgeUnloaded() ) ) + ( TRUE == isCartridgeUnloaded() ) && ( FALSE == isSyringeDetected() ) ) { cmdStopDG(); requestNewOperationMode( MODE_STAN ); Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r27f3db92495948d4c1192421c1b0c20338c4a034 -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 27f3db92495948d4c1192421c1b0c20338c4a034) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -252,6 +252,10 @@ SW_FAULT_ID_HD_INVALID_COMMAND_RESPONSE_ID, SW_FAULT_ID_HD_INVALID_RESERVOIR_ID, SW_FAULT_ID_HD_INVALID_VALVE_SETTING_ID, + SW_FAULT_ID_HD_SYRINGE_INVALID_BOLUS_CMD, + SW_FAULT_ID_HD_SYRINGE_INVALID_CONT_CMD, // 110 + SW_FAULT_ID_HD_SYRINGE_INVALID_VREF, + SW_FAULT_ID_HD_SYRINGE_INVALID_STATE, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/FPGA.c =================================================================== diff -u -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -169,13 +169,15 @@ U16 VDiPWMTarget; ///< Reg 374. PWM target duty cycle for VDi pinch valve. U16 VDoPWMTarget; ///< Reg 376. PWM target duty cycle for VDo pinch valve. U16 VSparePWMTarget; ///< Reg 378. PWM target duty cycle for Vspare pinch valve. - U16 SyringePumpStatus; ///< Reg 380. Syringe pump status register - U16 SyringePumpEncStatus; ///< Reg 382. Syringe pump encoder status - U32 SyringePumpEncPosition; ///< Reg 384. Syringe pump encoder position - U16 sPumpAdcDataReadChannel0; ///< Reg 388. - U16 sPumpAdcDataReadCh1; ///< Reg 390. - U16 sPumpAdcDataReadCh2; ///< Reg 392. - U16 sPumpAdcDataReadCh3; ///< Reg 394. + U08 syringePumpStatus; ///< Reg 380. Syringe pump status register. + U08 syringePumpADCReadCounter; ///< Reg 381. Syringe pump ADC read counter. + U08 syringePumpADCandDACStatus; ///< Reg 382. Syringe pump ADC and DAC status register. + U08 syringePumpEncoderStatus; ///< Reg 383. Syringe pump encoder status register. + U32 syringePumpEncPosition; ///< Reg 384. Syringe pump encoder position + U16 syringePumpAdcDataReadCh0; ///< Reg 388. Syringe pump ADC channel 0 register (10 bit). + U16 syringePumpAdcDataReadCh1; ///< Reg 390. Syringe pump ADC channel 1 register (10 bit). + U16 syringePumpAdcDataReadCh2; ///< Reg 392. Syringe pump ADC channel 2 register (10 bit). + U16 syringePumpAdcDataReadCh3; ///< Reg 394. Syringe pump ADC channel 3 register (10 bit). U16 VBASpeed; ///< Reg 396. VBA pinch valve speed (Register VAUX0) U16 VBVSpeed; ///< Reg 398. VBV pinch valve speed (Register VAUX1) U16 VBVCurrent; ///< Reg 400. VBV pinch valve current (Register VAUX2) @@ -203,7 +205,11 @@ U16 VDiPWMFixed; ///< Reg 28. VDi PWM set to fixed current by setting fixed PWM duty cycle. Range 750 to 4250. < 2500 is reverse direction. U16 VDoPWMFixed; ///< Reg 30. VDo PWM set to fixed current by setting fixed PWM duty cycle. Range 750 to 4250. < 2500 is reverse direction. U16 VSparePWMFixed; ///< Reg 32. Vspare PWM set to fixed current by setting fixed PWM duty cycle. Range 750 to 4250. < 2500 is reverse direction. - U08 AlarmControl; ///< Reg 34. Alarm (audio) control register. + U08 alarmControl; ///< Reg 34. Alarm (audio) control register. + U08 syringePumpControl; ///< Reg 35. Syringe pump control register. + U32 syringePumpStepToggleTime; ///< Reg 36. Syringe pump step time toggle register. Sets time between step toggle which dictates stepper motor speed. + U16 syringePumpDACOut; ///< Reg 40. Syringe pump DAC output level (12-bit). + U08 syringePumpADCandDACControl; ///< Reg 42. Syringe pump ADC and DAC control register. } FPGA_ACTUATORS_T; // TODO clean up the struct @@ -302,7 +308,7 @@ memset( &fpgaHeader, 0, sizeof(FPGA_HEADER_T) ); memset( &fpgaSensorReadings, 0, sizeof(FPGA_SENSORS_T) ); memset( &fpgaActuatorSetPoints, 0, sizeof(FPGA_ACTUATORS_T) ); - fpgaActuatorSetPoints.AlarmControl = (U08)MIN_ALARM_VOLUME_ATTENUATION << 2; // Start alarm audio volume at maximum + fpgaActuatorSetPoints.alarmControl = (U08)MIN_ALARM_VOLUME_ATTENUATION << 2; // Start alarm audio volume at maximum // Initialize fpga comm buffers memset( &fpgaWriteCmdBuffer, 0, FPGA_WRITE_CMD_BUFFER_LEN ); @@ -1077,15 +1083,15 @@ U08 audioCmd = (U08)state; audioCmd |= ( (U08)volumeLevel << 2 ); - fpgaActuatorSetPoints.AlarmControl = audioCmd; + fpgaActuatorSetPoints.alarmControl = audioCmd; } else { U08 audioCmd = (U08)ALARM_PRIORITY_HIGH; // 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 ); - fpgaActuatorSetPoints.AlarmControl = audioCmd; + 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 ) @@ -1332,6 +1338,184 @@ /*********************************************************************//** * @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.syringePumpControl = 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.syringePumpADCandDACControl = 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.syringePumpDACOut = 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.syringePumpStepToggleTime = 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.syringePumpStatus; +} + +/*********************************************************************//** + * @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.syringePumpADCReadCounter; +} + +/*********************************************************************//** + * @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.syringePumpADCandDACStatus; +} + +/*********************************************************************//** + * @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.syringePumpEncoderStatus; +} + +/*********************************************************************//** + * @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.syringePumpEncPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel0 function gets the latest syringe pump ADC + * channel 0 register reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 0 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel0( void ) +{ + return fpgaSensorReadings.syringePumpAdcDataReadCh0; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel1 function gets the latest syringe pump ADC + * channel 1 register reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 1 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel1( void ) +{ + return fpgaSensorReadings.syringePumpAdcDataReadCh1; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel2 function gets the latest syringe pump ADC + * channel 2 register reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 2 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel2( void ) +{ + return fpgaSensorReadings.syringePumpAdcDataReadCh2; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel3 function gets the latest syringe pump ADC + * channel 3 register reading. + * @details Inputs: fpgaSensorReadings + * @details Outputs: none + * @return last syringe pump ADC channel 3 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel3( void ) +{ + return fpgaSensorReadings.syringePumpAdcDataReadCh3; +} + +/*********************************************************************//** + * @brief * The getFPGAAccelAxes function gets the accelerometer axis readings. * Axis readings are in ADC counts. 0.004 g per LSB. * @details Inputs: fpgaSensorReadings Index: firmware/App/Services/FPGA.h =================================================================== diff -u -rf7b149d8b8c9ea6ac58e4739101693d251d7a355 -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Services/FPGA.h (.../FPGA.h) (revision f7b149d8b8c9ea6ac58e4739101693d251d7a355) +++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -21,11 +21,18 @@ #include "HDCommon.h" #include "Interrupts.h" + /** * @defgroup FPGA FPGA * @brief FPGA service module. - * Maintains latest sensor readings at priority task interval. Updates actuator - * states at priority task interval. + * The FPGA module manages communication between the HD and the FPGA via UART. + * This module is driven by the Priority Task via calls to two FPGA executive functions: + * 1) an incoming executive manages the states of the state machine that deal with responses and data received from the FPGA + * 2) an outgoing executive manages transmission of write and read commands to the FPGA. + * This module first reads the header record that includes the FPGA ID and revision and + * verifies the FPGA ID to check FPGA communication. It then initializes and configures the ADCs and + * various other sensors that are interfaced via the FPGA. Then, it essentially enters an infinite loop + * where a bulk write command updates actuator set points and a bulk read command retrieves the latest sensor readings. * * @addtogroup FPGA * @{ @@ -69,6 +76,20 @@ U16 getFPGADialInPumpOcclusion( void ); U16 getFPGADialOutPumpOcclusion( 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 ); +U16 getFPGASyringePumpADCChannel3( void ); + void getFPGAAccelAxes( S16 *x, S16 *y, S16 *z ); void getFPGAAccelMaxes( S16 *xm, S16*ym, S16*zm ); void getFPGAAccelStatus( U16 *cnt, U16 *accelFPGAFaultReg ); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r17b1e8df35d294dfa84a6ee9c23c1b4de956c4e9 -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 17b1e8df35d294dfa84a6ee9c23c1b4de956c4e9) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -204,6 +204,10 @@ *************************************************************************/ void checkInFromUI( void ) { + if ( FALSE == uiDidCommunicate ) + { // Start DG check-in timer when UI first communicates + timeOfLastDGCheckIn = getMSTimerCount(); + } uiIsCommunicating = TRUE; timeOfLastUICheckIn = getMSTimerCount(); uiDidCommunicate = TRUE; @@ -930,11 +934,13 @@ { activateAlarmNoData( ALARM_ID_UI_COMM_TIMEOUT ); } + + if ( TRUE == didTimeout( timeOfLastDGCheckIn, DG_COMM_TIMEOUT_IN_MS ) ) + { + activateAlarmNoData( ALARM_ID_DG_COMM_TIMEOUT ); + dgIsCommunicating = FALSE; + } } - if ( TRUE == didTimeout( timeOfLastDGCheckIn, DG_COMM_TIMEOUT_IN_MS ) ) - { - dgIsCommunicating = FALSE; - } } /*********************************************************************//** @@ -1191,6 +1197,10 @@ handleChangePressureLimitsRequest( message ); break; + case MSG_ID_UI_HEPARIN_PAUSE_RESUME_REQUEST: + handleHeparinCommandRequest( message ); + break; + case MSG_ID_UI_SET_UF_VOLUME_PARAMETER: handleUFVolumeSetRequest( message ); break; @@ -1463,6 +1473,38 @@ handleTestSuperClearAlarmsRequest( message ); break; + case MSG_ID_HD_SYRINGE_PUMP_SEND_INTERVAL_OVERRIDE: + handleTestSyringePumpDataBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_OPERATION_REQUEST: + handleTestSyringePumpOperationRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_MEASURED_RATE_OVERRIDE: + handleTestSyringePumpMeasuredRateOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_MEASURED_FORCE_OVERRIDE: + handleTestSyringePumpMeasuredForceOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_SYRINGE_DETECT_OVERRIDE: + handleTestSyringePumpMeasuredSyringeDetectOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_MEASURED_HOME_OVERRIDE: + handleTestSyringePumpMeasuredHomeOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_MEASURED_POSITION_OVERRIDE: + handleTestSyringePumpMeasuredPositionOverrideRequest( message ); + break; + + case MSG_ID_HD_SYRINGE_PUMP_MEASURED_VOLUME_OVERRIDE: + handleTestSyringePumpMeasuredVolumeOverrideRequest( message ); + break; + default: // TODO - unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r17b1e8df35d294dfa84a6ee9c23c1b4de956c4e9 -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 17b1e8df35d294dfa84a6ee9c23c1b4de956c4e9) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -434,6 +434,41 @@ return result; } +/*********************************************************************//** + * @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 + * @param heparinDeliveryState current Heparin delivery state + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason, U32 heparinDeliveryState ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) * 3; + + memcpy( payloadPtr, &accepted, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &heparinDeliveryState, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief * The sendTreatmentParamsRangesToUI function constructs a treatment parameter @@ -1084,6 +1119,62 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; +} + +/*********************************************************************//** + * @brief + * The broadcastSyringePumpData function constructs a syringe pump data + * msg to be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: syringe pump data msg constructed and queued. + * @param data syringe pump data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastSyringePumpData( SYRINGE_PUMP_DATA_PAYLOAD_T data ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SYRINGE_PUMP_DATA; + msg.hdr.payloadLen = sizeof( SYRINGE_PUMP_DATA_PAYLOAD_T ); + + memcpy( payloadPtr, &data, sizeof( SYRINGE_PUMP_DATA_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The broadcastHeparinData function constructs a Heparin data message + * to be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Heparin data msg constructed and queued. + * @param data Heparin data record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastHeparinData( F32 volume ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_HEPARIN_DATA_BROADCAST; + msg.hdr.payloadLen = sizeof( F32 ); + + memcpy( payloadPtr, &volume, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; } /*********************************************************************//** @@ -2216,6 +2307,31 @@ /*********************************************************************//** * @brief + * The handleHeparinCommandRequest function handles a Heparin command + * request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHeparinCommandRequest( MESSAGE_T *message ) +{ + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payload; + + memcpy( &payload, &message->payload[0], sizeof( U32 ) ); + + userHeparinRequest( (HEPARIN_CMD_T)payload ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief * The handleSalineBolusRequest function handles a saline bolus request * message from the UI. * @details Inputs: none @@ -4345,4 +4461,253 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The handleTestSyringePumpDataBroadcastIntervalOverrideRequest function handles a + * request to override the syringe pump data broadcast interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpDataPublishIntervalOverride( (U32)(payload.state.u32) ); + } + else + { + result = testResetSyringePumpDataPublishIntervalOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpOperationRequest function handles a + * request to initiate a syringe pump operation. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpOperationRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(SYRINGE_PUMP_OP_PAYLOAD_T) ) + { + SYRINGE_PUMP_OP_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(SYRINGE_PUMP_OP_PAYLOAD_T) ); + result = testSyringePumpOperationRequest( payload ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredRateOverrideRequest function handles a + * request to override the syringe pump measured rate. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredRateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpMeasuredRateOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredRateOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredForceOverrideRequest function handles a + * request to override the syringe pump measured force analog signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredForceOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpMeasuredForceOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredForceOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredSyringeDetectOverrideRequest function handles a + * request to override the syringe pump syringe detected analog signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredSyringeDetectOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpMeasuredSyringeDetectOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredSyringeDetectOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredHomeOverrideRequest function handles a + * request to override the syringe pump measured home analog signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredHomeOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpMeasuredHomeOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredHomeOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredPositionOverrideRequest function handles a + * request to override the syringe pump measured position. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredPositionOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpMeasuredPositionOverride( (S32)(payload.state.u32) ); + } + else + { + result = testResetSyringePumpMeasuredPositionOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpMeasuredVolumeOverrideRequest function handles a + * request to override the syringe pump measured volume delivered. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpMeasuredVolumeOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetSyringePumpMeasuredVolumeOverride( payload.state.f32 ); + } + else + { + result = testResetSyringePumpMeasuredVolumeOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r17b1e8df35d294dfa84a6ee9c23c1b4de956c4e9 -r2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 17b1e8df35d294dfa84a6ee9c23c1b4de956c4e9) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 2346a0cb59957d90fe61cb3bff4ec7ffc3df10a4) @@ -33,6 +33,7 @@ #include "NVDataMgmt.h" #include "PresOccl.h" #include "Rinseback.h" +#include "SyringePump.h" #include "Valves.h" /** @@ -163,6 +164,12 @@ // MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE BOOL sendPressureLimitsChangeResponse( PRESSURE_LIMIT_CHANGE_RESPONSE_T *data ); +// MSG_ID_UI_HEPARIN_PAUSE_RESUME_REQUEST +void handleHeparinCommandRequest( MESSAGE_T *message ); + +// MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE +BOOL sendHeparinCommandResponse( U32 accepted, U32 rejReason, U32 heparinDeliveryState ); + // MSG_ID_UI_RINSEBACK_CMD void handlRinsebackCmd( MESSAGE_T *message ); @@ -245,7 +252,13 @@ BOOL broadcastDialInFlowData( DIALIN_PUMP_STATUS_PAYLOAD_T *dialInData ); // MSG_ID_DIALYSATE_OUT_FLOW_DATA -BOOL broadcastDialOutFlowData( DIAL_OUT_FLOW_DATA_T *dialOutFlowData ); +BOOL broadcastDialOutFlowData( DIAL_OUT_FLOW_DATA_T *dialOutFlowData ); + +// MSG_ID_HD_SYRINGE_PUMP_DATA +BOOL broadcastSyringePumpData( SYRINGE_PUMP_DATA_PAYLOAD_T data ); + +// MSG_ID_HD_HEPARIN_DATA_BROADCAST +BOOL broadcastHeparinData( F32 volume ); // MSG_ID_PRESSURE_OCCLUSION_DATA BOOL broadcastPresOcclData( PRESSURE_OCCLUSION_DATA_T data ); @@ -481,6 +494,30 @@ // MSG_ID_HD_SET_OP_MODE_REQUEST void handleTestSetOpModeRequest( MESSAGE_T *message ); +// MSG_ID_HD_SYRINGE_PUMP_SEND_INTERVAL_OVERRIDE: +void handleTestSyringePumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_OPERATION_REQUEST: +void handleTestSyringePumpOperationRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_MEASURED_RATE_OVERRIDE: +void handleTestSyringePumpMeasuredRateOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_MEASURED_FORCE_OVERRIDE: +void handleTestSyringePumpMeasuredForceOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_SYRINGE_DETECT_OVERRIDE: +void handleTestSyringePumpMeasuredSyringeDetectOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_MEASURED_HOME_OVERRIDE: +void handleTestSyringePumpMeasuredHomeOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_MEASURED_POSITION_OVERRIDE: +void handleTestSyringePumpMeasuredPositionOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SYRINGE_PUMP_MEASURED_VOLUME_OVERRIDE: +void handleTestSyringePumpMeasuredVolumeOverrideRequest( MESSAGE_T *message ); + /**@}*/ #endif