Index: firmware/App/Modes/BloodPrime.c =================================================================== diff -u -rac6532c81f2a6d4ad1c67420c22d59f6aeeaae13 -rdb22e9d530c5c9d62b02e6dcc72ed96fb67c165a --- firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision ac6532c81f2a6d4ad1c67420c22d59f6aeeaae13) +++ firmware/App/Modes/BloodPrime.c (.../BloodPrime.c) (revision db22e9d530c5c9d62b02e6dcc72ed96fb67c165a) @@ -67,7 +67,7 @@ static U32 bloodPrimePublishTimerCtr; ///< Timer counter for determining interval for blood prime status to be published. static F32 cumulativeBloodPrimeVolume_mL; ///< Total cumulative blood prime volume (in mL). -static U32 bloodPrimeMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent blood prime volume check. +static S32 bloodPrimeMotorCount; ///< The cumulative sum of BP motor encoder counts used for independent blood prime volume check. static U32 bloodPrimeLastMotorCount; ///< The last BP motor encoder count read for independent blood prime volume check. static F32 bloodPrimeVolumeDelivered_Safety; ///< The cumulative independent blood prime volume (in mL) calculated so far. @@ -209,7 +209,7 @@ // update blood prime volume delivered so far cumulativeBloodPrimeVolume_mL += ( getMeasuredBloodFlowRate() * BLOOD_PRIME_FLOW_INTEGRATOR ); // update independent calculated safety volume delivered so far - bloodPrimeMotorCount = u32DiffWithWrap( bloodPrimeLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; + bloodPrimeMotorCount = u32BiDiffWithWrap( bloodPrimeLastMotorCount, getBloodPumpMotorCount() ) / BP_HALL_EDGE_COUNTS_PER_REV; bloodPrimeVolumeDelivered_Safety = ( (F32)bloodPrimeMotorCount * VOLUME_PER_BP_MOTOR_REV_ML ); // TODO - include upstream pressure compensation to this calc // Has blood prime completed?