Index: firmware/App/Common.h =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Common.h (.../Common.h) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Common.h (.../Common.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -22,9 +22,9 @@ // ********** build switches ********** #ifndef _VECTORCAST_ -// #define RM46_EVAL_BOARD_TARGET 1 + #define RM46_EVAL_BOARD_TARGET 1 // #define SIMULATE_UI 1 -// #define DEBUG_ENABLED 1 + #define DEBUG_ENABLED 1 #ifdef DEBUG_ENABLED #include Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -29,14 +29,19 @@ // ********** private definitions ********** -#define BLOOD_FLOW_DATA_PUB_INTERVAL (1000 / TASK_PRIORITY_INTERVAL) // interval (ms) at which the blood flow data is published on the CAN bus +#define BLOOD_FLOW_DATA_PUB_INTERVAL (1000 / TASK_PRIORITY_INTERVAL) // interval (ms/task time) at which the blood flow data is published on the CAN bus #define MAX_BLOOD_FLOW_RATE 600 // mL/min #define MAX_BLOOD_PUMP_PWM_STEP_CHANGE 0.005 // duty cycle TODO - fixed or parameterized or set in motor controller? #define MAX_BLOOD_PUMP_PWM_DUTY_CYCLE 0.88 // controller will error if PWM duty cycle > 90%, so set max to 88% #define MIN_BLOOD_PUMP_PWM_DUTY_CYCLE 0.12 // controller will error if PWM duty cycle < 10%, so set min to 12% +#define BP_CONTROL_INTERVAL (200 / TASK_PRIORITY_INTERVAL) // interval (ms/task time) at which the blood pump is controlled +#define BP_P_COEFFICIENT 0.001 // P term for blood pump control +#define BP_I_COEFFICIENT 0.001 // I term for blood pump control +#define BP_MAX_ERROR_SUM 20.0 // for anti-wind-up in I term + #define BP_SPEED_ADC_TO_RPM_FACTOR 1.375 // conversion factor from ADC counts to RPM for blood pump motor TODO - set appropriate value #define BP_CURRENT_ADC_TO_MA_FACTOR 2.65 // conversion factor from ADC counts to mA for blood pump motor TODO - set appropriate value @@ -80,20 +85,22 @@ static BLOOD_PUMP_STATE_T bloodPumpState = BLOOD_PUMP_OFF_STATE; // current state of blood flow controller state machine static U32 bloodFlowDataPublicationTimerCounter = 0; // used to schedule blood flow data publication to CAN bus -// interval (in ms) at which to publish blood flow data to CAN bus -DATA_DECL( U32, BloodFlowDataPub, bloodFlowDataPublishInterval, BLOOD_FLOW_DATA_PUB_INTERVAL, BLOOD_FLOW_DATA_PUB_INTERVAL ); static BOOL isBloodPumpOn = FALSE; // blood pump is currently running static F32 bloodPumpPWMDutyCyclePct = 0.0; // initial blood pump PWM duty cycle static F32 bloodPumpPWMDutyCyclePctSet = 0.0; // currently set blood pump PWM duty cycle static MOTOR_DIR_T bloodPumpDirection = MOTOR_DIR_FORWARD; // requested blood flow direction static MOTOR_DIR_T bloodPumpDirectionSet = MOTOR_DIR_FORWARD; // currently set blood flow direction +DATA_DECL( U32, BloodFlowDataPub, bloodFlowDataPublishInterval, BLOOD_FLOW_DATA_PUB_INTERVAL, BLOOD_FLOW_DATA_PUB_INTERVAL ); // interval (in ms) at which to publish blood flow data to CAN bus DATA_DECL( S32, TargetBloodFlowRate, targetBloodFlowRate, 0, 0 ); // requested blood flow rate -static S32 targetBloodFlowRateSet = 0; // currently set blood flow rate DATA_DECL( F32, MeasuredBloodFlowRate, measuredBloodFlowRate, 0.0, 0.0 ); // measured blood flow rate DATA_DECL( F32, MeasuredBloodPumpSpeed, adcBloodPumpSpeedRPM, 0.0, 0.0 ); // measured blood pump speed DATA_DECL( F32, MeasuredBloodPumpCurrent, adcBloodPumpCurrentmA, 0.0, 0.0 ); // measured blood pump motor current +static F32 bpFlowError = 0.0; // blood flow error +static F32 bpFlowErrorSum = 0.0; // blood flow error sum +static U32 bpControlTimerCounter = 0; // determines when to perform control on blood flow + static BLOOD_FLOW_SELF_TEST_STATE_T bloodPumpSelfTestState = BLOOD_FLOW_SELF_TEST_STATE_START; // current blood pump self test state static U32 bloodPumpSelfTestTimerCount = 0; // timer counter for blood pump self test @@ -149,6 +156,10 @@ // 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 bloodPumpPWMDutyCyclePct = BP_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%) bloodPumpPWMDutyCyclePct = MIN(bloodPumpPWMDutyCyclePct,MAX_BLOOD_PUMP_PWM_DUTY_CYCLE); // limit pwm duty cycle to controller maximum + // reset flow control stats + bpFlowError = 0.0; + bpFlowErrorSum = 0.0; + bpControlTimerCounter = 0; switch ( bloodPumpState ) { @@ -164,7 +175,7 @@ bloodPumpState = BLOOD_PUMP_RAMPING_UP_STATE; } break; - case BLOOD_PUMP_CONTROL_TO_TARGET_STATE: // start ramp in appropriate direction + case BLOOD_PUMP_CONTROL_TO_TARGET_STATE: // start ramp to new target in appropriate direction if ( bloodPumpPWMDutyCyclePctSet > bloodPumpPWMDutyCyclePct ) { bloodPumpState = BLOOD_PUMP_RAMPING_DOWN_STATE; @@ -175,7 +186,7 @@ } break; default: - // ok - do nothing + // ok - not all states need to be handled here break; } result = TRUE; @@ -218,7 +229,7 @@ F32 tmp = getFPGADialysateFlow(); char debugFlowStr[256]; - sprintf( debugFlowStr, "Target Flow:%5d, Meas. Flow:%5d, Speed:%5d RPM, Current:%5d mA \n", flowStPt, (S32)measFlow, (S32)measSpd, (S32)measCurr ); + sprintf( debugFlowStr, "Target Flow:%5d, Meas. Flow:%5d, Speed:%5d RPM, Current:%5d mA, PWM%:%5d \n", flowStPt, (S32)measFlow, (S32)measSpd, (S32)measCurr, (S32)bloodPumpPWMDutyCyclePctSet ); sendDebugData( (U08*)debugFlowStr, strlen(debugFlowStr) ); #endif broadcastBloodFlowData( flowStPt, measFlow, measSpd, measCurr ); @@ -318,7 +329,6 @@ // have we reached end of ramp up? else if ( bloodPumpPWMDutyCyclePctSet >= bloodPumpPWMDutyCyclePct ) { - targetBloodFlowRateSet = getTargetBloodFlowRate(); result = BLOOD_PUMP_CONTROL_TO_TARGET_STATE; } // continue ramp up @@ -354,7 +364,6 @@ // have we reached end of ramp down? else if ( bloodPumpPWMDutyCyclePctSet <= bloodPumpPWMDutyCyclePct ) { - targetBloodFlowRateSet = getTargetBloodFlowRate(); result = BLOOD_PUMP_CONTROL_TO_TARGET_STATE; } // continue ramp down @@ -380,10 +389,28 @@ static BLOOD_PUMP_STATE_T handleBloodPumpControlToTargetState( void ) { BLOOD_PUMP_STATE_T result = BLOOD_PUMP_CONTROL_TO_TARGET_STATE; + F32 tgtFlow = (F32)getTargetBloodFlowRate(); + F32 actFlow = getMeasuredBloodFlowRate(); + F32 pTerm, iTerm; + F32 newPWM; - // TODO - control -//MAX_BLOOD_PUMP_PWM_DUTY_CYCLE -//MIN_BLOOD_PUMP_PWM_DUTY_CYCLE + // control at set interval + if ( ++bpControlTimerCounter >= BP_CONTROL_INTERVAL ) + { + // compute P term + bpFlowError = tgtFlow - actFlow; + pTerm = bpFlowError * BP_P_COEFFICIENT; + // compute I term + bpFlowErrorSum += bpFlowError; + iTerm = RANGE( bpFlowErrorSum, BP_MAX_ERROR_SUM * -1.0, BP_MAX_ERROR_SUM ); + iTerm *= BP_I_COEFFICIENT; + // compute new PWM duty cycle % for blood pump motor + newPWM = bloodPumpPWMDutyCyclePctSet + pTerm + iTerm; + newPWM = RANGE( newPWM, MIN_BLOOD_PUMP_PWM_DUTY_CYCLE, MAX_BLOOD_PUMP_PWM_DUTY_CYCLE ); + bloodPumpPWMDutyCyclePctSet = newPWM; + etpwmSetCmpA( etpwmREG1, (U32)(bloodPumpPWMDutyCyclePctSet * (F32)(etpwmREG1->TBPRD)) ); + bpControlTimerCounter = 0; + } return result; } @@ -400,7 +427,6 @@ static void stopBloodPump( void ) { isBloodPumpOn = FALSE; - targetBloodFlowRateSet = 0; bloodPumpPWMDutyCyclePctSet = 0.0; etpwmSetCmpA( etpwmREG1, 0 ); etpwmStopTBCLK(); Index: firmware/App/Controllers/Buttons.c =================================================================== diff -u -r8592c629e9e6e212c1325239a21ceb641f9dc1fe -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision 8592c629e9e6e212c1325239a21ceb641f9dc1fe) +++ firmware/App/Controllers/Buttons.c (.../Buttons.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -43,6 +43,7 @@ #define OFF_REQUEST_PULSE_INTVL 50 // ms #define STOP_BUTTON_PENDING_TIMEOUT 500 // ms #define STUCK_BUTTON_TIMEOUT 1000 // ms +#define OFF_REQUEST_EXPIRATION_TIME (1000*60) // ms (1 minute) #define USER_CONFIRMED 1 #define USER_REJECTED 0 @@ -51,16 +52,17 @@ DATA_DECL( BUTTON_STATE_T, OffButtonState, dataOffButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); static BUTTON_STATE_T prevOffButtonState = BUTTON_STATE_RELEASED; +static BOOL offRequestAwaitingUserConfirmation = FALSE; +static U32 offRequestPendingTimer = 0; static BOOL offButtonPressPending = FALSE; +static U32 offRequestPulseCount = 0; +static U32 offRequestPulseTimer = 0; DATA_DECL( BUTTON_STATE_T, StopButtonState, dataStopButtonState, BUTTON_STATE_RELEASED, BUTTON_STATE_PRESSED ); static BUTTON_STATE_T prevStopButtonState = BUTTON_STATE_RELEASED; static BOOL stopButtonPressPending = FALSE; static U32 stopButtonPendingTimer = 0; -static U32 offRequestPulseCount = 0; -static U32 offRequestPulseTimer = 0; - static BUTTON_SELF_TEST_STATE_T buttonSelfTestState = BUTTON_SELF_TEST_STATE_START; static U32 buttonSelfTestTimerCount = 0; @@ -82,15 +84,16 @@ void initButtons( void ) { prevOffButtonState = BUTTON_STATE_RELEASED; + offRequestAwaitingUserConfirmation = FALSE; + offRequestPendingTimer = 0; offButtonPressPending = FALSE; + offRequestPulseCount = 0; + offRequestPulseTimer = 0; prevStopButtonState = BUTTON_STATE_RELEASED; stopButtonPressPending = FALSE; stopButtonPendingTimer = 0; - offRequestPulseCount = 0; - offRequestPulseTimer = 0; - buttonSelfTestState = BUTTON_SELF_TEST_STATE_START; buttonSelfTestTimerCount = 0; } @@ -165,35 +168,6 @@ DATA_GET( BUTTON_STATE_T, getStopButtonState, dataStopButtonState ) /************************************************************************* - * @brief userConfirmOffButton - * The userConfirmOffButton function handles user confirmation of the off \n - * button. The off request will be initiated here if confirmed or cancelled \n - * if rejected by user. - * @details - * Inputs : current operation mode - * Outputs : stopButtonPressPending - * @param response : 1 = confirmed, 0 = rejected - * @return none - *************************************************************************/ -void userConfirmOffButton( U08 response ) -{ - // did user confirm? - if ( USER_CONFIRMED == response ) - { - if ( TRUE == isCurrentOpModeOkToTurnOff() ) - { - offButtonPressPending = TRUE; - offRequestPulseCount = OFF_REQUEST_PULSE_COUNT; - offRequestPulseTimer = 0; - } - } - else // user did not confirm - { - // for now, don't need to do anything to reject off button press - } -} - -/************************************************************************* * @brief execStuckButtonTest * The execStuckButtonTest function executes the stuck button test. \n * This function should be called periodically until a pass or fail \n @@ -247,6 +221,39 @@ } /************************************************************************* + * @brief userConfirmOffButton + * The userConfirmOffButton function handles user confirmation of the off \n + * button. The off request will be initiated here if confirmed or cancelled \n + * if rejected by user. + * @details + * Inputs : current operation mode + * Outputs : stopButtonPressPending + * @param response : 1 = confirmed, 0 = rejected + * @return none + *************************************************************************/ +void userConfirmOffButton( U08 response ) +{ + // is an off request pending user confirmation? + if ( TRUE == offRequestAwaitingUserConfirmation ) + { + // did user confirm? + if ( USER_CONFIRMED == response ) + { + if ( TRUE == isCurrentOpModeOkToTurnOff() ) + { + offButtonPressPending = TRUE; + offRequestPulseCount = OFF_REQUEST_PULSE_COUNT; + offRequestPulseTimer = 0; + } + } + else // user did not confirm + { + offRequestAwaitingUserConfirmation = FALSE; + } + } +} + +/************************************************************************* * @brief isCurrentOpModeOkToTurnOff * The isCurrentOpModeOkToTurnOff function determines whether the system can \n * be turned off in current operation mode. @@ -290,7 +297,9 @@ if ( TRUE == isCurrentOpModeOkToTurnOff() ) { // send off button to UI for user confirmation - sendOffButtonMsgToUI(); + sendOffButtonMsgToUI( TRUE ); + offRequestAwaitingUserConfirmation = TRUE; + offRequestPendingTimer = 0; #ifdef SIMULATE_UI userConfirmOffButton( USER_CONFIRMED ); #endif @@ -299,6 +308,17 @@ prevOffButtonState = getOffButtonState(); } + // if off request has not been confirmed by user before it expires, cancel it + if ( TRUE == offRequestAwaitingUserConfirmation ) + { + offRequestPendingTimer += TASK_PRIORITY_INTERVAL; + if ( offRequestPendingTimer >= OFF_REQUEST_EXPIRATION_TIME ) + { + offRequestAwaitingUserConfirmation = FALSE; + sendOffButtonMsgToUI( FALSE ); + } + } + // if user confirmed off button press, manage off request sequence if ( TRUE == offButtonPressPending ) { Index: firmware/App/Drivers/CPLD.c =================================================================== diff -u -r90f6438e80dbe0a32472a076a0d1bc54db65d15a -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision 90f6438e80dbe0a32472a076a0d1bc54db65d15a) +++ firmware/App/Drivers/CPLD.c (.../CPLD.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -22,12 +22,6 @@ #include "WatchdogMgmt.h" #include "CPLD.h" -//#ifdef _VECTORCAST_ -// static mibspiBASE_t spi5; -// #undef mibspiREG5 -// #define mibspiREG5 ((mibspiBASE_t *)&spi5) -//#endif - // ********** private definitions ********** // GIO port A pin assignments for pins connected to CPLD @@ -234,6 +228,10 @@ { PIN_SIGNAL_STATE_T level = GET_OFF(); +#ifdef RM46_EVAL_BOARD_TARGET + level = (level == PIN_SIGNAL_LOW ? PIN_SIGNAL_HIGH : PIN_SIGNAL_LOW); +#endif + return level; } @@ -251,6 +249,10 @@ { PIN_SIGNAL_STATE_T level = GET_STOP(); +#ifdef RM46_EVAL_BOARD_TARGET + level = (level == PIN_SIGNAL_LOW ? PIN_SIGNAL_HIGH : PIN_SIGNAL_LOW); +#endif + return level; } Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -537,9 +537,10 @@ // 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] = 0x08; // start at FPGA address 8 + fpgaWriteCmdBuffer[1] = 0x03; // start at FPGA address 8 fpgaWriteCmdBuffer[2] = 0x00; fpgaWriteCmdBuffer[3] = sizeof(FPGA_ACTUATORS_T); + fpgaActuatorSetPoints.bloodValveSetState = 0x03; // TODO - remove memcpy( &(fpgaWriteCmdBuffer[FPGA_WRITE_CMD_HDR_LEN]), &fpgaActuatorSetPoints, sizeof(FPGA_ACTUATORS_T) ); crc = crc16( fpgaWriteCmdBuffer, FPGA_WRITE_CMD_HDR_LEN+sizeof(FPGA_ACTUATORS_T) ); fpgaWriteCmdBuffer[FPGA_WRITE_CMD_HDR_LEN+sizeof(FPGA_ACTUATORS_T)] = GET_MSB_OF_WORD( crc ); @@ -641,7 +642,11 @@ SELF_TEST_STATUS_T result; // check FPGA reported correct ID +#ifndef RM46_EVAL_BOARD_TARGET if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) +#else + if ( 1 ) +#endif { result = SELF_TEST_STATUS_PASSED; } Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -29,14 +29,34 @@ // ********** private data ********** -static U32 frameErrorCnt = 0; -static U32 overrunErrorCnt = 0; +static U32 sci1FrameErrorCnt = 0; +static U32 sci1OverrunErrorCnt = 0; +static U32 sci2FrameErrorCnt = 0; +static U32 sci2OverrunErrorCnt = 0; +static U32 can1PassiveCnt = 0; +static U32 can1WarningCnt = 0; +static U32 can1BusOffCnt = 0; +static U32 can1ParityCnt = 0; // ********** private function prototypes ********** /************************************************************************* + * @brief phantomInterrupt + * The phantomInterrupt function handles phantom interrupts. + * @details + * Inputs : none + * Outputs : phantom interrupt handled. + * @param none + * @return none + *************************************************************************/ +void phantomInterrupt(void) +{ + // TODO - what to do with phantom interrupts? +} + +/************************************************************************* * @brief canMessageNotification * The canMessageNotification function handles CAN message notifications. * @details @@ -48,10 +68,53 @@ *************************************************************************/ void canMessageNotification(canBASE_t *node, uint32 messageBox) { - handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); + if ( node == canREG1 ) + { + handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); + } } /************************************************************************* + * @brief canErrorNotification + * The canErrorNotification function handles CAN error notifications. + * @details + * Inputs : none + * Outputs : CAN error notification handled. + * @param node : which CAN controller + * @param notification : canLEVEL_PASSIVE (0x20) : When RX- or TX error counter are between 32 and 63 \n + * canLEVEL_WARNING (0x40) : When RX- or TX error counter are between 64 and 127 \n + * canLEVEL_BUS_OFF (0x80) : When RX- or TX error counter are between 128 and 255 \n + * canLEVEL_PARITY_ERR (0x100): When parity error detected on CAN RAM read access + * @return none + *************************************************************************/ +void canErrorNotification(canBASE_t *node, uint32 notification) +{ + if ( node == canREG1 ) + { + if ( notification & canLEVEL_PARITY_ERR ) + { + can1ParityCnt++; + } + else if ( notification & canLEVEL_BUS_OFF ) + { + can1BusOffCnt++; + } + else if ( notification & canLEVEL_WARNING ) + { + can1WarningCnt++; + } + else if ( notification & canLEVEL_PASSIVE ) + { + can1PassiveCnt++; + } + else + { + // ignore - other bits undefined + } + } +} + +/************************************************************************* * @brief sciNotification * The sciNotification function handles UART communication error interrupts. \n * Frame and Over-run errors are handled. @@ -64,16 +127,36 @@ *************************************************************************/ void sciNotification(sciBASE_t *sci, uint32 flags) { - if ( ( flags & SCI_FE_INT ) != 0 ) + if ( sci == sciREG ) { - frameErrorCnt++; - // TODO - clear and try to do something to recover (+ max retries = comm fault) + if ( ( flags & SCI_FE_INT ) != 0 ) + { + sci1FrameErrorCnt++; + // TODO - clear and try to do something to recover (+ max retries = comm fault) + } + if ( ( flags & SCI_OE_INT ) != 0 ) + { + sci1OverrunErrorCnt++; + // TODO - clear and try to do something to recover (+ max retries = comm fault) + } } - if ( ( flags & SCI_OE_INT ) != 0 ) + else if ( sci == scilinREG ) { - overrunErrorCnt++; - // TODO - clear and try to do something to recover (+ max retries = comm fault) + if ( ( flags & SCI_FE_INT ) != 0 ) + { + sci2FrameErrorCnt++; + // TODO - clear and try to do something to recover (+ max retries = comm fault) + } + if ( ( flags & SCI_OE_INT ) != 0 ) + { + sci2OverrunErrorCnt++; + // TODO - clear and try to do something to recover (+ max retries = comm fault) + } } + else + { + // TODO - ignore? - should not be any other SCI peripherals + } } /************************************************************************* Index: firmware/App/Services/SystemComm.h =================================================================== diff -u -r90f6438e80dbe0a32472a076a0d1bc54db65d15a -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Services/SystemComm.h (.../SystemComm.h) (revision 90f6438e80dbe0a32472a076a0d1bc54db65d15a) +++ firmware/App/Services/SystemComm.h (.../SystemComm.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -27,7 +27,7 @@ #define CAN_MESSAGE_PAYLOAD_SIZE 8 #define PC_MESSAGE_PACKET_SIZE 8 -typedef COMM_BUFFER_T CAN_MESSAGE_BOX_T; // the first 10 comm buffers align with the 10 active CAN message boxes +typedef COMM_BUFFER_T CAN_MESSAGE_BOX_T; // the first 12 comm buffers align with the 12 active CAN message boxes // ********** public function prototypes ********** Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -103,10 +103,11 @@ * @details * Inputs : none * Outputs : Off button msg constructed and queued. - * @param none + * @param promptUser : TRUE if UI should prompt user to confirm power off \n + * request, FALSE if UI should cancel the prompt. * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendOffButtonMsgToUI( void ) +BOOL sendOffButtonMsgToUI( BOOL promptUser ) { BOOL result; MESSAGE_T msg; @@ -117,6 +118,8 @@ blankMessage( &msg ); msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; msg.hdr.payloadLen = 0; +// msg.hdr.payloadLen = 1; +// msg.payload[0] = (U08)promptUser; // serialize the message (w/ sync, CRC, and appropriate CAN padding) msgSize = serializeMessage( msg, data ); Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 3417fd56afc9b21fb4c2d86c75dd33ac31fbd9f1) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -54,7 +54,7 @@ // ********** public function prototypes ********** // MSG_ID_OFF_BUTTON_PRESS -BOOL sendOffButtonMsgToUI( void ); +BOOL sendOffButtonMsgToUI( BOOL promptUser ); void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ); // MSG_ID_ALARM_STATUS Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r51c6a24b30643c8ce296ebfe1d703f289ffafe97 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 51c6a24b30643c8ce296ebfe1d703f289ffafe97) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -64,7 +64,7 @@ { lastUserPress = TRUE; setUserLED( FALSE ); - sendOffButtonMsgToUI(); + sendOffButtonMsgToUI(TRUE); } } else Index: firmware/HD.dil =================================================================== diff -u -r6c801cb0b32cba0e754cb6b1b57c1a8bd4e2bcf7 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/HD.dil (.../HD.dil) (revision 6c801cb0b32cba0e754cb6b1b57c1a8bd4e2bcf7) +++ firmware/HD.dil (.../HD.dil) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -1,4 +1,4 @@ -# RM46L852PGE 11/13/19 13:30:04 +# RM46L852PGE 11/27/19 14:53:01 # ARCH=RM46L852PGE # @@ -3311,7 +3311,7 @@ DRIVER.CAN.VAR.CAN_1_MESSAGE_37_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_1_MESSAGE_29_BOOL_ENA.VALUE=0 DRIVER.CAN.VAR.CAN_1_MESSAGE_6_INT_ENA.VALUE=0x00000800 -DRIVER.CAN.VAR.CAN_1_RAM_PARITY_ENA.VALUE=0x00000005 +DRIVER.CAN.VAR.CAN_1_RAM_PARITY_ENA.VALUE=0x0000000A DRIVER.CAN.VAR.CAN_1_MESSAGE_59_RTR.VALUE=0x00000000 DRIVER.CAN.VAR.CAN_3_MESSAGE_64_DLC.VALUE=8 DRIVER.CAN.VAR.CAN_3_MESSAGE_56_DLC.VALUE=8 Index: firmware/include/can.h =================================================================== diff -u -reff7b1575f008f81b29ef906f6346fac6012d3ab -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/include/can.h (.../can.h) (revision eff7b1575f008f81b29ef906f6346fac6012d3ab) +++ firmware/include/can.h (.../can.h) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -632,7 +632,7 @@ /* Configuration registers initial value for CAN1*/ #define CAN1_CTL_CONFIGVALUE ((uint32)0x00000200U \ | (uint32)0x00000000U \ - | (uint32)((uint32)0x00000005U << 10U) | 0x00020002U) + | (uint32)((uint32)0x0000000AU << 10U) | 0x00020002U) #define CAN1_ES_CONFIGVALUE 0x00000007U #define CAN1_BTR_CONFIGVALUE ((uint32)((uint32)0U << 16U) \ | (uint32)((uint32)(3U - 1U) << 12U) \ Index: firmware/source/can.c =================================================================== diff -u -r6c801cb0b32cba0e754cb6b1b57c1a8bd4e2bcf7 -rbe83f01a4d54cbd0d92b68cb95a15dcbb06a9a51 --- firmware/source/can.c (.../can.c) (revision 6c801cb0b32cba0e754cb6b1b57c1a8bd4e2bcf7) +++ firmware/source/can.c (.../can.c) (revision be83f01a4d54cbd0d92b68cb95a15dcbb06a9a51) @@ -106,7 +106,7 @@ */ canREG1->CTL = (uint32)0x00000200U | (uint32)0x00000000U - | (uint32)((uint32)0x00000005U << 10U) + | (uint32)((uint32)0x0000000AU << 10U) | (uint32)0x00020043U; /** - Clear all pending error flags and reset current status */