Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r9eca7842221b1510b0b7b926a3a792e09b4c80cb -r26c0af30da4b3756e7aeec861d6a465132139af5 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 9eca7842221b1510b0b7b926a3a792e09b4c80cb) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 26c0af30da4b3756e7aeec861d6a465132139af5) @@ -256,7 +256,8 @@ static U32 syringePumpEmptyForceCount; ///< Counter for empty syringe detection. -static U32 syringePumpSyringeDetectDebounceStartTime; ///< Syringe pump syringe detect debounce start time. +static U32 syringePumpSyringeNotDetectDebStartTime; ///< Syringe pump syringe not detect debounce start time. +static U32 syringePumpSyringeDetectDebStartTime; ///< Syringe pump syringe detect debounce start time. // ********** private function prototypes ********** @@ -927,31 +928,50 @@ * @brief * The isSyringeDetected function determines whether a syringe is currently * detected. - * @details Inputs: syringePumpSyringeDetectDebounceStartTime - * @details Outputs: syringePumpSyringeDetectDebounceStartTime + * @details Inputs: syringePumpSyringeNotDetectDebStartTime, + * syringePumpSyringeDetectDebStartTime + * @details Outputs: syringePumpSyringeNotDetectDebStartTime, + * syringePumpSyringeDetectDebStartTime * @return TRUE if syringe detected, FALSE if not *************************************************************************/ BOOL isSyringeDetected( void ) { // Assume the syringe is there until the debounce time has elapsed - BOOL result = TRUE; + BOOL result = TRUE; + F32 syringeDetectVoltV = getSyringePumpSyringeDetectorV(); - if ( getSyringePumpSyringeDetectorV() < SYRINGE_PUMP_SYRINGE_DETECT_THRESHOLD_V ) + if ( syringeDetectVoltV < SYRINGE_PUMP_SYRINGE_DETECT_THRESHOLD_V ) { - if ( 0 == syringePumpSyringeDetectDebounceStartTime ) + if ( 0 == syringePumpSyringeNotDetectDebStartTime ) { - syringePumpSyringeDetectDebounceStartTime = getMSTimerCount(); + syringePumpSyringeNotDetectDebStartTime = getMSTimerCount(); } - else if ( TRUE == didTimeout( syringePumpSyringeDetectDebounceStartTime, SYRINGE_PUMP_SYRINGE_DETECT_DEBOUNCE_TIME_MS ) ) + else if ( TRUE == didTimeout( syringePumpSyringeNotDetectDebStartTime, SYRINGE_PUMP_SYRINGE_DETECT_DEBOUNCE_TIME_MS ) ) { result = FALSE; } } else { - syringePumpSyringeDetectDebounceStartTime = 0; + syringePumpSyringeNotDetectDebStartTime = 0; } + if ( syringeDetectVoltV >= SYRINGE_PUMP_SYRINGE_DETECT_THRESHOLD_V ) + { + if ( 0 == syringePumpSyringeDetectDebStartTime ) + { + syringePumpSyringeDetectDebStartTime = getMSTimerCount(); + } + else if ( TRUE == didTimeout( syringePumpSyringeDetectDebStartTime, SYRINGE_PUMP_SYRINGE_DETECT_DEBOUNCE_TIME_MS ) ) + { + result = TRUE; + } + } + else + { + syringePumpSyringeDetectDebStartTime = 0; + } + return result; }