Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r7c03cfb8116f1e29ef3dbc60f84f2e6f26481f5c -rbd8d1a18ca5d9dd52c1082f74c19b90ca925af92 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 7c03cfb8116f1e29ef3dbc60f84f2e6f26481f5c) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision bd8d1a18ca5d9dd52c1082f74c19b90ca925af92) @@ -132,6 +132,10 @@ SYRINGE_PUMP_CONTROL_FORWARD_DIR | SYRINGE_PUMP_CONTROL_32TH_STEP; +#define SYRINGE_PUMP_DAC_WRITE_ERROR_BIT 0x40 ///< Syringe pump DAC write error bit flag in FPGA register. +#define SYRINGE_PUMP_ENCODER_DIRECTION_ERROR_BITS 0x3F ///< Syringe pump encoder direction error counter bits in FPGA register. +#define SYRINGE_PUMP_ENCODER_DIRECTION_BIT 0x80 ///< Syringe pump encoder direction bit in FPGA register. + /// Defined states for the syringe pump control state machine. typedef enum SyringePump_States { @@ -340,7 +344,7 @@ rejReason = REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE; } - sendHeparinCommandResponse( (U32)accepted, (U32)rejReason, (U32)heparinDeliveryState ); + sendHeparinCommandResponse( (U32)accepted, (U32)rejReason ); return accepted; } @@ -798,7 +802,6 @@ U08 pmpStatus = getFPGASyringePumpStatus(); U08 encStatus = getFPGASyringePumpEncoderStatus(); U08 adcReadCtr = getFPGASyringePumpADCReadCounter(); - U08 adcDACStatus= getFPGASyringePumpADCandDACStatus(); // Get latest ADC data and convert to V syringePumpMeasHome.data = ( (F32)getFPGASyringePumpADCChannel2() * SYRINGE_PUMP_ADC_REF_V ) / SYRINGE_PUMP_ADC_FULL_SCALE_BITS; @@ -812,7 +815,7 @@ // Calculate measured rate (mL/hr) calcMeasRate(); // Get measured direction - syringePumpMeasuredDirection = ( ( encStatus & 0x80 ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); + syringePumpMeasuredDirection = ( ( encStatus & SYRINGE_PUMP_ENCODER_DIRECTION_BIT ) != 0 ? MOTOR_DIR_REVERSE : MOTOR_DIR_FORWARD ); if ( syringePumpDACVrefWriteInProgress != TRUE ) { @@ -824,7 +827,7 @@ lastSyringePumpADCReadCtr = adcReadCtr; // Check encoder direction error. // TODO check direction in states - if ( ( encStatus & 0x3F ) != 0) + if ( ( encStatus & SYRINGE_PUMP_ENCODER_DIRECTION_ERROR_BITS ) != 0) { // TODO - alarm? } @@ -1222,6 +1225,7 @@ static SYRINGE_PUMP_STATE_T handleSyringePumpCalibrateForceSensorState( void ) { SYRINGE_PUMP_STATE_T result = SYRINGE_PUMP_CONFIG_FORCE_SENSOR_STATE; + U08 adcDACStatus= getFPGASyringePumpADCandDACStatus(); // Wait for DAC setting write to EEPROM to complete if ( ( getFPGASyringePumpADCandDACStatus() & SYRINGE_PUMP_ADC_DAC_ERROR_COUNT_DAC_WR_DONE ) != 0 ) @@ -1233,7 +1237,7 @@ result = SYRINGE_PUMP_OFF_STATE; } // Check DAC write error - else if ( ( adcDACStatus & 0x40 ) != 0 ) + else if ( ( adcDACStatus & SYRINGE_PUMP_DAC_WRITE_ERROR_BIT ) != 0 ) { // TODO - alarm }