Index: App/Services/CommInterrupts.c =================================================================== diff -u -r38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9 -r6c8c486d26306662402945537c5acaea2709d85b --- App/Services/CommInterrupts.c (.../CommInterrupts.c) (revision 38ff7a6fbf82b86ab1bac3b7b24c4ea33d5419f9) +++ App/Services/CommInterrupts.c (.../CommInterrupts.c) (revision 6c8c486d26306662402945537c5acaea2709d85b) @@ -15,6 +15,7 @@ * **************************************************************************/ +#include "can.h" #include "sci.h" #include "sys_dma.h" @@ -35,6 +36,21 @@ /************************************************************************* + * @brief canMessageNotification + * The canMessageNotification function handles CAN message notifications. + * @details + * Inputs : none + * 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) +{ + handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); +} + +/************************************************************************* * @brief sciNotification * The sciNotification function handles UART communication error interrupts. \n * Frame and Over-run errors are handled. @@ -74,27 +90,23 @@ switch ( channel ) { case DMA_CH0: // FPGA receive channel - // clear DMA receipt - scilinREG->CLEARINT = SCI_DMA_RECEIVE_INT; + clearSCI2DMAReceiveInterrupt(); signalFPGAReceiptCompleted(); break; case DMA_CH1: // PC receive channel - // clear DMA receipt - sciREG->CLEARINT = SCI_DMA_RECEIVE_INT; + clearSCI1DMAReceiveInterrupt(); // handle received packet from PC handleUARTMsgRecvPacketInterrupt(); break; case DMA_CH2: // FPGA transmit channel - // clear DMA xmit - scilinREG->CLEARINT = SCI_DMA_TRANSMIT_INT; + clearSCI2DMATransmitInterrupt(); signalFPGATransmitCompleted(); break; case DMA_CH3: // PC transmit channel - // clear DMA xmit - sciREG->CLEARINT = SCI_DMA_TRANSMIT_INT; + clearSCI1DMATransmitInterrupt(); // send next pending packet to PC (if any) handleUARTMsgXmitPacketInterrupt(); break; @@ -106,3 +118,176 @@ } } +/************************************************************************* + * @brief setSCI1DMAReceiveInterrupt + * The setSCI1DMAReceiveInterrupt function enables DMA receive interrupts \n + * for the SCI1 peripheral. + * @details + * Inputs : none + * Outputs : DMA receive interrupt is enabled. + * @param none + * @return none + *************************************************************************/ +void setSCI1DMAReceiveInterrupt( void ) +{ + sciREG->SETINT = SCI_DMA_RECEIVE_INT; +} + +/************************************************************************* + * @brief setSCI1DMATransmitInterrupt + * The setSCI1DMATransmitInterrupt function enables DMA transmit interrupts \n + * for the SCI1 peripheral. + * @details + * Inputs : none + * Outputs : DMA transmit interrupt is enabled. + * @param none + * @return none + *************************************************************************/ +void setSCI1DMATransmitInterrupt( void ) +{ + sciREG->SETINT = SCI_DMA_TRANSMIT_INT; +} + +/************************************************************************* + * @brief clearSCI1DMAReceiveInterrupt + * The clearSCI1DMAReceiveInterrupt function disables DMA receive interrupts \n + * for the SCI1 peripheral. + * @details + * Inputs : none + * Outputs : DMA receive interrupt is disabled. + * @param none + * @return none + *************************************************************************/ +void clearSCI1DMAReceiveInterrupt( void ) +{ + sciREG->CLEARINT = SCI_DMA_RECEIVE_INT; +} + +/************************************************************************* + * @brief clearSCI1DMATransmitInterrupt + * The clearSCI1DMATransmitInterrupt function disables DMA transmit interrupts \n + * for the SCI1 peripheral. + * @details + * Inputs : none + * Outputs : DMA transmit interrupt is disabled. + * @param none + * @return none + *************************************************************************/ +void clearSCI1DMATransmitInterrupt( void ) +{ + sciREG->CLEARINT = SCI_DMA_TRANSMIT_INT; +} + +/************************************************************************* + * @brief setSCI2DMAReceiveInterrupt + * The setSCI2DMAReceiveInterrupt function enables DMA receive interrupts \n + * for the SCI2 peripheral. + * @details + * Inputs : none + * Outputs : DMA receive interrupt is enabled. + * @param none + * @return none + *************************************************************************/ +void setSCI2DMAReceiveInterrupt( void ) +{ + scilinREG->SETINT = SCI_DMA_RECEIVE_INT; +} + +/************************************************************************* + * @brief setSCI2DMATransmitInterrupt + * The setSCI2DMATransmitInterrupt function enables DMA transmit interrupts \n + * for the SCI2 peripheral. + * @details + * Inputs : none + * Outputs : DMA transmit interrupt is enabled. + * @param none + * @return none + *************************************************************************/ +void setSCI2DMATransmitInterrupt( void ) +{ + scilinREG->SETINT = SCI_DMA_TRANSMIT_INT; +} + +/************************************************************************* + * @brief clearSCI2DMAReceiveInterrupt + * The clearSCI2DMAReceiveInterrupt function disables DMA receive interrupts \n + * for the SCI2 peripheral. + * @details + * Inputs : none + * Outputs : DMA receive interrupt is disabled. + * @param none + * @return none + *************************************************************************/ +void clearSCI2DMAReceiveInterrupt( void ) +{ + scilinREG->CLEARINT = SCI_DMA_RECEIVE_INT; +} + +/************************************************************************* + * @brief clearSCI2DMATransmitInterrupt + * The clearSCI2DMATransmitInterrupt function disables DMA transmit interrupts \n + * for the SCI2 peripheral. + * @details + * Inputs : none + * Outputs : DMA transmit interrupt is disabled. + * @param none + * @return none + *************************************************************************/ +void clearSCI2DMATransmitInterrupt( void ) +{ + scilinREG->CLEARINT = SCI_DMA_TRANSMIT_INT; +} + +/************************************************************************* + * @brief isSCI1DMATransmitInProgress + * The isSCI2DMATransmitInProgress function determines whether a DMA transmit \n + * is in progress on the SCI1 peripheral. + * @details + * Inputs : status registers + * Outputs : none + * @param none + * @return TRUE if a transmit is in progress, FALSE if not + *************************************************************************/ +BOOL isSCI1DMATransmitInProgress( void ) +{ + BOOL transmitterBusy = ( ( sciREG->FLR & (uint32)SCI_TX_INT ) == 0U ? TRUE : FALSE ); + BOOL dmaTransmitterBusy = ( ( sciREG->CLEARINT & SCI_DMA_RECEIVE_INT ) != 0 ? TRUE : FALSE ); + + return ( ( transmitterBusy == TRUE ) || ( dmaTransmitterBusy == TRUE ) ? TRUE : FALSE ); +} + +/************************************************************************* + * @brief isSCI2DMATransmitInProgress + * The isSCI2DMATransmitInProgress function determines whether a DMA transmit \n + * is in progress on the SCI2 peripheral. + * @details + * Inputs : status registers + * Outputs : none + * @param none + * @return TRUE if a transmit is in progress, FALSE if not + *************************************************************************/ +BOOL isSCI2DMATransmitInProgress( void ) +{ + BOOL transmitterBusy = ( ( scilinREG->FLR & (uint32)SCI_TX_INT ) == 0U ? TRUE : FALSE ); + BOOL dmaTransmitterBusy = ( ( scilinREG->CLEARINT & SCI_DMA_RECEIVE_INT ) != 0 ? TRUE : FALSE ); + + return ( ( transmitterBusy == TRUE ) || ( dmaTransmitterBusy == TRUE ) ? TRUE : FALSE ); +} + +/************************************************************************* + * @brief isCAN1TransmitInProgress + * The isCAN1TransmitInProgress function determines whether a transmit \n + * is in progress on the CAN1 peripheral. + * @details + * Inputs : status registers + * Outputs : none + * @param none + * @return TRUE if a transmit is in progress, FALSE if not + *************************************************************************/ +BOOL isCAN1TransmitInProgress( void ) +{ + BOOL result = ( ( canREG1->TXRQx[0] != 0 ) || ( canREG1->TXRQx[1] != 0 ) ? TRUE : FALSE ); + + return result; +} +