Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -173,7 +173,7 @@ { BOOL lower, upper; - // get latest level readings + // Get latest level readings getFPGAAirTrapLevels( &lower, &upper ); airTrapLevels[ AIR_TRAP_LEVEL_SENSOR_LOWER ].data = (U32)( TRUE == lower ? AIR_TRAP_LEVEL_AIR : AIR_TRAP_LEVEL_FLUID ); airTrapLevels[ AIR_TRAP_LEVEL_SENSOR_UPPER ].data = (U32)( TRUE == upper ? AIR_TRAP_LEVEL_AIR : AIR_TRAP_LEVEL_FLUID ); @@ -207,7 +207,7 @@ void execAirTrapMonitorPriming( void ) { // TODO - Implement when priming sub-mode of pre-treatment mode is implemented. - // activateAlarmNoData( ALARM_ID_AIR_TRAP_FILL_DURING_PRIME ); + // ActivateAlarmNoData( ALARM_ID_AIR_TRAP_FILL_DURING_PRIME ); } /*********************************************************************//** Index: firmware/App/Controllers/AlarmLamp.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -227,7 +227,7 @@ { alarmLampSelfTestState = ALARM_LAMP_SELF_TEST_STATE_YELLOW; alarmLampSelfTestStepTimerCount = getMSTimerCount(); - setCPLDLampGreen( PIN_SIGNAL_HIGH ); // green + red = yellow + setCPLDLampGreen( PIN_SIGNAL_HIGH ); // Green + red = yellow } break; 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 ) ) Index: firmware/App/Controllers/Buttons.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -138,14 +138,14 @@ PIN_SIGNAL_STATE_T off = getCPLDOffButton(); PIN_SIGNAL_STATE_T stop = getCPLDStopButton(); - // set current button states read from CPLD + // Set current button states read from CPLD dataOffButtonState.data = ( off == PIN_SIGNAL_HIGH ? BUTTON_STATE_PRESSED : BUTTON_STATE_RELEASED ); dataStopButtonState.data = ( stop == PIN_SIGNAL_HIGH ? BUTTON_STATE_PRESSED : BUTTON_STATE_RELEASED ); - // handle button state transitions for stop button + // Handle button state transitions for stop button handleStopButtonProcessing(); - // handle button state transitions for off button + // Handle button state transitions for off button handleOffButtonProcessing(); } @@ -225,7 +225,7 @@ case BUTTON_SELF_TEST_STATE_START: buttonSelfTestState = BUTTON_SELF_TEST_STATE_IN_PROGRESS; buttonSelfTestTimerCount = getMSTimerCount(); - // no break here so we pass through directly to in progress processing + // No break here so we pass through directly to in progress processing case BUTTON_SELF_TEST_STATE_IN_PROGRESS: if ( ( dataOffButtonState.data == BUTTON_STATE_RELEASED ) && ( dataStopButtonState.data == BUTTON_STATE_RELEASED ) ) @@ -241,11 +241,11 @@ buttonSelfTestState = BUTTON_SELF_TEST_STATE_COMPLETE; result = SELF_TEST_STATUS_FAILED; } - // else just stay in progress and wait for next call + // Else just stay in progress and wait for next call break; case BUTTON_SELF_TEST_STATE_COMPLETE: - // if we get called in this state, assume we're doing self-test again + // If we get called in this state, assume we're doing self-test again buttonSelfTestState = BUTTON_SELF_TEST_STATE_START; break; @@ -273,7 +273,7 @@ switch ( response ) { case OFF_BUTTON_RSP_USER_REQUESTS_POWER_OFF: - // if we're in a mode that allows power off, set off pending flag and request user confirmation + // If we're in a mode that allows power off, set off pending flag and request user confirmation if ( TRUE == isCurrentOpModeOkToTurnOff() ) { offRequestAwaitingUserConfirmation = TRUE; @@ -283,18 +283,18 @@ #endif } else - { // send rejection response to power off request + { // Send rejection response to power off request sendOffButtonMsgToUI( OFF_BUTTON_CMD_REJECT_USER_OFF_REQUEST ); } break; case OFF_BUTTON_RSP_USER_CONFIRMS_POWER_OFF: - // is an off request pending user confirmation? + // Is an off request pending user confirmation? if ( TRUE == offRequestAwaitingUserConfirmation ) { // Reset off request pending flag offRequestAwaitingUserConfirmation = FALSE; - // if we're in a mode that allows power off, initiate power off sequence + // If we're in a mode that allows power off, initiate power off sequence if ( TRUE == isCurrentOpModeOkToTurnOff() ) { broadcastPowerOffWarning(); @@ -315,7 +315,7 @@ break; case OFF_BUTTON_RSP_USER_REJECTS_POWER_OFF: - // is an off request pending user confirmation? + // Is an off request pending user confirmation? if ( TRUE == offRequestAwaitingUserConfirmation ) { // Reset off request pending flag @@ -324,9 +324,9 @@ break; default: - // ok - do nothing + // Ok - do nothing break; - } // end switch + } // End switch } /*********************************************************************//** @@ -360,12 +360,12 @@ *************************************************************************/ static void handleOffButtonProcessing( void ) { - // handle button state transitions for off button + // Handle button state transitions for off button if ( getOffButtonState() != prevOffButtonState ) { if ( getOffButtonState() == BUTTON_STATE_PRESSED ) { - // if off request in a valid mode, send to UI for user confirmation + // If off request in a valid mode, send to UI for user confirmation userConfirmOffButton( OFF_BUTTON_RSP_USER_REQUESTS_POWER_OFF ); #ifdef SIMULATE_UI userConfirmOffButton( OFF_BUTTON_RSP_USER_CONFIRMS_POWER_OFF ); @@ -374,7 +374,7 @@ prevOffButtonState = getOffButtonState(); } - // if off request has not been confirmed by user before it expires, cancel it + // If off request has not been confirmed by user before it expires, cancel it if ( TRUE == offRequestAwaitingUserConfirmation ) { offRequestPendingTimer += TASK_PRIORITY_INTERVAL; @@ -385,14 +385,14 @@ } } - // if user confirmed off button press, manage off request sequence + // If user confirmed off button press, manage off request sequence if ( TRUE == offButtonPressPending ) { - // delay power off to provide sub-systems time to prepare for shutdown + // Delay power off to provide sub-systems time to prepare for shutdown offRequestDelayTimer += TASK_PRIORITY_INTERVAL; if ( offRequestDelayTimer >= OFF_REQUEST_DELAY_TIME_MS ) { - // power off sequence is 4 50 ms toggles of the off request output signal + // Power off sequence is 4 50 ms toggles of the off request output signal offRequestPulseTimer += TASK_PRIORITY_INTERVAL; if ( offRequestPulseTimer >= OFF_REQUEST_PULSE_INTVL_MS ) { @@ -418,7 +418,7 @@ *************************************************************************/ static void handleStopButtonProcessing( void ) { - // handle button state transitions for stop button + // Handle button state transitions for stop button if ( getStopButtonState() != prevStopButtonState ) { if ( getStopButtonState() == BUTTON_STATE_PRESSED ) @@ -429,10 +429,10 @@ prevStopButtonState = getStopButtonState(); } - // handle when a stop button press is pending + // Handle when a stop button press is pending if ( TRUE == stopButtonPressPending ) { - // if stop button not consumed within a reasonable time, s/w fault + // If stop button not consumed within a reasonable time, s/w fault if ( TRUE == didTimeout( stopButtonPendingTimer, STOP_BUTTON_PENDING_TIMEOUT_MS ) ) { stopButtonPressPending = FALSE; Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -57,9 +57,9 @@ static BOOL dgTrimmerHeaterOn = FALSE; ///< Flag indicates whether we've commanded the DG to start or stop the trimmer heater. static BOOL dgWaterSampled = FALSE; ///< Flag indicates whether we've commanded the DG to sample water. -// state machine states +// State machine states static TREATMENT_RESERVOIR_MGMT_STATE_T currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_START_STATE; ///< Current state of treatment mode reservoir management. -static U32 resMgmtTimer = 0; ///< used for keeping state time. +static U32 resMgmtTimer = 0; ///< Used for keeping state time. // DG sensor data static F32 dgPressures[ NUM_OF_DG_PRESSURE_SENSORS ]; ///< Latest pressures reported by the DG. @@ -82,7 +82,7 @@ static U32 dgReservoirFillVolumeTargetSet = 0; ///< Fill-to volume commanded. static U32 dgReservoirDrainVolumeTarget = 0; ///< Latest drain-to volume reported by the DG. static U32 dgReservoirDrainVolumeTargetSet = 0; ///< Drain-to volume commanded. -static U32 resUseTimer = 0; ///< used to track time pumping from active reservoir (for volume used calculation). +static U32 resUseTimer = 0; ///< Used to track time pumping from active reservoir (for volume used calculation). static F32 resUseVolumeMl = 0.0; ///< Accumulated volume used from active reservoir. static BOOL resHasBeenTared[ NUM_OF_DG_RESERVOIRS ]; ///< Flags indicate whether the reservoir has been tared for this treatment. @@ -175,7 +175,7 @@ } resUseTimer = getMSTimerCount(); - // treatment reservoir mgmt. state machine + // Treatment reservoir mgmt. state machine switch ( currentTrtResMgmtState ) { case TREATMENT_RESERVOIR_MGMT_START_STATE: @@ -208,7 +208,7 @@ break; case TREATMENT_RESERVOIR_MGMT_WAIT_TO_FILL_STATE: - // delay fill start if we've paused treatment? + // Delay fill start if we've paused treatment? if ( getTreatmentState() == TREATMENT_DIALYSIS_STATE ) { if ( DG_MODE_CIRC == dgOpMode ) @@ -246,21 +246,21 @@ case TREATMENT_RESERVOIR_MGMT_WAIT_FOR_RES_SWITCH_STATE: // Reservoir switch during treatment should only occur in this state (i.e. when DG is ready). - // switch reservoirs when active reservoir is spent (i.e. we've pumped fill volume through dialyzer) and DG ready + // Switch reservoirs when active reservoir is spent (i.e. we've pumped fill volume through dialyzer) and DG ready if ( ( DG_MODE_CIRC == getDGOpMode() ) && ( DG_RECIRCULATE_MODE_STATE_RECIRC_WATER == getDGSubMode() ) && ( resUseVolumeMl >= (F32)dgReservoirFillVolumeTargetSet ) ) { DG_RESERVOIR_ID_T activeRes = dgActiveReservoirSet; DG_RESERVOIR_ID_T inactiveRes = ( activeRes == DG_RESERVOIR_1 ? DG_RESERVOIR_2 : DG_RESERVOIR_1 ); - // signal dialysis sub-mode to capture baseline volume for next reservoir. + // Signal dialysis sub-mode to capture baseline volume for next reservoir. setStartReservoirVolume(); // Command DG to switch reservoirs cmdSetDGActiveReservoir( inactiveRes ); - // signal dialysis sub-mode to switch reservoirs + // Signal dialysis sub-mode to switch reservoirs signalReservoirsSwitched(); resUseVolumeMl = 0.0; - // wait for used reservoir to settle + // Wait for used reservoir to settle resMgmtTimer = getMSTimerCount(); currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; } @@ -269,7 +269,7 @@ case TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE: if ( TRUE == didTimeout( resMgmtTimer, RESERVOIR_SETTLE_TIME_MS ) ) { - // signal dialysis sub-mode to capture final volume of prior reservoir after settling. + // Signal dialysis sub-mode to capture final volume of prior reservoir after settling. setFinalReservoirVolume(); // Reset to start state to restart drain, fill, switch process. currentTrtResMgmtState = TREATMENT_RESERVOIR_MGMT_START_STATE; Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -r85ab84d9a0668e1e3976b00eb29e79c38c81b651 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 85ab84d9a0668e1e3976b00eb29e79c38c81b651) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -52,8 +52,8 @@ { DG_PRESSURE_SENSOR_RO_PUMP_INLET = 0, ///< RO pump pressure sensor. DG_PRESSURE_SENSOR_RO_PUMP_OUTLET, ///< RO pump pressure sensor. - DG_PRESSURE_SENSOR_DRAIN_PUMP_INLET, ///< drain pump inlet pressure. - DG_PRESSURE_SENSOR_DRAIN_PUMP_OUTLET, ///< drain pump outlet pressure. + DG_PRESSURE_SENSOR_DRAIN_PUMP_INLET, ///< Drain pump inlet pressure. + DG_PRESSURE_SENSOR_DRAIN_PUMP_OUTLET, ///< Drain pump outlet pressure. NUM_OF_DG_PRESSURE_SENSORS ///< Number of pressure sensors. } DG_PRESSURE_SENSORS_T; Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -41,49 +41,49 @@ // ********** private definitions ********** -/// interval (ms/task time) at which the dialIn flow data is published on the CAN bus. +/// Interval (ms/task time) at which the dialIn flow data is published on the CAN bus. #define DIAL_IN_FLOW_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) -#define MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE 0.0133 ///< max duty cycle change when ramping up ~ 200 mL/min/s. -#define MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< max duty cycle change when ramping down ~ 300 mL/min/s. -#define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< controller will error if PWM duty cycle > 90%, so set max to 88%. -#define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< controller will error if PWM duty cycle < 10%, so set min to 12%. +#define MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE 0.0133 ///< Max duty cycle change when ramping up ~ 200 mL/min/s. +#define MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE 0.02 ///< Max duty cycle change when ramping down ~ 300 mL/min/s. +#define MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.88 ///< Controller will error if PWM duty cycle > 90%, so set max to 88%. +#define MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE 0.12 ///< Controller will error if PWM duty cycle < 10%, so set min to 12%. -#define DIP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the dialIn pump is controlled +#define DIP_CONTROL_INTERVAL ( 10000 / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the dialIn pump is controlled #define DIP_P_COEFFICIENT 0.00035 ///< P term for dialIn pump control. #define DIP_I_COEFFICIENT 0.00035 ///< I term for dialIn pump control. -#define DIP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. -#define DIP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). -/// interval (ms/task time) at which the blood pump speed is calculated (every 40 ms). +#define DIP_HOME_RATE 100 ///< Target pump speed (in estimate mL/min) for homing. +#define DIP_HOME_TIMEOUT_MS 10000 ///< Maximum time allowed for homing to complete (in ms). +/// Interval (ms/task time) at which the blood pump speed is calculated (every 40 ms). #define DIP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) -/// number of hall sensor counts kept in buffer to hold last 1 second of count data. +/// Number of hall sensor counts kept in buffer to hold last 1 second of count data. #define DIP_SPEED_CALC_BUFFER_LEN ( 1000 / DIP_SPEED_CALC_INTERVAL / TASK_PRIORITY_INTERVAL ) -#define DIP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. +#define DIP_HALL_EDGE_COUNTS_PER_REV 48 ///< Number of hall sensor edge counts per motor revolution. -#define DIP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< maximum difference between measured motor speed and speed implied by measured flow. -#define DIP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< maximum motor speed (RPM) while motor is commanded off. -#define DIP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< maximum difference in speed between motor and rotor (in rotor RPM). -#define DIP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< maximum difference in speed between measured and commanded RPM. -#define DIP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for flow vs. motor speed error condition. -#define DIP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for motor off error condition. -#define DIP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) motor speed error condition. -#define DIP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. -#define DIP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) pump direction error condition. +#define DIP_MAX_FLOW_VS_SPEED_DIFF_RPM 200.0 ///< Maximum difference between measured motor speed and speed implied by measured flow. +#define DIP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< Maximum motor speed (RPM) while motor is commanded off. +#define DIP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< Maximum difference in speed between motor and rotor (in rotor RPM). +#define DIP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. +#define DIP_FLOW_VS_SPEED_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for flow vs. motor speed error condition. +#define DIP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for motor off error condition. +#define DIP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) motor speed error condition. +#define DIP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) rotor speed error condition. +#define DIP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) pump direction error condition. -#define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< motor controller current should not exceed this when pump should be stopped. -#define DIP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< motor controller current should always exceed this when pump should be running. -#define DIP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< motor controller current should not exceed this when pump should be running. -#define DIP_MAX_CURR_ERROR_DURATION_MS 2000 ///< motor controller current errors persisting beyond this duration will trigger an alarm. +#define DIP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped. +#define DIP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< Motor controller current should always exceed this when pump should be running. +#define DIP_MAX_CURR_WHEN_RUNNING_MA 2000.0 ///< Motor controller current should not exceed this when pump should be running. +#define DIP_MAX_CURR_ERROR_DURATION_MS 2000 ///< Motor controller current errors persisting beyond this duration will trigger an alarm. -#define DIP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< conversion factor from ADC counts to RPM for dialIn pump motor. -#define DIP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< conversion factor from ADC counts to mA for dialIn pump motor. +#define DIP_SPEED_ADC_TO_RPM_FACTOR 1.280938 ///< Conversion factor from ADC counts to RPM for dialIn pump motor. +#define DIP_CURRENT_ADC_TO_MA_FACTOR 3.002 ///< Conversion factor from ADC counts to mA for dialIn pump motor. -#define DIP_REV_PER_LITER 150.0 ///< rotor revolutions per liter. +#define DIP_REV_PER_LITER 150.0 ///< Rotor revolutions per liter. /// Macro converts flow rate to motor RPM. #define DIP_ML_PER_MIN_TO_PUMP_RPM_FACTOR ( DIP_REV_PER_LITER / ML_PER_LITER ) -#define DIP_GEAR_RATIO 32.0 ///< dialIn pump motor to dialIn pump gear ratio. +#define DIP_GEAR_RATIO 32.0 ///< DialIn pump motor to dialIn pump gear ratio. #define DIP_MOTOR_RPM_TO_PWM_DC_FACTOR 0.00028 ///< ~28 BP motor RPM = 1% PWM duty cycle. #define DIP_PWM_ZERO_OFFSET 0.1 ///< 10% PWM duty cycle = zero speed. /// Macro converts flow rate to estimate PWM needed to achieve it. @@ -94,10 +94,10 @@ ///< Macro converts a 12-bit ADC reading to a signed 16-bit value. #define SIGN_FROM_12_BIT_VALUE(v) ( (S16)(v) - (S16)DIAL_IN_PUMP_ADC_ZERO ) -/// measured dialIn flow is filtered w/ moving average. +/// Measured dialIn flow is filtered w/ moving average. #define SIZE_OF_ROLLING_AVG ( ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) * 10 ) -/// dialysate flow sensor signal strength low alarm persistence. +/// Dialysate 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%). @@ -120,64 +120,64 @@ NUM_OF_DIAL_IN_FLOW_SELF_TEST_STATES ///< Number of dialysate inlet pump self-test states. } DIAL_IN_FLOW_SELF_TEST_STATE_T; -// pin assignments for pump stop and direction outputs +// Pin assignments for pump stop and direction outputs #define STOP_DI_PUMP_GIO_PORT_PIN 2U ///< Pin # on GIO A for stopping the dialysate inlet pump. #define DIR_DI_PUMP_SPI5_PORT_MASK 0x00000100 ///< Pin on unused SPI5 peripheral (ENA) - re-purposed as output GPIO to set dialysate inlet pump direction. -// dialIn pump stop and direction macros +// DialIn pump stop and direction macros #define SET_DIP_DIR() {mibspiREG5->PC3 |= DIR_DI_PUMP_SPI5_PORT_MASK;} ///< Macro for setting the dialysate inlet pump direction pin high. #define CLR_DIP_DIR() {mibspiREG5->PC3 &= ~DIR_DI_PUMP_SPI5_PORT_MASK;} ///< Macro for setting the dialysate inlet pump direction pin low. #define SET_DIP_STOP() gioSetBit( gioPORTA, STOP_DI_PUMP_GIO_PORT_PIN, PIN_SIGNAL_LOW ) ///< Macro for setting the dialysate inlet pump stop pin low. #define CLR_DIP_STOP() gioSetBit( gioPORTA, STOP_DI_PUMP_GIO_PORT_PIN, PIN_SIGNAL_HIGH ) ///< Macro for setting the dialysate inlet pump stop pin high. // ********** private data ********** -static DIAL_IN_PUMP_STATE_T dialInPumpState = DIAL_IN_PUMP_OFF_STATE; ///< current state of dialIn flow controller state machine -static U32 dialInFlowDataPublicationTimerCounter = 5; ///< used to schedule dialIn flow data publication to CAN bus -static BOOL isDialInPumpOn = FALSE; ///< dialIn pump is currently running -static F32 dialInPumpPWMDutyCyclePct = 0.0; ///< initial dialIn pump PWM duty cycle -static F32 dialInPumpPWMDutyCyclePctSet = 0.0; ///< currently set dialIn pump PWM duty cycle -static MOTOR_DIR_T dialInPumpDirection = MOTOR_DIR_FORWARD; ///< requested dialysate flow direction -static MOTOR_DIR_T dialInPumpDirectionSet = MOTOR_DIR_FORWARD; ///< currently set dialysate flow direction -static PUMP_CONTROL_MODE_T dialInPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< requested dialIn pump control mode. -static PUMP_CONTROL_MODE_T dialInPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP;///< currently set dialIn pump control mode. -static F32 dialInFlowCalGain = 1.0; ///< dialysate flow calibration gain. -static F32 dialInFlowCalOffset = 0.0; ///< dialysate flow calibration offset. +static DIAL_IN_PUMP_STATE_T dialInPumpState = DIAL_IN_PUMP_OFF_STATE; ///< Current state of dialIn flow controller state machine +static U32 dialInFlowDataPublicationTimerCounter = 5; ///< Used to schedule dialIn flow data publication to CAN bus +static BOOL isDialInPumpOn = FALSE; ///< DialIn pump is currently running +static F32 dialInPumpPWMDutyCyclePct = 0.0; ///< Initial dialIn pump PWM duty cycle +static F32 dialInPumpPWMDutyCyclePctSet = 0.0; ///< Currently set dialIn pump PWM duty cycle +static MOTOR_DIR_T dialInPumpDirection = MOTOR_DIR_FORWARD; ///< Requested dialysate flow direction +static MOTOR_DIR_T dialInPumpDirectionSet = MOTOR_DIR_FORWARD; ///< Currently set dialysate flow direction +static PUMP_CONTROL_MODE_T dialInPumpControlMode = PUMP_CONTROL_MODE_CLOSED_LOOP; ///< Requested dialIn pump control mode. +static PUMP_CONTROL_MODE_T dialInPumpControlModeSet = PUMP_CONTROL_MODE_CLOSED_LOOP;///< Currently set dialIn pump control mode. +static F32 dialInFlowCalGain = 1.0; ///< Dialysate flow calibration gain. +static F32 dialInFlowCalOffset = 0.0; ///< Dialysate flow calibration offset. -/// interval (in ms) at which to publish dialIn flow data to CAN bus +/// Interval (in ms) at which to publish dialIn flow data to CAN bus static OVERRIDE_U32_T dialInFlowDataPublishInterval = { DIAL_IN_FLOW_DATA_PUB_INTERVAL, DIAL_IN_FLOW_DATA_PUB_INTERVAL, DIAL_IN_FLOW_DATA_PUB_INTERVAL, 0 }; -static S32 targetDialInFlowRate = 0; ///< requested dialIn flow rate -static OVERRIDE_F32_T measuredDialInFlowRate = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet flow rate -static OVERRIDE_F32_T dialInPumpRotorSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump rotor speed -static OVERRIDE_F32_T dialInPumpSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump motor speed -static OVERRIDE_F32_T adcDialInPumpMCSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump motor controller speed -static OVERRIDE_F32_T adcDialInPumpMCCurrentmA = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate inlet pump motor controller current -static OVERRIDE_F32_T dialInFlowSignalStrength = { 0.0, 0.0, 0.0, 0 }; ///< measured dialysate flow signal strength (%) +static S32 targetDialInFlowRate = 0; ///< Requested dialIn flow rate +static OVERRIDE_F32_T measuredDialInFlowRate = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet flow rate +static OVERRIDE_F32_T dialInPumpRotorSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet pump rotor speed +static OVERRIDE_F32_T dialInPumpSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet pump motor speed +static OVERRIDE_F32_T adcDialInPumpMCSpeedRPM = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet pump motor controller speed +static OVERRIDE_F32_T adcDialInPumpMCCurrentmA = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate inlet pump motor controller current +static OVERRIDE_F32_T dialInFlowSignalStrength = { 0.0, 0.0, 0.0, 0 }; ///< Measured dialysate flow signal strength (%) -static U32 dipControlTimerCounter = 0; ///< determines when to perform control on dialIn flow +static U32 dipControlTimerCounter = 0; ///< Determines when to perform control on dialIn flow -static U32 dipRotorRevStartTime = 0; ///< dialysate inlet pump rotor rotation start time (in ms) -static BOOL dipStopAtHomePosition = FALSE; ///< stop dialysate inlet pump at next home position -static U32 dipHomeStartTime = 0; ///< when did dialysate inlet pump home command begin? (in ms) +static U32 dipRotorRevStartTime = 0; ///< Dialysate inlet pump rotor rotation start time (in ms) +static BOOL dipStopAtHomePosition = FALSE; ///< Stop dialysate inlet pump at next home position +static U32 dipHomeStartTime = 0; ///< When did dialysate inlet pump home command begin? (in ms) -static U16 dipLastMotorHallSensorCounts[ DIP_SPEED_CALC_BUFFER_LEN ]; ///< last hall sensor count for the dialysate inlet pump motor -static U32 dipMotorSpeedCalcIdx = 0; ///< index into 1 second buffer of motor speed hall sensor counts -static U32 dipMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating dialysate inlet pump motor speed from hall sensor count. +static U16 dipLastMotorHallSensorCounts[ DIP_SPEED_CALC_BUFFER_LEN ]; ///< Last hall sensor count for the dialysate inlet pump motor +static U32 dipMotorSpeedCalcIdx = 0; ///< Index into 1 second buffer of motor speed hall sensor counts +static U32 dipMotorSpeedCalcTimerCtr = 0; ///< Counter determines interval for calculating dialysate inlet pump motor speed from hall sensor count. -static U32 errorDialInFlowVsMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for flow vs. motor speed error condition. -static U32 errorDialInMotorOffPersistTimerCtr = 0; ///< persistence timer counter for motor off check error condition. -static U32 errorDialInMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for motor speed error condition. -static U32 errorDialInRotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for rotor speed error condition. -static U32 errorDialInPumpDirectionPersistTimerCtr = 0; ///< persistence timer counter for pump direction error condition. +static U32 errorDialInFlowVsMotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for flow vs. motor speed error condition. +static U32 errorDialInMotorOffPersistTimerCtr = 0; ///< Persistence timer counter for motor off check error condition. +static U32 errorDialInMotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for motor speed error condition. +static U32 errorDialInRotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for rotor speed error condition. +static U32 errorDialInPumpDirectionPersistTimerCtr = 0; ///< Persistence timer counter for pump direction error condition. -static F32 flowReadings[ SIZE_OF_ROLLING_AVG ]; ///< holds flow samples for a rolling average -static U32 flowReadingsIdx = 0; ///< index for next sample in rolling average array -static F32 flowReadingsTotal = 0.0; ///< rolling total - used to calc average -static U32 flowReadingsCount = 0; ///< number of samples in flow rolling average buffer +static F32 flowReadings[ SIZE_OF_ROLLING_AVG ]; ///< Holds flow samples for a rolling average +static U32 flowReadingsIdx = 0; ///< Index for next sample in rolling average array +static F32 flowReadingsTotal = 0.0; ///< Rolling total - used to calc average +static U32 flowReadingsCount = 0; ///< Number of samples in flow rolling average buffer -static U32 dipCurrErrorDurationCtr = 0; ///< used for tracking persistence of dip current errors +static U32 dipCurrErrorDurationCtr = 0; ///< Used for tracking persistence of dip current errors -static DIAL_IN_FLOW_SELF_TEST_STATE_T dialInPumpSelfTestState = DIAL_IN_FLOW_SELF_TEST_STATE_START; ///< current dialIn pump self-test state -static U32 dialInPumpSelfTestTimerCount = 0; ///< timer counter for dialIn pump self-test +static DIAL_IN_FLOW_SELF_TEST_STATE_T dialInPumpSelfTestState = DIAL_IN_FLOW_SELF_TEST_STATE_START; ///< Current dialIn pump self-test state +static U32 dialInPumpSelfTestTimerCount = 0; ///< Timer counter for dialIn pump self-test // ********** private function prototypes ********** @@ -215,22 +215,22 @@ stopDialInPump(); setDialInPumpDirection( MOTOR_DIR_FORWARD ); - // zero rolling flow average buffer + // Zero rolling flow average buffer resetDialInFlowMovingAverage(); - // zero motor hall sensors counts buffer + // Zero motor hall sensors counts buffer dipMotorSpeedCalcIdx = 0; for ( i = 0; i < DIP_SPEED_CALC_BUFFER_LEN; i++ ) { dipLastMotorHallSensorCounts[ i ] = 0; } - // initialize dialysate inlet flow PI controller + // Initialize dialysate inlet flow PI controller initializePIController( PI_CONTROLLER_ID_DIALYSATE_FLOW, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, DIP_P_COEFFICIENT, DIP_I_COEFFICIENT, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); - // initialize persistent alarm for flow sensor signal strength too low + // Initialize persistent alarm for flow sensor signal strength too low initPersistentAlarm( PERSISTENT_ALARM_DIALYSATE_FLOW_SIGNAL_STRENGTH, ALARM_ID_DIALYSATE_FLOW_SIGNAL_STRENGTH_TOO_LOW, FALSE, FLOW_SIG_STRGTH_ALARM_PERSIST, FLOW_SIG_STRGTH_ALARM_PERSIST ); @@ -251,34 +251,34 @@ { BOOL result = FALSE; - // direction change while pump is running is not allowed + // Direction change while pump is running is not allowed if ( ( FALSE == isDialInPumpOn ) || ( 0 == flowRate ) || ( dir == dialInPumpDirectionSet ) ) { - // verify flow rate + // Verify flow rate if ( flowRate <= MAX_DIAL_IN_FLOW_RATE ) { resetDialInFlowMovingAverage(); targetDialInFlowRate = ( dir == MOTOR_DIR_FORWARD ? (S32)flowRate : (S32)flowRate * -1 ); dialInPumpDirection = dir; dialInPumpControlMode = mode; - // set PWM duty cycle target to an estimated initial target to ramp to based on target flow rate - then we'll control to flow when ramp completed + // Set PWM duty cycle target to an estimated initial target to ramp to based on target flow rate - then we'll control to flow when ramp completed dialInPumpPWMDutyCyclePct = DIP_PWM_FROM_ML_PER_MIN((F32)flowRate); // ~ 8% per 100 mL/min with a 10% zero offset added in (e.g. 100 mL/min = 8+10 = 18%) switch ( dialInPumpState ) { - case DIAL_IN_PUMP_RAMPING_UP_STATE: // see if we need to reverse direction of ramp + case DIAL_IN_PUMP_RAMPING_UP_STATE: // See if we need to reverse direction of ramp if ( dialInPumpPWMDutyCyclePct < dialInPumpPWMDutyCyclePctSet ) { dialInPumpState = DIAL_IN_PUMP_RAMPING_DOWN_STATE; } break; - case DIAL_IN_PUMP_RAMPING_DOWN_STATE: // see if we need to reverse direction of ramp + case DIAL_IN_PUMP_RAMPING_DOWN_STATE: // See if we need to reverse direction of ramp if ( dialInPumpPWMDutyCyclePct > dialInPumpPWMDutyCyclePctSet ) { dialInPumpState = DIAL_IN_PUMP_RAMPING_UP_STATE; } break; - case DIAL_IN_PUMP_CONTROL_TO_TARGET_STATE: // start ramp to new target in appropriate direction + case DIAL_IN_PUMP_CONTROL_TO_TARGET_STATE: // Start ramp to new target in appropriate direction if ( dialInPumpPWMDutyCyclePctSet > dialInPumpPWMDutyCyclePct ) { dialInPumpState = DIAL_IN_PUMP_RAMPING_DOWN_STATE; @@ -289,7 +289,7 @@ } break; default: - // ok - not all states need to be handled here + // Ok - not all states need to be handled here break; } result = TRUE; @@ -338,7 +338,7 @@ dialInPumpRotorSpeedRPM.data = ( 1.0 / (F32)deltaTime ) * (F32)MS_PER_SECOND * (F32)SEC_PER_MIN; dipRotorRevStartTime = rotTime; - // if we're supposed to stop pump at home position, stop pump now. + // If we're supposed to stop pump at home position, stop pump now. if ( TRUE == dipStopAtHomePosition ) { signalDialInPumpHardStop(); @@ -403,7 +403,7 @@ // Calculate dialysate inlet pump motor speed/direction from hall sensor count updateDialInPumpSpeedAndDirectionFromHallSensors(); - // don't start enforcing checks until out of init/POST mode + // Don't start enforcing checks until out of init/POST mode if ( opMode != MODE_INIT ) { // Check pump direction @@ -419,7 +419,7 @@ checkDialInFlowSensorSignalStrength(); } - // publish dialIn flow data on interval + // Publish dialIn flow data on interval publishDialInFlowData(); } @@ -468,13 +468,13 @@ { DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_OFF_STATE; - // if we've been given a flow rate, setup ramp up and transition to ramp up state + // If we've been given a flow rate, setup ramp up and transition to ramp up state if ( targetDialInFlowRate != 0 ) { - // set initial PWM duty cycle + // Set initial PWM duty cycle dialInPumpPWMDutyCyclePctSet = DIP_PWM_ZERO_OFFSET + MAX_DIAL_IN_PUMP_PWM_STEP_UP_CHANGE; setDialInPumpControlSignalPWM( dialInPumpPWMDutyCyclePctSet ); - // allow dialIn pump to run in requested direction + // Allow dialIn pump to run in requested direction setDialInPumpDirection( dialInPumpDirection ); releaseDialInPumpStop(); isDialInPumpOn = TRUE; @@ -496,21 +496,21 @@ { DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_RAMPING_UP_STATE; - // have we been asked to stop the dialIn pump? + // Have we been asked to stop the dialIn pump? if ( 0 == targetDialInFlowRate ) { - // start ramp down to stop + // Start ramp down to stop dialInPumpPWMDutyCyclePctSet -= MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE; setDialInPumpControlSignalPWM( dialInPumpPWMDutyCyclePctSet ); result = DIAL_IN_PUMP_RAMPING_DOWN_STATE; } - // have we reached end of ramp up? + // Have we reached end of ramp up? else if ( dialInPumpPWMDutyCyclePctSet >= dialInPumpPWMDutyCyclePct ) { resetDialInFlowMovingAverage(); resetPIController( PI_CONTROLLER_ID_DIALYSATE_FLOW, dialInPumpPWMDutyCyclePctSet ); dialInPumpControlModeSet = dialInPumpControlMode; - // 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 ( dialInPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { dialInPumpPWMDutyCyclePctSet = dialInPumpPWMDutyCyclePct; @@ -540,19 +540,19 @@ { DIAL_IN_PUMP_STATE_T result = DIAL_IN_PUMP_RAMPING_DOWN_STATE; - // have we essentially reached zero speed + // Have we essentially reached zero speed if ( dialInPumpPWMDutyCyclePctSet < (MAX_DIAL_IN_PUMP_PWM_STEP_DN_CHANGE + DIP_PWM_ZERO_OFFSET) ) { stopDialInPump(); result = DIAL_IN_PUMP_OFF_STATE; } - // have we reached end of ramp down? + // Have we reached end of ramp down? else if ( dialInPumpPWMDutyCyclePctSet <= dialInPumpPWMDutyCyclePct ) { resetDialInFlowMovingAverage(); resetPIController( PI_CONTROLLER_ID_DIALYSATE_FLOW, dialInPumpPWMDutyCyclePctSet ); dialInPumpControlModeSet = dialInPumpControlMode; - // 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 ( dialInPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { dialInPumpPWMDutyCyclePctSet = dialInPumpPWMDutyCyclePct; @@ -835,7 +835,7 @@ *************************************************************************/ static void publishDialInFlowData( void ) { - // publish dialIn flow data on interval + // Publish dialIn flow data on interval if ( ++dialInFlowDataPublicationTimerCounter >= getPublishDialInFlowDataInterval() ) { DIALIN_PUMP_STATUS_PAYLOAD_T payload; @@ -914,7 +914,7 @@ U16 decDelta = HEX_64_K - incDelta; U16 delta; - // determine dialysate inlet pump speed/direction from delta hall sensor count since last interval + // Determine dialysate inlet pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { delta = incDelta; @@ -926,7 +926,7 @@ dialInPumpSpeedRPM.data = ( (F32)delta / (F32)DIP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN * -1.0; } - // update last count for next time + // Update last count for next time dipLastMotorHallSensorCounts[ nextIdx ] = dipMotorHallSensorCount; dipMotorSpeedCalcIdx = nextIdx; dipMotorSpeedCalcTimerCtr = 0; @@ -944,15 +944,15 @@ *************************************************************************/ static void checkDialInPumpRotor( void ) { - // if homing, check timeout + // If homing, check timeout if ( ( TRUE == dipStopAtHomePosition ) && ( TRUE == didTimeout( dipHomeStartTime, DIP_HOME_TIMEOUT_MS ) ) ) { signalDialInPumpHardStop(); dipStopAtHomePosition = FALSE; // TODO - alarm??? } - // 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( dipRotorRevStartTime, DIP_HOME_TIMEOUT_MS ) ) { dialInPumpRotorSpeedRPM.data = 0.0; @@ -1145,7 +1145,7 @@ { F32 dipCurr; - // dialIn pump should be off + // DialIn pump should be off if ( DIAL_IN_PUMP_OFF_STATE == dialInPumpState ) { dipCurr = fabs( getMeasuredDialInPumpMCCurrent() ); @@ -1164,7 +1164,7 @@ dipCurrErrorDurationCtr = 0; } } - // dialIn pump should be running + // DialIn pump should be running else { dipCurr = fabs( getMeasuredDialInPumpMCCurrent() ); @@ -1274,10 +1274,10 @@ CALIBRATION_DATA_T cal; getCalibrationData( &cal ); - // keep locally and apply immediately + // Keep locally and apply immediately dialInFlowCalGain = gain; dialInFlowCalOffset = offset; - // also update calibration record in non-volatile memory + // Also update calibration record in non-volatile memory cal.dialysateFlowGain = gain; cal.dialysateFlowOffset_mL_min = offset; if ( TRUE == setCalibrationData( cal ) ) Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -55,21 +55,21 @@ #define DOP_P_COEFFICIENT 0.0050 ///< P term for dialysate outlet pump control. #define DOP_I_COEFFICIENT 0.0001 ///< I term for dialysate outlet pump control. -#define DOP_HOME_RATE 100 ///< target pump speed (in estimate mL/min) for homing. -#define DOP_HOME_TIMEOUT_MS 10000 ///< maximum time allowed for homing to complete (in ms). -/// interval (ms/task time) at which the blood pump speed is calculated (every 40 ms). +#define DOP_HOME_RATE 100 ///< Target pump speed (in estimate mL/min) for homing. +#define DOP_HOME_TIMEOUT_MS 10000 ///< Maximum time allowed for homing to complete (in ms). +/// Interval (ms/task time) at which the blood pump speed is calculated (every 40 ms). #define DOP_SPEED_CALC_INTERVAL ( 40 / TASK_PRIORITY_INTERVAL ) -/// number of hall sensor counts kept in buffer to hold last 1 second of count data. +/// Number of hall sensor counts kept in buffer to hold last 1 second of count data. #define DOP_SPEED_CALC_BUFFER__LEN ( 1000 / DOP_SPEED_CALC_INTERVAL / TASK_PRIORITY_INTERVAL ) -#define DOP_HALL_EDGE_COUNTS_PER_REV 48 ///< number of hall sensor edge counts per motor revolution. +#define DOP_HALL_EDGE_COUNTS_PER_REV 48 ///< Number of hall sensor edge counts per motor revolution. -#define DOP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< maximum motor speed (RPM) while motor is commanded off. -#define DOP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< maximum difference in speed between motor and rotor (in rotor RPM). -#define DOP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< maximum difference in speed between measured and commanded RPM. -#define DOP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) for motor off error condition. -#define DOP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) motor speed error condition. -#define DOP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) rotor speed error condition. -#define DOP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< persist time (task intervals) pump direction error condition. +#define DOP_MAX_MOTOR_SPEED_WHILE_OFF_RPM 100.0 ///< Maximum motor speed (RPM) while motor is commanded off. +#define DOP_MAX_ROTOR_VS_MOTOR_DIFF_RPM 5.0 ///< Maximum difference in speed between motor and rotor (in rotor RPM). +#define DOP_MAX_MOTOR_SPEED_ERROR_RPM 300.0 ///< Maximum difference in speed between measured and commanded RPM. +#define DOP_OFF_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) for motor off error condition. +#define DOP_MOTOR_SPEED_ERROR_PERSIST ((5 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) motor speed error condition. +#define DOP_ROTOR_SPEED_ERROR_PERSIST ((12 * MS_PER_SECOND) / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) rotor speed error condition. +#define DOP_DIRECTION_ERROR_PERSIST (250 / TASK_PRIORITY_INTERVAL) ///< Persist time (task intervals) pump direction error condition. #define DOP_MAX_CURR_WHEN_STOPPED_MA 150.0 ///< Motor controller current should not exceed this when pump should be stopped. #define DOP_MIN_CURR_WHEN_RUNNING_MA 150.0 ///< Motor controller current should always exceed this when pump should be running. @@ -111,7 +111,7 @@ NUM_OF_DIAL_OUT_PUMP_SELF_TEST_STATES ///< Number of dialysate outlet pump self-test states. } DIAL_OUT_PUMP_SELF_TEST_STATE_T; -// pin assignments and macros for pump stop and direction outputs +// Pin assignments and macros for pump stop and direction outputs #define STOP_DO_PUMP_MIBSPI1_PORT_MASK 0x00000400 ///< MIBSPI1 SIMO[0] - re-purposed as GPIOoutput for pump controller run/stop pin. #define SET_DOP_STOP() {mibspiREG1->PC3 &= ~STOP_DO_PUMP_MIBSPI1_PORT_MASK;} ///< Macro sets pump controller run/stop signal to stop. #define CLR_DOP_STOP() {mibspiREG1->PC3 |= STOP_DO_PUMP_MIBSPI1_PORT_MASK;} ///< Macro sets pump controller run/stop signal to run. @@ -144,18 +144,18 @@ static U32 dopControlTimerCounter = 0; ///< Timer counter to determine when to control dialysate outlet pump. static U32 dopCurrErrorDurationCtr = 0; ///< Timer counter for motor current error persistence. -static U32 dopRotorRevStartTime = 0; ///< dialysate outlet pump rotor rotation start time (in ms) -static BOOL dopStopAtHomePosition = FALSE; ///< stop dialysate outlet pump at next home position -static U32 dopHomeStartTime = 0; ///< when did dialysate outlet pump home command begin? (in ms) +static U32 dopRotorRevStartTime = 0; ///< Dialysate outlet pump rotor rotation start time (in ms) +static BOOL dopStopAtHomePosition = FALSE; ///< Stop dialysate outlet pump at next home position +static U32 dopHomeStartTime = 0; ///< When did dialysate outlet pump home command begin? (in ms) -static U16 dopLastMotorHallSensorCounts[ DOP_SPEED_CALC_BUFFER__LEN ]; ///< last hall sensor count for the dialysate outlet pump motor -static U32 dopMotorSpeedCalcIdx = 0; ///< index into 1 second buffer of motor speed hall sensor counts -static U32 dopMotorSpeedCalcTimerCtr = 0; ///< counter determines interval for calculating dialysate outlet pump motor speed from hall sensor count. +static U16 dopLastMotorHallSensorCounts[ DOP_SPEED_CALC_BUFFER__LEN ]; ///< Last hall sensor count for the dialysate outlet pump motor +static U32 dopMotorSpeedCalcIdx = 0; ///< Index into 1 second buffer of motor speed hall sensor counts +static U32 dopMotorSpeedCalcTimerCtr = 0; ///< Counter determines interval for calculating dialysate outlet pump motor speed from hall sensor count. -static U32 errorDialOutMotorOffPersistTimerCtr = 0; ///< persistence timer counter for motor off check error condition. -static U32 errorDialOutMotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for motor speed error condition. -static U32 errorDialOutRotorSpeedPersistTimerCtr = 0; ///< persistence timer counter for rotor speed error condition. -static U32 errorDialOutPumpDirectionPersistTimerCtr = 0; ///< persistence timer counter for pump direction error condition. +static U32 errorDialOutMotorOffPersistTimerCtr = 0; ///< Persistence timer counter for motor off check error condition. +static U32 errorDialOutMotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for motor speed error condition. +static U32 errorDialOutRotorSpeedPersistTimerCtr = 0; ///< Persistence timer counter for rotor speed error condition. +static U32 errorDialOutPumpDirectionPersistTimerCtr = 0; ///< Persistence timer counter for pump direction error condition. static DIAL_OUT_PUMP_SELF_TEST_STATE_T dialOutPumpSelfTestState = DIAL_OUT_PUMP_SELF_TEST_STATE_START; ///< Current state of the dialysate outlet pump self-test state machine. static U32 dialOutPumpSelfTestTimerCount = 0; ///< Timer counter for time reference during self-test. @@ -196,20 +196,20 @@ stopDialOutPump(); setDialOutPumpDirection( MOTOR_DIR_FORWARD ); - // zero motor hall sensors counts buffer + // Zero motor hall sensors counts buffer dopMotorSpeedCalcIdx = 0; for ( i = 0; i < DOP_SPEED_CALC_BUFFER__LEN; i++ ) { dopLastMotorHallSensorCounts[ i ] = 0; } - // initialize load cell weights + // Initialize load cell weights for ( i = 0; i < NUM_OF_LOAD_CELLS; i++ ) { loadCellWeightInGrams[ i ].data = 0.0; } - // initialize dialysate outlet flow PI controller + // Initialize dialysate outlet flow PI controller initializePIController( PI_CONTROLLER_ID_ULTRAFILTRATION, MIN_DIAL_OUT_PUMP_PWM_DUTY_CYCLE, DOP_P_COEFFICIENT, DOP_I_COEFFICIENT, MIN_DIAL_OUT_PUMP_PWM_DUTY_CYCLE, MAX_DIAL_OUT_PUMP_PWM_DUTY_CYCLE ); @@ -230,10 +230,10 @@ { BOOL result = FALSE; - // direction change while pump is running is not allowed + // Direction change while pump is running is not allowed if ( ( FALSE == isDialOutPumpOn ) || ( 0 == flowRate ) || ( dir == dialOutPumpDirectionSet ) ) { - // verify flow rate + // Verify flow rate if ( flowRate <= MAX_DIAL_OUT_FLOW_RATE ) { F32 adjFlow = (F32)flowRate; @@ -245,24 +245,24 @@ lastGivenRate = flowRate; dialOutPumpDirection = dir; dialOutPumpControlMode = mode; - // set PWM duty cycle target to an estimated initial target to ramp to based on target flow rate - then we'll control to flow when ramp completed + // Set PWM duty cycle target to an estimated initial target to ramp to based on target flow rate - then we'll control to flow when ramp completed dialOutPumpPWMDutyCyclePct = DOP_PWM_FROM_ML_PER_MIN(adjFlow); switch ( dialOutPumpState ) { - case DIAL_OUT_PUMP_RAMPING_UP_STATE: // see if we need to reverse direction of ramp + case DIAL_OUT_PUMP_RAMPING_UP_STATE: // See if we need to reverse direction of ramp if ( dialOutPumpPWMDutyCyclePct < dialOutPumpPWMDutyCyclePctSet ) { dialOutPumpState = DIAL_OUT_PUMP_RAMPING_DOWN_STATE; } break; - case DIAL_OUT_PUMP_RAMPING_DOWN_STATE: // see if we need to reverse direction of ramp + case DIAL_OUT_PUMP_RAMPING_DOWN_STATE: // See if we need to reverse direction of ramp if ( dialOutPumpPWMDutyCyclePct > dialOutPumpPWMDutyCyclePctSet ) { dialOutPumpState = DIAL_OUT_PUMP_RAMPING_UP_STATE; } break; - case DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE: // start ramp to new target in appropriate direction + case DIAL_OUT_PUMP_CONTROL_TO_TARGET_STATE: // Start ramp to new target in appropriate direction if ( dialOutPumpPWMDutyCyclePctSet > dialOutPumpPWMDutyCyclePct ) { dialOutPumpState = DIAL_OUT_PUMP_RAMPING_DOWN_STATE; @@ -273,7 +273,7 @@ } break; default: - // ok - not all states need to be handled here + // Ok - not all states need to be handled here break; } result = TRUE; @@ -339,7 +339,7 @@ dialOutPumpRotorSpeedRPM.data = ( 1.0 / (F32)deltaTime ) * (F32)MS_PER_SECOND * (F32)SEC_PER_MIN; dopRotorRevStartTime = rotTime; - // if we're supposed to stop pump at home position, stop pump now. + // If we're supposed to stop pump at home position, stop pump now. if ( TRUE == dopStopAtHomePosition ) { signalDialOutPumpHardStop(); @@ -425,7 +425,7 @@ // Calculate dialysate outlet pump motor speed/direction from hall sensor count updateDialOutPumpSpeedAndDirectionFromHallSensors(); - // don't start enforcing checks until out of init/POST mode + // Don't start enforcing checks until out of init/POST mode if ( getCurrentOperationMode() != MODE_INIT ) { // Check pump direction @@ -487,13 +487,13 @@ { DIAL_OUT_PUMP_STATE_T result = DIAL_OUT_PUMP_OFF_STATE; - // if we've been given a flow rate, setup ramp up and transition to ramp up state + // If we've been given a flow rate, setup ramp up and transition to ramp up state if ( lastGivenRate > 0 ) { - // set initial PWM duty cycle + // Set initial PWM duty cycle dialOutPumpPWMDutyCyclePctSet = DOP_PWM_ZERO_OFFSET + MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE; setDialOutPumpControlSignalPWM( dialOutPumpPWMDutyCyclePctSet ); - // allow dialOut pump to run in requested direction + // Allow dialOut pump to run in requested direction setDialOutPumpDirection( dialOutPumpDirection ); releaseDialOutPumpStop(); isDialOutPumpOn = TRUE; @@ -519,20 +519,20 @@ { DIAL_OUT_PUMP_STATE_T result = DIAL_OUT_PUMP_RAMPING_UP_STATE; - // have we been asked to stop the dialOut pump? + // Have we been asked to stop the dialOut pump? if ( dialOutPumpPWMDutyCyclePct < (MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE + DOP_PWM_ZERO_OFFSET) ) { - // start ramp down to stop + // Start ramp down to stop dialOutPumpPWMDutyCyclePctSet -= MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE; setDialOutPumpControlSignalPWM( dialOutPumpPWMDutyCyclePctSet ); result = DIAL_OUT_PUMP_RAMPING_DOWN_STATE; } - // have we reached end of ramp up? + // Have we reached end of ramp up? else if ( dialOutPumpPWMDutyCyclePctSet >= dialOutPumpPWMDutyCyclePct ) { resetPIController( PI_CONTROLLER_ID_ULTRAFILTRATION, dialOutPumpPWMDutyCyclePctSet ); dialOutPumpControlModeSet = dialOutPumpControlMode; - // 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 ( dialOutPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { dialOutPumpPWMDutyCyclePctSet = dialOutPumpPWMDutyCyclePct; @@ -562,18 +562,18 @@ { DIAL_OUT_PUMP_STATE_T result = DIAL_OUT_PUMP_RAMPING_DOWN_STATE; - // have we essentially reached zero speed + // Have we essentially reached zero speed if ( dialOutPumpPWMDutyCyclePctSet < (MAX_DIAL_OUT_PUMP_PWM_STEP_DN_CHANGE + DOP_PWM_ZERO_OFFSET) ) { stopDialOutPump(); result = DIAL_OUT_PUMP_OFF_STATE; } - // have we reached end of ramp down? + // Have we reached end of ramp down? else if ( dialOutPumpPWMDutyCyclePctSet <= dialOutPumpPWMDutyCyclePct ) { resetPIController( PI_CONTROLLER_ID_ULTRAFILTRATION, dialOutPumpPWMDutyCyclePctSet ); dialOutPumpControlModeSet = dialOutPumpControlMode; - // 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 ( dialOutPumpControlModeSet == PUMP_CONTROL_MODE_OPEN_LOOP ) { dialOutPumpPWMDutyCyclePctSet = dialOutPumpPWMDutyCyclePct; @@ -613,17 +613,17 @@ F32 newPWMDutyCyclePct; F32 deltaPWMDutyCyclePct; - // get new PWM from PI controller + // Get new PWM from PI controller newPWMDutyCyclePct = runPIController( PI_CONTROLLER_ID_ULTRAFILTRATION, refVol, totVol ); - // limit PWM change to max + // Limit PWM change to max deltaPWMDutyCyclePct = newPWMDutyCyclePct - dialOutPumpPWMDutyCyclePctSet; if ( fabs( deltaPWMDutyCyclePct ) > MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ) { newPWMDutyCyclePct = ( deltaPWMDutyCyclePct < 0.0 ? \ dialOutPumpPWMDutyCyclePctSet - MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE : \ dialOutPumpPWMDutyCyclePctSet + MAX_DIAL_OUT_PUMP_PWM_STEP_UP_CHANGE ); } - // set new PWM + // Set new PWM dialOutPumpPWMDutyCyclePctSet = newPWMDutyCyclePct; setDialOutPumpControlSignalPWM( newPWMDutyCyclePct ); } @@ -714,7 +714,7 @@ *************************************************************************/ static void publishDialOutFlowData( void ) { - // publish dialysate outlet pump and UF volume data on interval + // Publish dialysate outlet pump and UF volume data on interval if ( ++dialOutFlowDataPublicationTimerCounter >= getPublishDialOutDataInterval() ) { DIAL_OUT_FLOW_DATA_T dialOutBroadCastVariables; @@ -753,7 +753,7 @@ U16 decDelta = HEX_64_K - incDelta; U16 delta; - // determine dialysate outlet pump speed/direction from delta hall sensor count since last interval + // Determine dialysate outlet pump speed/direction from delta hall sensor count since last interval if ( incDelta < decDelta ) { delta = incDelta; @@ -765,7 +765,7 @@ dialOutPumpSpeedRPM.data = ( (F32)delta / (F32)DOP_HALL_EDGE_COUNTS_PER_REV ) * (F32)SEC_PER_MIN * -1.0; } - // update last count for next time + // Update last count for next time dopLastMotorHallSensorCounts[ nextIdx ] = dopMotorHallSensorCount; dopMotorSpeedCalcIdx = nextIdx; dopMotorSpeedCalcTimerCtr = 0; @@ -783,15 +783,15 @@ *************************************************************************/ static void checkDialOutPumpRotor( void ) { - // if homing, check timeout + // If homing, check timeout if ( ( TRUE == dopStopAtHomePosition ) && ( TRUE == didTimeout( dopHomeStartTime, DOP_HOME_TIMEOUT_MS ) ) ) { signalDialOutPumpHardStop(); dopStopAtHomePosition = FALSE; // TODO - alarm??? } - // 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( dopRotorRevStartTime, DOP_HOME_TIMEOUT_MS ) ) { dialOutPumpRotorSpeedRPM.data = 0.0; @@ -942,7 +942,7 @@ { F32 dopCurr; - // dialOut pump should be off + // DialOut pump should be off if ( DIAL_OUT_PUMP_OFF_STATE == dialOutPumpState ) { dopCurr = fabs( getMeasuredDialOutPumpMCCurrent() ); @@ -961,7 +961,7 @@ dopCurrErrorDurationCtr = 0; } } - // dialOut pump should be running + // DialOut pump should be running else { dopCurr = fabs( getMeasuredDialOutPumpMCCurrent() ); Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -33,7 +33,7 @@ // ********** private definitions ********** /// Default publication interval for pressure and occlusion data. -#define PRES_OCCL_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< interval (ms/task time) at which the pressure/occlusion data is published on the CAN bus. +#define PRES_OCCL_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the pressure/occlusion data is published on the CAN bus. #define ARTERIAL_PRESSURE_V_BIAS ( 3.0 ) ///< Bias voltage for arterial pressure sensor. #define ARTERIAL_PRESSURE_SENSITIVITY ( 0.000005 ) ///< Sensitivity for arterial pressure sensor is 5 uV / mmHg @@ -77,22 +77,22 @@ // ********** private data ********** -static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; ///< current state of pressure monitor state machine. -static U32 presOcclDataPublicationTimerCounter = 0; ///< used to schedule pressure data publication to CAN bus. +static PRESSURE_STATE_T presOcclState = PRESSURE_INIT_STATE; ///< Current state of pressure monitor state machine. +static U32 presOcclDataPublicationTimerCounter = 0; ///< Used to schedule pressure data publication to CAN bus. -/// interval (in ms) at which to publish pressure/occlusion data to CAN bus. +/// Interval (in ms) at which to publish pressure/occlusion data to CAN bus. static OVERRIDE_U32_T presOcclDataPublishInterval = { PRES_OCCL_DATA_PUB_INTERVAL, PRES_OCCL_DATA_PUB_INTERVAL, 0, 0 }; -static OVERRIDE_F32_T arterialPressure = {0.0, 0.0, 0.0, 0 }; ///< measured arterial pressure. -static OVERRIDE_F32_T venousPressure = {0.0, 0.0, 0.0, 0 }; ///< measured venous pressure. -static OVERRIDE_U32_T bloodPumpOcclusion = {0, 0, 0, 0 }; ///< measured blood pump occlusion pressure. -static OVERRIDE_U32_T dialInPumpOcclusion = {0, 0, 0, 0 }; ///< measured dialysate inlet pump occlusion pressure. -static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< measured dialysate outlet pump occlusion pressure. +static OVERRIDE_F32_T arterialPressure = {0.0, 0.0, 0.0, 0 }; ///< Measured arterial pressure. +static OVERRIDE_F32_T venousPressure = {0.0, 0.0, 0.0, 0 }; ///< Measured venous pressure. +static OVERRIDE_U32_T bloodPumpOcclusion = {0, 0, 0, 0 }; ///< Measured blood pump occlusion pressure. +static OVERRIDE_U32_T dialInPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate inlet pump occlusion pressure. +static OVERRIDE_U32_T dialOutPumpOcclusion = {0, 0, 0, 0 }; ///< Measured dialysate outlet pump occlusion pressure. /// Current pressure self-test state. static PRESSURE_SELF_TEST_STATE_T presOcclSelfTestState = PRESSURE_SELF_TEST_STATE_START; -static U32 bloodPumpSelfTestTimerCount = 0; ///< timer counter for pressure self-test. +static U32 bloodPumpSelfTestTimerCount = 0; ///< Timer counter for pressure self-test. -static U32 staleVenousPressureCtr = 0; ///< timer counter for stale venous pressure reading. +static U32 staleVenousPressureCtr = 0; ///< Timer counter for stale venous pressure reading. // ********** private function prototypes ********** @@ -115,7 +115,7 @@ *************************************************************************/ void initPresOccl( void ) { - // initialize persistent pressure alarms + // Initialize persistent pressure alarms initPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_LOW, ALARM_ID_ARTERIAL_PRESSURE_LOW, isAlarmRecoverable( ALARM_ID_ARTERIAL_PRESSURE_LOW ), PRES_ALARM_PERSISTENCE, PRES_ALARM_PERSISTENCE ); initPersistentAlarm( PERSISTENT_ALARM_ARTERIAL_PRESSURE_HIGH, ALARM_ID_ARTERIAL_PRESSURE_HIGH, @@ -160,7 +160,7 @@ *************************************************************************/ void execPresOccl( void ) { - // state machine + // State machine switch ( presOcclState ) { case PRESSURE_INIT_STATE: @@ -176,7 +176,7 @@ break; } - // publish pressure/occlusion data on interval + // Publish pressure/occlusion data on interval publishPresOcclData(); } @@ -234,11 +234,11 @@ static void convertInlinePressures( void ) { U32 fpgaArtPres = getFPGAArterialPressure(); - S32 artPres = (S32)( fpgaArtPres & MASK_OFF_U32_MSB ) - 0x800000; // subtract 2^23 from low 24 bits to get signed reading - U08 artPresAlarm = (U08)( fpgaArtPres >> 24 ); // high byte is alarm code for arterial pressure + S32 artPres = (S32)( fpgaArtPres & MASK_OFF_U32_MSB ) - 0x800000; // Subtract 2^23 from low 24 bits to get signed reading + U08 artPresAlarm = (U08)( fpgaArtPres >> 24 ); // High byte is alarm code for arterial pressure U16 fpgaVenPres = getFPGAVenousPressure(); U16 venPres = fpgaVenPres & 0x3FFF; // 14-bit data - U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // high 2 bits is status code for venous pressure + U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // High 2 bits is status code for venous pressure F32 venPresPSI; // TODO - any filtering required??? @@ -263,7 +263,7 @@ venousPressure.data = venPresPSI * PSI_TO_MMHG; staleVenousPressureCtr = 0; } - // if venous pressure sensor status is not normal or reading is stale for too long, fault + // If venous pressure sensor status is not normal or reading is stale for too long, fault else { if ( ++staleVenousPressureCtr > MAX_TIME_BETWEEN_VENOUS_READINGS ) @@ -294,7 +294,7 @@ { // TODO - any filtering required??? - // occlusion sensor values have no unit - take as is + // Occlusion sensor values have no unit - take as is bloodPumpOcclusion.data = (U32)getFPGABloodPumpOcclusion(); dialInPumpOcclusion.data = (U32)getFPGADialInPumpOcclusion(); dialOutPumpOcclusion.data = (U32)getFPGADialOutPumpOcclusion(); @@ -512,7 +512,7 @@ *************************************************************************/ static void publishPresOcclData( void ) { - // publish pressure/occlusion data on interval + // Publish pressure/occlusion data on interval if ( ++presOcclDataPublicationTimerCounter >= getPublishPresOcclDataInterval() ) { PRESSURE_OCCLUSION_DATA_T data; Index: firmware/App/Controllers/PresOccl.h =================================================================== diff -u -r933a18d740285e70be9d00696ed0f5a5381bc8e4 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 933a18d740285e70be9d00696ed0f5a5381bc8e4) +++ firmware/App/Controllers/PresOccl.h (.../PresOccl.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -34,17 +34,17 @@ /// Enumeration of pressure sensors monitored by this module. typedef enum PressureSensors { - PRESSURE_SENSOR_ARTERIAL = 0, ///< arterial blood line pressure sensor - PRESSURE_SENSOR_VENOUS, ///< vensous blood line pressure sensor + PRESSURE_SENSOR_ARTERIAL = 0, ///< Arterial blood line pressure sensor + PRESSURE_SENSOR_VENOUS, ///< Vensous blood line pressure sensor NUM_OF_PRESSURE_SENSORS ///< Number of pressure sensors } PRESSURE_SENSORS_T; /// Enumeration of occlusion sensors monitored by this module. typedef enum OcclusionSensors { - OCCLUSION_SENSOR_BLOOD_PUMP = 0, ///< blood pump occlusion sensor - OCCLUSION_SENSOR_DIAL_IN_PUMP, ///< dialysate inlet pump occlusion sensor - OCCLUSION_SENSOR_DIAL_OUT_PUMP, ///< dialysate outlet pump occlusion sensor + OCCLUSION_SENSOR_BLOOD_PUMP = 0, ///< Blood pump occlusion sensor + OCCLUSION_SENSOR_DIAL_IN_PUMP, ///< Dialysate inlet pump occlusion sensor + OCCLUSION_SENSOR_DIAL_OUT_PUMP, ///< Dialysate outlet pump occlusion sensor NUM_OF_OCCLUSION_SENSORS ///< Number of occlusion sensors } OCCLUSION_SENSORS_T; Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -444,7 +444,7 @@ VALVE_T valve; // Monitoring should be done once POST is complete and the valves are - // set correctly + // Set correctly if ( valveSelfTestState == VALVE_SELF_TEST_COMPLETE ) { execMonitorValves(); @@ -584,7 +584,7 @@ BOOL isDoorClosed = TRUE; // If homing has been requested or POST is completed and the door has been close for the specified - // period of time, start the homing + // Period of time, start the homing if ( valveSelfTestState == VALVE_SELF_TEST_COMPLETE && ( valvesStatus[ valve ].hasHomingBeenRequested || isDoorClosed ) && ( ! valvesStatus[ valve ].hasHomingFailed ) ) { @@ -1145,7 +1145,7 @@ } // Check if the current position has deviated from the position it is supposed to be in - // for more than a certain amount of time. If it has, raise an alarm + // For more than a certain amount of time. If it has, raise an alarm // Absolute value is used for comparison to cover +/- from the commanded position if ( abs( currentPostion - commandedPoistion ) > maxDeviation ) { @@ -1256,9 +1256,9 @@ case VALVE_POSITION_A_INSERT_EJECT: // If the valve is currently in position A and its commanded position is position B, - // add the defined number of steps for the next transition + // Add the defined number of steps for the next transition // If the valve is currently in position A and its commanded position is position C, - // subtract the defined number of steps for the next transition + // Subtract the defined number of steps for the next transition if ( commandedPositionEnum == VALVE_POSITION_B_OPEN ) { valvesStatus[ valve ].targetPositionInCounts = valvesStatus[ valve ].currentPositionInCounts + nextStep; @@ -1285,7 +1285,7 @@ } // Call the function to send the set point to FPGA. Current relaxation is not - // enabled here, so it is always false + // Enabled here, so it is always false setFPGAValveSetPoint( valve, valvesStatus[ valve ].targetPositionInCounts, FALSE ); } @@ -1501,13 +1501,13 @@ BOOL homingStatus = valvesStatus[ valve ].hasValveBeenHomed; // The PWM should be in range and also the valve direction should be legal and the valve must have been homed - // prior to running this command + // Prior to running this command if ( pwm <= VALVE_MAX_ALLOWED_PWM_PERCENT && direction < NUM_OF_VALVE_DIRECTION && homingStatus ) { valvesStatus[ (VALVE_T)valve ].bypassModeStatus.commandedPWMInPercent = (U16)pwm; valvesStatus[ (VALVE_T)valve ].bypassModeStatus.direction = (VALVE_DIRECTION_T)direction; // This flag sets the valves to bypass mode in the idle state. After that the valve will be sitting in the - // bypass mode until this flag is set to FALSE in the reset function. + // Bypass mode until this flag is set to FALSE in the reset function. valvesStatus[ (VALVE_T)valve ].bypassModeStatus.hasBypassModeBeenRequeseted = TRUE; // This flag is used to check if a change in PWM has been requested so the new PWM is processed and set valvesStatus[ (VALVE_T)valve ].bypassModeStatus.hasChangeBeenRequested = TRUE; Index: firmware/App/Drivers/CPLD.c =================================================================== diff -u -rac05209d7b6c65b22359754eced5ad2672d3092a -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision ac05209d7b6c65b22359754eced5ad2672d3092a) +++ firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -73,13 +73,13 @@ *************************************************************************/ void initCPLD( void ) { - // initialize watchdog pet output low (inactive) + // Initialize watchdog pet output low (inactive) CLR_WD_PET(); - // initialize power off request output low (inactive) + // Initialize power off request output low (inactive) CLR_OFF_REQ(); - // initialize alarm lamp color LED outputs low (off) + // Initialize alarm lamp color LED outputs low (off) CLR_GREEN(); CLR_RED(); CLR_BLUE(); Index: firmware/App/Drivers/Comm.h =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Drivers/Comm.h (.../Comm.h) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Drivers/Comm.h (.../Comm.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,8 +31,8 @@ // ********** public definitions ********** -#define SCI_DMA_TRANSMIT_INT 0x00010000 ///< bit mask for setting/clearing serial DMA transmit interrupts. -#define SCI_DMA_RECEIVE_INT 0x00060000 ///< bit mask for setting/clearing serial DMA receive interrupts. +#define SCI_DMA_TRANSMIT_INT 0x00010000 ///< Bit mask for setting/clearing serial DMA transmit interrupts. +#define SCI_DMA_RECEIVE_INT 0x00060000 ///< Bit mask for setting/clearing serial DMA receive interrupts. // ********** public function prototypes ********** Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -rc67def50892f9a7c2f1f22985b5351465a8f6773 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision c67def50892f9a7c2f1f22985b5351465a8f6773) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -28,8 +28,8 @@ // ********** private definitions ********** #define MAX_ADC_CHANNELS 24 ///< ADC supports up to 24 channels. -#define SIZE_OF_ROLLING_AVG 16 ///< samples in rolling average calculations. -#define ROLLING_AVG_SHIFT_DIVIDER 4 ///< rolling average shift divider. +#define SIZE_OF_ROLLING_AVG 16 ///< Samples in rolling average calculations. +#define ROLLING_AVG_SHIFT_DIVIDER 4 ///< Rolling average shift divider. /// Mapping from enumerated used ADC channel to processor channel ID. const INT_ADC_CHANNEL_T adcChannelNum2ChannelId[ MAX_ADC_CHANNELS ] = @@ -83,7 +83,7 @@ { U32 c,r; - // zero all adc values and stats + // Zero all adc values and stats adcRawReadingsCount = 0; for ( c = 0; c < NUM_OF_INT_ADC_CHANNELS; c++ ) { @@ -98,7 +98,7 @@ } } - // enable interrupt when all channels converted + // Enable interrupt when all channels converted adcEnableNotification( adcREG1, adcGROUP1 ); } @@ -134,7 +134,7 @@ if ( adcRawReadingsCount < NUM_OF_INT_ADC_CHANNELS ) { - // process readings from last conversion + // Process readings from last conversion for ( i = 0; i < adcRawReadingsCount; i++ ) { U32 ch = adcChannelNum2ChannelId[ adcRawReadings[ i ].id ]; @@ -151,7 +151,7 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INT_ADC_DATA_OVERRUN, adcRawReadingsCount ) } - // start an adc channel group conversion + // Start an adc channel group conversion adcStartConversion( adcREG1, adcGROUP1 ); } Index: firmware/App/Drivers/SafetyShutdown.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Drivers/SafetyShutdown.c (.../SafetyShutdown.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -95,7 +95,7 @@ { // Remember natural state before override so we can reset safetyShutdownOverrideResetState = safetyShutdownActivated; - // override safety shutdown signal + // Override safety shutdown signal if ( value > 0 ) { activateSafetyShutdown(); Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -233,12 +233,12 @@ *************************************************************************/ void startDialysis( void ) { - // set last UF timestamp so UF ref is resumed from this time + // Set last UF timestamp so UF ref is resumed from this time lastUFTimeStamp = getMSTimerCount(); - // send dialysate outlet pump latest UF volumes + // Send dialysate outlet pump latest UF volumes setDialOutUFVolumes( refUFVolume, measUFVolume ); - // set valves for dialysis + // Set valves for dialysis setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setValvePosition( VDO, VALVE_POSITION_B_OPEN ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); @@ -253,7 +253,7 @@ #endif setDialOutPumpTargetRate( setDialysateFlowRate + (S32)setUFRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // TODO - Heparin pump - // tell DG to start heating dialysate + // Tell DG to start heating dialysate cmdStartDGTrimmerHeater(); } @@ -268,12 +268,12 @@ *************************************************************************/ void stopDialysis( void ) { - // stop pumps + // Stop pumps setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // TODO - stop Heparin pump - // tell DG to stop heating dialysate + // Tell DG to stop heating dialysate cmdStopDGTrimmerHeater(); } @@ -294,7 +294,7 @@ TREATMENT_STATE_T currTreatSubMode = getTreatmentState(); SALINE_BOLUS_STATE_T currSalineBolusState = getSalineBolusState(); - // must be in treatment mode, dialysis sub-mode, saline bolus in idle state in order to start a saline bolus + // Must be in treatment mode, dialysis sub-mode, saline bolus in idle state in order to start a saline bolus if ( currOpMode != MODE_TREA ) { rejReason = REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE; @@ -317,7 +317,7 @@ salineBolusStartRequested = TRUE; } - // send response + // Send response sendSalineBolusResponse( accept, rejReason, salineBolusVolume ); } @@ -338,7 +338,7 @@ TREATMENT_STATE_T currTreatSubMode = getTreatmentState(); SALINE_BOLUS_STATE_T currSalineBolusState = getSalineBolusState(); - // must be in treatment mode, dialysis sub-mode, saline bolus in delivery state in order to abort a saline bolus + // Must be in treatment mode, dialysis sub-mode, saline bolus in delivery state in order to abort a saline bolus if ( currOpMode != MODE_TREA ) { rejReason = REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE; @@ -357,7 +357,7 @@ salineBolusAbortRequested = TRUE; } - // send response + // Send response sendSalineBolusResponse( accept, rejReason, salineBolusVolume ); } @@ -430,9 +430,9 @@ ( DIALYSIS_UF_STATE == currentDialysisState ) && ( UF_RUNNING_STATE == currentUFState ) ) { result = TRUE; - // set outlet pump to dialysate rate + // Set outlet pump to dialysate rate setDialOutPumpTargetRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); - // go to UF paused state + // Go to UF paused state currentUFState = UF_PAUSED_STATE; } else @@ -455,9 +455,9 @@ } } - // send response w/ reason code if rejected + // Send response w/ reason code if rejected sendUFPauseResumeResponse( result, rejectReason, currentUFState ); - // send state data immediately for UI update + // Send state data immediately for UI update broadcastTreatmentTimeAndState(); return result; @@ -481,11 +481,11 @@ ( DIALYSIS_UF_STATE == currentDialysisState ) && ( UF_PAUSED_STATE == currentUFState ) ) { result = TRUE; - // set outlet pump to dialysate rate + set UF rate + // Set outlet pump to dialysate rate + set UF rate setDialOutPumpTargetRate( setDialysateFlowRate + FLOAT_TO_INT_WITH_ROUND( setUFRate ), MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // Restart UF time accumulation for reference volume calculation lastUFTimeStamp = getMSTimerCount(); - // go to UF paused state + // Go to UF paused state currentUFState = UF_RUNNING_STATE; } else @@ -508,9 +508,9 @@ } } - // send response w/ reason code if rejected + // Send response w/ reason code if rejected sendUFPauseResumeResponse( result, rejectReason, currentUFState ); - // send state data immediately for UI update + // Send state data immediately for UI update broadcastTreatmentTimeAndState(); return result; @@ -525,10 +525,10 @@ *************************************************************************/ void execDialysis( void ) { - // check ultrafiltration max rate and accuracy during dialysis (even when ultrafiltration is paused). + // Check ultrafiltration max rate and accuracy during dialysis (even when ultrafiltration is paused). checkUFAccuracyAndVolume(); - // dialysis state machine + // Dialysis state machine switch ( currentDialysisState ) { case DIALYSIS_START_STATE: @@ -548,7 +548,7 @@ break; } - // publish saline bolus data at set interval (whether we're delivering one or not) + // Publish saline bolus data at set interval (whether we're delivering one or not) publishSalineBolusData(); } @@ -675,14 +675,14 @@ { UF_STATE_T result = UF_PAUSED_STATE; - // calculate UF volumes and provide to dialysate outlet pump controller + // Calculate UF volumes and provide to dialysate outlet pump controller updateUFVolumes(); - // handle saline bolus start request from user + // Handle saline bolus start request from user if ( TRUE == salineBolusStartRequested ) { salineBolusAutoResumeUF = FALSE; - // go to saline bolus state if we can + // Go to saline bolus state if we can if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; @@ -692,11 +692,11 @@ salineBolusStartRequested = FALSE; } } - // handle auto-resume after saline bolus + // Handle auto-resume after saline bolus else if ( TRUE == salineBolusAutoResumeUF ) { salineBolusAutoResumeUF = FALSE; - // set outlet pump to dialysate rate + set UF rate + // Set outlet pump to dialysate rate + set UF rate setDialOutPumpTargetRate( setDialysateFlowRate + FLOAT_TO_INT_WITH_ROUND( setUFRate ), MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // Restart UF time accumulation for reference volume calculation lastUFTimeStamp = getMSTimerCount(); @@ -723,31 +723,31 @@ U32 newTime = getMSTimerCount(); U32 msSinceLast = calcTimeBetween( lastUFTimeStamp, newTime ); - // update UF time + // Update UF time uFTimeMS += msSinceLast; lastUFTimeStamp = newTime; - // update UF ref volume in UF running state only + // Update UF ref volume in UF running state only refUFVolume += ( ( (F32)msSinceLast / MS_PER_SECOND ) / SEC_PER_MIN ) * setUFRate; - // calculate UF volumes and provide to dialysate outlet pump controller + // Calculate UF volumes and provide to dialysate outlet pump controller updateUFVolumes(); - // if we've reached target UF volume, UF is complete + // If we've reached target UF volume, UF is complete if ( measUFVolume >= maxUFVolumeML ) { result = UF_COMPLETED_STATE; } - // handle saline bolus start request from user + // Handle saline bolus start request from user else if ( TRUE == salineBolusStartRequested ) { if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { - // since we were doing UF prior to saline bolus, we want to auto-resume when done + // Since we were doing UF prior to saline bolus, we want to auto-resume when done salineBolusAutoResumeUF = TRUE; - // go to UF paused state + // Go to UF paused state result = UF_PAUSED_STATE; - // go to saline bolus state + // Go to saline bolus state *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; } else @@ -772,14 +772,14 @@ { UF_STATE_T result = UF_OFF_STATE; - // calculate UF volumes and provide to dialysate outlet pump controller + // Calculate UF volumes and provide to dialysate outlet pump controller updateUFVolumes(); - // handle saline bolus start request from user + // Handle saline bolus start request from user if ( TRUE == salineBolusStartRequested ) { salineBolusAutoResumeUF = FALSE; - // go to saline bolus state + // Go to saline bolus state if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; @@ -806,14 +806,14 @@ { UF_STATE_T result = UF_COMPLETED_STATE; - // calculate UF volumes and provide to dialysate outlet pump controller + // Calculate UF volumes and provide to dialysate outlet pump controller updateUFVolumes(); - // handle saline bolus start request from user + // Handle saline bolus start request from user if ( TRUE == salineBolusStartRequested ) { salineBolusAutoResumeUF = FALSE; - // go to saline bolus state + // Go to saline bolus state if ( SALINE_BOLUS_STATE_IDLE == currentSalineBolusState ) { *dialysisState = DIALYSIS_SALINE_BOLUS_STATE; @@ -840,11 +840,11 @@ { SALINE_BOLUS_STATE_T result = SALINE_BOLUS_STATE_IDLE; - // handle saline bolus start request from user + // Handle saline bolus start request from user if ( TRUE == salineBolusStartRequested ) { salineBolusStartRequested = FALSE; - // cmd all pumps to stop + // Cmd all pumps to stop #ifndef RUN_PUMPS_OPEN_LOOP setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); @@ -854,7 +854,7 @@ setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); #endif - // begin saline bolus + // Begin saline bolus result = SALINE_BOLUS_STATE_WAIT_FOR_PUMPS_STOP; } @@ -883,24 +883,24 @@ bolusSalineLastMotorCount = getBloodPumpMotorCount(); bolusSalineLastVolumeTimeStamp = getMSTimerCount(); - // bypass dialyzer + // Bypass dialyzer setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - // switch to saline bag + // Switch to saline bag setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); - // start blood pump at saline bolus rate + // Start blood pump at saline bolus rate #ifndef RUN_PUMPS_OPEN_LOOP setBloodPumpTargetFlowRate( SALINE_BOLUS_FLOW_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); #else setBloodPumpTargetFlowRate( SALINE_BOLUS_FLOW_RATE, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); #endif - // start dialysate inlet pump at re-circ rate + // Start dialysate inlet pump at re-circ rate #ifndef RUN_PUMPS_OPEN_LOOP setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); #else setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); #endif - // begin saline bolus + // Begin saline bolus result = SALINE_BOLUS_STATE_IN_PROGRESS; } @@ -927,7 +927,7 @@ U32 bldPumpMotorCount = getBloodPumpMotorCount(); U32 bldPumpMotorDelta = u32DiffWithWrap( bolusSalineLastMotorCount, bldPumpMotorCount ); - // update saline bolus volumes + // Update saline bolus volumes bolusSalineLastVolumeTimeStamp = getMSTimerCount(); bolusSalineVolumeDelivered += volSinceLastUpdateMl; totalSalineVolumeDelivered += volSinceLastUpdateMl; @@ -944,17 +944,17 @@ } #endif - // determine if we've reached maximum saline delivery volume + // Determine if we've reached maximum saline delivery volume if ( ( totalSalineVolumeDelivered >= (F32)MAX_SALINE_VOLUME_DELIVERED ) ) { result = SALINE_BOLUS_STATE_MAX_DELIVERED; } else { - // determine if bolus is complete + // Determine if bolus is complete if ( bolusSalineVolumeDelivered >= bolusTargetVolume ) { - // if safety thinks we've under-delivered the bolus, throw a fault + // If safety thinks we've under-delivered the bolus, throw a fault if ( bolusSalineVolumeDelivered_Safety < ( bolusTargetVolume * MIN_SALINE_BOLUS_VOLUME_PCT ) ) { #ifndef DISABLE_SALINE_BOLUS_CHECKS @@ -964,13 +964,13 @@ } result = SALINE_BOLUS_STATE_IDLE; } - // user is aborting saline bolus + // User is aborting saline bolus else if ( TRUE == salineBolusAbortRequested ) { salineBolusAbortRequested = FALSE; result = SALINE_BOLUS_STATE_IDLE; } - // determine if safety thinks we've over-delivered the bolus + // Determine if safety thinks we've over-delivered the bolus else if ( bolusSalineVolumeDelivered_Safety > ( bolusTargetVolume * MAX_SALINE_BOLUS_VOLUME_PCT ) ) { #ifndef DISABLE_SALINE_BOLUS_CHECKS @@ -981,19 +981,19 @@ } } - // are we stopping the bolus? + // Are we stopping the bolus? if ( result != SALINE_BOLUS_STATE_IN_PROGRESS ) { - // hard stop blood and dialysate pumps + // Hard stop blood and dialysate pumps signalBloodPumpHardStop(); signalDialInPumpHardStop(); - // send last saline bolus data + // Send last saline bolus data bolusSalineVolumeDelivered = 0.0; salineBolusBroadcastTimerCtr = SALINE_BOLUS_DATA_PUB_INTERVAL; publishSalineBolusData(); - // dialysis back to UF state + // Dialysis back to UF state *dialysisState = DIALYSIS_UF_STATE; - // end dialyzer bypass and resume dialysis if no alarms triggered + // End dialyzer bypass and resume dialysis if no alarms triggered if ( FALSE == errorFound ) { // Resume UF if appropriate @@ -1022,8 +1022,8 @@ { SALINE_BOLUS_STATE_T result = SALINE_BOLUS_STATE_MAX_DELIVERED; - // this is a terminal state for a given treatment - no more saline may be delivered to patient - // if we get here, pop back to UF + // This is a terminal state for a given treatment - no more saline may be delivered to patient + // If we get here, pop back to UF *dialysisState = DIALYSIS_UF_STATE; return result; @@ -1062,16 +1062,16 @@ *************************************************************************/ static void checkUFAccuracyAndVolume( void ) { - F32 uFMeasRate = measUFVolume - lastUFVolumeChecked; // volumes are at start/end of 1 hour period, so implied rate is per hour + F32 uFMeasRate = measUFVolume - lastUFVolumeChecked; // Volumes are at start/end of 1 hour period, so implied rate is per hour - // check UF rate diff from target in last hour + // Check UF rate diff from target in last hour if ( uFMeasRate > maxUFRateAccuracyError_Ml_hr ) { #ifndef DISABLE_UF_ALARMS SET_ALARM_WITH_1_F32_DATA( ALARM_ID_UF_RATE_TOO_HIGH_ERROR, uFMeasRate ); #endif } - // if actively performing ultrafiltration right now, increment timer and see if time to start another 1 hour check period + // If actively performing ultrafiltration right now, increment timer and see if time to start another 1 hour check period if ( UF_RUNNING_STATE == currentUFState ) { if ( ++uFAccuracyCheckTimerCtr >= UF_ACCURACY_CHECK_INTERVAL ) @@ -1082,7 +1082,7 @@ } } - // check total UF volume error + // Check total UF volume error if ( ( fabs( refUFVolume - measUFVolume ) ) >= (F32)MAX_UF_ACCURACY_ERROR_ML ) { #ifndef DISABLE_UF_ALARMS @@ -1106,7 +1106,7 @@ DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); F32 latestResVolume; - // get volume of active reservoir + // Get volume of active reservoir if ( DG_RESERVOIR_1 == activeRes ) { latestResVolume = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_1_PRIMARY ); @@ -1116,7 +1116,7 @@ latestResVolume = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_2_PRIMARY ); } - // calculate UF volumes and provide to dialysate outlet pump controller + // Calculate UF volumes and provide to dialysate outlet pump controller measUFVolume = measUFVolumeFromPriorReservoirs + ( latestResVolume - resStartVolume[ activeRes ] ); resFinalVolume[ activeRes ] = latestResVolume; setDialOutUFVolumes( refUFVolume, measUFVolume ); @@ -1137,7 +1137,7 @@ DG_RESERVOIR_ID_T inactiveRes; F32 resVolume; - // get volume of inactive reservoir + // Get volume of inactive reservoir if ( DG_RESERVOIR_2 == activeRes ) { inactiveRes = DG_RESERVOIR_1; @@ -1149,7 +1149,7 @@ resVolume = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_2_PRIMARY ); } - // set starting baseline volume for next reservoir before we switch to it + // Set starting baseline volume for next reservoir before we switch to it resStartVolume[ inactiveRes ] = resVolume; } @@ -1167,7 +1167,7 @@ DG_RESERVOIR_ID_T activeRes = getDGActiveReservoir(); DG_RESERVOIR_ID_T inactiveRes = ( activeRes == DG_RESERVOIR_1 ? DG_RESERVOIR_2 : DG_RESERVOIR_1 ); - // update UF volume from prior reservoirs per tentative res volume for last reservoir + // Update UF volume from prior reservoirs per tentative res volume for last reservoir measUFVolumeFromPriorReservoirs += ( resFinalVolume[ inactiveRes ] - resStartVolume[ inactiveRes ] ); } @@ -1186,7 +1186,7 @@ DG_RESERVOIR_ID_T inactiveRes; F32 resVolume; - // get volume of inactive reservoir + // Get volume of inactive reservoir if ( DG_RESERVOIR_2 == activeRes ) { inactiveRes = DG_RESERVOIR_1; @@ -1198,7 +1198,7 @@ resVolume = getLoadCellWeightInGrams( LOAD_CELL_RESERVOIR_2_PRIMARY ); } - // update UF volume from prior reservoirs per final res volume for last reservoir a bit after we've switched and reservoir has settled + // Update UF volume from prior reservoirs per final res volume for last reservoir a bit after we've switched and reservoir has settled measUFVolumeFromPriorReservoirs -= ( resFinalVolume[ inactiveRes ] - resStartVolume[ inactiveRes ] ); resFinalVolume[ inactiveRes ] = resVolume; measUFVolumeFromPriorReservoirs += ( resFinalVolume[ inactiveRes ] - resStartVolume[ inactiveRes ] ); Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -rce3e0696642099164fa482c864509c67ce65579b -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision ce3e0696642099164fa482c864509c67ce65579b) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -17,9 +17,7 @@ #include "AlarmLamp.h" #include "BloodFlow.h" -#ifdef EMC_TEST_BUILD // TODO - test code #include "Buttons.h" -#endif #include "DialInFlow.h" #include "DialOutFlow.h" #include "ModeFault.h" @@ -56,7 +54,7 @@ *************************************************************************/ void transitionToFaultMode( void ) { - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); @@ -74,11 +72,11 @@ BOOL stop = isStopButtonPressed(); #ifndef EMC_TEST_BUILD - // ensure all pumps are stopped + // Ensure all pumps are stopped signalBloodPumpHardStop(); signalDialInPumpHardStop(); signalDialOutPumpHardStop(); - // ensure all valves are in safe position + // Ensure all valves are in safe position setValveAirTrap( STATE_CLOSED ); setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); @@ -96,33 +94,33 @@ toggle = INC_WRAP( toggle, 0, 3 ); switch ( toggle ) { - case 0: // pumps and valves off + case 0: // Pumps and valves off setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); break; - case 1: // pumps on, valves off + case 1: // Pumps on, valves off setBloodPumpTargetFlowRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); break; - case 2: // pumps on, valves on + case 2: // Pumps on, valves on setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setValvePosition( VDO, VALVE_POSITION_B_OPEN ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); break; - case 3: // pumps off, valves on + case 3: // Pumps off, valves on setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); break; - default: // shouldn't get here, reset if we do + default: // Shouldn't get here, reset if we do toggle = 0; setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); @@ -152,7 +150,7 @@ *************************************************************************/ void signalAlarmActionToFaultMode( ALARM_ACTION_T action ) { - // fault mode is terminal and already in safe state - no alarm actions handled in this mode. + // Fault mode is terminal and already in safe state - no alarm actions handled in this mode. } /**@}*/ Index: firmware/App/Modes/ModeFault.h =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,10 +31,10 @@ // ********** private function prototypes ********** -void initFaultMode( void ); // initialize this module -void transitionToFaultMode( void ); // prepares for transition to fault mode -U32 execFaultMode( void ); // execute the fault mode state machine (call from OperationModes) -void signalAlarmActionToFaultMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for fault mode +void initFaultMode( void ); // Initialize this module +void transitionToFaultMode( void ); // Prepares for transition to fault mode +U32 execFaultMode( void ); // Execute the fault mode state machine (call from OperationModes) +void signalAlarmActionToFaultMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for fault mode /**@}*/ Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rac05209d7b6c65b22359754eced5ad2672d3092a -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision ac05209d7b6c65b22359754eced5ad2672d3092a) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -72,7 +72,7 @@ *************************************************************************/ void transitionToInitAndPOSTMode( void ) { - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); @@ -91,7 +91,7 @@ // TODO - send POST status on CAN - // execute current POST state *Note - these switch cases must be in same order as enum HD_POST_States + // Execute current POST state *Note - these switch cases must be in same order as enum HD_POST_States switch ( postState ) { case POST_STATE_START: @@ -153,7 +153,7 @@ // Should be last POST case POST_STATE_STUCK_BUTTON: testStatus = execStuckButtonTest(); - handlePOSTStatus( testStatus ); // ignoring return value because last test + handlePOSTStatus( testStatus ); // Ignoring return value because last test if ( TRUE == tempPOSTPassed ) { @@ -166,17 +166,17 @@ break; case POST_STATE_COMPLETED: - // set overall HD POST status to "passed" + // Set overall HD POST status to "passed" postPassed = TRUE; - // set overall HD POST completed status to TRUE + // Set overall HD POST completed status to TRUE postCompleted = TRUE; // TODO - send POST status on CAN - // go to standby mode + // Go to standby mode requestNewOperationMode( MODE_STAN ); break; case POST_STATE_FAILED: - // should not get here - any failed post test should have already triggered a fault and taken us to fault mode + // Should not get here - any failed post test should have already triggered a fault and taken us to fault mode default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_INIT_POST_INVALID_POST_STATE, postState ) postState = POST_STATE_FAILED; @@ -242,7 +242,7 @@ if ( testStatus == SELF_TEST_STATUS_PASSED ) { - result = (HD_POST_STATE_T)((int)postState + 1); // move on to next POST test + result = (HD_POST_STATE_T)((int)postState + 1); // Move on to next POST test } else if ( testStatus == SELF_TEST_STATUS_FAILED ) { @@ -252,7 +252,7 @@ } else { - // test still in progress - do nothing + // Test still in progress - do nothing } return result; Index: firmware/App/Modes/ModeInitPOST.h =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,12 +31,12 @@ // ********** private function prototypes ********** -void initInitAndPOSTMode( void ); // initialize this module -void transitionToInitAndPOSTMode( void ); // prepares for transition to init. & POST mode -U32 execInitAndPOSTMode( void ); // execute the init. & POST mode state machine (call from OperationModes) -BOOL isPOSTCompleted( void ); // determine whether POST has completed yet -BOOL isPOSTPassed( void ); // determine whether POST has passed -void signalAlarmActionToInitAndPOSTMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for fault mode +void initInitAndPOSTMode( void ); // Initialize this module +void transitionToInitAndPOSTMode( void ); // Prepares for transition to init. & POST mode +U32 execInitAndPOSTMode( void ); // Execute the init. & POST mode state machine (call from OperationModes) +BOOL isPOSTCompleted( void ); // Determine whether POST has completed yet +BOOL isPOSTPassed( void ); // Determine whether POST has passed +void signalAlarmActionToInitAndPOSTMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for fault mode /**@}*/ Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -rac05209d7b6c65b22359754eced5ad2672d3092a -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision ac05209d7b6c65b22359754eced5ad2672d3092a) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -53,7 +53,7 @@ *************************************************************************/ void transitionToPostTreatmentMode( void ) { - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); Index: firmware/App/Modes/ModePostTreat.h =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,10 +31,10 @@ // ********** private function prototypes ********** -void initPostTreatmentMode( void ); // initialize this module -void transitionToPostTreatmentMode( void ); // prepares for transition to post-treatment mode -U32 execPostTreatmentMode( void ); // execute the post-treatment mode state machine (call from OperationModes) -void signalAlarmActionToPostTreatmentMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for post-treatment mode +void initPostTreatmentMode( void ); // Initialize this module +void transitionToPostTreatmentMode( void ); // Prepares for transition to post-treatment mode +U32 execPostTreatmentMode( void ); // Execute the post-treatment mode state machine (call from OperationModes) +void signalAlarmActionToPostTreatmentMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for post-treatment mode /**@}*/ Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -60,7 +60,7 @@ { treatStartReqReceived = FALSE; - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); Index: firmware/App/Modes/ModePreTreat.h =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/ModePreTreat.h (.../ModePreTreat.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,11 +31,11 @@ // ********** private function prototypes ********** -void initPreTreatmentMode( void ); // initialize this module -void transitionToPreTreatmentMode( void ); // prepares for transition to pre-treatment mode -U32 execPreTreatmentMode( void ); // execute the pre-treatment mode state machine (call from OperationModes) -BOOL signalUserBeginningTreatment( void ); // signal that user requests treatment begin -void signalAlarmActionToPreTreatmentMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for pre-treatment mode +void initPreTreatmentMode( void ); // Initialize this module +void transitionToPreTreatmentMode( void ); // Prepares for transition to pre-treatment mode +U32 execPreTreatmentMode( void ); // Execute the pre-treatment mode state machine (call from OperationModes) +BOOL signalUserBeginningTreatment( void ); // Signal that user requests treatment begin +void signalAlarmActionToPreTreatmentMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for pre-treatment mode /**@}*/ Index: firmware/App/Modes/ModeService.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -47,7 +47,7 @@ *************************************************************************/ void transitionToServiceMode( void ) { - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); Index: firmware/App/Modes/ModeService.h =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeService.h (.../ModeService.h) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/ModeService.h (.../ModeService.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,10 +31,10 @@ // ********** private function prototypes ********** -void initServiceMode( void ); // initialize this module -void transitionToServiceMode( void ); // prepares for transition to service mode -U32 execServiceMode( void ); // execute the service mode state machine (call from OperationModes) -void signalAlarmActionToServiceMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for Service mode +void initServiceMode( void ); // Initialize this module +void transitionToServiceMode( void ); // Prepares for transition to service mode +U32 execServiceMode( void ); // Execute the service mode state machine (call from OperationModes) +void signalAlarmActionToServiceMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Service mode /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -74,12 +74,12 @@ initDGInterface(); resetAirTrap(); - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); - // pumps should be off + // Pumps should be off setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); @@ -108,11 +108,11 @@ activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); } - // state machine to get DG to prep a reservoir so we can start a treatment + // State machine to get DG to prep a reservoir so we can start a treatment switch ( currentStandbyState ) { case STANDBY_START_STATE: - // temporary test code - TODO - remove later + // Temporary test code - TODO - remove later if ( TRUE == isDGCommunicating() ) { homeBloodPump(); @@ -126,7 +126,7 @@ break; case STANDBY_FLUSH_DG_LINES_STATE: - // temporary test code - TODO - remove later + // Temporary test code - TODO - remove later cmdSetDGActiveReservoir( DG_RESERVOIR_2 ); if ( DG_MODE_CIRC == dgOpMode ) { @@ -146,15 +146,15 @@ break; case STANDBY_DRAIN_RESERVOIR_STATE: - // temporary test code - TODO - remove later + // Temporary test code - TODO - remove later if ( DG_MODE_CIRC == dgOpMode ) { currentStandbyState = STANDBY_WAIT_FOR_PRIME_STATE; } break; case STANDBY_WAIT_FOR_PRIME_STATE: - // temporary test code - TODO - remove later + // Temporary test code - TODO - remove later if ( DG_MODE_CIRC == dgOpMode ) { if ( DG_RECIRCULATE_MODE_STATE_RECIRC_WATER == dgSubMode ) @@ -169,7 +169,7 @@ break; case STANDBY_FILL_RESERVOIR_STATE: - // temporary test code - TODO - remove later + // Temporary test code - TODO - remove later if ( DG_MODE_CIRC == dgOpMode ) { currentStandbyState = STANDBY_WAIT_FOR_TREATMENT_STATE; @@ -201,12 +201,12 @@ break; } #else - // state machine to get DG to prep a reservoir so we can start a treatment + // State machine to get DG to prep a reservoir so we can start a treatment switch ( currentStandbyState ) { case STANDBY_START_STATE: currentStandbyState = STANDBY_WAIT_FOR_TREATMENT_STATE; - // temporary test code - TODO - remove later + // Temporary test code - TODO - remove later homeBloodPump(); homeDialInPump(); homeDialOutPump(); @@ -236,33 +236,33 @@ toggle = INC_WRAP( toggle, 0, 3 ); switch ( toggle ) { - case 0: // pumps and valves off + case 0: // Pumps and valves off setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); break; - case 1: // pumps on, valves off + case 1: // Pumps on, valves off setBloodPumpTargetFlowRate( 200, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( 500, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); break; - case 2: // pumps on, valves on + case 2: // Pumps on, valves on setValvePosition( VDI, VALVE_POSITION_B_OPEN ); setValvePosition( VDO, VALVE_POSITION_B_OPEN ); setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); break; - case 3: // pumps off, valves on + case 3: // Pumps off, valves on setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialOutPumpTargetRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); break; - default: // shouldn't get here, reset if we do + default: // Shouldn't get here, reset if we do toggle = 0; setBloodPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); setDialInPumpTargetFlowRate( 0, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,12 +31,12 @@ // ********** public function prototypes ********** -void initStandbyMode( void ); // initialize this module -void transitionToStandbyMode( void ); // prepares for transition to standby mode -U32 execStandbyMode( void ); // execute the standby mode state machine (call from OperationModes) +void initStandbyMode( void ); // Initialize this module +void transitionToStandbyMode( void ); // Prepares for transition to standby mode +U32 execStandbyMode( void ); // Execute the standby mode state machine (call from OperationModes) BOOL signalUserStartingTreatment( void ); // User has initiated a treatment - go to treatment parameters mode -void signalAlarmActionToStandbyMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for Standby mode +void signalAlarmActionToStandbyMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Standby mode /**@}*/ Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -104,7 +104,7 @@ treatmentTimeMS = 0; lastTreatmentTimeStamp = 0; treatmentTimeBroadcastTimerCtr = 0; - treatmentParamsRangesBroadcastTimerCtr = TREATMENT_SETTINGS_RANGES_PUB_INTERVAL; // so we send ranges immediately + treatmentParamsRangesBroadcastTimerCtr = TREATMENT_SETTINGS_RANGES_PUB_INTERVAL; // So we send ranges immediately presTreatmentTimeSecs = 0; presBloodFlowRate = 0; @@ -129,14 +129,14 @@ *************************************************************************/ void transitionToTreatmentMode( void ) { - // initialize treatment mode each time we transition to it + // Initialize treatment mode each time we transition to it initTreatmentMode(); initTreatmentReservoirMgmt(); - // initialize treatment sub-modes each time we transition to treatment mode + // Initialize treatment sub-modes each time we transition to treatment mode initDialysis(); initTreatmentStop(); - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); @@ -208,7 +208,7 @@ break; default: - // ignore + // Ignore break; } break; @@ -232,7 +232,7 @@ break; default: - // ignore + // Ignore break; } break; @@ -247,7 +247,7 @@ break; case ALARM_ACTION_ACK: - // nothing to be done here + // Nothing to be done here break; default: @@ -272,7 +272,7 @@ activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); } - // treatment mode state machine + // Treatment mode state machine switch ( currentTreatmentState ) { case TREATMENT_START_STATE: @@ -326,11 +326,11 @@ currentTreatmentState = TREATMENT_END_STATE; break; } - // broadcast treatment data + // Broadcast treatment data broadcastTreatmentTimeAndState(); broadcastTreatmentSettingsRanges(); - // call various execs for treatment mode + // Call various execs for treatment mode execTreatmentReservoirMgmt(); execAirTrapMonitorTreatment(); @@ -349,7 +349,7 @@ { TREATMENT_STATE_T result = TREATMENT_DIALYSIS_STATE; - // initialize treatment time + // Initialize treatment time treatmentTimeMS = 0; lastTreatmentTimeStamp = getMSTimerCount(); @@ -359,7 +359,7 @@ presMaxUFVolumeML = getTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME ) * (F32)ML_PER_LITER; presUFRate = presMaxUFVolumeML / (F32)getTreatmentParameterU32( TREATMENT_PARAM_TREATMENT_DURATION ); - // kick dialysis sub-mode off + // Kick dialysis sub-mode off setDialysisParams( presBloodFlowRate, presDialysateFlowRate, presMaxUFVolumeML, presUFRate ); startDialysis(); @@ -381,19 +381,19 @@ U32 newTime = getMSTimerCount(); U32 msSinceLast = calcTimeBetween( lastTreatmentTimeStamp, newTime ); - // update treatment time (unless delivering a saline bolus) + // Update treatment time (unless delivering a saline bolus) if ( getDialysisState() != DIALYSIS_SALINE_BOLUS_STATE ) { treatmentTimeMS += msSinceLast; } lastTreatmentTimeStamp = newTime; - // end treatment if treatment duration has been reached + // End treatment if treatment duration has been reached if ( CALC_ELAPSED_TREAT_TIME_IN_SECS() >= presTreatmentTimeSecs ) { result = TREATMENT_END_STATE; } - // otherwise, execute state machine for treatment dialysis sub-mode + // Otherwise, execute state machine for treatment dialysis sub-mode else { execDialysis(); @@ -430,14 +430,14 @@ { TREATMENT_STATE_T result = TREATMENT_STOP_STATE; - // if user requests treatment end, end treatment + // If user requests treatment end, end treatment if ( TRUE == pendingUserEndTreatmentRequest ) { result = TREATMENT_END_STATE; } else { - // execute state machine for treatment stop sub-mode + // Execute state machine for treatment stop sub-mode execTreatmentStop(); } @@ -476,15 +476,15 @@ REQUEST_REJECT_REASON_CODE_T rejectReason = REQUEST_REJECT_REASON_NONE; HD_OP_MODE_T currMode = getCurrentOperationMode(); - // check if we are in an appropriate treatment state for settings adjustment + // Check if we are in an appropriate treatment state for settings adjustment if ( ( MODE_TREA == currMode ) && ( currentTreatmentState > TREATMENT_START_STATE ) && ( currentTreatmentState < TREATMENT_DIALYSIS_END_STATE ) && ( CALC_ELAPSED_TREAT_TIME_IN_MIN() < treatmentTime ) && ( treatmentTime >= MIN_TREATMENT_TIME_MINUTES ) ) { F32 uFVolume; - U32 dialVolume = presDialysateFlowRate * treatmentTime; // in mL + U32 dialVolume = presDialysateFlowRate * treatmentTime; // In mL - // always adjust UF volume to accommodate treatment time change (not UF rate) + // Always adjust UF volume to accommodate treatment time change (not UF rate) uFVolume = ( (F32)( treatmentTime - CALC_ELAPSED_TREAT_TIME_IN_MIN() ) * presUFRate ) + getUltrafiltrationVolumeCollected(); if ( ( treatmentTime <= MAX_TREATMENT_TIME_MINUTES ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) && @@ -531,11 +531,11 @@ rejectReason = REQUEST_REJECT_REASON_TREATMENT_TIME_LESS_THAN_CURRENT; } } - // send response to request + // Send response to request sendChangeTreatmentDurationResponse( result, rejectReason, presTreatmentTimeSecs / SEC_PER_MIN, presMaxUFVolumeML ); - // send new ranges for settings + // Send new ranges for settings broadcastTreatmentSettingsRanges(); - // send time/state data immediately for UI update + // Send time/state data immediately for UI update broadcastTreatmentTimeAndState(); return result; @@ -563,17 +563,17 @@ pendingUFRateChange = presUFRate; pendingTreatmentTimeChange = presTreatmentTimeSecs / SEC_PER_MIN; - // check if we are in an appropriate treatment state for settings adjustment + // Check if we are in an appropriate treatment state for settings adjustment if ( ( MODE_TREA == currMode ) && ( currentTreatmentState > TREATMENT_START_STATE ) && ( currentTreatmentState < TREATMENT_DIALYSIS_END_STATE ) && ( uFVolume <= MAX_UF_VOLUME_ML ) && ( CALC_TREAT_TIME_REMAINING_IN_SECS() >= PREVENT_UF_VOL_CHANGE_IF_NEARLY_DONE_SEC ) ) { DIALYSIS_STATE_T currDialysisState = getDialysisState(); UF_STATE_T currUFState = getUltrafiltrationState(); - F32 uFRate = uFVolume / ((F32)presTreatmentTimeSecs / (F32)SEC_PER_MIN); // what UF rate would be if user selected to adjust it - U32 trtTime = (S32)( uFVolume / presUFRate ) + 1; // what the treatment duration would be if user selected to adjust it - U32 dialVolume = presDialysateFlowRate * trtTime; // what dialysate volume would be if user selected to adjust time + F32 uFRate = uFVolume / ((F32)presTreatmentTimeSecs / (F32)SEC_PER_MIN); // What UF rate would be if user selected to adjust it + U32 trtTime = (S32)( uFVolume / presUFRate ) + 1; // What the treatment duration would be if user selected to adjust it + U32 dialVolume = presDialysateFlowRate * trtTime; // What dialysate volume would be if user selected to adjust time // UF should already be paused but let's make sure. if ( ( TREATMENT_DIALYSIS_STATE == currentTreatmentState ) && @@ -583,10 +583,10 @@ pauseUF(); } - // start t/o timer - user must confirm UF changes within 1 minute from now + // Start t/o timer - user must confirm UF changes within 1 minute from now pendingParamChangesTimer = getMSTimerCount(); - // verify UF rate change would be valid (leave zero if not valid - UI will disable option) + // Verify UF rate change would be valid (leave zero if not valid - UI will disable option) if ( uFRate <= (F32)MAX_UF_RATE_ML_MIN ) { result = TRUE; @@ -598,7 +598,7 @@ { pendingUFRateChange = 0.0; } - // verify treatment duration change would be valid (leave zero if not valid - UI will disable option) + // Verify treatment duration change would be valid (leave zero if not valid - UI will disable option) if ( ( trtTime <= MAX_TREATMENT_TIME_MINUTES ) && ( trtTime >= MIN_TREATMENT_TIME_MINUTES ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) ) { @@ -611,7 +611,7 @@ { pendingTreatmentTimeChange = 0; } - // if neither option works, reject for UF rate + // If neither option works, reject for UF rate if ( FALSE == result ) { rejectReason = REQUEST_REJECT_REASON_UF_RATE_OUT_OF_RANGE; @@ -659,7 +659,7 @@ REQUEST_REJECT_REASON_CODE_T rejectReason = REQUEST_REJECT_REASON_NONE; HD_OP_MODE_T currMode = getCurrentOperationMode(); - // user confirmed UF settings change(s)? + // User confirmed UF settings change(s)? if ( ( MODE_TREA == currMode ) && ( FALSE == didTimeout( pendingParamChangesTimer, USER_CONFIRM_CHANGE_TIMEOUT_MS ) ) ) { DIALYSIS_STATE_T currDialysisState = getDialysisState(); @@ -668,18 +668,18 @@ result = TRUE; presMaxUFVolumeML = pendingUFVolumeChange; - // which setting does user want to adjust to accommodate the UF volume change? (treatment time or UF rate) + // Which setting does user want to adjust to accommodate the UF volume change? (treatment time or UF rate) if ( UF_ADJ_TREATMENT_TIME == adjustment ) { presTreatmentTimeSecs = pendingTreatmentTimeChange * SEC_PER_MIN; } - else // must be adjusting UF rate then + else // Must be adjusting UF rate then { presUFRate = pendingUFRateChange; } setDialysisParams( presBloodFlowRate, presDialysateFlowRate, presMaxUFVolumeML, presUFRate ); - // if UF paused, resume with new settings + // If UF paused, resume with new settings if ( ( TREATMENT_DIALYSIS_STATE == currentTreatmentState ) && ( DIALYSIS_UF_STATE == currDialysisState ) && ( UF_PAUSED_STATE == currUFState ) ) @@ -700,9 +700,9 @@ } // Respond to UF settings change confirmation sendChangeUFSettingsOptionResponse( result, rejectReason, presMaxUFVolumeML, presTreatmentTimeSecs / SEC_PER_MIN, presUFRate ); - // send new ranges for settings + // Send new ranges for settings broadcastTreatmentSettingsRanges(); - // send time/state data immediately for UI update + // Send time/state data immediately for UI update broadcastTreatmentTimeAndState(); return result; @@ -724,18 +724,18 @@ REQUEST_REJECT_REASON_CODE_T rejectReason = REQUEST_REJECT_REASON_NONE; HD_OP_MODE_T currMode = getCurrentOperationMode(); - // check if we are in treatment mode for settings change + // Check if we are in treatment mode for settings change if ( MODE_TREA == currMode ) { - U32 dialVolume = dialRate * ( (U32)( (F32)presTreatmentTimeSecs / (F32)SEC_PER_MIN ) + 1 ); // in mL + U32 dialVolume = dialRate * ( (U32)( (F32)presTreatmentTimeSecs / (F32)SEC_PER_MIN ) + 1 ); // In mL - // validate new rates + // Validate new rates if ( ( bloodRate >= MIN_BLOOD_FLOW_RATE ) && ( bloodRate <= MAX_BLOOD_FLOW_RATE ) && ( dialRate >= MIN_DIAL_IN_FLOW_RATE ) && ( dialRate <= MAX_DIAL_IN_FLOW_RATE ) && ( dialVolume <= MAX_DIALYSATE_VOLUME_ML ) ) { result = TRUE; - // set to new rates + // Set to new rates presBloodFlowRate = bloodRate; presDialysateFlowRate = dialRate; setDialysisParams( presBloodFlowRate, presDialysateFlowRate, presMaxUFVolumeML, presUFRate ); @@ -761,7 +761,7 @@ rejectReason = REQUEST_REJECT_REASON_NOT_IN_TREATMENT_MODE; } sendChangeBloodDialysateRateChangeResponse( result, (U32)rejectReason, presBloodFlowRate, presDialysateFlowRate ); - // send new ranges for settings + // Send new ranges for settings broadcastTreatmentSettingsRanges(); return result; @@ -789,7 +789,7 @@ proposedNewVenLowLimit.sInt = data->venLowLimit; proposedNewVenHighLimit.sInt = data->venHighLimit; - // check ranges for changed limits + // Check ranges for changed limits if ( FALSE == isTreatmentParamInRange( TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT, proposedNewArtLowLimit ) ) { respRecord.rejReasonCode = REQUEST_REJECT_REASON_PARAM_OUT_OF_RANGE; @@ -811,31 +811,31 @@ result = FALSE; } - // if ranges ok, check separation between low/high limits + // If ranges ok, check separation between low/high limits if ( TRUE == result ) { S32 arterialPresLimitDelta = data->artHighLimit - data->artLowLimit; S32 venousPresLimitDelta = data->venHighLimit - data->venLowLimit; - // check arterial alarm limits dependency + // Check arterial alarm limits dependency if ( arterialPresLimitDelta < MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ) { respRecord.rejReasonCode = REQUEST_REJECT_REASON_ARTERIAL_PRESSURE_LOW_VS_HIGH; result = FALSE; } - // check venous alarm limits dependency + // Check venous alarm limits dependency if ( venousPresLimitDelta < MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ) { respRecord.rejReasonCode = REQUEST_REJECT_REASON_VENOUS_PRESSURE_LOW_VS_HIGH; result = FALSE; } } - // set overall result - are changes accepted? + // Set overall result - are changes accepted? respRecord.accepted = result; - // if changes accepted, set new pressure limits + // If changes accepted, set new pressure limits if ( TRUE == result ) { setTreatmentParameterS32( TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT, data->artLowLimit ); @@ -849,7 +849,7 @@ respRecord.artHighLimit = getTreatmentParameterS32( TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT ); respRecord.venLowLimit = getTreatmentParameterS32( TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT ); respRecord.venHighLimit = getTreatmentParameterS32( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ); - // send response + // Send response sendPressureLimitsChangeResponse( &respRecord ); return result; @@ -867,15 +867,15 @@ { U32 elapsedTreatmentTimeInSecs; - // update treatment time stats and broadcast - end treatment if time + // Update treatment time stats and broadcast - end treatment if time elapsedTreatmentTimeInSecs = treatmentTimeMS / MS_PER_SECOND; if ( elapsedTreatmentTimeInSecs >= presTreatmentTimeSecs ) { stopDialysis(); elapsedTreatmentTimeInSecs = presTreatmentTimeSecs; currentTreatmentState = TREATMENT_DIALYSIS_END_STATE; } - // broadcast treatment time and state data at interval + // Broadcast treatment time and state data at interval if ( ++treatmentTimeBroadcastTimerCtr >= TREATMENT_TIME_DATA_PUB_INTERVAL ) { U32 timeRemaining = presTreatmentTimeSecs - elapsedTreatmentTimeInSecs; @@ -903,31 +903,31 @@ { if ( ++treatmentParamsRangesBroadcastTimerCtr >= TREATMENT_SETTINGS_RANGES_PUB_INTERVAL ) { - // compute minimum treatment duration + // Compute minimum treatment duration U32 presTime = ( presTreatmentTimeSecs / SEC_PER_MIN ); U32 elapseTime = CALC_ELAPSED_TREAT_TIME_IN_MIN(); - U32 minTime = MAX( (elapseTime + 2), MIN_TREATMENT_TIME_MINUTES ); // treatment duration cannot be < 1 hour. add two minutes to cover rounding and ensure it's valid for next minute - // compute maximum treatment duration (from both UF and dialysate volume perspectives) + U32 minTime = MAX( (elapseTime + 2), MIN_TREATMENT_TIME_MINUTES ); // Treatment duration cannot be < 1 hour. add two minutes to cover rounding and ensure it's valid for next minute + // Compute maximum treatment duration (from both UF and dialysate volume perspectives) U32 maxTimeRem = ( MAX_UF_VOLUME_ML - (U32)getUltrafiltrationVolumeCollected() ) / ( presUFRate > 0.0 ? (U32)presUFRate : 1 ); U32 maxTime1 = minTime + maxTimeRem; U32 maxTime2 = MAX_DIALYSATE_VOLUME_ML / presDialysateFlowRate; U32 maxTime = MAX( maxTime1, maxTime2 ); - // compute minimum UF volume + // Compute minimum UF volume F32 minUFVol = getUltrafiltrationVolumeCollected() + presUFRate; - // compute maximum UF volume (considering from adjustment of UF rate and time perspectives) + // Compute maximum UF volume (considering from adjustment of UF rate and time perspectives) F32 maxUFVol1 = minUFVol + ( (F32)( presTime - elapseTime ) * MAX_UF_RATE_ML_MIN ); F32 maxUFVol2 = ( presUFRate > 0.0 ? minUFVol + ( (F32)( MAX_TREATMENT_TIME_MINUTES - elapseTime - 1 ) * presUFRate ) : minUFVol ); F32 maxUFVol = MAX( maxUFVol1, maxUFVol2 ); - // compute minimum dialysate flow rate + // Compute minimum dialysate flow rate U32 minDialRate = MIN_DIAL_IN_FLOW_RATE; - // compute maximum dialysate flow rate from max dialysate volume perspective + // Compute maximum dialysate flow rate from max dialysate volume perspective U32 maxDialRate = MAX_DIALYSATE_VOLUME_ML / presTime; - // now ensure maximums do not exceed the literal maximums + // Now ensure maximums do not exceed the literal maximums maxTime = MIN( maxTime, MAX_TREATMENT_TIME_MINUTES ); maxUFVol = MIN( maxUFVol, (F32)MAX_UF_VOLUME_ML ); maxDialRate = MIN( maxDialRate, MAX_DIAL_IN_FLOW_RATE ); - // send updated treatment parameter ranges to UI + // Send updated treatment parameter ranges to UI sendTreatmentParamsRangesToUI( minTime, maxTime, minUFVol, maxUFVol, minDialRate, maxDialRate ); treatmentParamsRangesBroadcastTimerCtr = 0; } Index: firmware/App/Modes/ModeTreatment.h =================================================================== diff -u -rac05209d7b6c65b22359754eced5ad2672d3092a -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision ac05209d7b6c65b22359754eced5ad2672d3092a) +++ firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -78,15 +78,15 @@ // ********** private function prototypes ********** -void initTreatmentMode( void ); // initialize this module -void transitionToTreatmentMode( void ); // prepares for transition to treatment mode -U32 execTreatmentMode( void ); // execute the treatment mode state machine (call from OperationModes) -void signalAlarmActionToTreatmentMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for Treatment mode +void initTreatmentMode( void ); // Initialize this module +void transitionToTreatmentMode( void ); // Prepares for transition to treatment mode +U32 execTreatmentMode( void ); // Execute the treatment mode state machine (call from OperationModes) +void signalAlarmActionToTreatmentMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Treatment mode -TREATMENT_STATE_T getTreatmentState( void ); // determine the current treatment sub-mode (state) +TREATMENT_STATE_T getTreatmentState( void ); // Determine the current treatment sub-mode (state) -BOOL userRequestEndTreatment( void ); // user has requested to ????? -void broadcastTreatmentTimeAndState( void ); // broadcast the times and states of this treatment +BOOL userRequestEndTreatment( void ); // User has requested to ????? +void broadcastTreatmentTimeAndState( void ); // Broadcast the times and states of this treatment BOOL verifyTreatmentDurationSettingChange( U32 treatmentTime ); BOOL verifyUFSettingsChange( F32 uFVolume ); Index: firmware/App/Modes/ModeTreatmentParams.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/ModeTreatmentParams.c (.../ModeTreatmentParams.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include // for memcpy() +#include // For memcpy() #include "AlarmLamp.h" #include "BloodFlow.h" @@ -39,9 +39,9 @@ typedef struct { CRITICAL_DATA_TYPES_T dataType; ///< Data type for the treatment parameter - CRITICAL_DATAS_T min; ///< minimum of range - CRITICAL_DATAS_T max; ///< maximum of range - CRITICAL_DATAS_T def; ///< default value + CRITICAL_DATAS_T min; ///< Minimum of range + CRITICAL_DATAS_T max; ///< Maximum of range + CRITICAL_DATAS_T def; ///< Default value } TREATMENT_PARAMS_PROPERTIES_T; // ********** private data ********** @@ -71,11 +71,11 @@ { CRITICAL_DATA_TYPE_F32, {.sFlt=0.0}, {.sFlt=8.0}, {.sFlt=0.0} }, // TREATMENT_PARAM_UF_VOLUME }; -// current treatment parameter values +// Current treatment parameter values static CRITICAL_DATA_T treatmentParameters[ NUM_OF_TREATMENT_PARAMS ]; ///< Treatment parameters. static CRITICAL_DATAS_T stagedParams[ NUM_OF_TREATMENT_PARAMS ]; ///< Temporary staged treatment parameters for validation and awaiting user confirmation. -// original treatment parameter values (for those that can be changed during treatment) +// Original treatment parameter values (for those that can be changed during treatment) static ADJ_TREATMENT_PARAMS_T origTreatmentParams; ///< Originally set (before treatment) treatment parameters. static BOOL validTreatParamsReceived = FALSE; ///< Flag indicates user has provided treatment parameters. @@ -126,7 +126,7 @@ treatParamsRejected = FALSE; treatmentCancelled = FALSE; - // set user alarm recovery actions allowed in this mode + // Set user alarm recovery actions allowed in this mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); @@ -146,17 +146,17 @@ for ( param = 0; param < NUM_OF_TREATMENT_PARAMS; param++ ) { - // set type, range, and default value for each treatment parameter + // Set type, range, and default value for each treatment parameter treatmentParameters[ param ].typ = treatParamsProperties[ param ].dataType; treatmentParameters[ param ].minimum = treatParamsProperties[ param ].min; treatmentParameters[ param ].maximum = treatParamsProperties[ param ].max; treatmentParameters[ param ].defValue = treatParamsProperties[ param ].def; resetCriticalData( &treatmentParameters[ param ] ); - // set staged parameter values to zero + // Set staged parameter values to zero stagedParams[ param ].uInt = 0; } - // zero original parameter values + // Zero original parameter values origTreatmentParams.bloodFlowRate_mL_min = 0; origTreatmentParams.dialysateFlowRate_mL_min = 0; origTreatmentParams.treatmentDuration_min = 0; @@ -255,7 +255,7 @@ *************************************************************************/ U32 execTreatParamsMode( void ) { - // execute mode state machine + // Execute mode state machine switch ( currentTreatmentParamsState ) { case HD_TREATMENT_PARAMS_MODE_STATE_START: @@ -293,14 +293,14 @@ if ( TRUE == treatmentCancelled ) { - // go back to standby mode + // Go back to standby mode requestNewOperationMode( MODE_STAN ); treatmentCancelled = FALSE; } else if ( TRUE == validTreatParamsReceived ) { - // go to wait for user confirmation state + // Go to wait for user confirmation state result = HD_TREATMENT_PARAMS_MODE_STATE_WAIT_4_UI_2_CONFIRM; validTreatParamsReceived = FALSE; @@ -321,12 +321,12 @@ { HD_TREATMENT_PARAMS_MODE_STATE_T result = HD_TREATMENT_PARAMS_MODE_STATE_WAIT_4_UI_2_CONFIRM; - // if user confirms treatment parameters, set them + // If user confirms treatment parameters, set them if ( TRUE == treatParamsConfirmed ) { TREATMENT_PARAM_T param; - // set all treatment parameters (except UF volume which is not yet received) + // Set all treatment parameters (except UF volume which is not yet received) for ( param = TREATMENT_PARAM_FIRST_UINT; param < TREATMENT_PARAM_UF_VOLUME; param++ ) { if ( FALSE == setCriticalData( &treatmentParameters[ param ], stagedParams[ param ] ) ) @@ -343,22 +343,22 @@ origTreatmentParams.venousPressureLowLimit_mmHg = getCriticalData( &treatmentParameters[ TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT ] ).sInt; origTreatmentParams.venousPressureHighLimit_mmHg = getCriticalData( &treatmentParameters[ TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ] ).sInt; - // go to pre-treatment mode + // Go to pre-treatment mode requestNewOperationMode( MODE_PRET ); treatParamsConfirmed = FALSE; } else if ( TRUE == treatParamsRejected ) { treatParamsRejected = FALSE; - // user rejected last parameter set, so reset them and wait for new set + // User rejected last parameter set, so reset them and wait for new set resetAllTreatmentParameters(); result = HD_TREATMENT_PARAMS_MODE_STATE_WAIT_4_UI_2_SEND; } else if ( TRUE == treatmentCancelled ) { treatmentCancelled = FALSE; - // go back to standby mode + // Go back to standby mode requestNewOperationMode( MODE_STAN ); } @@ -380,7 +380,7 @@ REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NONE; F32 uFVolumeL = uFVolumeMl / (F32)ML_PER_LITER; - // validate given UF volume TODO - check dependencies too + // Validate given UF volume TODO - check dependencies too accepted = setTreatmentParameterF32( TREATMENT_PARAM_UF_VOLUME, uFVolumeL ); if ( FALSE == accepted ) { @@ -410,16 +410,16 @@ BOOL paramsAreInRange, paramsAreConsistent; U32 rejReasons[ NUM_OF_TREATMENT_PARAMS ]; - // extract treatment parameters from given payload to staging array so we can more easily work with them + // Extract treatment parameters from given payload to staging array so we can more easily work with them extractTreatmentParamsFromPayload( params ); // Range check each treatment parameter paramsAreInRange = checkTreatmentParamsInRange( &rejReasons[0] ); - // validate dependencies + // Validate dependencies paramsAreConsistent = checkTreatmentParamsDependencies( &rejReasons[0] ); - // determine overall validity of received treatment parameters + // Determine overall validity of received treatment parameters if ( ( TRUE == paramsAreInRange ) && ( TRUE == paramsAreConsistent ) ) { paramsAreInvalid = FALSE; @@ -480,30 +480,30 @@ S32 venousPresLimitDelta = stagedParams[ TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ].sInt - \ stagedParams[ TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT ].sInt; - // check max dialysate volume dependency + // Check max dialysate volume dependency if ( dialysateVolume_mL > MAX_DIALYSATE_VOLUME_ML ) { reasons[ TREATMENT_PARAM_DIALYSATE_FLOW ] = REQUEST_REJECT_REASON_DIAL_VOLUME_OUT_OF_RANGE; reasons[ TREATMENT_PARAM_TREATMENT_DURATION ] = REQUEST_REJECT_REASON_DIAL_VOLUME_OUT_OF_RANGE; result = FALSE; } - // check Heparin pre-stop vs. treatment duration + // Check Heparin pre-stop vs. treatment duration if ( stagedParams[ TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME ].uInt > stagedParams[ TREATMENT_PARAM_TREATMENT_DURATION ].uInt ) { reasons[ TREATMENT_PARAM_HEPARIN_PRE_STOP_TIME ] = REQUEST_REJECT_REASON_HEPARIN_PRESTOP_EXCEEDS_DURATION; result = FALSE; } - // check arterial alarm limits dependency + // Check arterial alarm limits dependency if ( arterialPresLimitDelta < MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ) { reasons[ TREATMENT_PARAM_ART_PRESSURE_LOW_LIMIT ] = REQUEST_REJECT_REASON_ARTERIAL_PRESSURE_LOW_VS_HIGH; reasons[ TREATMENT_PARAM_ART_PRESSURE_HIGH_LIMIT ] = REQUEST_REJECT_REASON_ARTERIAL_PRESSURE_LOW_VS_HIGH; result = FALSE; } - // check venous alarm limits dependency + // Check venous alarm limits dependency if ( venousPresLimitDelta < MIN_PRESSURE_ALARM_LIMIT_DELTA_MMHG ) { reasons[ TREATMENT_PARAM_VEN_PRESSURE_LOW_LIMIT ] = REQUEST_REJECT_REASON_VENOUS_PRESSURE_LOW_VS_HIGH; @@ -572,7 +572,7 @@ *************************************************************************/ static void extractTreatmentParamsFromPayload( TREATMENT_PARAMS_DATA_PAYLOAD_T payload ) { - // pull treatment parameters into data array so we can more easily work with them + // Pull treatment parameters into data array so we can more easily work with them memcpy( &stagedParams[0], &payload, sizeof(TREATMENT_PARAMS_DATA_PAYLOAD_T) ); } @@ -611,7 +611,7 @@ { BOOL result = FALSE; - // validate parameter + // Validate parameter if ( param <= TREATMENT_PARAM_LAST_UINT ) { CRITICAL_DATAS_T data = treatmentParameters[ param ].data; @@ -641,7 +641,7 @@ { BOOL result = FALSE; - // validate parameter + // Validate parameter if ( ( param >= TREATMENT_PARAM_FIRST_INT ) && ( param <= TREATMENT_PARAM_LAST_INT ) ) { CRITICAL_DATAS_T data = treatmentParameters[ param ].data; @@ -671,7 +671,7 @@ { BOOL result = FALSE; - // validate parameter + // Validate parameter if ( ( param >= TREATMENT_PARAM_FIRST_F32 ) && ( param < NUM_OF_TREATMENT_PARAMS ) ) { CRITICAL_DATAS_T data = treatmentParameters[ param ].data; @@ -700,7 +700,7 @@ { U32 result = 1; - // validate parameter + // Validate parameter if ( param <= TREATMENT_PARAM_LAST_UINT ) { CRITICAL_DATAS_T data = getCriticalData( &treatmentParameters[ param ] ); @@ -728,7 +728,7 @@ { S32 result = 1; - // validate parameter + // Validate parameter if ( ( param >= TREATMENT_PARAM_FIRST_INT ) && ( param <= TREATMENT_PARAM_LAST_INT ) ) { CRITICAL_DATAS_T data = getCriticalData( &treatmentParameters[ param ] ); @@ -756,7 +756,7 @@ { F32 result = 1.0; - // validate parameter + // Validate parameter if ( ( param >= TREATMENT_PARAM_FIRST_F32 ) && ( param < NUM_OF_TREATMENT_PARAMS ) ) { CRITICAL_DATAS_T data = getCriticalData( &treatmentParameters[ param ] ); @@ -795,7 +795,7 @@ { if ( TRUE == isTestingActivated() ) { - // set parameter per its type + // Set parameter per its type if ( CRITICAL_DATA_TYPE_U32 == treatParamsProperties[ param ].dataType ) { result = setTreatmentParameterU32( param, value.uInt ); Index: firmware/App/Modes/ModeTreatmentParams.h =================================================================== diff -u -rce3e0696642099164fa482c864509c67ce65579b -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision ce3e0696642099164fa482c864509c67ce65579b) +++ firmware/App/Modes/ModeTreatmentParams.h (.../ModeTreatmentParams.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -71,17 +71,17 @@ // ********** Public function prototypes ********** -void initTreatParamsMode( void ); // initialize this module -void transitionToTreatParamsMode( void ); // prepares for transition to treatment parameters mode -U32 execTreatParamsMode( void ); // execute the treatment parameters mode state machine (call from OperationModes) +void initTreatParamsMode( void ); // Initialize this module +void transitionToTreatParamsMode( void ); // Prepares for transition to treatment parameters mode +U32 execTreatParamsMode( void ); // Execute the treatment parameters mode state machine (call from OperationModes) -BOOL validateAndSetTreatmentParameters( TREATMENT_PARAMS_DATA_PAYLOAD_T params ); // user provided treatment params to be set and validated -BOOL signalUserConfirmationOfTreatmentParameters( void ); // user has confirmed treatment parameters -BOOL signalUserRejectionOfTreatmentParameters( void ); // user has rejected treatment parameters -BOOL signalUserCancelTreatment( void ); // user has cancelled treatment -void signalAlarmActionToTreatParamsMode( ALARM_ACTION_T action ); // execute alarm action as appropriate for treatment parameters mode +BOOL validateAndSetTreatmentParameters( TREATMENT_PARAMS_DATA_PAYLOAD_T params ); // User provided treatment params to be set and validated +BOOL signalUserConfirmationOfTreatmentParameters( void ); // User has confirmed treatment parameters +BOOL signalUserRejectionOfTreatmentParameters( void ); // User has rejected treatment parameters +BOOL signalUserCancelTreatment( void ); // User has cancelled treatment +void signalAlarmActionToTreatParamsMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for treatment parameters mode -BOOL validateAndSetUFVolume( F32 uFVolumeMl ); // user provided ultrafiltration volume to be set and validated +BOOL validateAndSetUFVolume( F32 uFVolumeMl ); // User provided ultrafiltration volume to be set and validated BOOL setTreatmentParameterU32( TREATMENT_PARAM_T param, U32 value ); // Set a specified unsigned integer treatment parameter value BOOL setTreatmentParameterS32( TREATMENT_PARAM_T param, S32 value ); // Set a specified signed integer treatment parameter value Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rf6888c7e4e05cb84b11fceb4340458d8af543ce8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision f6888c7e4e05cb84b11fceb4340458d8af543ce8) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -49,7 +49,7 @@ /// This matrix determines legal transitions from one mode to another static const HD_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_MODES - 1 ][ NUM_OF_MODES - 1 ] = { -// from to-> FAULT SERVICE INIT STANBY TRT.PARAMS PRE-TREAT TREATMENT POST_TREA +// From to-> FAULT SERVICE INIT STANBY TRT.PARAMS PRE-TREAT TREATMENT POST_TREA /* FAUL */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, }, /* SERV */{ MODE_FAUL, MODE_SERV, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, }, /* INIT */{ MODE_FAUL, MODE_NLEG, MODE_INIT, MODE_STAN, MODE_NLEG, MODE_NLEG, MODE_NLEG, MODE_NLEG, }, @@ -76,18 +76,18 @@ { U32 i; - // initialize mode requests to none pending + // Initialize mode requests to none pending for ( i = 0; i < ( NUM_OF_MODES - 1 ); i++ ) { modeRequest[ i ] = FALSE; } - // start in init mode + // Start in init mode currentMode = MODE_INIT; currentSubMode = 0; transitionToNewOperationMode( MODE_INIT ); - // call initializers for the individual modes + // Call initializers for the individual modes initFaultMode(); initServiceMode(); initInitAndPOSTMode(); @@ -109,27 +109,27 @@ { HD_OP_MODE_T newMode; - // any new mode requests? - newMode = arbitrateModeRequest(); // will return current mode if no pending requests + // Any new mode requests? + newMode = arbitrateModeRequest(); // Will return current mode if no pending requests newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; - // is requested new mode valid and legal at this time? + // Is requested new mode valid and legal at this time? if ( newMode >= MODE_NLEG ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_ILLEGAL_MODE_TRANSITION_REQUESTED, newMode ) newMode = currentMode; } - // has mode changed? + // Has mode changed? if ( currentMode != newMode ) { - // handle transition to new mode + // Handle transition to new mode lastMode = currentMode; transitionToNewOperationMode( newMode ); currentMode = newMode; } - // mode specific processing to be done continuously + // Mode specific processing to be done continuously switch ( currentMode ) { case MODE_FAUL: @@ -169,9 +169,9 @@ currentSubMode = 0; SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_STATE, currentMode ) break; - } // end switch + } // End switch - // broadcast current operation mode on interval + // Broadcast current operation mode on interval broadcastOperationMode(); } @@ -186,14 +186,14 @@ *************************************************************************/ void requestNewOperationMode( HD_OP_MODE_T newMode ) { - // validate requested mode + // Validate requested mode if ( newMode < MODE_NLEG ) { - // make request + // Make request modeRequest[ newMode ] = TRUE; } else - { // invalid mode requested + { // Invalid mode requested SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_REQUESTED, newMode ) } } @@ -221,7 +221,7 @@ *************************************************************************/ void initiateAlarmAction( ALARM_ACTION_T action ) { - // forward request to the current operation mode + // Forward request to the current operation mode switch ( currentMode ) { case MODE_FAUL: @@ -267,10 +267,10 @@ HD_OP_MODE_T reqMode = currentMode; U32 i; - // block additional requests until after mode arbitration + // Block additional requests until after mode arbitration _disable_IRQ(); - // select highest priority mode request -or- current mode if no requests pending + // Select highest priority mode request -or- current mode if no requests pending for ( i = 0; i < MODE_NLEG; i++ ) { if ( modeRequest[ i ] != FALSE ) @@ -280,13 +280,13 @@ } } - // clear all requests now that an arbitration winner is selected + // Clear all requests now that an arbitration winner is selected for ( i = 0; i < MODE_NLEG; i++ ) { modeRequest[ i ] = FALSE; } - // un-block requests + // Un-block requests _enable_IRQ(); return reqMode; @@ -302,7 +302,7 @@ *************************************************************************/ static void transitionToNewOperationMode( HD_OP_MODE_T newMode ) { - // setup for new operating mode + // Setup for new operating mode switch ( newMode ) { case MODE_FAUL: Index: firmware/App/Modes/OperationModes.h =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -33,11 +33,11 @@ // ********** public function prototypes ********** -void initOperationModes( void ); // initialize this module -void execOperationModes( void ); // execute the operation modes state machine (scheduled periodic call) +void initOperationModes( void ); // Initialize this module +void execOperationModes( void ); // Execute the operation modes state machine (scheduled periodic call) void requestNewOperationMode( HD_OP_MODE_T newMode ); // Request a transition to a new operation mode -HD_OP_MODE_T getCurrentOperationMode( void ); // get the current operation mode -void initiateAlarmAction( ALARM_ACTION_T action ); // initiate an alarm or alarm recovery action according to current op mode +HD_OP_MODE_T getCurrentOperationMode( void ); // Get the current operation mode +void initiateAlarmAction( ALARM_ACTION_T action ); // Initiate an alarm or alarm recovery action according to current op mode /**@}*/ Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -53,16 +53,16 @@ *************************************************************************/ void transitionToTreatmentStop( void ) { - // set valves to safe state + // Set valves to safe state setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); // Reset saline bolus state in case alarm interrupted one resetSalineBolus(); - // stop air trap control + // Stop air trap control endAirTrapControl(); - // should always have stopped alarm active in treatment stop sub-mode so that user can take action + // Should always have stopped alarm active in treatment stop sub-mode so that user can take action activateAlarmNoData( ALARM_ID_TREATMENT_STOPPED_BY_USER ); } Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r395b6a6a9df782ebf1d331c43dc2d26a3fa59a03 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 395b6a6a9df782ebf1d331c43dc2d26a3fa59a03) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -49,29 +49,29 @@ /// A blank alarm data record for alarms that do not include alarm data when triggered. const ALARM_DATA_T BLANK_ALARM_DATA = { ALARM_DATA_TYPE_NONE, 0 }; -// pin assignment for backup alarm audio enable -#define BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK 0x00000001 ///< pin SPI3-CS0 - re-purposed as output GPIO for back audio enable. -// backup alarm audio enable/disable macros +// Pin assignment for backup alarm audio enable +#define BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK 0x00000001 ///< Pin SPI3-CS0 - re-purposed as output GPIO for back audio enable. +// Backup alarm audio enable/disable macros #define SET_BACKUP_AUDIO_ENABLE() {mibspiREG3->PC3 |= BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK;} ///< Macro to enable backup alarm audio. #define CLR_BACKUP_AUDIO_ENABLE() {mibspiREG3->PC3 &= ~BACKUP_AUDIO_ENABLE_SPI3_PORT_MASK;} ///< Macro to disable backup alarm audio. -/// alarm priority ranking record. +/// Alarm priority ranking record. typedef struct { ALARM_ID_T alarmID; ///< ID of highest priority alarm in this priority category - U32 subRank; ///< sub-rank of this alarm + U32 subRank; ///< Sub-rank of this alarm U32 timeSinceTriggeredMS; ///< Time (in ms) since this alarm was triggered } ALARM_PRIORITY_RANKS_T; // ********** private data ********** static U32 alarmStatusPublicationTimerCounter = 0; ///< Used to schedule alarm status publication to CAN bus. -/// table - current state of each alarm +/// Table - current state of each alarm static BOOL alarmIsActive[ NUM_OF_ALARM_IDS ]; -/// table - current state of each alarm condition (detected or cleared) +/// Table - current state of each alarm condition (detected or cleared) static BOOL alarmIsDetected[ NUM_OF_ALARM_IDS ]; -/// table - when alarm became active for each alarm (if active) or zero (if inactive) +/// Table - when alarm became active for each alarm (if active) or zero (if inactive) static OVERRIDE_U32_T alarmStartedAt[ NUM_OF_ALARM_IDS ]; /// Record for the current composite alarm status. @@ -80,7 +80,7 @@ /// FIFO - first activated or highest sub-rank alarm in each alarm priority category. static ALARM_PRIORITY_RANKS_T alarmPriorityFIFO[ NUM_OF_ALARM_PRIORITIES ]; -/// alarm user recovery actions enabled flags. +/// Alarm user recovery actions enabled flags. static BOOL alarmUserRecoveryActionEnabled[ NUMBER_OF_ALARM_USER_ACTIONS ]; static U32 alarmAudioVolumeLevel = 3; //MIN_ALARM_VOLUME_ATTENUATION; ///< Set alarm audio volume attenuation level (0..4 - lower level = higher gain). @@ -113,10 +113,10 @@ ALARM_PRIORITY_T p; ALARM_ID_T a; - // disable backup audio + // Disable backup audio CLR_BACKUP_AUDIO_ENABLE(); - // initialize alarm states and start time stamps + // Initialize alarm states and start time stamps for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { alarmIsActive[ a ] = FALSE; @@ -126,14 +126,14 @@ alarmStartedAt[ a ].ovInitData = 0; alarmStartedAt[ a ].override = OVERRIDE_RESET; } - // initialize alarm FIFOs + // Initialize alarm FIFOs for ( p = ALARM_PRIORITY_NONE; p < NUM_OF_ALARM_PRIORITIES; p++ ) { alarmPriorityFIFO[ p ].alarmID = ALARM_ID_NO_ALARM; alarmPriorityFIFO[ p ].subRank = LOWEST_ALARM_SUB_RANK; alarmPriorityFIFO[ p ].timeSinceTriggeredMS = 0; } - // initialize composite alarm state + // Initialize composite alarm state alarmStatus.alarmsState = ALARM_PRIORITY_NONE; alarmStatus.alarmsSilenced = FALSE; alarmStatus.alarmsSilenceStart = 0; @@ -167,10 +167,10 @@ updateAlarmsState(); updateAlarmsFlags(); updateAlarmsSilenceStatus(); - // publish alarm status at interval + // Publish alarm status at interval if ( ++alarmStatusPublicationTimerCounter >= ALARM_STATUS_PUBLISH_INTERVAL ) { - // lamp and audio timing sync'd with broadcast so UI can stay in sync with lamp rhythm + // Lamp and audio timing sync'd with broadcast so UI can stay in sync with lamp rhythm setAlarmLamp(); setAlarmAudio(); broadcastAlarmStatus( alarmStatus ); @@ -188,29 +188,29 @@ *************************************************************************/ static void activateAlarm( ALARM_ID_T alarm ) { - // verify given alarm + // Verify given alarm if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { - // no need to do anything if alarm is already active + // No need to do anything if alarm is already active if ( FALSE == alarmIsActive[ alarm ] ) { - // if alarms silenced, end silence due to new alarm + // If alarms silenced, end silence due to new alarm alarmStatus.alarmsSilenced = FALSE; - // if alarm is a fault, request transition to fault mode + // If alarm is a fault, request transition to fault mode if ( TRUE == ALARM_TABLE[ alarm ].alarmIsFault ) { requestNewOperationMode( MODE_FAUL ); } - // activate alarm + // Activate alarm alarmIsActive[ alarm ] = TRUE; alarmStartedAt[ alarm ].data = getMSTimerCount(); alarmIsDetected[ alarm ] = TRUE; - // if alarm has clear condition immediately property, clear condition now + // If alarm has clear condition immediately property, clear condition now if ( TRUE == ALARM_TABLE[ alarm ].alarmConditionClearImmed ) { clearAlarmCondition( alarm ); } - // if alarm has stop property, signal stop now + // If alarm has stop property, signal stop now if ( TRUE == ALARM_TABLE[ alarm ].alarmStops ) { initiateAlarmAction( ALARM_ACTION_STOP ); @@ -235,7 +235,7 @@ *************************************************************************/ void activateAlarmNoData( ALARM_ID_T alarm ) { - // broadcast alarm and data if alarm not already active + // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { broadcastAlarmTriggered( (U16)alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA ); @@ -268,7 +268,7 @@ *************************************************************************/ void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) { - // broadcast alarm and data if alarm not already active + // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { broadcastAlarmTriggered( (U16)alarm, alarmData, BLANK_ALARM_DATA ); @@ -302,7 +302,7 @@ *************************************************************************/ void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2 ) { - // broadcast alarm and data if alarm not already active + // Broadcast alarm and data if alarm not already active if ( FALSE == alarmIsActive[ alarm ] ) { broadcastAlarmTriggered( (U16)alarm, alarmData1, alarmData2 ); @@ -333,10 +333,10 @@ *************************************************************************/ void clearAlarmCondition( ALARM_ID_T alarm ) { - // verify given alarm + // Verify given alarm if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { - // clear alarm condition and broadcast alarm condition clear if not already cleared + // Clear alarm condition and broadcast alarm condition clear if not already cleared if ( TRUE == alarmIsDetected[ alarm ] ) { alarmIsDetected[ alarm ] = FALSE; @@ -357,21 +357,21 @@ *************************************************************************/ void clearAlarm( ALARM_ID_T alarm ) { - // verify given alarm + // Verify given alarm if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) { - // verify alarm can be cleared + // Verify alarm can be cleared if ( FALSE == ALARM_TABLE[ alarm ].alarmNoClear ) { - // clear alarm and broadcast alarm clear if not already cleared + // Clear alarm and broadcast alarm clear if not already cleared if ( TRUE == alarmIsActive[ alarm ] ) { broadcastAlarmCleared( alarm ); alarmIsActive[ alarm ] = FALSE; alarmIsDetected[ alarm ] = FALSE; alarmStartedAt[ alarm ].data = 0; - // clear FIFO if this alarm was in it + // Clear FIFO if this alarm was in it if ( alarmPriorityFIFO[ ALARM_TABLE[ alarm ].alarmPriority ].alarmID == alarm ) { resetAlarmPriorityFIFO( ALARM_TABLE[ alarm ].alarmPriority ); @@ -461,19 +461,19 @@ *************************************************************************/ void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ) { - // validate given action + // Validate given action if ( action < NUMBER_OF_ALARM_USER_ACTIONS ) { ALARM_ID_T a = alarmStatus.alarmTop; if ( ALARM_USER_ACTION_ACK == action ) { - // if user acknowledged top alarm, just clear that alarm + // If user acknowledged top alarm, just clear that alarm if ( TRUE == ALARM_TABLE[ a ].alarmUserAckRequired ) { clearAlarm( a ); } - // otherwise we must be in mode/state where ack was only option - so clear all like other options + // Otherwise we must be in mode/state where ack was only option - so clear all like other options else { clearAllRecoverableAlarms(); @@ -485,7 +485,7 @@ } } - // initiate user selected action + // Initiate user selected action switch ( action ) { case ALARM_USER_ACTION_RESUME: @@ -566,7 +566,7 @@ void setAlarmAudioVolume( U32 volumeLevel ) { if ( ( volumeLevel > 0 ) && ( volumeLevel <= MAX_ALARM_VOLUME_LEVEL ) ) - { // convert volume level to attenuation level + { // Convert volume level to attenuation level alarmAudioVolumeLevel = MAX_ALARM_VOLUME_LEVEL - volumeLevel; } } @@ -616,7 +616,7 @@ ALARM_ID_T a; BOOL faultsActive = FALSE; - // update FIFOs and sub-ranks per active alarms table - for alarm ranking purposes to determine "top" alarm + // Update FIFOs and sub-ranks per active alarms table - for alarm ranking purposes to determine "top" alarm for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[a] ) @@ -625,10 +625,10 @@ U32 subRank = ALARM_TABLE[ a ].alarmSubRank; U32 msSinceTriggered = calcTimeSince( getAlarmStartTime( a ) ); - // see if this alarm is higher rank than highest active alarm in this priority category so far + // See if this alarm is higher rank than highest active alarm in this priority category so far if ( subRank <= alarmPriorityFIFO[ almPriority ].subRank ) { - // if sub-rank is a tie, see which alarm was triggered first + // If sub-rank is a tie, see which alarm was triggered first if ( subRank == alarmPriorityFIFO[ almPriority ].subRank ) { if ( msSinceTriggered > alarmPriorityFIFO[ almPriority ].timeSinceTriggeredMS ) @@ -638,25 +638,25 @@ alarmPriorityFIFO[ almPriority ].timeSinceTriggeredMS = msSinceTriggered; } } - // otherwise, this alarm simply outranks current candidate and wins outright + // Otherwise, this alarm simply outranks current candidate and wins outright else { alarmPriorityFIFO[ almPriority ].alarmID = a; alarmPriorityFIFO[ almPriority ].subRank = subRank; alarmPriorityFIFO[ almPriority ].timeSinceTriggeredMS = msSinceTriggered; } } - // track highest priority alarm found so far of all priority categories + // Track highest priority alarm found so far of all priority categories highestPriority = MAX( almPriority, highestPriority ); - // track whether any active faults have been found so far + // Track whether any active faults have been found so far if ( TRUE == ALARM_TABLE[ a ].alarmIsFault ) { faultsActive = TRUE; } } } - // update alarm to display per highest priority FIFO + // Update alarm to display per highest priority FIFO alarmStatus.alarmsState = highestPriority; alarmStatus.alarmTop = alarmPriorityFIFO[ highestPriority ].alarmID; alarmStatus.systemFault = faultsActive; @@ -672,7 +672,7 @@ *************************************************************************/ static void setAlarmLamp( void ) { - // set alarm lamp pattern to appropriate pattern for current alarm state + // Set alarm lamp pattern to appropriate pattern for current alarm state if ( getCurrentAlarmLampPattern() != LAMP_PATTERN_MANUAL ) { switch ( alarmStatus.alarmsState ) @@ -707,10 +707,10 @@ } } - // execute alarm lamp controller + // Execute alarm lamp controller execAlarmLamp(); - // set lamp on flag to match current state of alarm lamp + // Set lamp on flag to match current state of alarm lamp if ( getCurrentAlarmLampPattern() != LAMP_PATTERN_MANUAL ) { alarmStatus.lampOn = getAlarmLampOn(); @@ -735,7 +735,7 @@ { setAlarmAudioState( ALARM_PRIORITY_NONE, alarmAudioVolumeLevel ); } - else // alarms not silenced + else // Alarms not silenced { if ( alarmStatus.alarmsState < NUM_OF_ALARM_PRIORITIES ) { @@ -760,7 +760,7 @@ *************************************************************************/ static void updateAlarmsSilenceStatus( void ) { - // if alarms not silenced, reset alarms silence related properties + // If alarms not silenced, reset alarms silence related properties if ( TRUE != alarmStatus.alarmsSilenced ) { alarmStatus.alarmsSilenceExpiresIn = 0; @@ -778,7 +778,7 @@ { alarmStatus.alarmsSilenceExpiresIn = ALARM_SILENCE_EXPIRES_IN_SECS - timeSinceAlarmSilenceStart; } - // if alarms silence expires, end it + // If alarms silence expires, end it if ( 0 == alarmStatus.alarmsSilenceExpiresIn ) { alarmStatus.alarmsSilenced = FALSE; @@ -799,42 +799,42 @@ ALARM_ID_T nextAlarmToEscalate = ALARM_ID_NO_ALARM; ALARM_ID_T a; - // update escalations + // Update escalations for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[ a ] ) { - // does active alarm escalate? + // Does active alarm escalate? if ( ALARM_ID_NO_ALARM != ALARM_TABLE[ a ].alarmEscalatesTo ) { S32 msRemaining = (S32)ALARM_TABLE[ a ].alarmEscalatesAfter - (S32)calcTimeSince( getAlarmStartTime( a ) ); S32 secsRemaining = ( msRemaining / MS_PER_SECOND ) + 1; - // time to escalate? + // Time to escalate? if ( msRemaining <= 0 ) { activateAlarmNoData( ALARM_TABLE[ a ].alarmEscalatesTo ); clearAlarm( a ); } else - { // no candidates for alarm escalation yet? + { // No candidates for alarm escalation yet? if ( ALARM_ID_NO_ALARM == nextAlarmToEscalate ) { secsToEscalate = secsRemaining; nextAlarmToEscalate = a; } - // sooner candidate for alarm escalation? + // Sooner candidate for alarm escalation? else if ( secsRemaining < secsToEscalate ) { secsToEscalate = secsRemaining; nextAlarmToEscalate = a; } } - } // if alarm escalates - } // if alarm active - } // alarm table loop + } // If alarm escalates + } // If alarm active + } // Alarm table loop - // update alarm escalation properties + // Update alarm escalation properties if ( TRUE == alarmStatus.systemFault || ALARM_ID_NO_ALARM == nextAlarmToEscalate ) { alarmStatus.alarmsToEscalate = FALSE; @@ -867,7 +867,7 @@ BOOL usrAckReq = FALSE; ALARM_ID_T a; - // determine alarm flags + // Determine alarm flags for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[ a ] ) @@ -876,7 +876,7 @@ stop = ( TRUE == ALARM_TABLE[ a ].alarmStops ? TRUE : stop ); noClear = ( TRUE == ALARM_TABLE[ a ].alarmNoClear ? TRUE : noClear ); noNewTreatment = ( TRUE == ALARM_TABLE[ a ].alarmNoNewTreatment ? TRUE : noNewTreatment ); - // set user alarm recovery actions allowed flags + // Set user alarm recovery actions allowed flags if ( TRUE == alarmUserRecoveryActionEnabled[ ALARM_USER_ACTION_RESUME ] ) { noResume = ( TRUE == ALARM_TABLE[ a ].alarmNoResume ? TRUE : noResume ); @@ -901,17 +901,17 @@ { noEndTreatment = TRUE; } - } // if alarm active - } // alarm table loop + } // If alarm active + } // Alarm table loop - // if top alarm condition not cleared, block resume and rinseback flags + // If top alarm condition not cleared, block resume and rinseback flags if ( TRUE == alarmStatus.topAlarmConditionnDetected ) { noResume = TRUE; noRinseback = TRUE; } - // if top alarm requires user ack or no other user options enabled for recoverable alarm and condition cleared, set user ack flag and block other flags + // If top alarm requires user ack or no other user options enabled for recoverable alarm and condition cleared, set user ack flag and block other flags if ( ( TRUE == ALARM_TABLE[ alarmStatus.alarmTop ].alarmUserAckRequired ) || ( ( FALSE == alarmStatus.noClear ) && ( noResume ) && ( noRinseback ) && ( noEndTreatment ) && ( FALSE == alarmStatus.topAlarmConditionnDetected ) ) ) @@ -922,7 +922,7 @@ noEndTreatment = TRUE; } - // set updated alarm flags + // Set updated alarm flags alarmStatus.systemFault = systemFault; alarmStatus.stop = stop; alarmStatus.noClear = noClear; @@ -947,7 +947,7 @@ for ( a = ALARM_ID_HD_SOFTWARE_FAULT; a < NUM_OF_ALARM_IDS; a++ ) { - // is alarm recoverable? + // Is alarm recoverable? if ( FALSE == ALARM_TABLE[ a ].alarmNoClear ) { clearAlarm( a ); @@ -966,7 +966,7 @@ *************************************************************************/ static void resetAlarmPriorityFIFO( ALARM_PRIORITY_T priority ) { - // verify priority + // Verify priority if ( priority < NUM_OF_ALARM_PRIORITIES ) { alarmPriorityFIFO[ priority ].alarmID = ALARM_ID_NO_ALARM; @@ -1002,7 +1002,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { if ( TRUE == state ) @@ -1035,7 +1035,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { result = TRUE; @@ -1062,7 +1062,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { U32 tim = getMSTimerCount(); @@ -1094,7 +1094,7 @@ if ( alarmID < NUM_OF_ALARM_IDS ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { result = TRUE; @@ -1120,23 +1120,23 @@ { BOOL result = FALSE; - // verify key + // Verify key if ( SUPERVISOR_ALARM_KEY == key ) { - // verify tester has logged in with HD + // Verify tester has logged in with HD if ( TRUE == isTestingActivated() ) { ALARM_ID_T a; - // clear all active alarms + // Clear all active alarms for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) { if ( TRUE == alarmIsActive[ a ] ) { broadcastAlarmCleared( a ); alarmIsActive[ a ] = FALSE; alarmStartedAt[ a ].data = 0; - // clear FIFO if this alarm was in it + // Clear FIFO if this alarm was in it if ( alarmPriorityFIFO[ ALARM_TABLE[ a ].alarmPriority ].alarmID == a ) { resetAlarmPriorityFIFO( ALARM_TABLE[ a ].alarmPriority ); Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r395b6a6a9df782ebf1d331c43dc2d26a3fa59a03 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 395b6a6a9df782ebf1d331c43dc2d26a3fa59a03) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -67,23 +67,23 @@ /// Record structure for detailing the properties of the current composite alarm status. typedef struct { - ALARM_PRIORITY_T alarmsState; ///< current alarm priority level - BOOL alarmsSilenced; ///< alarms are currently silenced? - U32 alarmsSilenceStart; ///< time stamp for when alarms were silenced (ms) - U32 alarmsSilenceExpiresIn; ///< time until alarm silence expires (seconds) - BOOL alarmsToEscalate; ///< are any active alarms due to escalate (should UI show count down timer?) - U32 alarmsEscalatesIn; ///< time until alarm will escalate (seconds) + ALARM_PRIORITY_T alarmsState; ///< Current alarm priority level + BOOL alarmsSilenced; ///< Alarms are currently silenced? + U32 alarmsSilenceStart; ///< Time stamp for when alarms were silenced (ms) + U32 alarmsSilenceExpiresIn; ///< Time until alarm silence expires (seconds) + BOOL alarmsToEscalate; ///< Are any active alarms due to escalate (should UI show count down timer?) + U32 alarmsEscalatesIn; ///< Time until alarm will escalate (seconds) ALARM_ID_T alarmTop; ///< ID of current top alarm that will drive lamp/audio and UI should be displaying right now - BOOL topAlarmConditionnDetected; ///< condition for top alarm is still being detected - BOOL systemFault; ///< a system fault is active? - BOOL stop; ///< we should be in controlled stop right now - BOOL noClear; ///< no recovery will be possible - BOOL noResume; ///< treatment may not be resumed at this time - BOOL noRinseback; ///< rinseback may not be initiated at this time - BOOL noEndTreatment; ///< ending the treatment is not an option at this time - BOOL noNewTreatment; ///< no new treatments may be started even if current treatment is ended - BOOL usrACKRequired; ///< the user must acknowledge top alarm - BOOL lampOn; ///< the alarm lamp is on + BOOL topAlarmConditionnDetected; ///< Condition for top alarm is still being detected + BOOL systemFault; ///< A system fault is active? + BOOL stop; ///< We should be in controlled stop right now + BOOL noClear; ///< No recovery will be possible + BOOL noResume; ///< Treatment may not be resumed at this time + BOOL noRinseback; ///< Rinseback may not be initiated at this time + BOOL noEndTreatment; ///< Ending the treatment is not an option at this time + BOOL noNewTreatment; ///< No new treatments may be started even if current treatment is ended + BOOL usrACKRequired; ///< The user must acknowledge top alarm + BOOL lampOn; ///< The alarm lamp is on } COMP_ALARM_STATUS_T; /// Record structure for unsigned integer alarm data. @@ -135,7 +135,7 @@ U32 alarmTop; ///< ID of top active alarm U32 escalatesIn; ///< Top active alarm escalates in this many seconds U32 silenceExpiresIn; ///< Silencing of alarms expires in this many seconds - U16 alarmsFlags; ///< bit flags: 1 = true, 0 = false for each bit flag + U16 alarmsFlags; ///< Bit flags: 1 = true, 0 = false for each bit flag } ALARM_COMP_STATUS_PAYLOAD_T; #pragma pack(pop) Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -16,7 +16,7 @@ ***************************************************************************/ #include -#include // for memcpy() +#include // For memcpy() #include "CommBuffers.h" #include "SystemComm.h" @@ -30,16 +30,16 @@ // ********** private definitions ********** -#define COMM_BUFFER_LENGTH 512 ///< max bytes in each comm buffer (each side of double buffer is this size) -#define DOUBLE_BUFFERS 2 ///< need 2 buffers for double buffering -#define BUFFER_OVERFLOW_PERSISTENCE_MS 5000 ///< how many ms buffer overflows must persist before fault +#define COMM_BUFFER_LENGTH 512 ///< Max bytes in each comm buffer (each side of double buffer is this size) +#define DOUBLE_BUFFERS 2 ///< Need 2 buffers for double buffering +#define BUFFER_OVERFLOW_PERSISTENCE_MS 5000 ///< How many ms buffer overflows must persist before fault // ********** private data ********** -static volatile U32 commBufferByteCount[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ]; ///< for each buffer, how many bytes does it contain? (also index to next available) -static volatile U32 activeDoubleBuffer[ NUM_OF_COMM_BUFFERS ]; ///< for each buffer, which double buffer is being fed right now? -static U08 commBuffers[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ][ COMM_BUFFER_LENGTH ]; ///< each is double buffered to avoid thread contention -static U32 firstBufferOverflowTimeStamp = 0; ///< time stamp of a prior overflow event - allows for an overflow persistence check +static volatile U32 commBufferByteCount[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ]; ///< For each buffer, how many bytes does it contain? (also index to next available) +static volatile U32 activeDoubleBuffer[ NUM_OF_COMM_BUFFERS ]; ///< For each buffer, which double buffer is being fed right now? +static U08 commBuffers[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ][ COMM_BUFFER_LENGTH ]; ///< Each is double buffered to avoid thread contention +static U32 firstBufferOverflowTimeStamp = 0; ///< Time stamp of a prior overflow event - allows for an overflow persistence check // ********** private function prototypes ********** @@ -80,7 +80,7 @@ { S32 d; - // thread protection for queue operations + // Thread protection for queue operations _disable_IRQ(); activeDoubleBuffer[ buffer ] = 0; @@ -113,44 +113,44 @@ { BOOL result = FALSE; - // verify given buffer + // Verify given buffer if ( buffer < NUM_OF_COMM_BUFFERS ) { BOOL bufferFull = FALSE; U32 activeBuffer; - U32 currentActiveBufCount; // where to start adding new data to buffer (after existing data) + U32 currentActiveBufCount; // Where to start adding new data to buffer (after existing data) if ( ( FALSE == isHDOnlyCANNode() ) || ( FALSE == isCANBoxForXmit( (CAN_MESSAGE_BOX_T)buffer ) ) ) { - // thread protection for queue operations + // Thread protection for queue operations _disable_IRQ(); activeBuffer = activeDoubleBuffer[ buffer ]; currentActiveBufCount = commBufferByteCount[ buffer ][ activeBuffer ]; - // check to make sure buffer is not too full to service this add + // Check to make sure buffer is not too full to service this add if ( len <= ( COMM_BUFFER_LENGTH - currentActiveBufCount ) ) { - U08 *buffPtr; // buffer destination for added data + U08 *buffPtr; // Buffer destination for added data - // set destination pointer to end of active buffer data + // Set destination pointer to end of active buffer data buffPtr = &commBuffers[ buffer ][ activeBuffer ][ currentActiveBufCount ]; - // copy source data to destination buffer + // Copy source data to destination buffer memcpy( buffPtr, data, len ); - // adjust buffer count per this data add (also reserves space to add data before releasing thread protection) + // Adjust buffer count per this data add (also reserves space to add data before releasing thread protection) commBufferByteCount[ buffer ][ activeBuffer ] += len; - // data successfully added to buffer + // Data successfully added to buffer result = TRUE; } - else // buffer too full to add this much data + else // Buffer too full to add this much data { bufferFull = TRUE; } // Release thread protection _enable_IRQ(); } - // if buffer was full, check persistence - trigger s/w fault if persists + // If buffer was full, check persistence - trigger s/w fault if persists if ( TRUE == bufferFull ) { #ifdef DEBUG_ENABLED @@ -160,29 +160,29 @@ sendDebugDataToUI( (U08*)debugStr ); #endif clearBuffer( buffer ); - // not first overflow? + // Not first overflow? if ( firstBufferOverflowTimeStamp != 0 ) { - // if buffer overflows persists, fault + // If buffer overflows persists, fault if ( calcTimeSince( firstBufferOverflowTimeStamp ) > BUFFER_OVERFLOW_PERSISTENCE_MS ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_ADD_TOO_MUCH_DATA, (U32)buffer ) } } - else // first overflow - set time stamp for persistence check + else // First overflow - set time stamp for persistence check { firstBufferOverflowTimeStamp = getMSTimerCount(); } } else - { // if good for persistence time period, reset persistence check + { // If good for persistence time period, reset persistence check if ( ( firstBufferOverflowTimeStamp != 0 ) && ( calcTimeSince( firstBufferOverflowTimeStamp ) > BUFFER_OVERFLOW_PERSISTENCE_MS ) ) { firstBufferOverflowTimeStamp = 0; } } } - else // invalid buffer given + else // Invalid buffer given { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_ADD_INVALID_BUFFER, buffer ) } @@ -211,38 +211,38 @@ { U32 result = 0; - // verify given buffer + // Verify given buffer if ( buffer < NUM_OF_COMM_BUFFERS ) { - // thread protection for queue operations + // Thread protection for queue operations _disable_IRQ(); - // verify requested # of bytes to get are in the buffer + // Verify requested # of bytes to get are in the buffer if ( ( len <= ( COMM_BUFFER_LENGTH * DOUBLE_BUFFERS ) ) && ( len <= numberOfBytesInCommBuffer( buffer ) ) ) { U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); U32 bytesInInactiveBuffer = commBufferByteCount[ buffer ][ inactiveBuffer ]; U32 sizeOfFirstConsumption = MIN( len, bytesInInactiveBuffer ); - // see what we can get from inactive buffer - getDataFromInactiveBuffer( buffer, data, sizeOfFirstConsumption ); // will switch double buffers if we empty inactive buffer - // will return # of bytes consumed + // See what we can get from inactive buffer + getDataFromInactiveBuffer( buffer, data, sizeOfFirstConsumption ); // Will switch double buffers if we empty inactive buffer + // Will return # of bytes consumed result = sizeOfFirstConsumption; - // do we need more from active buffer? + // Do we need more from active buffer? if ( len > bytesInInactiveBuffer ) { U32 remNumOfBytes = len - sizeOfFirstConsumption; U08 *remPtr = data + sizeOfFirstConsumption; getDataFromInactiveBuffer( buffer, remPtr, remNumOfBytes ); - // will return # of bytes consumed + // Will return # of bytes consumed result += remNumOfBytes; } } // Release thread protection _enable_IRQ(); } - else // invalid buffer given + else // Invalid buffer given { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_GET_INVALID_BUFFER, buffer ) } @@ -269,12 +269,12 @@ { U32 numOfBytesPeeked = 0; - // verify given buffer + // Verify given buffer if ( buffer < NUM_OF_COMM_BUFFERS ) { - // thread protection for queue operations + // Thread protection for queue operations _disable_IRQ(); - // verify requested # of bytes to peek are in the buffer + // Verify requested # of bytes to peek are in the buffer if ( ( len <= ( COMM_BUFFER_LENGTH * DOUBLE_BUFFERS ) ) && ( len <= numberOfBytesInCommBuffer( buffer ) ) ) { U32 activeBuffer = activeDoubleBuffer[ buffer ]; @@ -286,7 +286,7 @@ memcpy( data, &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], len ); numOfBytesPeeked = len; } - else // will need to get the rest from active buffer + else // Will need to get the rest from active buffer { U32 remNumOfBytes = len - bytesInInactiveBuffer; U08 *remPtr = data + bytesInInactiveBuffer; @@ -299,7 +299,7 @@ // Release thread protection _enable_IRQ(); } - else // invalid buffer given + else // Invalid buffer given { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_PEEK_INVALID_BUFFER, buffer ) } @@ -321,15 +321,15 @@ { U32 result = 0; - // verify given buffer + // Verify given buffer if ( buffer < NUM_OF_COMM_BUFFERS ) { U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = GET_TOGGLE( activeBuffer, 0, 1 ); result = commBufferByteCount[ buffer ][ inactiveBuffer ] + commBufferByteCount[ buffer ][ activeBuffer ]; } - else // invalid buffer + else // Invalid buffer { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_COUNT_INVALID_BUFFER, buffer ) } @@ -353,9 +353,9 @@ U32 activeBuffer = activeDoubleBuffer[ buffer ]; U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); - // ensure inactive buffer is reset before making active + // Ensure inactive buffer is reset before making active commBufferByteCount[ buffer ][ inactiveBuffer ] = 0; - // switch buffers + // Switch buffers activeDoubleBuffer[ buffer ] = inactiveBuffer; // Return the new active buffer (was just inactive) @@ -380,22 +380,22 @@ U32 inactiveBuffer = ( activeBuffer == 0 ? 1 : 0 ); U32 bytesInInactiveBuffer = commBufferByteCount[ buffer ][ inactiveBuffer ]; - // get the requested data from inactive buffer + // Get the requested data from inactive buffer memcpy( data, &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], len ); if ( len < bytesInInactiveBuffer ) { U08 *endPtr = (&commBuffers[ buffer ][ inactiveBuffer ][ 0 ] + len); - // move un-consumed data in inactive buffer to start of inactive buffer + // Move un-consumed data in inactive buffer to start of inactive buffer memcpy( &commBuffers[ buffer ][ inactiveBuffer ][ 0 ], endPtr, ( bytesInInactiveBuffer - len ) ); // Reduce byte count for inactive buffer by # of bytes consumed commBufferByteCount[ buffer ][ inactiveBuffer ] -= len; } else { - // inactive buffer has been emptied so switch double buffers - switchDoubleBuffer( buffer ); // switch will zero count off inactive buffer + // Inactive buffer has been emptied so switch double buffers + switchDoubleBuffer( buffer ); // Switch will zero count off inactive buffer } } Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include // for memset(), memcpy() +#include // For memset(), memcpy() #include "sci.h" #include "sys_dma.h" @@ -295,104 +295,104 @@ *************************************************************************/ void initFPGA( void ) { - // initialize fpga data structures + // Initialize fpga data structures 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 + // Initialize fpga comm buffers memset( &fpgaWriteCmdBuffer, 0, FPGA_WRITE_CMD_BUFFER_LEN ); memset( &fpgaReadCmdBuffer, 0, FPGA_READ_CMD_BUFFER_LEN ); memset( &fpgaWriteResponseBuffer, 0, FPGA_WRITE_RSP_BUFFER_LEN ); memset( &fpgaReadResponseBuffer, 0, FPGA_READ_RSP_BUFFER_LEN ); - // enable interrupt notifications for FPGA serial port + // Enable interrupt notifications for FPGA serial port sciEnableNotification( scilinREG, SCI_OE_INT | SCI_FE_INT ); - // assign DMA channels to h/w DMA requests + // Assign DMA channels to h/w DMA requests dmaReqAssign( DMA_CH0, SCI2_RECEIVE_DMA_REQUEST ); dmaReqAssign( DMA_CH2, SCI2_TRANSMIT_DMA_REQUEST ); - // set DMA channel priorities + // Set DMA channel priorities dmaSetPriority( DMA_CH0, HIGHPRIORITY ); dmaSetPriority( DMA_CH2, LOWPRIORITY ); // Enable DMA block transfer complete interrupts dmaEnableInterrupt( DMA_CH0, BTC ); dmaEnableInterrupt( DMA_CH2, BTC ); - // initialize FPGA DMA Write Control Record - fpgaDMAWriteControlRecord.PORTASGN = 4; // port B (only choice per datasheet) - fpgaDMAWriteControlRecord.SADD = (U32)fpgaWriteCmdBuffer; // transfer source address - fpgaDMAWriteControlRecord.DADD = (U32)(&(scilinREG->TD)); // dest. is SCI2 xmit register - fpgaDMAWriteControlRecord.CHCTRL = 0; // no chaining - fpgaDMAWriteControlRecord.ELCNT = 1; // frame is 1 element - fpgaDMAWriteControlRecord.FRCNT = 0; // block is TBD frames - will be populated later when known - fpgaDMAWriteControlRecord.RDSIZE = ACCESS_8_BIT; // element size is 1 byte + // Initialize FPGA DMA Write Control Record + fpgaDMAWriteControlRecord.PORTASGN = 4; // Port B (only choice per datasheet) + fpgaDMAWriteControlRecord.SADD = (U32)fpgaWriteCmdBuffer; // Transfer source address + fpgaDMAWriteControlRecord.DADD = (U32)(&(scilinREG->TD)); // Dest. is SCI2 xmit register + fpgaDMAWriteControlRecord.CHCTRL = 0; // No chaining + fpgaDMAWriteControlRecord.ELCNT = 1; // Frame is 1 element + fpgaDMAWriteControlRecord.FRCNT = 0; // Block is TBD frames - will be populated later when known + fpgaDMAWriteControlRecord.RDSIZE = ACCESS_8_BIT; // Element size is 1 byte fpgaDMAWriteControlRecord.WRSIZE = ACCESS_8_BIT; // - fpgaDMAWriteControlRecord.TTYPE = FRAME_TRANSFER; // transfer type is block transfer - fpgaDMAWriteControlRecord.ADDMODERD = ADDR_INC1; // source addressing mode is post-increment - fpgaDMAWriteControlRecord.ADDMODEWR = ADDR_FIXED; // dest. addressing mode is fixed - fpgaDMAWriteControlRecord.AUTOINIT = AUTOINIT_OFF; // auto-init off - fpgaDMAWriteControlRecord.ELSOFFSET = 0; // not used - fpgaDMAWriteControlRecord.ELDOFFSET = 0; // not used - fpgaDMAWriteControlRecord.FRSOFFSET = 0; // not used - fpgaDMAWriteControlRecord.FRDOFFSET = 0; // not used + fpgaDMAWriteControlRecord.TTYPE = FRAME_TRANSFER; // Transfer type is block transfer + fpgaDMAWriteControlRecord.ADDMODERD = ADDR_INC1; // Source addressing mode is post-increment + fpgaDMAWriteControlRecord.ADDMODEWR = ADDR_FIXED; // Dest. addressing mode is fixed + fpgaDMAWriteControlRecord.AUTOINIT = AUTOINIT_OFF; // Auto-init off + fpgaDMAWriteControlRecord.ELSOFFSET = 0; // Not used + fpgaDMAWriteControlRecord.ELDOFFSET = 0; // Not used + fpgaDMAWriteControlRecord.FRSOFFSET = 0; // Not used + fpgaDMAWriteControlRecord.FRDOFFSET = 0; // Not used - // initialize FPGA DMA Write Response Control Record - fpgaDMAWriteRespControlRecord.PORTASGN = 4; // port B (only choice per datasheet) - fpgaDMAWriteRespControlRecord.SADD = (U32)(&(scilinREG->RD));// source is SCI2 recv register - fpgaDMAWriteRespControlRecord.DADD = (U32)fpgaWriteResponseBuffer; // transfer destination address - fpgaDMAWriteRespControlRecord.CHCTRL = 0; // no chaining - fpgaDMAWriteRespControlRecord.ELCNT = 1; // frame is 1 element - fpgaDMAWriteRespControlRecord.FRCNT = 0; // block is TBD frames - will be populated later when known - fpgaDMAWriteRespControlRecord.RDSIZE = ACCESS_8_BIT; // element size is 1 byte + // Initialize FPGA DMA Write Response Control Record + fpgaDMAWriteRespControlRecord.PORTASGN = 4; // Port B (only choice per datasheet) + fpgaDMAWriteRespControlRecord.SADD = (U32)(&(scilinREG->RD));// Source is SCI2 recv register + fpgaDMAWriteRespControlRecord.DADD = (U32)fpgaWriteResponseBuffer; // Transfer destination address + fpgaDMAWriteRespControlRecord.CHCTRL = 0; // No chaining + fpgaDMAWriteRespControlRecord.ELCNT = 1; // Frame is 1 element + fpgaDMAWriteRespControlRecord.FRCNT = 0; // Block is TBD frames - will be populated later when known + fpgaDMAWriteRespControlRecord.RDSIZE = ACCESS_8_BIT; // Element size is 1 byte fpgaDMAWriteRespControlRecord.WRSIZE = ACCESS_8_BIT; // - fpgaDMAWriteRespControlRecord.TTYPE = FRAME_TRANSFER; // transfer type is block transfer - fpgaDMAWriteRespControlRecord.ADDMODERD = ADDR_FIXED; // source addressing mode is fixed - fpgaDMAWriteRespControlRecord.ADDMODEWR = ADDR_INC1; // dest. addressing mode is post-increment - fpgaDMAWriteRespControlRecord.AUTOINIT = AUTOINIT_OFF; // auto-init off - fpgaDMAWriteRespControlRecord.ELDOFFSET = 0; // not used - fpgaDMAWriteRespControlRecord.ELSOFFSET = 0; // not used - fpgaDMAWriteRespControlRecord.FRDOFFSET = 0; // not used - fpgaDMAWriteRespControlRecord.FRSOFFSET = 0; // not used + fpgaDMAWriteRespControlRecord.TTYPE = FRAME_TRANSFER; // Transfer type is block transfer + fpgaDMAWriteRespControlRecord.ADDMODERD = ADDR_FIXED; // Source addressing mode is fixed + fpgaDMAWriteRespControlRecord.ADDMODEWR = ADDR_INC1; // Dest. addressing mode is post-increment + fpgaDMAWriteRespControlRecord.AUTOINIT = AUTOINIT_OFF; // Auto-init off + fpgaDMAWriteRespControlRecord.ELDOFFSET = 0; // Not used + fpgaDMAWriteRespControlRecord.ELSOFFSET = 0; // Not used + fpgaDMAWriteRespControlRecord.FRDOFFSET = 0; // Not used + fpgaDMAWriteRespControlRecord.FRSOFFSET = 0; // Not used - // initialize FPGA DMA Read Control Record - fpgaDMAReadControlRecord.PORTASGN = 4; // port B (only choice per datasheet) - fpgaDMAReadControlRecord.SADD = (U32)fpgaReadCmdBuffer; // transfer source address - fpgaDMAReadControlRecord.DADD = (U32)(&(scilinREG->TD)); // dest. is SCI2 xmit register - fpgaDMAReadControlRecord.CHCTRL = 0; // no chaining - fpgaDMAReadControlRecord.ELCNT = 1; // frame is 1 element - fpgaDMAReadControlRecord.FRCNT = 0; // block is TBD frames - will be populated later when known - fpgaDMAReadControlRecord.RDSIZE = ACCESS_8_BIT; // element size is 1 byte + // Initialize FPGA DMA Read Control Record + fpgaDMAReadControlRecord.PORTASGN = 4; // Port B (only choice per datasheet) + fpgaDMAReadControlRecord.SADD = (U32)fpgaReadCmdBuffer; // Transfer source address + fpgaDMAReadControlRecord.DADD = (U32)(&(scilinREG->TD)); // Dest. is SCI2 xmit register + fpgaDMAReadControlRecord.CHCTRL = 0; // No chaining + fpgaDMAReadControlRecord.ELCNT = 1; // Frame is 1 element + fpgaDMAReadControlRecord.FRCNT = 0; // Block is TBD frames - will be populated later when known + fpgaDMAReadControlRecord.RDSIZE = ACCESS_8_BIT; // Element size is 1 byte fpgaDMAReadControlRecord.WRSIZE = ACCESS_8_BIT; // - fpgaDMAReadControlRecord.TTYPE = FRAME_TRANSFER; // transfer type is block transfer - fpgaDMAReadControlRecord.ADDMODERD = ADDR_INC1; // source addressing mode is post-increment - fpgaDMAReadControlRecord.ADDMODEWR = ADDR_FIXED; // dest. addressing mode is fixed - fpgaDMAReadControlRecord.AUTOINIT = AUTOINIT_OFF; // auto-init off - fpgaDMAReadControlRecord.ELSOFFSET = 0; // not used - fpgaDMAReadControlRecord.ELDOFFSET = 0; // not used - fpgaDMAReadControlRecord.FRSOFFSET = 0; // not used - fpgaDMAReadControlRecord.FRDOFFSET = 0; // not used + fpgaDMAReadControlRecord.TTYPE = FRAME_TRANSFER; // Transfer type is block transfer + fpgaDMAReadControlRecord.ADDMODERD = ADDR_INC1; // Source addressing mode is post-increment + fpgaDMAReadControlRecord.ADDMODEWR = ADDR_FIXED; // Dest. addressing mode is fixed + fpgaDMAReadControlRecord.AUTOINIT = AUTOINIT_OFF; // Auto-init off + fpgaDMAReadControlRecord.ELSOFFSET = 0; // Not used + fpgaDMAReadControlRecord.ELDOFFSET = 0; // Not used + fpgaDMAReadControlRecord.FRSOFFSET = 0; // Not used + fpgaDMAReadControlRecord.FRDOFFSET = 0; // Not used - // initialize FPGA DMA Read Response Control Record - fpgaDMAReadRespControlRecord.PORTASGN = 4; // port B (only choice per datasheet) - fpgaDMAReadRespControlRecord.SADD = (U32)(&(scilinREG->RD)); // source is SCI2 recv register - fpgaDMAReadRespControlRecord.DADD = (U32)fpgaReadResponseBuffer; // transfer destination address - fpgaDMAReadRespControlRecord.CHCTRL = 0; // no chaining - fpgaDMAReadRespControlRecord.ELCNT = 1; // frame is 1 element - fpgaDMAReadRespControlRecord.FRCNT = 0; // block is TBD frames - will be populated later when known - fpgaDMAReadRespControlRecord.RDSIZE = ACCESS_8_BIT; // element size is 1 byte + // Initialize FPGA DMA Read Response Control Record + fpgaDMAReadRespControlRecord.PORTASGN = 4; // Port B (only choice per datasheet) + fpgaDMAReadRespControlRecord.SADD = (U32)(&(scilinREG->RD)); // Source is SCI2 recv register + fpgaDMAReadRespControlRecord.DADD = (U32)fpgaReadResponseBuffer; // Transfer destination address + fpgaDMAReadRespControlRecord.CHCTRL = 0; // No chaining + fpgaDMAReadRespControlRecord.ELCNT = 1; // Frame is 1 element + fpgaDMAReadRespControlRecord.FRCNT = 0; // Block is TBD frames - will be populated later when known + fpgaDMAReadRespControlRecord.RDSIZE = ACCESS_8_BIT; // Element size is 1 byte fpgaDMAReadRespControlRecord.WRSIZE = ACCESS_8_BIT; // - fpgaDMAReadRespControlRecord.TTYPE = FRAME_TRANSFER; // transfer type is block transfer - fpgaDMAReadRespControlRecord.ADDMODERD = ADDR_FIXED; // source addressing mode is fixed - fpgaDMAReadRespControlRecord.ADDMODEWR = ADDR_INC1; // dest. addressing mode is post-increment - fpgaDMAReadRespControlRecord.AUTOINIT = AUTOINIT_OFF; // auto-init off - fpgaDMAReadRespControlRecord.ELDOFFSET = 0; // not used - fpgaDMAReadRespControlRecord.ELSOFFSET = 0; // not used - fpgaDMAReadRespControlRecord.FRDOFFSET = 0; // not used - fpgaDMAReadRespControlRecord.FRSOFFSET = 0; // not used + fpgaDMAReadRespControlRecord.TTYPE = FRAME_TRANSFER; // Transfer type is block transfer + fpgaDMAReadRespControlRecord.ADDMODERD = ADDR_FIXED; // Source addressing mode is fixed + fpgaDMAReadRespControlRecord.ADDMODEWR = ADDR_INC1; // Dest. addressing mode is post-increment + fpgaDMAReadRespControlRecord.AUTOINIT = AUTOINIT_OFF; // Auto-init off + fpgaDMAReadRespControlRecord.ELDOFFSET = 0; // Not used + fpgaDMAReadRespControlRecord.ELSOFFSET = 0; // Not used + fpgaDMAReadRespControlRecord.FRDOFFSET = 0; // Not used + fpgaDMAReadRespControlRecord.FRSOFFSET = 0; // Not used - // there shouldn't be any data pending yet + // There shouldn't be any data pending yet consumeUnexpectedData(); } @@ -426,7 +426,7 @@ void signalFPGAReceiptCompleted( void ) { fpgaReceiptCounter++; - // did FPGA Ack last command? + // Did FPGA Ack last command? if ( TRUE == fpgaWriteCommandInProgress ) { fpgaWriteCommandInProgress = FALSE; @@ -438,12 +438,12 @@ fpgaReadCommandResponseReceived = TRUE; } - // see if we want to follow up with a bulk read command + // See if we want to follow up with a bulk read command if ( TRUE == fpgaBulkWriteAndReadInProgress ) { fpgaBulkWriteAndReadInProgress = FALSE; fpgaReadCommandInProgress = TRUE; - // initiate bulk read command + // Initiate bulk read command startDMAReceiptOfReadResp(); startDMAReadCmd(); } @@ -495,7 +495,7 @@ #endif case FPGA_STATE_FAILED: - // do nothing - we'll be stuck here + // Do nothing - we'll be stuck here break; default: @@ -505,12 +505,12 @@ } else { - // ok, some states handled in the outgoing state machine + // Ok, some states handled in the outgoing state machine } break; } - // if retries for commands exceeds limit, fault + // If retries for commands exceeds limit, fault if ( fpgaCommRetryCount > MAX_COMM_ERROR_RETRIES ) { activateAlarmNoData( ALARM_ID_FPGA_COMM_TIMEOUT ); @@ -543,7 +543,7 @@ break; case FPGA_STATE_FAILED: - // do nothing - we'll be stuck here + // Do nothing - we'll be stuck here break; #ifdef READ_FPGA_ASYNC_DATA @@ -559,7 +559,7 @@ } else { - // ok, some states handled in the incoming state machine + // Ok, some states handled in the incoming state machine } break; } @@ -578,15 +578,15 @@ FPGA_STATE_T result = FPGA_STATE_RCV_HEADER; U16 crc; - // construct read command to read 3 registers starting at address 0 + // Construct read command to read 3 registers starting at address 0 fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_HEADER_START_ADDR ); fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_HEADER_START_ADDR ); fpgaReadCmdBuffer[ 3 ] = sizeof(FPGA_HEADER_T); crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); - // prep DMA for sending the read cmd and receiving the response + // Prep DMA for sending the read cmd and receiving the response fpgaReadCommandInProgress = TRUE; setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_HEADER_T) + FPGA_CRC_LEN ); setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); @@ -608,21 +608,21 @@ { FPGA_STATE_T result = FPGA_STATE_READ_HEADER; - // did we get an FPGA response? + // Did we get an FPGA response? if ( TRUE == fpgaReadCommandResponseReceived ) { - // did FPGA Ack the read command? + // Did FPGA Ack the read command? if ( fpgaReadResponseBuffer[ 0 ] == FPGA_READ_CMD_ACK ) { U32 rspSize = FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_HEADER_T); U32 crcPos = rspSize; U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[ crcPos ], fpgaReadResponseBuffer[ crcPos + 1 ] ); - // does the FPGA response CRC check out? + // Does the FPGA response CRC check out? if ( crc == crc16( fpgaReadResponseBuffer, rspSize ) ) { fpgaCommRetryCount = 0; - // capture the read values + // Capture the read values memcpy( &fpgaHeader, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], sizeof( FPGA_HEADER_T ) ); result = FPGA_STATE_WRITE_ALL_ACTUATORS; } @@ -631,17 +631,17 @@ fpgaCommRetryCount++; } } - else // header read was NAK'd + else // Header read was NAK'd { fpgaCommRetryCount++; } } - else // no response to read command + else // No response to read command { fpgaCommRetryCount++; } - // shouldn't be any data received at this time + // Shouldn't be any data received at this time consumeUnexpectedData(); return result; @@ -660,7 +660,7 @@ FPGA_STATE_T result = FPGA_STATE_RCV_ALL_SENSORS; U16 crc; - // construct bulk write command to write actuator data registers starting at address 3 (TODO - change address later) + // Construct bulk write command to write actuator data registers starting at address 3 (TODO - change address later) fpgaWriteCmdBuffer[ 0 ] = FPGA_WRITE_CMD_CODE; fpgaWriteCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_WRITE_START_ADDR ); fpgaWriteCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_WRITE_START_ADDR ); @@ -670,7 +670,7 @@ fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) ] = GET_MSB_OF_WORD( crc ); fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) + 1 ] = GET_LSB_OF_WORD( crc ); - // construct bulk read command to read sensor data registers starting at address 8 + // Construct bulk read command to read sensor data registers starting at address 8 fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_READ_START_ADDR ); fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_READ_START_ADDR ); @@ -679,16 +679,16 @@ fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); - // prep DMA for sending the bulk write cmd and receiving its response + // Prep DMA for sending the bulk write cmd and receiving its response setupDMAForWriteCmd( FPGA_WRITE_CMD_HDR_LEN + sizeof( FPGA_ACTUATORS_T ) + FPGA_CRC_LEN ); setupDMAForWriteResp( FPGA_WRITE_RSP_HDR_LEN + FPGA_CRC_LEN ); - // prep DMA for sending the bulk read cmd and receiving its response + // Prep DMA for sending the bulk read cmd and receiving its response setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof( FPGA_SENSORS_T ) + FPGA_CRC_LEN ); - // set fpga comm flags for bulk write cmd and follow-up bulk read command + // Set fpga comm flags for bulk write cmd and follow-up bulk read command fpgaWriteCommandInProgress = TRUE; fpgaBulkWriteAndReadInProgress = TRUE; - // initiate bulk write command and it's receipt - read will follow + // Initiate bulk write command and it's receipt - read will follow startDMAReceiptOfWriteResp(); startDMAWriteCmd(); @@ -707,35 +707,35 @@ { FPGA_STATE_T result = FPGA_STATE_WRITE_ALL_ACTUATORS; - // check bulk write command success + // Check bulk write command success if ( ( FALSE == fpgaWriteCommandResponseReceived ) || ( fpgaWriteResponseBuffer[ 0 ] != FPGA_WRITE_CMD_ACK ) ) { fpgaCommRetryCount++; } - // if bulk read command is ACK'd, collect the readings + // If bulk read command is ACK'd, collect the readings if ( TRUE == fpgaReadCommandResponseReceived ) { - // did FPGA Ack the read command? + // Did FPGA Ack the read command? if ( fpgaReadResponseBuffer[ 0 ] == FPGA_READ_CMD_ACK ) { U32 rspSize = FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_SENSORS_T); U32 crcPos = rspSize; U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[ crcPos ], fpgaReadResponseBuffer[ crcPos + 1 ] ); - // does the FPGA response CRC check out? + // Does the FPGA response CRC check out? if ( crc == crc16( fpgaReadResponseBuffer, rspSize ) ) { fpgaCommRetryCount = 0; - // capture the read values + // Capture the read values memcpy( &fpgaSensorReadings, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], sizeof( FPGA_SENSORS_T ) ); #ifndef READ_FPGA_ASYNC_DATA result = FPGA_STATE_WRITE_ALL_ACTUATORS; #else result = FPGA_STATE_READ_ALL_SENSORS_ASYNC; #endif } - else // bad CRC + else // Bad CRC { fpgaCommRetryCount++; } @@ -745,12 +745,12 @@ fpgaCommRetryCount++; } } - else // no response to read command + else // No response to read command { fpgaCommRetryCount++; } - // shouldn't be any data received at this time + // Shouldn't be any data received at this time consumeUnexpectedData(); return result; @@ -770,15 +770,15 @@ FPGA_STATE_T result = FPGA_STATE_RCV_ALL_SENSORS_ASYNC; U16 crc; - // construct read command to read low priority async registers starting at address 0x200 + // Construct read command to read low priority async registers starting at address 0x200 fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE; fpgaReadCmdBuffer[ 1 ] = GET_LSB_OF_WORD( FPGA_BULK_ASYNC_READ_START_ADDR ); fpgaReadCmdBuffer[ 2 ] = GET_MSB_OF_WORD( FPGA_BULK_ASYNC_READ_START_ADDR ); fpgaReadCmdBuffer[ 3 ] = sizeof(FPGA_SENSORS_ASYNC_T); crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN ); fpgaReadCmdBuffer[ 4 ] = GET_MSB_OF_WORD( crc ); fpgaReadCmdBuffer[ 5 ] = GET_LSB_OF_WORD( crc ); - // prep DMA for sending the read cmd and receiving the response + // Prep DMA for sending the read cmd and receiving the response fpgaReadCommandInProgress = TRUE; setupDMAForReadResp( FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_SENSORS_ASYNC_T) + FPGA_CRC_LEN ); setupDMAForReadCmd( FPGA_READ_CMD_HDR_LEN + FPGA_CRC_LEN ); @@ -800,25 +800,25 @@ { FPGA_STATE_T result = FPGA_STATE_READ_ALL_SENSORS_ASYNC; - // if bulk read command is ACK'd, collect the readings + // If bulk read command is ACK'd, collect the readings if ( TRUE == fpgaReadCommandResponseReceived ) { - // did FPGA Ack the read command? + // Did FPGA Ack the read command? if ( fpgaReadResponseBuffer[ 0 ] == FPGA_READ_CMD_ACK ) { U32 rspSize = FPGA_READ_RSP_HDR_LEN + sizeof(FPGA_SENSORS_ASYNC_T); U32 crcPos = rspSize; U16 crc = MAKE_WORD_OF_BYTES( fpgaReadResponseBuffer[ crcPos ], fpgaReadResponseBuffer[ crcPos + 1 ] ); - // does the FPGA response CRC check out? + // Does the FPGA response CRC check out? if ( crc == crc16( fpgaReadResponseBuffer, rspSize ) ) { fpgaCommRetryCount = 0; - // capture the read values + // Capture the read values memcpy( &fpgaSensorReadingsAsync, &fpgaReadResponseBuffer[ FPGA_READ_RSP_HDR_LEN ], sizeof( FPGA_SENSORS_ASYNC_T ) ); result = FPGA_STATE_WRITE_ALL_ACTUATORS; } - else // bad CRC + else // Bad CRC { fpgaCommRetryCount++; } @@ -828,12 +828,12 @@ fpgaCommRetryCount++; } } - else // no response to read command + else // No response to read command { fpgaCommRetryCount++; } - // shouldn't be any data received at this time + // Shouldn't be any data received at this time consumeUnexpectedData(); return result; @@ -851,7 +851,7 @@ { SELF_TEST_STATUS_T result; - // check FPGA reported correct ID + // Check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { result = SELF_TEST_STATUS_PASSED; @@ -875,10 +875,10 @@ *************************************************************************/ static void consumeUnexpectedData( void ) { - // clear any errors + // Clear any errors sciRxError( scilinREG ); - // if a byte is pending read, read it + // If a byte is pending read, read it if ( sciIsRxReady( scilinREG ) != 0 ) { sciReceiveByte( scilinREG ); @@ -896,7 +896,7 @@ *************************************************************************/ static void setupDMAForWriteCmd( U32 bytes2Transmit ) { - // verify # of bytes does not exceed buffer length + // Verify # of bytes does not exceed buffer length if ( bytes2Transmit <= FPGA_WRITE_CMD_BUFFER_LEN ) { fpgaDMAWriteControlRecord.FRCNT = bytes2Transmit; @@ -933,7 +933,7 @@ *************************************************************************/ static void setupDMAForWriteResp( U32 bytes2Receive ) { - // verify # of bytes does not exceed buffer length + // Verify # of bytes does not exceed buffer length if ( bytes2Receive <= FPGA_WRITE_RSP_BUFFER_LEN ) { fpgaDMAWriteRespControlRecord.FRCNT = bytes2Receive; @@ -970,7 +970,7 @@ *************************************************************************/ static void setupDMAForReadCmd( U32 bytes2Transmit ) { - // verify # of bytes does not exceed buffer length + // Verify # of bytes does not exceed buffer length if ( bytes2Transmit <= FPGA_READ_CMD_BUFFER_LEN ) { fpgaDMAReadControlRecord.FRCNT = bytes2Transmit; @@ -1007,7 +1007,7 @@ *************************************************************************/ static void setupDMAForReadResp( U32 bytes2Receive ) { - // verify # of bytes does not exceed buffer length + // Verify # of bytes does not exceed buffer length if ( bytes2Receive <= FPGA_READ_RSP_BUFFER_LEN ) { fpgaDMAReadRespControlRecord.FRCNT = bytes2Receive; @@ -1080,10 +1080,10 @@ { 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 + // 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; - // s/w fault to indicate issue w/ s/w + // 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 ) } Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -rc67def50892f9a7c2f1f22985b5351465a8f6773 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision c67def50892f9a7c2f1f22985b5351465a8f6773) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -77,7 +77,7 @@ *************************************************************************/ void initInterrupts( void ) { - // initialize various time windowed counts for monitoring CAN & UART errors and warnings + // Initialize various time windowed counts for monitoring CAN & UART errors and warnings initTimeWindowedCount( TIME_WINDOWED_COUNT_CAN_PASSIVE, MAX_COMM_ERRORS, COMM_ERROR_TIME_WINDOW_MS ); initTimeWindowedCount( TIME_WINDOWED_COUNT_CAN_OFF, MAX_COMM_ERRORS, COMM_ERROR_TIME_WINDOW_MS ); initTimeWindowedCount( TIME_WINDOWED_COUNT_CAN_PARITY, MAX_COMM_ERRORS, COMM_ERROR_TIME_WINDOW_MS ); @@ -127,7 +127,7 @@ break; case rtiNOTIFICATION_COMPARE2: - // do nothing - unused at this time + // Do nothing - unused at this time break; case rtiNOTIFICATION_COMPARE3: @@ -227,7 +227,7 @@ } else { - // ignore - other notifications undefined + // Ignore - other notifications undefined } } } @@ -314,7 +314,7 @@ *************************************************************************/ void dmaGroupANotification(dmaInterrupt_t inttype, uint32 channel) { - if ( inttype == BTC ) // block transfer completed interrupt + if ( inttype == BTC ) // Block transfer completed interrupt { switch ( channel ) { @@ -326,7 +326,7 @@ #ifdef DEBUG_ENABLED case DMA_CH1: // PC receive channel clearSCI1DMAReceiveInterrupt(); - // handle received packet from PC + // Handle received packet from PC handleUARTMsgRecvPacketInterrupt(); break; #endif @@ -338,7 +338,7 @@ #ifdef DEBUG_ENABLED case DMA_CH3: // PC transmit channel clearSCI1DMATransmitInterrupt(); - // send next pending packet to PC (if any) + // Send next pending packet to PC (if any) handleUARTMsgXmitPacketInterrupt(); break; #endif Index: firmware/App/Services/MsgQueues.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/MsgQueues.c (.../MsgQueues.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/MsgQueues.c (.../MsgQueues.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -73,25 +73,25 @@ { BOOL result = FALSE; - // verify given message queue + // Verify given message queue if ( queue < NUM_OF_MSG_QUEUES ) { if ( FALSE == isMsgQueueFull( queue ) ) { result = TRUE; - // add message to queue + // Add message to queue msgQueues[ queue ][ msgQueueNexts[ queue ] ] = *msg; - // increment next index to add to + // Increment next index to add to msgQueueNexts[ queue ] = INC_WRAP( msgQueueNexts[ queue ], 0, MAX_MSG_QUEUE_SIZE - 1 ); - // increment queue count + // Increment queue count msgQueueCounts[ queue ]++; } - else // msg queue is full + else // Msg queue is full { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_QUEUES_ADD_QUEUE_FULL ) } } - else // invalid message queue + else // Invalid message queue { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_QUEUES_ADD_INVALID_QUEUE, queue ) } @@ -114,25 +114,25 @@ { BOOL result = FALSE; - // verify given message queue + // Verify given message queue if ( queue < NUM_OF_MSG_QUEUES ) { if ( FALSE == isMsgQueueEmpty( queue ) ) { result = TRUE; - // get message from queue + // Get message from queue *msg = msgQueues[ queue ][ msgQueueStarts[ queue ] ]; - // increment queue next index to get from + // Increment queue next index to get from msgQueueStarts[ queue ] = INC_WRAP( msgQueueStarts[ queue ], 0, MAX_MSG_QUEUE_SIZE - 1 ); - // decrement queue count + // Decrement queue count msgQueueCounts[ queue ]--; } - else // message queue is empty + else // Message queue is empty { // Result already set to FALSE } } - else // invalid message queue + else // Invalid message queue { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_QUEUES_GET_INVALID_QUEUE, queue ) } @@ -152,15 +152,15 @@ { BOOL result = FALSE; - // verify given message queue + // Verify given message queue if ( queue < NUM_OF_MSG_QUEUES ) { if ( msgQueueCounts[ queue ] == 0 ) { result = TRUE; } } - else // invalid message queue + else // Invalid message queue { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_QUEUES_IS_EMPTY_INVALID_QUEUE, queue ) } @@ -180,15 +180,15 @@ { BOOL result = TRUE; - // verify given message queue + // Verify given message queue if ( queue < NUM_OF_MSG_QUEUES ) { if ( msgQueueCounts[ queue ] < MAX_MSG_QUEUE_SIZE ) { result = FALSE; } } - else // invalid message queue + else // Invalid message queue { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_QUEUES_IS_FULL_INVALID_QUEUE, queue ) } @@ -210,7 +210,7 @@ U32 msgSize = sizeof(MESSAGE_T); U08 *msgContent = (U08*)message; - // zero out the message + // Zero out the message for ( i = 0; i < msgSize; i++ ) { *msgContent++ = 0x0; @@ -231,13 +231,13 @@ U32 msgSize = sizeof(MESSAGE_T); U08 *msgContent = (U08*)message; - // zero out the message + // Zero out the message for ( i = 0; i < msgSize; i++ ) { *msgContent++ = 0x0; } - // set msg ID out of bounds in case blank message goes somewhere + // Set msg ID out of bounds in case blank message goes somewhere message->msg.hdr.msgID = 0xFFFF; } Index: firmware/App/Services/MsgQueues.h =================================================================== diff -u -ref25ad960d479d1237d8b6e844941b6680a8edc0 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/MsgQueues.h (.../MsgQueues.h) (revision ef25ad960d479d1237d8b6e844941b6680a8edc0) +++ firmware/App/Services/MsgQueues.h (.../MsgQueues.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -31,7 +31,7 @@ // ********** public definitions ********** -#define MAX_MSG_PAYLOAD_SIZE 250 ///< bytes +#define MAX_MSG_PAYLOAD_SIZE 250 ///< Bytes /// Enumeration of message queues. typedef enum Msg_Queues @@ -45,23 +45,23 @@ /// Record structure for message header. typedef struct { - S16 seqNo; ///< sequence number (and ACK required bit) of message + S16 seqNo; ///< Sequence number (and ACK required bit) of message U16 msgID; ///< ID of message - U08 payloadLen; ///< length of payload in bytes + U08 payloadLen; ///< Length of payload in bytes } MESSAGE_HEADER_T; /// Record structure for a message (header + payload). typedef struct { - MESSAGE_HEADER_T hdr; ///< message header - U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; ///< message payload + MESSAGE_HEADER_T hdr; ///< Message header + U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; ///< Message payload } MESSAGE_T; /// Record structure for a wrapped message (message + CRC). typedef struct { - MESSAGE_T msg; ///< message - U08 crc; ///< message CRC + MESSAGE_T msg; ///< Message + U08 crc; ///< Message CRC } MESSAGE_WRAPPER_T; #pragma pack(pop) Index: firmware/App/Services/PIControllers.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/PIControllers.c (.../PIControllers.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/PIControllers.c (.../PIControllers.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -27,7 +27,7 @@ // ********** private definitions ********** -/// minimum integral coefficient - cannot be zero. +/// Minimum integral coefficient - cannot be zero. #define MIN_KI NEARLY_ZERO /// Record for PI controller. @@ -38,15 +38,15 @@ F32 uMax; ///< Maximum control signal. F32 uMin; ///< Minimum control signal. // -- PI's signals -- - F32 referenceSignal; ///< reference signal. - F32 measuredSignal; ///< measured signal. - F32 errorSignal; ///< reference - measured signal. - F32 errorSumBeforeWindUp; ///< error signal before windup correction. - F32 errorSum; ///< error integral after windup correction. - F32 controlSignal; ///< actual control signal. + F32 referenceSignal; ///< Reference signal. + F32 measuredSignal; ///< Measured signal. + F32 errorSignal; ///< Reference - measured signal. + F32 errorSumBeforeWindUp; ///< Error signal before windup correction. + F32 errorSum; ///< Error integral after windup correction. + F32 controlSignal; ///< Actual control signal. } PI_CONTROLLER_T; -#define SET_CONTROLLER( c, id ) ((c) = &piControllers[id]) ///< macro to set a local controller pointer to a given piController. +#define SET_CONTROLLER( c, id ) ((c) = &piControllers[id]) ///< Macro to set a local controller pointer to a given piController. // ********** private data ********** @@ -84,7 +84,7 @@ SET_CONTROLLER( controller, controllerID ); controller->Kp = kP; - if ( fabs( kI ) > MIN_KI ) // ensure kI is not zero + if ( fabs( kI ) > MIN_KI ) // Ensure kI is not zero { controller->Ki = kI; } @@ -156,15 +156,15 @@ controller->referenceSignal = referenceSignal; controller->measuredSignal = measuredSignal; - // calculate error signal + // Calculate error signal controller->errorSignal = fabs( referenceSignal ) - ( referenceSignal < 0.0 ? ( measuredSignal * -1.0 ) : measuredSignal ); controller->errorSum += controller->errorSignal; - // anti-windup + // Anti-windup controller->errorSumBeforeWindUp = controller->errorSum; - // calculate control signal + // Calculate control signal controlSignalBeforeWindup = ( controller->Kp * controller->errorSignal ) + ( controller->Ki * controller->errorSum ); controller->controlSignal = RANGE( controlSignalBeforeWindup, controller->uMin, controller->uMax ); - // handle anti-windup for i term + // Handle anti-windup for i term windupError = controlSignalBeforeWindup - controller->controlSignal; if ( fabs( windupError ) > NEARLY_ZERO ) { @@ -235,10 +235,10 @@ default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_PI_CTRL_INVALID_SIGNAL, (U32)signalID ) break; - } // end of switch + } // End of switch } else - { // invalid controller given + { // Invalid controller given SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_PI_CTRL_INVALID_CONTROLLER, (U32)controllerID ) } Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include // for memcpy() +#include // For memcpy() #include "can.h" #include "sci.h" @@ -35,29 +35,29 @@ // ********** private definitions ********** -#define NUM_OF_CAN_OUT_BUFFERS 5 ///< number of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 7 ///< number of CAN buffers for receiving +#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 7 ///< Number of CAN buffers for receiving #ifndef DEBUG_ENABLED - #define NUM_OF_MSG_IN_BUFFERS 7 ///< number of Msg buffers for receiving + #define NUM_OF_MSG_IN_BUFFERS 7 ///< Number of Msg buffers for receiving #else #define NUM_OF_MSG_IN_BUFFERS 8 #define SCI1_RECEIVE_DMA_REQUEST 30 #define SCI1_TRANSMIT_DMA_REQUEST 31 #endif -#define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< if transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on -#define MAX_XMIT_RETRIES 5 ///< maximum number of retries on no transmit complete interrupt timeout +#define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< If transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on +#define MAX_XMIT_RETRIES 5 ///< Maximum number of retries on no transmit complete interrupt timeout #define UI_COMM_TIMEOUT_IN_MS 5000 ///< UI has not checked in for this much time #define DG_COMM_TIMEOUT_IN_MS 2000 ///< DG has not checked in for this much time -#define MAX_COMM_CRC_FAILURES 5 ///< maximum number of CRC errors within window period before alarm +#define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm #define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window -#define MSG_NOT_ACKED_TIMEOUT_MS 150 ///< maximum time for a Denali message that requires ACK to be ACK'd -#define MSG_NOT_ACKED_MAX_RETRIES 3 ///< maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm -#define PENDING_ACK_LIST_SIZE 25 ///< maximum number of Delanli messages that can be pending ACK at any given time +#define MSG_NOT_ACKED_TIMEOUT_MS 150 ///< Maximum time for a Denali message that requires ACK to be ACK'd +#define MSG_NOT_ACKED_MAX_RETRIES 3 ///< Maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm +#define PENDING_ACK_LIST_SIZE 25 ///< Maximum number of Delanli messages that can be pending ACK at any given time #pragma pack(push, 1) @@ -106,22 +106,22 @@ static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = (CAN_MESSAGE_BOX_T)0; ///< Keep channel last packet was sent on CAN bus in case we need to re-send. static U32 lastCANPacketSentTimeStamp = 0; ///< Keep time last packet sent on CAN bus so we can timeout on transmission attempt. -static volatile PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< list of outgoing messages that are awaiting an ACK +static volatile PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< List of outgoing messages that are awaiting an ACK -static volatile BOOL hdIsOnlyCANNode = TRUE; ///< flag indicating whether HD is alone on CAN bus. -static U32 canXmitRetryCtr = 0; ///< counter for CAN transmit retries. -static volatile BOOL dgIsCommunicating = FALSE; ///< has DG sent a message since last check -static U32 timeOfLastDGCheckIn = 0; ///< last time DG checked in -static volatile BOOL uiIsCommunicating = FALSE; ///< has UI sent a message since last check -static U32 timeOfLastUICheckIn = 0; ///< last time UI checked in -static volatile BOOL uiDidCommunicate = FALSE; ///< has UI every sent a message +static volatile BOOL hdIsOnlyCANNode = TRUE; ///< Flag indicating whether HD is alone on CAN bus. +static U32 canXmitRetryCtr = 0; ///< Counter for CAN transmit retries. +static volatile BOOL dgIsCommunicating = FALSE; ///< Has DG sent a message since last check +static U32 timeOfLastDGCheckIn = 0; ///< Last time DG checked in +static volatile BOOL uiIsCommunicating = FALSE; ///< Has UI sent a message since last check +static U32 timeOfLastUICheckIn = 0; ///< Last time UI checked in +static volatile BOOL uiDidCommunicate = FALSE; ///< Has UI every sent a message #ifdef EMC_TEST_BUILD - static U32 badCANCount; // test code in support of EMC testing + static U32 badCANCount; // Test code in support of EMC testing #endif #ifdef DEBUG_ENABLED - // debug buffers + // Debug buffers static U08 pcXmitPacket[ 1024 ]; static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -166,14 +166,14 @@ U32 i; #ifdef DEBUG_ENABLED - // initialize UART and DMA for PC communication + // Initialize UART and DMA for PC communication initUARTAndDMA(); #endif - // initialize bad message CRC time windowed count + // Initialize bad message CRC time windowed count initTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC, MAX_COMM_CRC_FAILURES, MAX_COMM_CRC_FAILURE_WINDOW_MS ); - // initialize pending ACK list + // Initialize pending ACK list for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { pendingAckList[ i ].used = FALSE; @@ -273,16 +273,16 @@ *************************************************************************/ void execSystemCommRx( void ) { - // parse messages from comm buffers and queue them + // Parse messages from comm buffers and queue them processIncomingData(); - // process received messages in the queue + // Process received messages in the queue processReceivedMessages(); - // check for sub-system comm timeouts + // Check for sub-system comm timeouts checkForCommTimeouts(); - // check ACK list for messages that need to be re-sent because they haven't been ACK'd + // Check ACK list for messages that need to be re-sent because they haven't been ACK'd checkPendingACKList(); } @@ -296,23 +296,23 @@ *************************************************************************/ void execSystemCommTx( void ) { - // don't bother with transmitting if no other nodes on CAN bus + // Don't bother with transmitting if no other nodes on CAN bus if ( FALSE == hdIsOnlyCANNode ) { - // if CAN transmitter is idle, start transmitting any pending packets + // If CAN transmitter is idle, start transmitting any pending packets if ( FALSE == isCAN1TransmitInProgress() ) { transmitNextCANPacket(); } else { - // generally, transmitter should not be busy at time of this function call - check timeout just in case so we don't get stuck waiting forever + // Generally, transmitter should not be busy at time of this function call - check timeout just in case so we don't get stuck waiting forever if ( TRUE == didTimeout( lastCANPacketSentTimeStamp, CAN_XMIT_PACKET_TIMEOUT_MS ) ) { - // assume last packet was not successfully transmitted. Re-send last packet. + // Assume last packet was not successfully transmitted. Re-send last packet. if ( ++canXmitRetryCtr <= MAX_XMIT_RETRIES ) { - // ensure we have a previous CAN packet/channel to resend - canTransmit() channel param MUST be valid + // Ensure we have a previous CAN packet/channel to resend - canTransmit() channel param MUST be valid if ( ( lastCANPacketSentChannel > COMM_BUFFER_NOT_USED ) && ( lastCANPacketSentChannel <= COMM_BUFFER_LAST_CAN_BUFFER ) ) { canTransmit( canREG1, lastCANPacketSentChannel, lastCANPacketSent ); @@ -326,13 +326,13 @@ } #endif } - // we must be only node on CAN bus - nobody is ACKing our transmitted frames + // We must be only node on CAN bus - nobody is ACKing our transmitted frames else { - hdIsOnlyCANNode = TRUE; // set only CAN node flag + hdIsOnlyCANNode = TRUE; // Set only CAN node flag canXmitRetryCtr = MAX_XMIT_RETRIES; - signalCANXmitsCompleted(); // clear pending xmit flag - clearCANXmitBuffers(); // clear xmit buffers - nothing is going out right now + signalCANXmitsCompleted(); // Clear pending xmit flag + clearCANXmitBuffers(); // Clear xmit buffers - nothing is going out right now #ifdef DEBUG_ENABLED { char debugStr[100]; @@ -346,7 +346,7 @@ } #ifdef DEBUG_ENABLED - // if UART transmitter is idle, start transmitting any pending packets + // If UART transmitter is idle, start transmitting any pending packets if ( FALSE == isSCI1DMATransmitInProgress() ) { transmitNextUARTPacket(); @@ -367,14 +367,14 @@ *************************************************************************/ void handleCANMsgInterrupt( CAN_MESSAGE_BOX_T srcCANBox ) { - // message interrupt is for a transmit message box? + // Message interrupt is for a transmit message box? if ( TRUE == isCANBoxForXmit( srcCANBox ) ) { U32 bytesXmitted; bytesXmitted = transmitNextCANPacket(); - // if nothing more to send, signal that transmitter is available + // If nothing more to send, signal that transmitter is available if ( 0 == bytesXmitted ) { signalCANXmitsCompleted(); @@ -384,22 +384,22 @@ { U08 data[ CAN_MESSAGE_PAYLOAD_SIZE ]; - // get CAN packet received on given CAN message box + // Get CAN packet received on given CAN message box if ( FALSE != canIsRxMessageArrived( canREG1, srcCANBox ) ) { U32 result = canGetData( canREG1, srcCANBox, data ); - // if packet retrieved, add to buffer + // If packet retrieved, add to buffer if ( result != 0 ) { - // add CAN packet to appropriate comm buffer based on the message box it came in on (s/b same #) + // Add CAN packet to appropriate comm buffer based on the message box it came in on (s/b same #) addToCommBuffer( srcCANBox, data, CAN_MESSAGE_PAYLOAD_SIZE ); } } } else { - // shouldn't get here - not an active message box + // Shouldn't get here - not an active message box // TODO - s/w fault? } } @@ -415,9 +415,9 @@ #ifdef DEBUG_ENABLED void handleUARTMsgRecvPacketInterrupt( void ) { - // buffer received packet + // Buffer received packet addToCommBuffer( COMM_BUFFER_IN_UART_PC, pcRecvPacket, PC_MESSAGE_PACKET_SIZE ); - // prepare to receive next packet + // Prepare to receive next packet dmaSetCtrlPacket( DMA_CH1, pcDMARecvControlRecord ); dmaSetChEnable( DMA_CH1, DMA_HW ); setSCI1DMAReceiveInterrupt(); @@ -459,50 +459,50 @@ dmaEnableInterrupt( DMA_CH1, BTC ); dmaEnableInterrupt( DMA_CH3, BTC ); - // assign DMA channels to h/w DMA requests + // Assign DMA channels to h/w DMA requests dmaReqAssign( DMA_CH1, SCI1_RECEIVE_DMA_REQUEST ); dmaReqAssign( DMA_CH3, SCI1_TRANSMIT_DMA_REQUEST ); - // set DMA channel priorities + // Set DMA channel priorities dmaSetPriority( DMA_CH1, HIGHPRIORITY ); dmaSetPriority( DMA_CH3, LOWPRIORITY ); - // initialize PC DMA Transmit Control Record - pcDMAXmitControlRecord.PORTASGN = 4; // port B (only choice per datasheet) - pcDMAXmitControlRecord.DADD = (U32)(&(sciREG->TD)); // dest. is SCI2 xmit register - pcDMAXmitControlRecord.SADD = (U32)pcXmitPacket; // source - pcDMAXmitControlRecord.CHCTRL = 0; // no chaining - pcDMAXmitControlRecord.ELCNT = 1; // frame is 1 element - pcDMAXmitControlRecord.FRCNT = PC_MESSAGE_PACKET_SIZE; // block is 8 frames - pcDMAXmitControlRecord.RDSIZE = ACCESS_8_BIT; // element size is 1 byte + // Initialize PC DMA Transmit Control Record + pcDMAXmitControlRecord.PORTASGN = 4; // Port B (only choice per datasheet) + pcDMAXmitControlRecord.DADD = (U32)(&(sciREG->TD)); // Dest. is SCI2 xmit register + pcDMAXmitControlRecord.SADD = (U32)pcXmitPacket; // Source + pcDMAXmitControlRecord.CHCTRL = 0; // No chaining + pcDMAXmitControlRecord.ELCNT = 1; // Frame is 1 element + pcDMAXmitControlRecord.FRCNT = PC_MESSAGE_PACKET_SIZE; // Block is 8 frames + pcDMAXmitControlRecord.RDSIZE = ACCESS_8_BIT; // Element size is 1 byte pcDMAXmitControlRecord.WRSIZE = ACCESS_8_BIT; // - pcDMAXmitControlRecord.TTYPE = FRAME_TRANSFER; // transfer type is block transfer - pcDMAXmitControlRecord.ADDMODEWR = ADDR_FIXED; // dest. addressing mode is fixed - pcDMAXmitControlRecord.ADDMODERD = ADDR_INC1; // source addressing mode is post-increment - pcDMAXmitControlRecord.AUTOINIT = AUTOINIT_OFF; // auto-init off - pcDMAXmitControlRecord.ELSOFFSET = 0; // not used - pcDMAXmitControlRecord.ELDOFFSET = 0; // not used - pcDMAXmitControlRecord.FRSOFFSET = 0; // not used - pcDMAXmitControlRecord.FRDOFFSET = 0; // not used + pcDMAXmitControlRecord.TTYPE = FRAME_TRANSFER; // Transfer type is block transfer + pcDMAXmitControlRecord.ADDMODEWR = ADDR_FIXED; // Dest. addressing mode is fixed + pcDMAXmitControlRecord.ADDMODERD = ADDR_INC1; // Source addressing mode is post-increment + pcDMAXmitControlRecord.AUTOINIT = AUTOINIT_OFF; // Auto-init off + pcDMAXmitControlRecord.ELSOFFSET = 0; // Not used + pcDMAXmitControlRecord.ELDOFFSET = 0; // Not used + pcDMAXmitControlRecord.FRSOFFSET = 0; // Not used + pcDMAXmitControlRecord.FRDOFFSET = 0; // Not used - // initialize PC DMA Receipt Control Record - pcDMARecvControlRecord.PORTASGN = 4; // port B (only choice per datasheet) - pcDMARecvControlRecord.SADD = (U32)(&(sciREG->RD)); // source is SCI2 recv register - pcDMARecvControlRecord.DADD = (U32)pcRecvPacket; // transfer destination address - pcDMARecvControlRecord.CHCTRL = 0; // no chaining - pcDMARecvControlRecord.ELCNT = 1; // frame is 1 element - pcDMARecvControlRecord.FRCNT = PC_MESSAGE_PACKET_SIZE; // block is 8 frames - pcDMARecvControlRecord.RDSIZE = ACCESS_8_BIT; // element size is 1 byte + // Initialize PC DMA Receipt Control Record + pcDMARecvControlRecord.PORTASGN = 4; // Port B (only choice per datasheet) + pcDMARecvControlRecord.SADD = (U32)(&(sciREG->RD)); // Source is SCI2 recv register + pcDMARecvControlRecord.DADD = (U32)pcRecvPacket; // Transfer destination address + pcDMARecvControlRecord.CHCTRL = 0; // No chaining + pcDMARecvControlRecord.ELCNT = 1; // Frame is 1 element + pcDMARecvControlRecord.FRCNT = PC_MESSAGE_PACKET_SIZE; // Block is 8 frames + pcDMARecvControlRecord.RDSIZE = ACCESS_8_BIT; // Element size is 1 byte pcDMARecvControlRecord.WRSIZE = ACCESS_8_BIT; // - pcDMARecvControlRecord.TTYPE = FRAME_TRANSFER; // transfer type is block transfer - pcDMARecvControlRecord.ADDMODERD = ADDR_FIXED; // source addressing mode is fixed - pcDMARecvControlRecord.ADDMODEWR = ADDR_INC1; // dest. addressing mode is post-increment - pcDMARecvControlRecord.AUTOINIT = AUTOINIT_OFF; // auto-init off - pcDMARecvControlRecord.ELDOFFSET = 0; // not used - pcDMARecvControlRecord.ELSOFFSET = 0; // not used - pcDMARecvControlRecord.FRDOFFSET = 0; // not used - pcDMARecvControlRecord.FRSOFFSET = 0; // not used + pcDMARecvControlRecord.TTYPE = FRAME_TRANSFER; // Transfer type is block transfer + pcDMARecvControlRecord.ADDMODERD = ADDR_FIXED; // Source addressing mode is fixed + pcDMARecvControlRecord.ADDMODEWR = ADDR_INC1; // Dest. addressing mode is post-increment + pcDMARecvControlRecord.AUTOINIT = AUTOINIT_OFF; // Auto-init off + pcDMARecvControlRecord.ELDOFFSET = 0; // Not used + pcDMARecvControlRecord.ELSOFFSET = 0; // Not used + pcDMARecvControlRecord.FRDOFFSET = 0; // Not used + pcDMARecvControlRecord.FRSOFFSET = 0; // Not used - // initiate PC packet receiving readiness via DMA + // Initiate PC packet receiving readiness via DMA dmaSetCtrlPacket( DMA_CH1, pcDMARecvControlRecord ); dmaSetChEnable( DMA_CH1, DMA_HW ); setSCI1DMAReceiveInterrupt(); @@ -598,13 +598,13 @@ COMM_BUFFER_T result = COMM_BUFFER_NOT_USED; U32 i; - // search for next priority CAN packet to transmit + // Search for next priority CAN packet to transmit for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) { if ( numberOfBytesInCommBuffer( CAN_OUT_BUFFERS[ i ] ) >= CAN_MESSAGE_PAYLOAD_SIZE ) { result = CAN_OUT_BUFFERS[ i ]; - break; // found highest priority packet to transmit - we're done + break; // Found highest priority packet to transmit - we're done } } @@ -624,17 +624,17 @@ U32 result = 0; COMM_BUFFER_T buffer = findNextHighestPriorityCANPacketToTransmit(); - // if a buffer is found with a packet to transmit, get packet from buffer and transmit it + // If a buffer is found with a packet to transmit, get packet from buffer and transmit it if ( buffer != COMM_BUFFER_NOT_USED ) { U08 data[ CAN_MESSAGE_PAYLOAD_SIZE ]; U32 dataSize = getFromCommBuffer( buffer, data, CAN_MESSAGE_PAYLOAD_SIZE ); CAN_MESSAGE_BOX_T mBox = buffer; // CAN message boxes and comm buffers are aligned - // if there's another CAN packet to send, send it + // If there's another CAN packet to send, send it if ( dataSize == CAN_MESSAGE_PAYLOAD_SIZE ) { - // we're transmitting another packet - signal transmitter is busy + // We're transmitting another packet - signal transmitter is busy signalCANXmitsInitiated(); // Remember packet data being transmitted here in case transmission fails and we need to re-send memcpy( lastCANPacketSent, data, CAN_MESSAGE_PAYLOAD_SIZE ); @@ -678,11 +678,11 @@ { result = getFromCommBuffer( COMM_BUFFER_OUT_UART_PC, pcXmitPacket, dataPend ); - // if there's data to transmit, transmit it + // If there's data to transmit, transmit it if ( result > 0 ) { signalSCI1XmitsInitiated(); - pcDMAXmitControlRecord.FRCNT = result; // set DMA transfer size + pcDMAXmitControlRecord.FRCNT = result; // Set DMA transfer size dmaSetCtrlPacket( DMA_CH3, pcDMAXmitControlRecord ); dmaSetChEnable( DMA_CH3, DMA_HW ); setSCI1DMATransmitInterrupt(); @@ -708,77 +708,77 @@ *************************************************************************/ static void processIncomingData( void ) { - U08 data[ 512 ]; // message work space + U08 data[ 512 ]; // Message work space U32 i; BOOL badCRCDetected = FALSE; - // queue any received messages + // Queue any received messages for ( i = 0; i < NUM_OF_MSG_IN_BUFFERS; i++ ) { - BOOL messagesInBuffer = TRUE; // assume true at first to get into while loop + BOOL messagesInBuffer = TRUE; // Assume true at first to get into while loop while ( TRUE == messagesInBuffer ) { U32 numOfBytesInBuffer; - // assume false so we don't get stuck in loop - only set to true if we find another complete message in buffer + // Assume false so we don't get stuck in loop - only set to true if we find another complete message in buffer messagesInBuffer = FALSE; - // since messages can have 8-byte alignment padding left unconsumed by last get, get padding out of buffer + // Since messages can have 8-byte alignment padding left unconsumed by last get, get padding out of buffer consumeBufferPaddingBeforeSync( MSG_IN_BUFFERS[ i ] ); - // do we have enough bytes in buffer for smallest message? + // Do we have enough bytes in buffer for smallest message? numOfBytesInBuffer = numberOfBytesInCommBuffer( MSG_IN_BUFFERS[ i ] ); if ( numOfBytesInBuffer >= MESSAGE_OVERHEAD_SIZE ) - { // peek at minimum of all bytes available or max message size (+1 for sync byte) + { // Peek at minimum of all bytes available or max message size (+1 for sync byte) U32 bytesPeeked = peekFromCommBuffer( MSG_IN_BUFFERS[ i ], data, MIN( numOfBytesInBuffer, sizeof( MESSAGE_WRAPPER_T ) + 1 ) ); S32 msgSize = parseMessageFromBuffer( data, bytesPeeked ); - hdIsOnlyCANNode = FALSE; // if we're getting a message, we can't be alone + hdIsOnlyCANNode = FALSE; // If we're getting a message, we can't be alone canXmitRetryCtr = 0; - if ( msgSize > 0 ) // valid, complete message found? + if ( msgSize > 0 ) // Valid, complete message found? { MESSAGE_WRAPPER_T rcvMsg; - U08 *dataPtr = data+1; // skip over sync byte + U08 *dataPtr = data+1; // Skip over sync byte - // consume message (+sync byte) + // Consume message (+sync byte) msgSize = getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, msgSize + 1 ); - // convert received message data to a message and add to message queue - messagesInBuffer = TRUE; // keep processing this buffer - // blank the new message record + // Convert received message data to a message and add to message queue + messagesInBuffer = TRUE; // Keep processing this buffer + // Blank the new message record blankMessageInWrapper( &rcvMsg ); - // copy message header portion of message data to the new message + // Copy message header portion of message data to the new message memcpy( &(rcvMsg.msg.hdr), dataPtr, sizeof(MESSAGE_HEADER_T) ); dataPtr += sizeof(MESSAGE_HEADER_T); - // copy message payload portion of message data to the new message + // Copy message payload portion of message data to the new message memcpy( &(rcvMsg.msg.payload), dataPtr, rcvMsg.msg.hdr.payloadLen ); dataPtr += rcvMsg.msg.hdr.payloadLen; - // copy CRC portion of message data to the new message + // Copy CRC portion of message data to the new message rcvMsg.crc = *dataPtr; - // add new message to queue for later processing + // Add new message to queue for later processing addToMsgQueue( MSG_Q_IN, &rcvMsg ); - // if message from DG broadcast channel, update DG comm status + // If message from DG broadcast channel, update DG comm status if ( COMM_BUFFER_IN_CAN_DG_BROADCAST == MSG_IN_BUFFERS[ i ] ) { dgIsCommunicating = TRUE; timeOfLastDGCheckIn = getMSTimerCount(); } } - else if ( -1 == msgSize ) // candidate message with bad CRC found? + else if ( -1 == msgSize ) // Candidate message with bad CRC found? { badCRCDetected = TRUE; #ifdef EMC_TEST_BUILD badCANCount++; broadcastCANErrorCount( badCANCount ); #endif - getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, 1 ); // consume sync byte so we can re-sync - messagesInBuffer = TRUE; // keep processing this buffer - } // looks like there is a complete message in the comm buffer - } // enough data left in comm buffer to possibly be a complete message - } // while loop to get all complete messages for each comm buffer - } // for loop to check all comm buffers for messages + getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, 1 ); // Consume sync byte so we can re-sync + messagesInBuffer = TRUE; // Keep processing this buffer + } // Looks like there is a complete message in the comm buffer + } // Enough data left in comm buffer to possibly be a complete message + } // While loop to get all complete messages for each comm buffer + } // For loop to check all comm buffers for messages - // if any bad CRCs detected, see if too many + // If any bad CRCs detected, see if too many if ( TRUE == badCRCDetected ) { checkTooManyBadMsgCRCs(); @@ -799,15 +799,15 @@ U08 data; U32 numOfBytesInBuffer = numberOfBytesInCommBuffer( buffer ); - // consume bytes out of buffer 1 at a time until we find the sync byte or it's empty + // Consume bytes out of buffer 1 at a time until we find the sync byte or it's empty while ( numOfBytesInBuffer > 0 ) { peekFromCommBuffer( buffer, &data, 1 ); if ( MESSAGE_SYNC_BYTE == data ) { - break; // we found a sync - we're done + break; // We found a sync - we're done } - else // not a sync byte, so consume it + else // Not a sync byte, so consume it { getFromCommBuffer( buffer, &data, 1 ); numOfBytesInBuffer = numberOfBytesInCommBuffer( buffer ); @@ -835,27 +835,27 @@ for ( i = 0; i < len; i++ ) { - // find sync byte + // Find sync byte if ( MESSAGE_SYNC_BYTE == data[ i ] ) { - U32 pos = i + 1; // skip past sync byte implemented + U32 pos = i + 1; // Skip past sync byte implemented U32 remSize = len - pos; - // if a minimum sized msg would fit in remaining, continue + // If a minimum sized msg would fit in remaining, continue if ( remSize >= MESSAGE_OVERHEAD_SIZE ) { payloadSize = data[ pos + sizeof(MESSAGE_HEADER_T) - sizeof(U08) ]; msgSize = MESSAGE_OVERHEAD_SIZE + payloadSize; - // we now know the size of the message - we can now know if full message is contained in buffer + // We now know the size of the message - we can now know if full message is contained in buffer if ( msgSize <= remSize ) - { // check CRC to make sure it's a valid message + { // Check CRC to make sure it's a valid message if ( data[i+msgSize] == crc8( &data[pos], msgSize - 1 ) ) { - result = msgSize; // we found a complete, valid message of this size + result = msgSize; // We found a complete, valid message of this size } else // CRC failed { - result = -1; // we found a complete, invalid message + result = -1; // We found a complete, invalid message } } } @@ -876,30 +876,30 @@ *************************************************************************/ static void processReceivedMessages( void ) { - BOOL isThereMsgRcvd = TRUE; // assume TRUE at first to get into while loop + BOOL isThereMsgRcvd = TRUE; // Assume TRUE at first to get into while loop MESSAGE_WRAPPER_T message; while ( TRUE == isThereMsgRcvd ) { - // see if any messages received + // See if any messages received isThereMsgRcvd = getFromMsgQueue( MSG_Q_IN, &message ); if ( TRUE == isThereMsgRcvd ) { // CRC should be good because we checked it during parsing before adding to queue - but check it again for good measure if ( message.crc == crc8( (U08*)(&message), sizeof(MESSAGE_HEADER_T) + message.msg.hdr.payloadLen ) ) { - // if ACK, mark pending message ACK'd + // If ACK, mark pending message ACK'd if ( MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK == message.msg.hdr.msgID ) { matchACKtoPendingACKList( message.msg.hdr.seqNo ); } else { - // if received message requires ACK, queue one up + // If received message requires ACK, queue one up if ( message.msg.hdr.seqNo < 0 ) { sendACKMsg( &message.msg ); } - // process the received message + // Process the received message processReceivedMessage( &message.msg ); } } @@ -981,10 +981,10 @@ BOOL result = FALSE; U32 i; - // find first open slot in pending ACK list and add given msg data to it + // Find first open slot in pending ACK list and add given msg data to it for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { - _disable_IRQ(); // slot selection needs interrupt protection + _disable_IRQ(); // Slot selection needs interrupt protection if ( FALSE == pendingAckList[ i ].used ) { S16 seqNo = msg->hdr.seqNo * -1; // Remove ACK bit from seq # @@ -1026,7 +1026,7 @@ BOOL result = FALSE; U32 i; - // find match + // Find match for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { if ( ( TRUE == pendingAckList[ i ].used ) && ( pendingAckList[ i ].seqNo == seqNo ) ) @@ -1053,25 +1053,25 @@ { U32 i; - // find expired messages pending ACK + // Find expired messages pending ACK for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) - { // pending ACK expired? + { // Pending ACK expired? if ( ( TRUE == pendingAckList[ i ].used ) && ( TRUE == didTimeout( pendingAckList[ i ].timeStamp, MSG_NOT_ACKED_TIMEOUT_MS ) ) ) - { // if retries left, reset and resend pending message + { // If retries left, reset and resend pending message if ( pendingAckList[ i ].retries > 0 ) { // Re-queue message for transmit pendingAckList[ i ].retries--; pendingAckList[ i ].timeStamp = getMSTimerCount(); addToCommBuffer( pendingAckList[ i ].channel, (U08*)pendingAckList[ i ].msg, pendingAckList[ i ].msgSize ); } - // if no retries left, alarm + // If no retries left, alarm else { U16 msgID; memcpy( &msgID, (U08*)&pendingAckList[ i ].msg[ sizeof( U08 ) + sizeof( U16) ], sizeof( U16 ) ); SET_ALARM_WITH_1_U32_DATA( ALARM_ID_CAN_MESSAGE_NOT_ACKED, (U32)msgID ); - pendingAckList[ i ].used = FALSE; // take pending message off of list + pendingAckList[ i ].used = FALSE; // Take pending message off of list } } } @@ -1089,7 +1089,7 @@ { U16 msgID = message->hdr.msgID; - // handle any messages from other sub-systems + // Handle any messages from other sub-systems switch ( msgID ) { case MSG_ID_OFF_BUTTON_PRESS: @@ -1209,7 +1209,7 @@ break; } - // handle any test messages if tester has logged in successfully + // Handle any test messages if tester has logged in successfully if ( ( msgID > MSG_ID_FIRST_TESTER_MESSAGE ) && ( msgID <= END_OF_MSG_IDS ) && ( TRUE == isTestingActivated() ) ) { switch ( msgID ) Index: firmware/App/Services/SystemComm.h =================================================================== diff -u -r6a414654391c1729525d55812abbf111ddef7d6a -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/SystemComm.h (.../SystemComm.h) (revision 6a414654391c1729525d55812abbf111ddef7d6a) +++ firmware/App/Services/SystemComm.h (.../SystemComm.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -44,7 +44,7 @@ #define MIN_MSG_SEQ_NO 0x0001 ///< Minimum sequence number for Denali message. #define MAX_ACK_MSG_SIZE ( sizeof( MESSAGE_WRAPPER_T ) + 1 + CAN_MESSAGE_PAYLOAD_SIZE ) ///< Maximum size (in bytes) of Denali message including full (wrapped) message + sync + any CAN padding) -typedef COMM_BUFFER_T CAN_MESSAGE_BOX_T; ///< the CAN comm buffers align with the active CAN message boxes +typedef COMM_BUFFER_T CAN_MESSAGE_BOX_T; ///< The CAN comm buffers align with the active CAN message boxes // ********** public function prototypes ********** Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include // for memcpy() +#include // For memcpy() #include "reg_system.h" @@ -84,15 +84,15 @@ U32 sizeMod, sizePad; U32 i; U08 crc; - U08 data[ MAX_ACK_MSG_SIZE ]; // byte array to populate with message data + U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data - // prefix data with message sync byte + // Prefix data with message sync byte data[ msgSize++ ] = MESSAGE_SYNC_BYTE; - // set sequence # and ACK bit (unless this is an ACK to a received message) + // Set sequence # and ACK bit (unless this is an ACK to a received message) if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) { - // thread protect next sequence # access & increment + // Thread protect next sequence # access & increment _disable_IRQ(); msg.hdr.seqNo = nextSeqNo; nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); @@ -103,21 +103,21 @@ } } - // calculate message CRC + // Calculate message CRC crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); - // serialize message header data + // Serialize message header data memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); msgSize += sizeof( MESSAGE_HEADER_T ); - // serialize message payload (only used bytes per payloadLen field) + // Serialize message payload (only used bytes per payloadLen field) memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); msgSize += msg.hdr.payloadLen; - // add 8-bit CRC + // Add 8-bit CRC data[ msgSize++ ] = crc; - // pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) + // Pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); for ( i = 0; i < sizePad; i++ ) @@ -126,7 +126,7 @@ } #ifndef DISABLE_ACK_ERRORS - // if ACK required, add to pending ACK list + // If ACK required, add to pending ACK list if ( TRUE == ackReq ) { if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) @@ -139,7 +139,7 @@ if ( FALSE == error ) { - // add serialized message data to appropriate out-going comm buffer + // Add serialized message data to appropriate out-going comm buffer result = addToCommBuffer( buffer, data, msgSize ); } @@ -160,16 +160,16 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); - // send ACK back with same seq. #, but w/o ACK bit + // Send ACK back with same seq. #, but w/o ACK bit msg.hdr.seqNo = message->hdr.seqNo * -1; // ACK messages always have this ID msg.hdr.msgID = MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK; // ACK messages always have no payload msg.hdr.payloadLen = 0; - // serialize and queue the message for transmit on broadcast channel + // Serialize and queue the message for transmit on broadcast channel result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; @@ -192,13 +192,13 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; msg.hdr.payloadLen = sizeof( U08 ); msg.payload[ 0 ] = (U08)ack; - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); return result; @@ -222,13 +222,13 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; msg.hdr.payloadLen = sizeof( U08 ); msg.payload[ 0 ] = cmd; - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_NOT_REQUIRED ); return result; @@ -257,7 +257,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( S32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( F32 ); @@ -278,7 +278,7 @@ payloadPtr += sizeof( F32 ); memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -304,7 +304,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ); @@ -319,7 +319,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -344,7 +344,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); @@ -357,7 +357,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -382,7 +382,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); @@ -395,7 +395,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &dialRate, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -417,14 +417,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE; msg.hdr.payloadLen = sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ); memcpy( payloadPtr, (U08*)data, sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -450,7 +450,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( U32 ); @@ -467,7 +467,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &maxDialRate, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -489,7 +489,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ); @@ -498,7 +498,7 @@ payloadPtr += sizeof( F32 ); memcpy( payloadPtr, &trimmer, sizeof( F32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -519,14 +519,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &activeReservoir, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -547,14 +547,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_FILL_CMD; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &fillToVolumeMl, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -577,14 +577,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; msg.hdr.payloadLen = sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ); memcpy( payloadPtr, payload, sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -605,14 +605,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( payloadPtr, &start, sizeof( BOOL ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -634,14 +634,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( payloadPtr, &start, sizeof( BOOL ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -660,12 +660,12 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; msg.hdr.payloadLen = 0; - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_DG, ACK_REQUIRED ); return result; @@ -695,7 +695,7 @@ U08 *payloadPtr = msg.payload; ACCEL_DATA_PAYLOAD_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_ACCELEROMETER_DATA; msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); @@ -711,7 +711,7 @@ memcpy( payloadPtr, &payload, sizeof( ACCEL_DATA_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -733,7 +733,7 @@ U08 *payloadPtr = msg.payload; ALARM_COMP_STATUS_PAYLOAD_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_STATUS; msg.hdr.payloadLen = sizeof( ALARM_COMP_STATUS_PAYLOAD_T ); @@ -758,7 +758,7 @@ memcpy( payloadPtr, &payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_ALARM, ACK_NOT_REQUIRED ); return result; @@ -781,7 +781,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) * 2 * 2; // 2 alarm data recs w/ 2 32-bit values each @@ -796,7 +796,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &almData2.data, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_ALARM, ACK_REQUIRED ); return result; @@ -817,14 +817,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_CLEARED; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &alarm, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_ALARM, ACK_REQUIRED ); return result; @@ -846,14 +846,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_CONDITION_CLEARED; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &alarm, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_ALARM, ACK_REQUIRED ); return result; @@ -874,14 +874,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_BLOOD_FLOW_DATA; msg.hdr.payloadLen = sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ); memcpy( payloadPtr, bloodData, sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -902,14 +902,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DIALYSATE_FLOW_DATA; msg.hdr.payloadLen = sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ); memcpy( payloadPtr, dialInData, sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -930,14 +930,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DIALYSATE_OUT_FLOW_DATA; msg.hdr.payloadLen = sizeof( DIAL_OUT_FLOW_DATA_T ); memcpy( payloadPtr, dialOutFlowData, sizeof( DIAL_OUT_FLOW_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -958,14 +958,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_PRESSURE_OCCLUSION_DATA; msg.hdr.payloadLen = sizeof( PRESSURE_OCCLUSION_DATA_T ); memcpy( payloadPtr, &data, sizeof( PRESSURE_OCCLUSION_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -986,14 +986,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_RTC_EPOCH; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &epoch, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1017,7 +1017,7 @@ U08 *payloadPtr = msg.payload; TREATMENT_TIME_DATA_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_TIME; msg.hdr.payloadLen = sizeof( TREATMENT_TIME_DATA_T ); @@ -1028,7 +1028,7 @@ memcpy( payloadPtr, &payload, sizeof( TREATMENT_TIME_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1052,7 +1052,7 @@ U08 *payloadPtr = msg.payload; TREATMENT_STATE_DATA_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_STATE; msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); @@ -1064,7 +1064,7 @@ memcpy( payloadPtr, &payload, sizeof( TREATMENT_STATE_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1083,12 +1083,12 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_POWER_OFF_WARNING; msg.hdr.payloadLen = 0; - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1109,7 +1109,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_OP_MODE; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); @@ -1118,7 +1118,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &subMode, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1138,14 +1138,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_VALVES_DATA; msg.hdr.payloadLen = sizeof( HD_VALVE_DATA_T ); memcpy( payloadPtr, valveData, sizeof( HD_VALVE_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1165,14 +1165,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_SALINE_BOLUS_DATA; msg.hdr.payloadLen = sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ); memcpy( payloadPtr, &data, sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1194,7 +1194,7 @@ U32 lower = (U32)lowerLevel; U32 upper = (U32)upperLevel; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); @@ -1203,7 +1203,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &upper, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1216,14 +1216,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_CAN_ERROR_COUNT; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &count, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1330,7 +1330,7 @@ { if ( message->hdr.payloadLen == sizeof( U32 ) ) { - U32 *payloadPtr = message->payload; + U08 *payloadPtr = message->payload; U32 cmd; memcpy( &cmd, payloadPtr, sizeof( U32 ) ); @@ -1570,7 +1570,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); @@ -1581,7 +1581,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &ufState, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1606,15 +1606,15 @@ memcpy( &cmd, message->payload, sizeof(U32) ); - if ( 0 == cmd ) // initiate treatment (go to treatment params mode) + if ( 0 == cmd ) // Initiate treatment (go to treatment params mode) { result = signalUserStartingTreatment(); } - else if ( 1 == cmd ) // cancel treatment (return from aborted treatment params mode) + else if ( 1 == cmd ) // Cancel treatment (return from aborted treatment params mode) { result = signalUserCancelTreatment(); } - else if ( 2 == cmd ) // start treatment + else if ( 2 == cmd ) // Start treatment { result = signalUserBeginningTreatment(); } @@ -1640,7 +1640,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_START_TREATMENT_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); @@ -1649,7 +1649,7 @@ payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, &reason, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1692,14 +1692,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_TREATMENT_END_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ); memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1778,7 +1778,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; @@ -1787,7 +1787,7 @@ payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, rejectReasons, byteLength ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1835,7 +1835,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_SET_UF_VOLUME_PARAMETER_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ); @@ -1846,7 +1846,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &uFVolumeMl, sizeof( F32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -2030,7 +2030,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_SALINE_BOLUS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); @@ -2041,7 +2041,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &bolusVol, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -2089,22 +2089,22 @@ HD_VERSIONS_T payload; U08 *payloadPtr = msg.payload; - // populate payload + // Populate payload payload.major = (U08)HD_VERSION_MAJOR; payload.minor = (U08)HD_VERSION_MINOR; payload.micro = (U08)HD_VERSION_MICRO; payload.build = (U16)HD_VERSION_BUILD; getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_VERSION; msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); - // fill message payload + // Fill message payload memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } @@ -2129,7 +2129,7 @@ { BOOL result; - // add serialized message data to appropriate comm buffer + // Add serialized message data to appropriate comm buffer result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); return result; @@ -2150,15 +2150,15 @@ U32 txtLen = strlen( (char*)str ); U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_DEBUG_EVENT; - msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // add 1 byte for null terminator + msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // Add 1 byte for null terminator if ( txtLen <= DEBUG_EVENT_MAX_TEXT_LEN ) { memcpy( payloadPtr, str, txtLen + 1 ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -2193,13 +2193,13 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; msg.hdr.payloadLen = sizeof( U08 ); msg.payload[ 0 ] = (U08)ack; - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_PC, ACK_NOT_REQUIRED ); return result; @@ -2216,12 +2216,12 @@ *************************************************************************/ void handleTesterLogInRequest( MESSAGE_T *message ) { - // verify pass code + // Verify pass code // TODO - placeholder - how do we want to authenticate tester? if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) { testerLoggedIn = TRUE; - checkInFromUI(); // allow tasks to begin normal processing when tester has logged in + checkInFromUI(); // Allow tasks to begin normal processing when tester has logged in } else { @@ -2245,7 +2245,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2278,7 +2278,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = 0; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2310,7 +2310,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = 0; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2342,7 +2342,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2374,7 +2374,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2406,7 +2406,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2438,7 +2438,7 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); @@ -2463,7 +2463,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2495,7 +2495,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2527,7 +2527,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2559,7 +2559,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2591,7 +2591,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2623,7 +2623,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2655,7 +2655,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2687,7 +2687,7 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); @@ -2712,7 +2712,7 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); @@ -2737,7 +2737,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2769,7 +2769,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2801,7 +2801,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2833,7 +2833,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2865,7 +2865,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2897,7 +2897,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2929,7 +2929,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2961,7 +2961,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2993,7 +2993,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3025,7 +3025,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3057,7 +3057,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3089,7 +3089,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3121,7 +3121,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3183,7 +3183,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3216,7 +3216,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3249,7 +3249,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3282,7 +3282,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3315,7 +3315,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3347,7 +3347,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3379,7 +3379,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3411,7 +3411,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3443,7 +3443,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3475,7 +3475,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3507,7 +3507,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3539,7 +3539,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3570,7 +3570,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) { ACCEL_CAL_PAYLOAD_T payload; @@ -3596,7 +3596,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3622,7 +3622,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3648,7 +3648,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) { CRITICAL_DATAS_T payload[2]; @@ -3673,7 +3673,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(U32) ) { U32 valve; @@ -3702,7 +3702,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3761,7 +3761,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3794,7 +3794,7 @@ OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) ); @@ -3827,7 +3827,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3859,7 +3859,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3890,12 +3890,12 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( 0 == message->hdr.payloadLen ) { - // tester must be logged in + // Tester must be logged in if ( TRUE == isTestingActivated() ) - { // s/w reset of processor + { // S/w reset of processor result = TRUE; // Reset will prevent this from getting transmitted though #ifndef _VECTORCAST_ systemREG1->SYSECR = (0x2) << 14; // Reset processor @@ -4024,18 +4024,18 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // get calibration data + // Get calibration data result = getCalibrationData( &cal ); if ( TRUE == result ) { - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); memcpy( payloadPtr, &cal, sizeof( CALIBRATION_DATA_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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 ); } } Index: firmware/App/Services/WatchdogMgmt.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Services/WatchdogMgmt.c (.../WatchdogMgmt.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -74,7 +74,7 @@ watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; watchdogSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; watchdogSelfTestTimerCount = 0; - // initialize task check-ins to false + // Initialize task check-ins to false for ( i = 0; i < NUM_OF_TASKS; i++ ) { watchdogTaskCheckedIn[ i ].data = FALSE; @@ -95,22 +95,22 @@ { BOOL allTasksCheckedIn; - // called by background task, so give bg task credit for checking in + // Called by background task, so give bg task credit for checking in checkInWithWatchdogMgmt( TASK_BG ); - // check to see if all monitored tasks have checked in + // Check to see if all monitored tasks have checked in allTasksCheckedIn = haveAllTasksCheckedIn(); - // if all monitored tasks checked in, pet watchdog and clear the slate + // If all monitored tasks checked in, pet watchdog and clear the slate if ( ( TRUE == allTasksCheckedIn ) && ( didTimeout( lastWatchdogPetTime, MIN_WATCHDOG_PET_INTERVAL_MS ) ) ) { petWatchdog(); resetWDTaskCheckIns(); } - // check to see if watchdog has expired + // Check to see if watchdog has expired if ( getCPLDWatchdogExpired() == PIN_SIGNAL_LOW ) { - // ignore expired watchdog until after watchdog POST + // Ignore expired watchdog until after watchdog POST if ( WATCHDOG_SELF_TEST_STATE_COMPLETE == watchdogSelfTestState ) { #ifndef DEBUG_ENABLED @@ -156,12 +156,12 @@ case WATCHDOG_SELF_TEST_STATE_START: watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_IN_PROGRESS; watchdogSelfTestTimerCount = getMSTimerCount(); - // no break here so we pass through directly to in progress processing + // No break here so we pass through directly to in progress processing case WATCHDOG_SELF_TEST_STATE_IN_PROGRESS: while ( FALSE == didTimeout( watchdogSelfTestTimerCount, WATCHDOG_POST_TIMEOUT_MS ) ) { - // waiting here for w.d. test period to prevent this task from checking in - watchdog should expire + // Waiting here for w.d. test period to prevent this task from checking in - watchdog should expire } if ( getCPLDWatchdogExpired() == PIN_SIGNAL_HIGH ) { @@ -185,7 +185,7 @@ break; case WATCHDOG_SELF_TEST_STATE_COMPLETE: - // if we get called in this state, assume we're doing self-test again + // If we get called in this state, assume we're doing self-test again watchdogSelfTestStatus = SELF_TEST_STATUS_IN_PROGRESS; watchdogSelfTestState = WATCHDOG_SELF_TEST_STATE_START; break; @@ -210,7 +210,7 @@ { U32 i; - // initialize task check-ins to false + // Initialize task check-ins to false for ( i = 0; i < NUM_OF_TASKS; i++ ) { watchdogTaskCheckedIn[ i ].data = FALSE; @@ -230,7 +230,7 @@ BOOL result = TRUE; U32 i; - // check that each task has checked in + // Check that each task has checked in for ( i = 0; i < NUM_OF_TASKS; i++ ) { if ( FALSE == hasTaskGeneralCheckedIn( i ) ) @@ -285,7 +285,7 @@ *************************************************************************/ static void petWatchdog( void ) { - // pulse the watchdog signal + // Pulse the watchdog signal toggleCPLDWatchdog(); // Remember when we last pet the watchdog Index: firmware/App/Tasks/TaskBG.c =================================================================== diff -u -rc67def50892f9a7c2f1f22985b5351465a8f6773 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision c67def50892f9a7c2f1f22985b5351465a8f6773) +++ firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -50,11 +50,11 @@ { startUICommTimeout = getMSTimerCount(); -#ifndef _VECTORCAST_ // can't have infinite loop in unit test tool +#ifndef _VECTORCAST_ // Can't have infinite loop in unit test tool while ( 1 ) #endif { - // wait for UI to come up after power up + // Wait for UI to come up after power up if ( FALSE == uiCommunicated() ) { #ifndef SIMULATE_UI @@ -65,7 +65,7 @@ #endif } - // manage the watchdog + // Manage the watchdog execWatchdogMgmt(); // Manage Non-volatile data manager Index: firmware/App/Tasks/TaskBG.h =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskBG.h (.../TaskBG.h) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Tasks/TaskBG.h (.../TaskBG.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -27,7 +27,7 @@ * @{ */ -// public function prototypes +// Public function prototypes void taskBackground( void ); Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r78c03fb021407eaf8d17dd0f74f6969443b397ce -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 78c03fb021407eaf8d17dd0f74f6969443b397ce) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -48,51 +48,51 @@ void taskGeneral( void ) { #ifdef TASK_TIMING_OUTPUT_ENABLED - // set GPIO high to indicate general task has begun executing + // Set GPIO high to indicate general task has begun executing setCPLDLampGreen( PIN_SIGNAL_HIGH ); #endif - // check in with watchdog manager - checkInWithWatchdogMgmt( TASK_GENERAL ); // do this first to keep timing consistent with watchdog management + // Check in with watchdog manager + checkInWithWatchdogMgmt( TASK_GENERAL ); // Do this first to keep timing consistent with watchdog management - // manage data received from other sub-systems + // Manage data received from other sub-systems execSystemCommRx(); - // prevent most processing until UI has started communicating + // Prevent most processing until UI has started communicating #ifndef SIMULATE_UI if ( TRUE == uiCommunicated() ) #endif { - // monitor pressure/occlusion sensors + // Monitor pressure/occlusion sensors execPresOccl(); // Run operation mode state machine execOperationModes(); - // control air trap valve + // Control air trap valve execAirTrapController(); - // control blood pump + // Control blood pump execBloodFlowController(); - // control dialysate inlet pump + // Control dialysate inlet pump execDialInFlowController(); - // control dialysate outlet pump + // Control dialysate outlet pump execDialOutFlowController(); - // manage RTC + // Manage RTC execRTC(); - // manage alarm state + // Manage alarm state execAlarmMgmt(); - // manage data to be transmitted to other sub-systems + // Manage data to be transmitted to other sub-systems execSystemCommTx(); } #ifdef TASK_TIMING_OUTPUT_ENABLED - // set GPIO low to indicate general task has finished executing + // Set GPIO low to indicate general task has finished executing setCPLDLampGreen( PIN_SIGNAL_LOW ); #endif } Index: firmware/App/Tasks/TaskGeneral.h =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskGeneral.h (.../TaskGeneral.h) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Tasks/TaskGeneral.h (.../TaskGeneral.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -29,11 +29,11 @@ * @{ */ -// public definitions +// Public definitions #define TASK_GENERAL_INTERVAL (50) ///< General task timer interrupt interval (in ms). -// public function prototypes +// Public function prototypes void taskGeneral( void ); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r1a685471524555a374854c0c9ec8e208e71fe2df -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 1a685471524555a374854c0c9ec8e208e71fe2df) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -45,11 +45,11 @@ void taskPriority( void ) { #ifdef TASK_TIMING_OUTPUT_ENABLED - // set GPIO high to indicate priority task has begun executing + // Set GPIO high to indicate priority task has begun executing setCPLDLampRed( PIN_SIGNAL_HIGH ); #endif - // prevent most processing until UI has started communicating + // Prevent most processing until UI has started communicating #ifndef SIMULATE_UI if ( TRUE == uiCommunicated() ) #endif @@ -58,26 +58,26 @@ execFPGAIn(); #ifndef CAN_TEST - // monitor and process buttons + // Monitor and process buttons execButtons(); - // monitor internal ADC channels + // Monitor internal ADC channels execInternalADC(); - // monitor air trap level sensors + // Monitor air trap level sensors execAirTrapMonitor(); - // monitor blood pump and flow + // Monitor blood pump and flow execBloodFlowMonitor(); - // monitor dialysate inlet pump and flow + // Monitor dialysate inlet pump and flow execDialInFlowMonitor(); - // monitor dialysate outlet pump and load cells + // Monitor dialysate outlet pump and load cells execDialOutFlowMonitor(); #ifndef DISABLE_ACCELS - // monitor accelerometer + // Monitor accelerometer execAccel(); #endif #ifndef DISABLE_3WAY_VALVES @@ -89,11 +89,11 @@ execFPGAOut(); } - // check in with watchdog manager + // Check in with watchdog manager checkInWithWatchdogMgmt( TASK_PRIORITY ); #ifdef TASK_TIMING_OUTPUT_ENABLED - // set GPIO low to indicate priority task has finished executing + // Set GPIO low to indicate priority task has finished executing setCPLDLampRed( PIN_SIGNAL_LOW ); #endif } Index: firmware/App/Tasks/TaskPriority.h =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskPriority.h (.../TaskPriority.h) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Tasks/TaskPriority.h (.../TaskPriority.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -28,11 +28,11 @@ * @{ */ -// public definitions +// Public definitions #define TASK_PRIORITY_INTERVAL (10) ///< Priority task timer interrupt interval (in ms). -// public function prototypes +// Public function prototypes void taskPriority( void ); Index: firmware/App/Tasks/TaskTimer.c =================================================================== diff -u -rc67def50892f9a7c2f1f22985b5351465a8f6773 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskTimer.c (.../TaskTimer.c) (revision c67def50892f9a7c2f1f22985b5351465a8f6773) +++ firmware/App/Tasks/TaskTimer.c (.../TaskTimer.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -37,18 +37,18 @@ void taskTimer( void ) { #ifdef TASK_TIMING_OUTPUT_ENABLED - // set GPIO high to indicate timer task has begun executing + // Set GPIO high to indicate timer task has begun executing setCPLDLampBlue( PIN_SIGNAL_HIGH ); #endif - // increment ms timer count + // Increment ms timer count incMSTimerCount(); - // check in with watchdog manager + // Check in with watchdog manager checkInWithWatchdogMgmt( TASK_TIMER ); #ifdef TASK_TIMING_OUTPUT_ENABLED - // set GPIO low to indicate timer task has finished executing + // Set GPIO low to indicate timer task has finished executing setCPLDLampBlue( PIN_SIGNAL_LOW ); #endif } Index: firmware/App/Tasks/TaskTimer.h =================================================================== diff -u -rd91a24c730aeb5cd7e3eba9ef4eca78e442911f8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/App/Tasks/TaskTimer.h (.../TaskTimer.h) (revision d91a24c730aeb5cd7e3eba9ef4eca78e442911f8) +++ firmware/App/Tasks/TaskTimer.h (.../TaskTimer.h) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -27,11 +27,11 @@ * @{ */ -// public definitions +// Public definitions #define TASK_TIMER_INTERVAL (1) ///< Timer task timer interrupt interval (in ms). -// public function prototypes +// Public function prototypes void taskTimer( void ); Index: firmware/source/sys_main.c =================================================================== diff -u -r37a8a58b766a496b39241dd7ae46dc10dbda35e4 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/source/sys_main.c (.../sys_main.c) (revision 37a8a58b766a496b39241dd7ae46dc10dbda35e4) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -107,12 +107,12 @@ { /* USER CODE BEGIN (3) */ - initProcessor(); // configure processor - initSoftware(); // initialize software modules - initHardware(); // configure external hardware - initTasks(); // setup and start the scheduled tasks + initProcessor(); // Configure processor + initSoftware(); // Initialize software modules + initHardware(); // Configure external hardware + initTasks(); // Setup and start the scheduled tasks - // start task background (will not return) + // Start task background (will not return) #ifndef _VECTORCAST_ taskBackground(); #endif @@ -135,11 +135,11 @@ *************************************************************************/ static void initProcessor( void ) { - gioInit(); // configure GPIO pins - hetInit(); // configure HET1 - adcInit(); // configure internal ADC channels - mibspiInit(); // re-purposing MIBSPI5 I/O/C pins as GPIO - etpwmInit(); // configure PWMs + gioInit(); // Configure GPIO pins + hetInit(); // Configure HET1 + adcInit(); // Configure internal ADC channels + mibspiInit(); // Re-purposing MIBSPI5 I/O/C pins as GPIO + etpwmInit(); // Configure PWMs etpwmSetCmpA( etpwmREG1, 0 ); etpwmSetCmpA( etpwmREG2, 0 ); etpwmSetCmpA( etpwmREG3, 0 ); @@ -150,7 +150,7 @@ canInit(); // CAN1 = CAN, re-purposing CAN2 and CAN3 Rx and Tx pins as GPIO //canEnableloopback( canREG1, External_Lbk ); // TODO - debug code sciInit(); // SCI1 used for PC serial interface, SCI2 used for FPGA serial interface - dmaEnable(); // enable DMA + dmaEnable(); // Enable DMA } /************************************************************************* @@ -162,36 +162,36 @@ *************************************************************************/ static void initSoftware( void ) { - // initialize ms timer counter + // Initialize ms timer counter initTimers(); - // initialize alarm manager + // Initialize alarm manager initAlarmMgmt(); - // initialize drivers + // Initialize drivers initCPLD(); initSafetyShutdown(); initInternalADC(); initRTC(); - // initialize services + // Initialize services initCommBuffers(); initFPGA(); initMsgQueues(); initNVDataMgmt(); initSystemComm(); initWatchdogMgmt(); - // initialize monitors + // Initialize monitors initAccel(); initButtons(); initPresOccl(); - // initialize controllers + // Initialize controllers initAirTrap(); initAlarmLamp(); initBloodFlow(); initDialInFlow(); initDialOutFlow(); initValves(); - // initialize modes + // Initialize modes initOperationModes(); - // initialize async interrupt handlers + // Initialize async interrupt handlers initInterrupts(); } @@ -215,13 +215,13 @@ *************************************************************************/ static void initTasks( void ) { - // initialize RTI to setup the 3 tasks + // Initialize RTI to setup the 3 tasks rtiInit(); rtiEnableNotification( rtiNOTIFICATION_COMPARE0 | rtiNOTIFICATION_COMPARE1 | rtiNOTIFICATION_COMPARE3 ); rtiStartCounter( rtiCOUNTER_BLOCK0 ); - // the timer task requires FIQ enabled + // The timer task requires FIQ enabled _enable_FIQ(); - // the general and priority tasks require IRQ enabled + // The general and priority tasks require IRQ enabled _enable_IRQ(); } Index: firmware/source/sys_startup.c =================================================================== diff -u -rbf7c3835ce5a7bcbc47c305fb2fe5490d0899db8 -r30f049651877229042e3f8700c8596e5b9a1e0f4 --- firmware/source/sys_startup.c (.../sys_startup.c) (revision bf7c3835ce5a7bcbc47c305fb2fe5490d0899db8) +++ firmware/source/sys_startup.c (.../sys_startup.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) @@ -636,7 +636,7 @@ vimInit(); /* USER CODE BEGIN (74) */ - // shuffle IRQ priorities per design requirements + // Shuffle IRQ priorities per design requirements vimChannelMap( 3, 40, &rtiCompare1Interrupt ); vimChannelMap( 5, 64, &rtiCompare3Interrupt ); vimChannelMap( 10, 3, &het1HighLevelInterrupt );