Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r677cc9e7b67ea71140271aff307043abbf964764 -r4d1572f8226f06febef4a536cdd0946d0dd0fb02 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 677cc9e7b67ea71140271aff307043abbf964764) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 4d1572f8226f06febef4a536cdd0946d0dd0fb02) @@ -37,11 +37,14 @@ #define NUM_OF_CAN_OUT_BUFFERS 4 // # of CAN buffers for transmit #define NUM_OF_CAN_IN_BUFFERS 6 // # of CAN buffers for receiving -#define NUM_OF_MSG_IN_BUFFERS 7 // # of Msg buffers for receiving - 1 is UART +#ifndef DEBUG_ENABLED + #define NUM_OF_MSG_IN_BUFFERS 6 // # of Msg buffers for receiving +#else + #define NUM_OF_MSG_IN_BUFFERS 7 // # of Msg buffers for receiving - 1 is UART + #define SCI1_RECEIVE_DMA_REQUEST 30 + #define SCI1_TRANSMIT_DMA_REQUEST 31 +#endif -#define SCI1_RECEIVE_DMA_REQUEST 30 -#define SCI1_TRANSMIT_DMA_REQUEST 31 - #define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< if transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on #define HD_COMM_TIMEOUT_IN_MS 2000 @@ -86,19 +89,21 @@ COMM_BUFFER_IN_CAN_HD_BROADCAST, COMM_BUFFER_IN_CAN_UI_BROADCAST, COMM_BUFFER_IN_CAN_PC, +#ifdef DEBUG_ENABLED COMM_BUFFER_IN_UART_PC +#endif }; static U08 lastCANPacketSent[ CAN_MESSAGE_PAYLOAD_SIZE ]; -static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = 0; +static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = (CAN_MESSAGE_BOX_T)0; static U32 lastCANPacketSentTimeStamp = 0; +#ifdef DEBUG_ENABLED static U08 pcXmitPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static U08 pcRecvPacket[ PC_MESSAGE_PACKET_SIZE ] = { 0, 0, 0, 0, 0, 0, 0, 0 }; +#endif -#ifndef ACK_NOT_IMPLEMENTED static PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; // list of outgoing messages that are awaiting an ACK -#endif // DMA control records static g_dmaCTRL pcDMAXmitControlRecord; // DMA transmit control record (UART-debug) @@ -122,13 +127,16 @@ // ********** private function prototypes ********** -static void initUARTAndDMA( void ); +#ifdef DEBUG_ENABLED + static void initUARTAndDMA( void ); + static U32 transmitNextUARTPacket( void ); +#endif + static BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ); static BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ); static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ); static U32 transmitNextCANPacket( void ); -static U32 transmitNextUARTPacket( void ); static void processIncomingData( void ); static S32 parseMessageFromBuffer( U08 *data, U32 len ); @@ -139,10 +147,8 @@ static void checkForCommTimeouts( void ); static void checkTooManyBadMsgCRCs( void ); -#ifndef ACK_NOT_IMPLEMENTED static BOOL matchACKtoPendingACKList( S16 seqNo ); static void checkPendingACKList( void ); -#endif /************************************************************************* * @brief initSystemComm @@ -157,22 +163,22 @@ { U32 i; +#ifdef DEBUG_ENABLED // initialize UART and DMA for PC communication initUARTAndDMA(); +#endif // initialize bad message CRC list for ( i = 0; i < MAX_COMM_CRC_FAILURES; i++ ) { badCRCTimeStamps[ i ] = 0; } -#ifndef ACK_NOT_IMPLEMENTED // initialize pending ACK list for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) { pendingAckList[ i ].used = FALSE; } -#endif } /************************************************************************* @@ -214,10 +220,8 @@ // check for sub-system comm timeouts checkForCommTimeouts(); -#ifndef ACK_NOT_IMPLEMENTED // check ACK list for messages that need to be re-sent because they haven't been ACK'd checkPendingACKList(); -#endif } /************************************************************************* @@ -247,11 +251,13 @@ } } +#ifdef DEBUG_ENABLED // if UART transmitter is idle, start transmitting any pending packets if ( FALSE == isSCI1DMATransmitInProgress() ) { transmitNextUARTPacket(); } +#endif } /************************************************************************* @@ -331,6 +337,7 @@ * @param none * @return none *************************************************************************/ +#ifdef DEBUG_ENABLED void handleUARTMsgRecvPacketInterrupt( void ) { // buffer received packet @@ -340,6 +347,7 @@ dmaSetChEnable( DMA_CH1, DMA_HW ); setSCI1DMAReceiveInterrupt(); } +#endif /************************************************************************* * @brief handleUARTMsgXmitPacketInterrupt @@ -351,6 +359,7 @@ * @param none * @return none *************************************************************************/ +#ifdef DEBUG_ENABLED void handleUARTMsgXmitPacketInterrupt( void ) { U32 bytesXmitted = transmitNextUARTPacket(); @@ -360,6 +369,7 @@ signalSCI1XmitsCompleted(); } } +#endif /************************************************************************* * @brief initUARTAndDMA @@ -371,6 +381,7 @@ * @param none * @return none *************************************************************************/ +#ifdef DEBUG_ENABLED static void initUARTAndDMA( void ) { // Enable DMA block transfer complete interrupts @@ -424,6 +435,7 @@ dmaSetChEnable( DMA_CH1, DMA_HW ); setSCI1DMAReceiveInterrupt(); } +#endif /************************************************************************* * @brief isCANBoxForXmit @@ -587,6 +599,7 @@ * @param msg : none * @return # of bytes transmitted *************************************************************************/ +#ifdef DEBUG_ENABLED static U32 transmitNextUARTPacket( void ) { U32 result = 0; @@ -610,6 +623,7 @@ return result; } +#endif /************************************************************************* @@ -805,23 +819,19 @@ { // CRC should be good because we checked it during parsing before adding to queue - but check it again for good measure if ( message.crc == crc8( (U08*)(&message), sizeof(MESSAGE_HEADER_T) + message.msg.hdr.payloadLen ) ) { -#ifndef ACK_NOT_IMPLEMENTED // if ACK, mark pending message ACK'd if ( MSG_ID_ACK == message.msg.hdr.msgID ) { matchACKtoPendingACKList( message.msg.hdr.seqNo ); } else -#endif { -#ifndef ACK_NOT_IMPLEMENTED // if received message requires ACK, queue one up if ( message.msg.hdr.seqNo < 0 ) { sendACKMsg( &message.msg ); } else -#endif { // otherwise, process the received message processReceivedMessage( &message.msg ); } @@ -889,7 +899,6 @@ } } -#ifndef ACK_NOT_IMPLEMENTED /************************************************************************* * @brief addMsgToPendingACKList * The addMsgToPendingACKList function adds a given message to the pending \n @@ -1002,7 +1011,6 @@ } } } -#endif /************************************************************************* * @brief processReceivedMessage