Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -rcdb087f7607a88b29c5ed4cdc9a76e3240fe42a3 -r2c1c34c153a146d659976b3aa499937b88264b1b --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision cdb087f7607a88b29c5ed4cdc9a76e3240fe42a3) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision 2c1c34c153a146d659976b3aa499937b88264b1b) @@ -1352,7 +1352,7 @@ bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].length = 5; bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + bloodLeakEmbModeCmd[ D_EMB_MODE_CMD ].isCmdRespRdy = FALSE; // Calibrate command bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].commandASCII = 67; @@ -1361,7 +1361,7 @@ bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].length = 4; bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].timeoutMS = 5 * MS_PER_SECOND; bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].commandResp = 0; - bloodLeakEmbModeCmd[ CS_EMB_MODE_CMD ].isCmdRespRdy = FALSE; + bloodLeakEmbModeCmd[ C_EMB_MODE_CMD ].isCmdRespRdy = FALSE; } /*********************************************************************//** Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r2a03f6c87706478406a4962d70f5bae2ccb57728 -r2c1c34c153a146d659976b3aa499937b88264b1b --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 2a03f6c87706478406a4962d70f5bae2ccb57728) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 2c1c34c153a146d659976b3aa499937b88264b1b) @@ -418,7 +418,7 @@ U08 artPresStatus = (U08)( fpgaArtPres >> SHIFT_14_BITS ); checkFPGAPersistentAlarms( FPGA_PERS_ERROR_ARTERIAL_PRESSURE_SENSOR, artReadCtr ); - //checkFPGAPersistentAlarms( FPGA_PERS_ERROR_VENOUS_PRESSURE_SESNOR, venReadCtr, venReadCtr ); // TODO investigate this with Noe + checkFPGAPersistentAlarms( FPGA_PERS_ERROR_VENOUS_PRESSURE_SESNOR, venReadCtr ); // TODO investigate this with Noe if ( ARTERIAL_PRESSURE_NORMAL_OP == artPresStatus ) { Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -r0a4dcd288d4347b85baaa0b07da568b6add5eac7 -r2c1c34c153a146d659976b3aa499937b88264b1b --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 0a4dcd288d4347b85baaa0b07da568b6add5eac7) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 2c1c34c153a146d659976b3aa499937b88264b1b) @@ -14,27 +14,27 @@ * @date (original) 05-Nov-2019 * ***************************************************************************/ - -#include -#include "can.h" -#include "het.h" -#include "rti.h" -#include "sci.h" -#include "sys_dma.h" - -#include "AlarmMgmt.h" -#include "BloodFlow.h" + +#include +#include "can.h" +#include "het.h" +#include "rti.h" +#include "sci.h" +#include "sys_dma.h" + +#include "AlarmMgmt.h" +#include "BloodFlow.h" #include "Comm.h" -#include "DialInFlow.h" -#include "DialOutFlow.h" -#include "Interrupts.h" -#include "FPGA.h" -#include "SystemComm.h" -#include "TaskGeneral.h" -#include "TaskPriority.h" +#include "DialInFlow.h" +#include "DialOutFlow.h" +#include "Interrupts.h" +#include "FPGA.h" +#include "SystemComm.h" +#include "TaskGeneral.h" +#include "TaskPriority.h" #include "TaskTimer.h" -#include "Utilities.h" - +#include "Utilities.h" + /** * @addtogroup Interrupts * @{ @@ -44,22 +44,24 @@ #define MAX_COMM_ERRORS 5 ///< Maximum number of a given comm error for a given time window. #define COMM_ERROR_TIME_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< Time window for comm error counts. +#define MAX_FPGA_HDW_COMM_ERRORS 5 ///< Maximum number of a given FPGA HDW comm errors for a given time window. +#define FPGA_HDW_COMM_ERROR_TIME_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< Time window for FPGA HDW comm error counts. -#define HET1_EDGE_BP_ROTOR_HALL_SENSOR 0 ///< HET1 edge detector associated with blood pump rotor hall sensor. -#define HET1_EDGE_DPO_ROTOR_HALL_SENSOR 1 ///< HET1 edge detector associated with dialysate outlet pump rotor hall sensor. +#define HET1_EDGE_BP_ROTOR_HALL_SENSOR 0 ///< HET1 edge detector associated with blood pump rotor hall sensor. +#define HET1_EDGE_DPO_ROTOR_HALL_SENSOR 1 ///< HET1 edge detector associated with dialysate outlet pump rotor hall sensor. #define HET1_EDGE_DPI_ROTOR_HALL_SENSOR 2 ///< HET1 edge detector associated with dialysate inlet pump rotor hall sensor. - -// ********** private data ********** - -static U32 sci2FrameErrorCnt = 0; ///< FPGA serial frame error counter. -static U32 sci2OverrunErrorCnt = 0; ///< FPGA serial overrun error counter. - -static U32 can1WarningCnt = 0; ///< CAN warning mode counter. -static U32 can1BusOffCnt = 0; ///< CAN buss off mode counter. -static U32 can1ParityCnt = 0; ///< CAN parity error counter. - -// ********** private function prototypes ********** - + +// ********** private data ********** + +static U32 sci2FrameErrorCnt = 0; ///< FPGA serial frame error counter. +static U32 sci2OverrunErrorCnt = 0; ///< FPGA serial overrun error counter. + +static U32 can1WarningCnt = 0; ///< CAN warning mode counter. +static U32 can1BusOffCnt = 0; ///< CAN buss off mode counter. +static U32 can1ParityCnt = 0; ///< CAN parity error counter. + +// ********** private function prototypes ********** + /*********************************************************************//** * @brief * The initInterrupts function initializes the Interrupts module. @@ -72,218 +74,220 @@ // Initialize various time windowed counts for monitoring CAN & UART errors and warnings 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 ); - initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR, MAX_COMM_ERRORS, COMM_ERROR_TIME_WINDOW_MS ); - initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_OVERRUN, MAX_COMM_ERRORS, COMM_ERROR_TIME_WINDOW_MS ); + initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR, MAX_FPGA_HDW_COMM_ERRORS, FPGA_HDW_COMM_ERROR_TIME_WINDOW_MS ); + initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_OVERRUN, MAX_FPGA_HDW_COMM_ERRORS, FPGA_HDW_COMM_ERROR_TIME_WINDOW_MS ); } - -/*********************************************************************//** - * @brief - * The phantomInterrupt function handles phantom interrupts. - * @details Inputs: none - * @details Outputs: phantom interrupt handled. - * @return none - *************************************************************************/ -void phantomInterrupt(void) -{ + +/*********************************************************************//** + * @brief + * The phantomInterrupt function handles phantom interrupts. + * @details Inputs: none + * @details Outputs: phantom interrupt handled. + * @return none + *************************************************************************/ +void phantomInterrupt(void) +{ SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_PHANTOM_INTERRUPT ) -} - -/*********************************************************************//** - * @brief - * The rtiNotification function handles real-time interrupt notifications. - * @details Inputs: none - * @details Outputs: RTI notification handled. - * @param notification Which RTI timer caused this interrupt - * @return none - *************************************************************************/ -void rtiNotification(uint32 notification) -{ - switch ( notification ) - { - case rtiNOTIFICATION_COMPARE0: - taskTimer(); - break; - - case rtiNOTIFICATION_COMPARE1: - taskPriority(); - break; - - case rtiNOTIFICATION_COMPARE2: - // Do nothing - unused at this time - break; - - case rtiNOTIFICATION_COMPARE3: - taskGeneral(); - break; - - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_RTI_NOTIFICATION, notification ) - break; - } -} - -/*********************************************************************//** - * @brief - * The canMessageNotification function handles CAN message notifications. - * @details Inputs: none - * @details Outputs: CAN message notification handled. - * @param node which CAN controller - * @param messageBox which message box triggered the message notification - * @return none - *************************************************************************/ -void canMessageNotification(canBASE_t *node, uint32 messageBox) -{ - if ( node == canREG1 ) - { - handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); - } -} - -/*********************************************************************//** - * @brief - * The canErrorNotification function handles CAN error notifications. - * @details Inputs: none - * @details 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 - * canLEVEL_WARNING (0x40) : When RX- or TX error counter are between 64 and 127 - * canLEVEL_BUS_OFF (0x80) : When RX- or TX error counter are between 128 and 255 - * 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 ) +} + +/*********************************************************************//** + * @brief + * The rtiNotification function handles real-time interrupt notifications. + * @details Inputs: none + * @details Outputs: RTI notification handled. + * @param notification Which RTI timer caused this interrupt + * @return none + *************************************************************************/ +void rtiNotification(uint32 notification) +{ + switch ( notification ) { - // Parity error - message RAM is corrupted - if ( notification & canLEVEL_PARITY_ERR ) - { - can1ParityCnt++; + case rtiNOTIFICATION_COMPARE0: + taskTimer(); + break; + + case rtiNOTIFICATION_COMPARE1: + taskPriority(); + break; + + case rtiNOTIFICATION_COMPARE2: + // Do nothing - unused at this time + break; + + case rtiNOTIFICATION_COMPARE3: + taskGeneral(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_RTI_NOTIFICATION, notification ) + break; + } +} + +/*********************************************************************//** + * @brief + * The canMessageNotification function handles CAN message notifications. + * @details Inputs: none + * @details Outputs: CAN message notification handled. + * @param node which CAN controller + * @param messageBox which message box triggered the message notification + * @return none + *************************************************************************/ +void canMessageNotification(canBASE_t *node, uint32 messageBox) +{ + if ( node == canREG1 ) + { + handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); + } +} + +/*********************************************************************//** + * @brief + * The canErrorNotification function handles CAN error notifications. + * @details Inputs: none + * @details 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 + * canLEVEL_WARNING (0x40) : When RX- or TX error counter are between 64 and 127 + * canLEVEL_BUS_OFF (0x80) : When RX- or TX error counter are between 128 and 255 + * 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 ) + { + // Parity error - message RAM is corrupted + if ( notification & canLEVEL_PARITY_ERR ) + { + can1ParityCnt++; if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_CAN_PARITY ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_CAN_PARITY_ERROR ) } } - // Bus off - our transmitter has counted 255+ errors - else if ( notification & canLEVEL_BUS_OFF ) - { - can1BusOffCnt++; + // Bus off - our transmitter has counted 255+ errors + else if ( notification & canLEVEL_BUS_OFF ) + { + can1BusOffCnt++; if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_CAN_OFF ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_CAN_OFF_ERROR ) } } - // Warning - our transmitter has counted 96+ errors - else if ( notification & canLEVEL_WARNING ) - { - can1WarningCnt++; - } - else - { - // Ignore other notifications - unhandled - } - } -} - -/*********************************************************************//** - * @brief - * The sciNotification function handles UART communication error interrupts. - * Frame and Over-run errors are handled. - * @details Inputs: none - * @details Outputs: UART error interrupts handled. - * @param sci Pointer to the SCI peripheral that detected the error - * @param flags error flag(s) - * @return none - *************************************************************************/ -void sciNotification(sciBASE_t *sci, uint32 flags) -{ - if ( sci == scilinREG ) - { - if ( ( flags & SCI_FE_INT ) != 0 ) - { - sci2FrameErrorCnt++; - clearSCI2CommErrors(); + // Warning - our transmitter has counted 96+ errors + else if ( notification & canLEVEL_WARNING ) + { + can1WarningCnt++; + } + else + { + // Ignore other notifications - unhandled + } + } +} + +/*********************************************************************//** + * @brief + * The sciNotification function handles UART communication error interrupts. + * Frame and Over-run errors are handled. + * @details Inputs: none + * @details Outputs: UART error interrupts handled. + * @param sci Pointer to the SCI peripheral that detected the error + * @param flags error flag(s) + * @return none + *************************************************************************/ +void sciNotification(sciBASE_t *sci, uint32 flags) +{ + if ( sci == scilinREG ) + { + if ( ( flags & SCI_FE_INT ) != 0 ) + { + sci2FrameErrorCnt++; + scilinREG->FLR |= SCI_FE_INT; if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_UART_FRAME_ERROR ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_COMM_TIMEOUT, MAX_FPGA_HDW_COMM_ERRORS, sci2FrameErrorCnt ) + //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_UART_OVERRUN_ERROR ) } - } - if ( ( flags & SCI_OE_INT ) != 0 ) - { - sci2OverrunErrorCnt++; - clearSCI2CommErrors(); + } + if ( ( flags & SCI_OE_INT ) != 0 ) + { + sci2OverrunErrorCnt++; + scilinREG->FLR |= SCI_OE_INT; if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_OVERRUN ) ) { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_UART_OVERRUN_ERROR ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_FPGA_COMM_TIMEOUT, MAX_FPGA_HDW_COMM_ERRORS, sci2OverrunErrorCnt ) + //SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_UART_OVERRUN_ERROR ) } - } - } -} - -/*********************************************************************//** - * @brief - * The dmaGroupANotification function handles communication DMA interrupts. - * @details Inputs: none - * @details Outputs: DMA interrupt is handled. - * @param inttype type of DMA interrupt - * @param channel DMA channel that caused the interrupt - * @return none - *************************************************************************/ -void dmaGroupANotification(dmaInterrupt_t inttype, uint32 channel) -{ - if ( inttype == BTC ) // Block transfer completed interrupt - { - switch ( channel ) - { - case DMA_CH0: // FPGA receive channel - clearSCI2DMAReceiveInterrupt(); - signalFPGAReceiptCompleted(); - break; - - case DMA_CH2: // FPGA transmit channel - clearSCI2DMATransmitInterrupt(); - signalFPGATransmitCompleted(); - break; - - default: + } + } +} + +/*********************************************************************//** + * @brief + * The dmaGroupANotification function handles communication DMA interrupts. + * @details Inputs: none + * @details Outputs: DMA interrupt is handled. + * @param inttype type of DMA interrupt + * @param channel DMA channel that caused the interrupt + * @return none + *************************************************************************/ +void dmaGroupANotification(dmaInterrupt_t inttype, uint32 channel) +{ + if ( inttype == BTC ) // Block transfer completed interrupt + { + switch ( channel ) + { + case DMA_CH0: // FPGA receive channel + clearSCI2DMAReceiveInterrupt(); + signalFPGAReceiptCompleted(); + break; + + case DMA_CH2: // FPGA transmit channel + clearSCI2DMATransmitInterrupt(); + signalFPGATransmitCompleted(); + break; + + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_UNEXPECTED_DMA_INTERRUPT, channel ) - break; - } - } -} - -/*********************************************************************//** - * @brief - * The edgeNotification function handles rotor hall sensor interrupts. - * @details Inputs: none - * @details Outputs: Rotor hall sensor interrupt is handled according to pin associated with given edge. - * @param hetREG HET controller associated with the edge - * @param edge Which edge was detected - * @return none - *************************************************************************/ -void edgeNotification(hetBASE_t * hetREG, uint32 edge) -{ - if ( hetREG == hetREG1 ) - { - switch ( edge ) - { - case HET1_EDGE_BP_ROTOR_HALL_SENSOR: - signalBloodPumpRotorHallSensor(); - break; - - case HET1_EDGE_DPO_ROTOR_HALL_SENSOR: - signalDialOutPumpRotorHallSensor(); - break; - + break; + } + } +} + +/*********************************************************************//** + * @brief + * The edgeNotification function handles rotor hall sensor interrupts. + * @details Inputs: none + * @details Outputs: Rotor hall sensor interrupt is handled according to pin associated with given edge. + * @param hetREG HET controller associated with the edge + * @param edge Which edge was detected + * @return none + *************************************************************************/ +void edgeNotification(hetBASE_t * hetREG, uint32 edge) +{ + if ( hetREG == hetREG1 ) + { + switch ( edge ) + { + case HET1_EDGE_BP_ROTOR_HALL_SENSOR: + signalBloodPumpRotorHallSensor(); + break; + + case HET1_EDGE_DPO_ROTOR_HALL_SENSOR: + signalDialOutPumpRotorHallSensor(); + break; + case HET1_EDGE_DPI_ROTOR_HALL_SENSOR: signalDialInPumpRotorHallSensor(); break; - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INTERRUPTS_INVALID_EDGE_DETECTED, edge ) - break; - } - } -} + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INTERRUPTS_INVALID_EDGE_DETECTED, edge ) + break; + } + } +} /**@}*/