/************************************************************************** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file MsgQueues.h * * @author (last) Sean Nash * @date (last) 24-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ #ifndef __MSG_QUEUES_H__ #define __MSG_QUEUES_H__ #include "HDCommon.h" /** * @defgroup MsgQueues MsgQueues * @brief The message queues module provides queuing services for * incoming CAN messages. * * @addtogroup MsgQueues * @{ */ // ********** public definitions ********** #define MAX_MSG_PAYLOAD_SIZE 250 ///< Bytes /// Enumeration of message queues. typedef enum Msg_Queues { MSG_Q_IN = 0, ///< Incoming CAN message queue. NUM_OF_MSG_QUEUES ///< Number of message queues. } MSG_QUEUE_T; #pragma pack(push,1) /// Record structure for message header. typedef struct { S16 seqNo; ///< Sequence number (and ACK required bit) of message U16 msgID; ///< ID of message U08 payloadLen; ///< Length of payload in bytes } MESSAGE_HEADER_T; /// Record structure for a message (header + payload). typedef struct { MESSAGE_HEADER_T hdr; ///< Message header U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; ///< Message payload } MESSAGE_T; /// Record structure for a wrapped message (message + CRC). typedef struct { MESSAGE_T msg; ///< Message U08 crc; ///< Message CRC } MESSAGE_WRAPPER_T; #pragma pack(pop) #define MESSAGE_OVERHEAD_SIZE (sizeof(MESSAGE_HEADER_T) + sizeof(U08)) ///< Byte size of a message's overhead (fixed at 6 bytes). // ********** public function prototypes ********** void initMsgQueues( void ); BOOL addToMsgQueue( MSG_QUEUE_T queue, MESSAGE_WRAPPER_T *msg ); BOOL getFromMsgQueue( MSG_QUEUE_T queue, MESSAGE_WRAPPER_T *msg ); BOOL isMsgQueueEmpty( MSG_QUEUE_T queue ); BOOL isMsgQueueFull( MSG_QUEUE_T queue ); void blankMessage( MESSAGE_T *message ); void blankMessageInWrapper( MESSAGE_WRAPPER_T *message ); /**@}*/ #endif