Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -r47c41046beba8affaaaa13a4f222a7b99bd193f1 -r7d4711edd7b40cd3e29f43e766f79a8a09586fe9 --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 47c41046beba8affaaaa13a4f222a7b99bd193f1) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 7d4711edd7b40cd3e29f43e766f79a8a09586fe9) @@ -1,17 +1,17 @@ /************************************************************************** * -* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +* Copyright (c) 2019-2024 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) Quang Nguyen -* @date (last) 01-Sep-2020 +* @author (last) Dara Navaei +* @date (last) 23-Sep-2023 * -* @author (original) Dara Navaei -* @date (original) 05-Nov-2019 +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 * ***************************************************************************/ @@ -41,6 +41,8 @@ #define COMM_ERROR_TIME_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< Time window for comm error counts. // ********** private data ********** + +static BOOL sci2FEOEError = FALSE; ///< FPGA serial frame or overrun flag; static U32 can1WarningCnt; ///< CAN1 warning count. static U32 can1BusOffCnt; ///< CAN1 bus offline count. @@ -62,8 +64,6 @@ // 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 ); } /*********************************************************************//** @@ -75,7 +75,7 @@ *************************************************************************/ void phantomInterrupt( void ) { - // TODO - what to do with phantom interrupts? + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_PHANTOM_INTERRUPT ) } /*********************************************************************//** @@ -174,8 +174,39 @@ // 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) +{ +#ifndef _VECTORCAST_ + // Cannot set the pointers to be equal in VectorCAST. Can define pointers but the user does not have any control on the address of it + if ( sci == scilinREG ) +#endif + { + if ( ( flags & SCI_FE_INT ) != 0 ) + { + sci2FEOEError = TRUE; + scilinREG->FLR |= SCI_FE_INT; + } + + if ( ( flags & SCI_OE_INT ) != 0 ) + { + sci2FEOEError = TRUE; + scilinREG->FLR |= SCI_OE_INT; + } + } +} + /*********************************************************************//** * @brief * The dmaGroupANotification function handles communication DMA interrupts. @@ -196,30 +227,36 @@ signalFPGAReceiptCompleted(); break; -#ifdef DEBUG_ENABLED - case DMA_CH1: // PC receive channel - clearSCI1DMAReceiveInterrupt(); - // handle received packet from PC - handleUARTMsgRecvPacketInterrupt(); - break; -#endif case DMA_CH2: // FPGA transmit channel clearSCI2DMATransmitInterrupt(); signalFPGATransmitCompleted(); break; -#ifdef DEBUG_ENABLED - case DMA_CH3: // PC transmit channel - clearSCI1DMATransmitInterrupt(); - // send next pending packet to PC (if any) - handleUARTMsgXmitPacketInterrupt(); - break; -#endif default: // TODO - ignore? break; } } -} +} + +/*********************************************************************//** + * @brief + * The getSci2FEOEError function returns the sci2FEOEError (OE - Overrun, + * FE - Framing Error) status and resets the status if TRUE + * @details Inputs: sci2FEOEError + * @details Outputs: none + * @return sci2 FE / OE error + *************************************************************************/ +BOOL getSci2FEOEError( void ) +{ + BOOL returnValue = sci2FEOEError; + if ( TRUE == returnValue ) + { + sci2FEOEError = FALSE; + } + + return returnValue; +} + /**@}*/