Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -r850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f -rc74c1d99a011dd0fb7f98f183faecda675221fce --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 850f8042a02fd17ee53b8db24bc2e3d17bbb9c7f) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision c74c1d99a011dd0fb7f98f183faecda675221fce) @@ -1,28 +1,69 @@ -/* - * Interrupts.c - * - * Created on: Aug 1, 2024 - * Author: fw - */ #include "can.h" #include "rti.h" #include "sci.h" #include "sys_dma.h" #include "BLCommon.h" -#include "CommBuffers.h" +#include "Comm.h" +#include "FPGA.h" +#include "SystemComm.h" #include "TaskGeneral.h" #include "TaskPriority.h" #include "TaskTimer.h" +/** + * @addtogroup Interrupts + * @{ + */ +// ********** private definitions ********** + +// TODO do we need more error handling? (i.e. canErrorNotification) + +// ********** private data ********** + +static BOOL sci2FEOEError; ///< FPGA serial frame or overrun flag; + +// ********** private function prototypes ********** + +/*********************************************************************//** + * @brief + * The initInterrupts function initializes the Interrupts unit. + * @details \b Inputs: none + * @details \b Outputs: Interrupts unit initialized. + * @return none + *************************************************************************/ void initInterrupts( void ) { - // TODO fill up + sci2FEOEError = FALSE; } +/*********************************************************************//** + * @brief + * The getSci2FEOEError function returns the sci2FEOEError (OE - Overrun, + * FE - Framing Error) status and resets the status if TRUE + * @details \b Inputs: sci2FEOEError + * @details \b Outputs: none + * @return sci2 FE / OE error + *************************************************************************/ +BOOL getSci2FEOEError( void ) +{ + BOOL returnValue = sci2FEOEError; + sci2FEOEError = ( TRUE == returnValue ? FALSE : sci2FEOEError ); + + return returnValue; +} + +/*********************************************************************//** + * @brief + * The rtiNotification function handles real-time interrupt notifications. + * @details \b Inputs: none + * @details \b Outputs: Task associated with given notification is executed. + * @param notification ID of RTI timer that caused this interrupt + * @return none + *************************************************************************/ void rtiNotification( uint32 notification ) { switch ( notification ) @@ -46,10 +87,86 @@ } } +/*********************************************************************//** + * @brief + * The canMessageNotification function handles CAN message notifications. + * @details \b Inputs: none + * @details \b Outputs: CAN message notification handled. + * @param node ID of CAN controller that given notification came from. + * @param messageBox ID of CAN mailbox that triggered the message notification + * @return none + *************************************************************************/ void canMessageNotification( canBASE_t *node, uint32 messageBox ) { if ( node == canREG1 ) { - handleCANMsgInterrupt( (SW_UPDATE_CAN_MAIL_BOXES_T)messageBox ); + handleCANMsgInterrupt( (SW_UPDATE_CAN_MAIL_BOX_T)messageBox ); } } + +/*********************************************************************//** + * @brief + * The sciNotification function handles UART communication error interrupts. + * Frame and Over-run errors are recorded and cleared. + * @details \b Inputs: none + * @details \b Outputs: sci2FEOEError, sci2FEOEError + * @param sci Pointer to the SCI peripheral that detected the error + * @param flags 32 bits of error flags + * @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. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given DMA channel is + * invalid/unexpected. + * @details \b Inputs: none + * @details \b 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(); + break; + + default: + // Do nothing + break; + } + } +} + +/**@}*/ +