Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -95,12 +95,12 @@ #define BLOODPUMP_ADC_FULL_SCALE_V 3.0 ///< BP analog signals are 0-3V (while int. ADC ref may be different) #define BLOODPUMP_ADC_ZERO 1998 ///< Blood pump ADC channel zero offset. -/// macro converts 12 bit ADC value to signed 16-bit value. +/// Macro converts 12 bit ADC value to signed 16-bit value. #define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)BLOODPUMP_ADC_ZERO ) -/// measured blood flow is filtered w/ moving average +/// Measured blood flow is filtered w/ moving average #define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) -/// blood flow sensor signal strength low alarm persistence. +/// Blood flow sensor signal strength low alarm persistence. #define FLOW_SIG_STRGTH_ALARM_PERSIST ( 5 * MS_PER_SECOND ) #define MIN_FLOW_SIG_STRENGTH 0.9 ///< Minimum flow sensor signal strength (90%). @@ -123,10 +123,10 @@ NUM_OF_BLOOD_FLOW_SELF_TEST_STATES ///< Number of blood pump self-test states. } BLOOD_FLOW_SELF_TEST_STATE_T; -// pin assignments for pump stop and direction outputs +// Pin assignments for pump stop and direction outputs #define STOP_CAN3_PORT_MASK 0x00000002 // (Tx - re-purposed as output GPIO for blood pump stop signal) #define DIR_CAN3_PORT_MASK 0x00000002 // (Rx - re-purposed as output GPIO for blood pump direction signal) -// blood pump stop and direction macros +// Blood pump stop and direction macros #define SET_BP_DIR() {canREG3->RIOC |= DIR_CAN3_PORT_MASK;} // Macro to set blood pump direction signal high. #define CLR_BP_DIR() {canREG3->RIOC &= ~DIR_CAN3_PORT_MASK;} // Macro to set blood pump direction signal low. #define SET_BP_STOP() {canREG3->TIOC &= ~STOP_CAN3_PORT_MASK;} // Macro to set blood pump stop signal (active low). @@ -531,21 +531,21 @@ { BLOOD_PUMP_STATE_T result = BLOOD_PUMP_RAMPING_UP_STATE; - // have we been asked to stop the blood pump? + // Have we been asked to stop the blood pump? if ( 0 == targetBloodFlowRate ) { - // start ramp down to stop + // Start ramp down to stop bloodPumpPWMDutyCyclePctSet -= MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE; setBloodPumpControlSignalPWM( bloodPumpPWMDutyCyclePctSet ); result = BLOOD_PUMP_RAMPING_DOWN_STATE; } - // have we reached end of ramp up? + // Have we reached end of ramp up? else if ( bloodPumpPWMDutyCyclePctSet >= bloodPumpPWMDutyCyclePct ) { resetBloodFlowMovingAverage(); resetPIController( PI_CONTROLLER_ID_BLOOD_FLOW, bloodPumpPWMDutyCyclePctSet ); bloodPumpControlModeSet = bloodPumpControlMode; - // if open loop mode, set PWM to requested duty cycle where it will stay during control state + // If open loop mode, set PWM to requested duty cycle where it will stay during control state if ( bloodPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { bloodPumpPWMDutyCyclePctSet = bloodPumpPWMDutyCyclePct; @@ -575,19 +575,19 @@ { BLOOD_PUMP_STATE_T result = BLOOD_PUMP_RAMPING_DOWN_STATE; - // have we essentially reached zero speed + // Have we essentially reached zero speed if ( bloodPumpPWMDutyCyclePctSet < (MAX_BLOOD_PUMP_PWM_STEP_DN_CHANGE + BP_PWM_ZERO_OFFSET) ) { stopBloodPump(); result = BLOOD_PUMP_OFF_STATE; } - // have we reached end of ramp down? + // Have we reached end of ramp down? else if ( bloodPumpPWMDutyCyclePctSet <= bloodPumpPWMDutyCyclePct ) { resetBloodFlowMovingAverage(); resetPIController( PI_CONTROLLER_ID_BLOOD_FLOW, bloodPumpPWMDutyCyclePctSet ); bloodPumpControlModeSet = bloodPumpControlMode; - // if open loop mode, set PWM to requested duty cycle where it will stay during control state + // If open loop mode, set PWM to requested duty cycle where it will stay during control state if ( bloodPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { bloodPumpPWMDutyCyclePctSet = bloodPumpPWMDutyCyclePct; @@ -857,7 +857,7 @@ *************************************************************************/ static void publishBloodFlowData( void ) { - // publish blood flow data on interval + // Publish blood flow data on interval if ( ++bloodFlowDataPublicationTimerCounter >= getPublishBloodFlowDataInterval() ) { BLOOD_PUMP_STATUS_PAYLOAD_T payload; @@ -937,7 +937,7 @@ U16 decDelta = HEX_64_K - incDelta; U16 delta; - // determine blood pump speed/direction from delta hall sensor count since last interval + // Determine blood pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { delta = incDelta; @@ -950,7 +950,7 @@ } bloodPumpMotorEdgeCount += delta; - // update last count for next time + // Update last count for next time bpLastMotorHallSensorCounts[ nextIdx ] = bpMotorHallSensorCount; bpMotorSpeedCalcIdx = nextIdx; bpMotorSpeedCalcTimerCtr = 0; @@ -970,15 +970,15 @@ { F32 rotorSpeed = getMeasuredBloodPumpRotorSpeed(); - // if homing, check timeout + // If homing, check timeout if ( ( TRUE == bpStopAtHomePosition ) && ( TRUE == didTimeout( bpHomeStartTime, BP_HOME_TIMEOUT_MS ) ) ) { signalBloodPumpHardStop(); bpStopAtHomePosition = FALSE; // TODO - alarm??? } - // ensure rotor speed below maximum + // Ensure rotor speed below maximum if ( rotorSpeed > BP_MAX_ROTOR_SPEED_RPM ) { if ( ++errorBloodPumpRotorTooFastPersistTimerCtr >= BP_MAX_ROTOR_SPEED_ERROR_PERSIST ) @@ -991,7 +991,7 @@ errorBloodPumpRotorTooFastPersistTimerCtr = 0; } - // if pump is stopped or running very slowly, set rotor speed to zero + // If pump is stopped or running very slowly, set rotor speed to zero if ( TRUE == didTimeout( bpRotorRevStartTime, BP_HOME_TIMEOUT_MS ) ) { bloodPumpRotorSpeedRPM.data = 0.0; @@ -1183,7 +1183,7 @@ { F32 bpCurr; - // blood pump should be off + // Blood pump should be off if ( BLOOD_PUMP_OFF_STATE == bloodPumpState ) { bpCurr = fabs( getMeasuredBloodPumpMCCurrent() ); @@ -1202,7 +1202,7 @@ bpCurrErrorDurationCtr = 0; } } - // blood pump should be running + // Blood pump should be running else { bpCurr = fabs( getMeasuredBloodPumpMCCurrent() ); @@ -1312,10 +1312,10 @@ CALIBRATION_DATA_T cal; getCalibrationData( &cal ); - // keep locally and apply immediately + // Keep locally and apply immediately bloodFlowCalGain = gain; bloodFlowCalOffset = offset; - // also update calibration record in non-volatile memory + // Also update calibration record in non-volatile memory cal.bloodFlowGain = gain; cal.bloodFlowOffset_mL_min = offset; if ( TRUE == setCalibrationData( cal ) )