#ifndef _MESSAGE_H
#define _MESSAGE_H

#include "stdint.h" 
#include "string.h"

#define	MAX_FIFO_DEPTH							20			//消息缓存区宽度	

typedef enum
{
	_FALSE = 0,
	_TRUE = !_FALSE
}_bool;

typedef enum {
	_ERROR = 0, 
	_OK = !_ERROR
}_ErrStatus;

//通讯协议消息结构体
typedef struct _ControlMessage
{
	uint16_t         				msgType;					//协议类型	
	uint8_t 								msgData;					//消息的内容
}	Com_ProtocolMessage;


//消息FIFO结构体
typedef struct _MESSAGE_FIFO
{
 	uint8_t									IndexHead;
	uint8_t									Count;
	Com_ProtocolMessage 		Buf[MAX_FIFO_DEPTH];			//通信协议消息对列

} MESSAGE_FIFO;

//消息类型定义
typedef enum _MSG_FIFO_INDEX
{
	MSG_FIFO_PROTOCOL = 0,										//后台通讯协议消息
	MSG_FIFO_RS485_PROTOCOL,									//RS485通讯协议消息	
	MSG_FIFO_COUNT														//消息fifo存储区计数

} MSG_FIFO_INDEX;

extern Com_ProtocolMessage sendMsg;

void MessageInit(void);
_ErrStatus MessageSend(uint8_t MsgFifoIndex, Com_ProtocolMessage event);
Com_ProtocolMessage *MessageGet(uint8_t MsgFifoIndex);

#endif 
