Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -r30f049651877229042e3f8700c8596e5b9a1e0f4 -r24b2fe72608344e67ef37234085d15ad5e4fcc37 --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 30f049651877229042e3f8700c8596e5b9a1e0f4) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 24b2fe72608344e67ef37234085d15ad5e4fcc37) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2022 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * -* @file Interrupts.c +* @file Interrupts.c * -* @author (last) Sean Nash -* @date (last) 24-Sep-2020 +* @author (last) Sean Nash +* @date (last) 13-Aug-2021 * -* @author (original) Dara Navaei -* @date (original) 05-Nov-2019 +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 * ***************************************************************************/ @@ -34,9 +34,6 @@ #include "TaskPriority.h" #include "TaskTimer.h" #include "Utilities.h" -#ifdef DEBUG_ENABLED - #include "SystemCommMessages.h" -#endif /** * @addtogroup Interrupts @@ -54,14 +51,9 @@ // ********** private data ********** -#ifdef DEBUG_ENABLED - static U32 sci1FrameErrorCnt = 0; - static U32 sci1OverrunErrorCnt = 0; -#endif static U32 sci2FrameErrorCnt = 0; ///< FPGA serial frame error counter. static U32 sci2OverrunErrorCnt = 0; ///< FPGA serial overrun error counter. -static U32 can1PassiveCnt = 0; ///< CAN passive mode 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. @@ -78,7 +70,6 @@ void initInterrupts( void ) { // 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 ); initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_UART_FRAME_ERROR, MAX_COMM_ERRORS, COMM_ERROR_TIME_WINDOW_MS ); @@ -94,16 +85,7 @@ *************************************************************************/ void phantomInterrupt(void) { - // TODO - what to do with phantom interrupts? -#ifdef DEBUG_ENABLED - { - char debugStr[ 256 ]; - - sprintf( debugStr, "HD-phantom interrupt\n" ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); - } -#endif + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_PHANTOM_INTERRUPT ) } /*********************************************************************//** @@ -135,7 +117,7 @@ break; default: - // TODO - s/w fault? + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_RTI_NOTIFICATION, notification ) break; } } @@ -171,63 +153,34 @@ *************************************************************************/ void canErrorNotification(canBASE_t *node, uint32 notification) { -#ifdef DEBUG_ENABLED - char debugStr[ 256 ]; -#endif - 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 ) } -#ifdef DEBUG_ENABLED - sprintf( debugStr, "CAN parity error:%5d \n", can1ParityCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); -#endif - } + } + // 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 ) } -#ifdef DEBUG_ENABLED - sprintf( debugStr, "CAN bus off error:%5d \n", can1BusOffCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); -#endif - } + } + // Warning - our transmitter has counted 96+ errors else if ( notification & canLEVEL_WARNING ) { can1WarningCnt++; -#ifdef DEBUG_ENABLED - sprintf( debugStr, "CAN bus warning:%5d \n", can1WarningCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); -#endif } - else if ( notification & canLEVEL_PASSIVE ) - { - can1PassiveCnt++; - if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_CAN_PASSIVE ) ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_CAN_PASSIVE_WARNING ) - } -#ifdef DEBUG_ENABLED - sprintf( debugStr, "CAN passive warning:%5d \n", can1PassiveCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); -#endif - } else { - // Ignore - other notifications undefined + // Ignore other notifications - unhandled } } } @@ -244,63 +197,27 @@ *************************************************************************/ void sciNotification(sciBASE_t *sci, uint32 flags) { -#ifdef DEBUG_ENABLED - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; -#endif - if ( sci == scilinREG ) { if ( ( flags & SCI_FE_INT ) != 0 ) { sci2FrameErrorCnt++; - clearSCI2CommErrors(); + clearSCI2CommErrors(); 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 ) } -#ifdef DEBUG_ENABLED - sprintf( debugStr, "FPGA UART FR err:%5d \n", sci2FrameErrorCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); -#endif } if ( ( flags & SCI_OE_INT ) != 0 ) { sci2OverrunErrorCnt++; - clearSCI2CommErrors(); + clearSCI2CommErrors(); 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 ) } -#ifdef DEBUG_ENABLED - sprintf( debugStr, "FPGA UART OR err:%5d \n", sci2OverrunErrorCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); -#endif } } -#ifdef DEBUG_ENABLED - if ( sci == sciREG ) - { - if ( ( flags & SCI_FE_INT ) != 0 ) - { - sci1FrameErrorCnt++; - clearSCI1CommErrors(); - sprintf( debugStr, "Debug UART FR err:%5d\n", sci1FrameErrorCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); - } - if ( ( flags & SCI_OE_INT ) != 0 ) - { - sci1OverrunErrorCnt++; - clearSCI1CommErrors(); - sprintf( debugStr, "Debug UART OR err:%5d\n", sci1OverrunErrorCnt ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - sendDebugDataToUI( (U08*)debugStr ); - } - } -#endif } /*********************************************************************//** @@ -343,7 +260,7 @@ break; #endif default: - // TODO - ignore? + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_UNEXPECTED_DMA_INTERRUPT, channel ) break; } }