#ifndef __MX_SERIAL_CORE_H
#define __MX_SERIAL_CORE_H
#include "at32a423.h"

#define SERIAL_HEAD	0x5AA5
#define FRAME_HEAD	0XA55A

typedef enum 
{
	DATA_SRC_ERR,
	SOF_ERR,
	DATA_LEN_OVER,
	FRAME_LEN_LITTLE,
	CHECK_SUM_ERR,
	REV_SUCCESSFUL,	
}mx_frame_rev_err;

typedef enum
{
	SOF_GET = 0,
	TRANTYPE_GET,
	DATALEN_GET,
	TYPE_GET,
	DATA_GET,
	CHECKSUM_GET,
}mx_frame_rev_enum;


#pragma pack (1)
typedef struct
{
	uint16_t sof;
	uint8_t trantype;
  uint16_t datalen;
	uint8_t type;
	uint8_t *data;
	uint16_t checksum;
}mx_frame_struct;
#pragma pack ()
uint8_t mx_frame_rev(uint8_t* rev_buff, uint16_t rev_buff_len, mx_frame_struct *mx_out_frame);
uint16_t create_frame(uint8_t *out_frame_buff, uint16_t out_fram_buff_len, mx_frame_struct *mx_input_frame);
#endif

