Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r66c624837b7b915415810e67249048ce5a46c163 -r5e0cd9b5be11ff4b2acaadbdcafc4ffe05172aa1 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 66c624837b7b915415810e67249048ce5a46c163) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 5e0cd9b5be11ff4b2acaadbdcafc4ffe05172aa1) @@ -35,40 +35,40 @@ // ********** private definitions ********** -#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 6 ///< Number of CAN buffers for receiving +#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 6 ///< Number of CAN buffers for receiving #ifndef DEBUG_ENABLED - #define NUM_OF_MSG_IN_BUFFERS 6 ///< Number of Msg buffers for receiving + #define NUM_OF_MSG_IN_BUFFERS 6 ///< Number of Msg buffers for receiving #else #define NUM_OF_MSG_IN_BUFFERS 7 #define SCI1_RECEIVE_DMA_REQUEST 30 #define SCI1_TRANSMIT_DMA_REQUEST 31 #endif -#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 MAX_XMIT_RETRIES 5 ///< maximum number of retries on no transmit complete interrupt timeout +#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 MAX_XMIT_RETRIES 5 ///< maximum number of retries on no transmit complete interrupt timeout -#define HD_COMM_TIMEOUT_IN_MS 2000 ///< HD has not sent any broadcast messages for this much time +#define HD_COMM_TIMEOUT_IN_MS 2000 ///< HD has not sent any broadcast messages for this much time -#define MAX_COMM_CRC_FAILURES 5 ///< maximum number of CRC errors within window period before alarm +#define MAX_COMM_CRC_FAILURES 5 ///< maximum number of CRC errors within window period before alarm #define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window -#define MSG_NOT_ACKED_TIMEOUT_MS ( MS_PER_SECOND * 1 ) ///< maximum time for a Denali message that requires ACK to be ACK'd -#define MSG_NOT_ACKED_MAX_RETRIES 3 ///< maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm -#define PENDING_ACK_LIST_SIZE 25 ///< maximum number of Delanli messages that can be pending ACK at any given time +#define MSG_NOT_ACKED_TIMEOUT_MS ( MS_PER_SECOND * 1 ) ///< maximum time for a Denali message that requires ACK to be ACK'd +#define MSG_NOT_ACKED_MAX_RETRIES 3 ///< maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm +#define PENDING_ACK_LIST_SIZE 25 ///< maximum number of Delanli messages that can be pending ACK at any given time #pragma pack(push, 1) /// Record for transmitted message that is pending acknowledgement from receiver. typedef struct { - BOOL used; - U16 seqNo; - U16 retries; - U32 timeStamp; - COMM_BUFFER_T channel; - U32 msgSize; - U08 msg[ MAX_ACK_MSG_SIZE ]; + BOOL used; ///< Flag indicates whether the pending ACK slot is used or not + U16 seqNo; ///< Sequence number + U16 retries; ///< Retry count + U32 timeStamp; ///< Message time stamp + COMM_BUFFER_T channel; ///< Comm buffer channel + U32 msgSize; ///< Message size + U08 msg[ MAX_ACK_MSG_SIZE ]; ///< Bytes representation of the message } PENDING_ACK_RECORD_T; #pragma pack(pop) @@ -103,12 +103,12 @@ static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = (CAN_MESSAGE_BOX_T)0; ///< Keep channel last packet was sent on CAN bus in case we need to re-send. static U32 lastCANPacketSentTimeStamp = 0; ///< Keep time last packet sent on CAN bus so we can timeout on transmission attempt. -static PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< list of outgoing messages that are awaiting an ACK +static PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< list of outgoing messages that are awaiting an ACK -static volatile BOOL dgIsOnlyCANNode = TRUE; ///< flag indicating whether DG is alone on CAN bus. -static U32 canXmitRetryCtr = 0; ///< counter for CAN transmit retries. -static volatile BOOL hdIsCommunicating = FALSE; ///< has HD sent a message since last check -static volatile U32 timeOfLastHDCheckIn = 0; ///< last time we received an HD broadcast +static volatile BOOL dgIsOnlyCANNode = TRUE; ///< flag indicating whether DG is alone on CAN bus. +static U32 canXmitRetryCtr = 0; ///< counter for CAN transmit retries. +static volatile BOOL hdIsCommunicating = FALSE; ///< has HD sent a message since last check +static volatile U32 timeOfLastHDCheckIn = 0; ///< last time we received an HD broadcast #ifdef DEBUG_ENABLED // debug buffers @@ -172,7 +172,7 @@ /*********************************************************************//** * @brief - * The isHDCommunicating function determines whether the HD is communicating \n + * The isHDCommunicating function determines whether the HD is communicating * with the DG. * @details * Inputs : hdIsCommunicating @@ -186,7 +186,7 @@ /*********************************************************************//** * @brief - * The isDGOnlyCANNode function determines whether the DG is the only node \n + * The isDGOnlyCANNode function determines whether the DG is the only node * currently on the CAN bus. * @details * Inputs : dgIsOnlyCANNode @@ -223,8 +223,7 @@ /*********************************************************************//** * @brief - * The execSystemCommTx function manages data to be transmitted to other \n - * sub-systems. + * The execSystemCommTx function manages data to be transmitted to other sub-systems. * @details * Inputs : none * Outputs : Next outgoing frame transmitted. @@ -290,10 +289,9 @@ /*********************************************************************//** * @brief - * The handleCANMsgInterrupt function handles a CAN message interrupt. \n - * This may have occurred because a CAN packet transmission has completed \n - * or because a CAN packet has been received. The appropriate handler is \n - * called. + * The handleCANMsgInterrupt function handles a CAN message interrupt. This + * may have occurred because a CAN packet transmission has completed or + * because a CAN packet has been received. The appropriate handler is called. * @details * Inputs : none * Outputs : message interrupt handled @@ -338,7 +336,7 @@ /*********************************************************************//** * @brief - * The handleUARTMsgRecvPacketInterrupt function handles a DMA UART receive \n + * The handleUARTMsgRecvPacketInterrupt function handles a DMA UART receive * packet completed interrupt. * @details * Inputs : none @@ -359,7 +357,7 @@ /*********************************************************************//** * @brief - * The handleUARTMsgXmitPacketInterrupt function handles a DMA UART transmit \n + * The handleUARTMsgXmitPacketInterrupt function handles a DMA UART transmit * packet completed interrupt. * @details * Inputs : none @@ -380,7 +378,7 @@ /*********************************************************************//** * @brief - * The initUARTAndDMA function initializes the SCI1 peripheral and the DMA \n + * The initUARTAndDMA function initializes the SCI1 peripheral and the DMA * to go with it for PC communication. * @details * Inputs : none @@ -445,7 +443,7 @@ /*********************************************************************//** * @brief - * The isCANBoxForXmit function determines whether a given CAN message box \n + * The isCANBoxForXmit function determines whether a given CAN message box * is configured for transmit. * @details * Inputs : CAN_OUT_BUFFERS[] @@ -472,7 +470,7 @@ /*********************************************************************//** * @brief - * The isCANBoxForRecv function determines whether a given CAN message box \n + * The isCANBoxForRecv function determines whether a given CAN message box * is configured for receiving. * @details * Inputs : MSG_IN_BUFFERS[] @@ -520,15 +518,14 @@ ********************** TRANSMIT SUPPORT FUNCTIONS ************************ *************************************************************************/ - /*********************************************************************//** * @brief - * The findNextHighestPriorityCANPacketToTransmit function gets the next \n - * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. \n + * The findNextHighestPriorityCANPacketToTransmit function gets the next + * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. * @details * Inputs : Output CAN Comm Buffer(s) * Outputs : none - * @return buffer with highest priority CAN packet to transmit, \n + * @return buffer with highest priority CAN packet to transmit, * COMM_BUFFER_NOT_USED if not CAN packets pending transmit found *************************************************************************/ static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ) @@ -551,7 +548,7 @@ /*********************************************************************//** * @brief - * The transmitNextCANPacket function gets the next 8 byte packet and initiates \n + * The transmitNextCANPacket function gets the next 8 byte packet and initiates * a CAN transmit on the appropriate CAN channel. * @details * Inputs : Output CAN Comm Buffers @@ -601,7 +598,7 @@ /*********************************************************************//** * @brief - * The transmitNextUARTPacket function sets up and initiates a DMA transmit \n + * The transmitNextUARTPacket function sets up and initiates a DMA transmit * of the next packet pending transmit (if any) via UART. * @details * Inputs : Output UART Comm Buffer(s) @@ -638,14 +635,13 @@ ********************** RECEIVE SUPPORT FUNCTIONS ************************* *************************************************************************/ - /*********************************************************************//** * @brief - * The processIncomingData function parses out messages from the Input \n - * Comm Buffers and adds them to the Received Message Queue. + * The processIncomingData function parses out messages from the input + * comm buffers and adds them to the received message queue. * @details * Inputs : Input Comm Buffers - * Outputs : Parsed message(s) added to Received Message Queue + * Outputs : Parsed message(s) added to received message queue * @return none *************************************************************************/ static void processIncomingData( void ) @@ -725,7 +721,7 @@ /*********************************************************************//** * @brief - * The consumeBufferPaddingBeforeSync function removes any bytes in a given \n + * The consumeBufferPaddingBeforeSync function removes any bytes in a given * buffer that lie before a sync byte. * @details * Inputs : none @@ -756,14 +752,14 @@ /*********************************************************************//** * @brief - * The parseMessageFromBuffer function looks for a complete message in a \n - * given buffer. If a message is found, its size is returned. + * The parseMessageFromBuffer function looks for a complete message in a + * given buffer. If a message is found, its size is returned. * @details * Inputs : none * Outputs : If a complete message can be found in buffer contents, it is parsed out. * @param data pointer to byte array to search for a message - * @param len # of bytes in the data to search - * @return size of message if found, zero if no complete message found, \n + * @param len number of bytes in the data to search + * @return size of message if found, zero if no complete message found, * -1 if message found but CRC fails. *************************************************************************/ static S32 parseMessageFromBuffer( U08 *data, U32 len ) @@ -808,7 +804,7 @@ /*********************************************************************//** * @brief - * The processReceivedMessages function processes any messages in the \n + * The processReceivedMessages function processes any messages in the * received message queues. * @details * Inputs : Received Message Queues @@ -854,8 +850,7 @@ /*********************************************************************//** * @brief - * The checkForCommTimeouts function checks for sub-system communication \n - * timeout errors. + * The checkForCommTimeouts function checks for sub-system communication timeout errors. * @details * Inputs : timeOfLastDGCheckIn, timeOfLastUICheckIn * Outputs : possibly a comm t/o alarm @@ -874,8 +869,8 @@ /*********************************************************************//** * @brief - * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs \n - * within a set period of time. Assumed function is being called when a new \n + * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs + * within a set period of time. Assumed function is being called when a new * bad CRC is detected so a new bad CRC will be added to the list. * @details * Inputs : badCRCTimeStamps[], badCRCListIdx, badCRCListCount @@ -900,15 +895,15 @@ /*********************************************************************//** * @brief - * The addMsgToPendingACKList function adds a given message to the pending \n - * ACK list. Messages in this list will require receipt of an ACK message \n + * The addMsgToPendingACKList function adds a given message to the pending + * ACK list. Messages in this list will require receipt of an ACK message * for this particular message within a limited time. * @details * Inputs : pendingAckList[] * Outputs : pendingAckList[] * @param msg pointer to msg within the message data * @param msgData pointer to message data to add to pending ACK list - * @param len # of bytes of message data + * @param len number of bytes of message data * @return TRUE if message added successfully, FALSE if not *************************************************************************/ BOOL addMsgToPendingACKList( MESSAGE_T *msg, COMM_BUFFER_T channel, U08 *msgData, U32 len ) @@ -946,13 +941,13 @@ /*********************************************************************//** * @brief - * The matchACKtoPendingACKList function searches the pending ACK list to \n - * see if the sequence # from a received ACK msg matches any. If found, \n + * The matchACKtoPendingACKList function searches the pending ACK list to + * see if the sequence number from a received ACK msg matches any. If found, * the list entry is removed. * @details * Inputs : pendingAckList[] * Outputs : pendingAckList[] - * @param seqNo sequence # to match to an entry in the list + * @param seqNo sequence number to match to an entry in the list * @return TRUE if a match was found, FALSE if not *************************************************************************/ static BOOL matchACKtoPendingACKList( S16 seqNo ) @@ -976,8 +971,8 @@ /*********************************************************************//** * @brief - * The checkPendingACKList function searches the pending ACK list to \n - * see if any have expired. Any such messages will be queued for retransmission \n + * The checkPendingACKList function searches the pending ACK list to see if + * any have expired. Any such messages will be queued for retransmission * and if max retries reached a fault is triggered. * @details * Inputs : pendingAckList[]