/************************************************************************** * * Copyright (c) 2024-2024 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) Vinayakam Mani * @date (last) 05-Aug-2024 * * @author (original) Vinayakam Mani * @date (original) 05-Aug-2024 * ***************************************************************************/ #ifndef __MSG_QUEUES_H__ #define __MSG_QUEUES_H__ #include "DDCommon.h" /** * @defgroup MsgQueues MsgQueues * @brief Message queues service module. Provides message queue functionality * including support functions for adding and getting a message. * * @addtogroup MsgQueues * @{ */ // ********** public definitions ********** #define MAX_MSG_PAYLOAD_SIZE 250 ///< Maximum message payload size in bytes. /// List of message queues. typedef enum Msg_Queues { MSG_Q_IN = 0, ///< Incoming message queue NUM_OF_MSG_QUEUES ///< Number of message queues } MSG_QUEUE_T; #pragma pack(push,1) /// Message header struct. 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; /// Message struct. typedef struct { MESSAGE_HEADER_T hdr; ///< Message header U08 payload[ MAX_MSG_PAYLOAD_SIZE ]; ///< Message payload } MESSAGE_T; /// Message wrapper struct. typedef struct { MESSAGE_T msg; ///< Message struct U08 crc; ///< Message's crc } MESSAGE_WRAPPER_T; #pragma pack(pop) #define MESSAGE_OVERHEAD_SIZE (sizeof(MESSAGE_HEADER_T) + sizeof(U08)) ///< Message overhead size // ********** 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