Index: source/sys_main.c =================================================================== diff -u -r3323966fe741edbb36dffc78317ccf06ed93a68e -rcb47c5f896477ceae7597cb1a4191b3972e93f0d --- source/sys_main.c (.../sys_main.c) (revision 3323966fe741edbb36dffc78317ccf06ed93a68e) +++ source/sys_main.c (.../sys_main.c) (revision cb47c5f896477ceae7597cb1a4191b3972e93f0d) @@ -47,20 +47,23 @@ /* Include Files */ -#include -#include #include "sys_common.h" /* USER CODE BEGIN (1) */ #include "system.h" +#include "sys_dma.h" +#include "can.h" #include "gio.h" #include "mibspi.h" -#include "can.h" +#include "sci.h" #include "rti.h" #include "Common.h" +#include "AlarmLamp.h" +#include "Buttons.h" #include "CommBuffers.h" #include "CPLD.h" +#include "FPGA.h" #include "MsgQueues.h" #include "OperationModes.h" #include "SafetyShutdown.h" @@ -122,6 +125,8 @@ gioInit(); // configure GPIO pins mibspiInit(); // re-purposing MIBSPI5 I/O/C pins as GPIO canInit(); // CAN1 = CAN, re-purposing CAN2 and CAN3 Rx and Tx pins as GPIO + sciInit(); // SCI1 used for PC serial interface, SCI2 used for FPGA serial interface + dmaEnable(); // enable DMA } /************************************************************************* @@ -141,6 +146,7 @@ initAlarmLamp(); initButtons(); initWatchdogMgmt(); + initFPGA(); initCommBuffers(); initMsgQueues(); initSystemComm(); @@ -178,20 +184,58 @@ _enable_IRQ(); } -/************************************************************************* - * @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) +void sciNotification(sciBASE_t *sci, uint32 flags) { - handleCANMsgInterrupt( (CAN_MESSAGE_BOX_T)messageBox ); + static U32 fErrorCnt = 0; + static U32 oErrorCnt = 0; + + if ( ( flags & SCI_FE_INT ) != 0 ) + { + fErrorCnt++; + } + if ( ( flags & SCI_OE_INT ) != 0 ) + { + oErrorCnt++; + } } +void dmaGroupANotification(dmaInterrupt_t inttype, uint32 channel) +{ + if ( inttype == BTC ) + { + switch ( channel ) + { + case DMA_CH0: + // clear DMA receipt + scilinREG->CLEARINT = (uint32)((uint32)1U << 17U); /* Rx DMA */ + scilinREG->CLEARINT = (uint32)((uint32)1U << 18U); /* Rx DMA All */ + break; + case DMA_CH1: + // clear DMA receipt + sciREG->CLEARINT = (uint32)((uint32)1U << 17U); /* Rx DMA */ + sciREG->CLEARINT = (uint32)((uint32)1U << 18U); /* Rx DMA All */ + // handle received packet from PC + handleUARTMsgRecvPacketInterrupt(); + break; + + case DMA_CH2: + // clear DMA xmit + scilinREG->CLEARINT = (uint32)((uint32)1U << 16U); /* Tx DMA */ + break; + + case DMA_CH3: + // clear DMA xmit + sciREG->CLEARINT = (uint32)((uint32)1U << 16U); /* Tx DMA */ + // send next pending packet to PC (if any) + handleUARTMsgXmitPacketInterrupt(); + break; + + default: + // TODO - ignore? + break; + } + } +} + /* USER CODE END */