#ifndef _BSP_LIN_H
#define _BSP_LIN_H
#include "at32a423.h"
#define 	Lin_Speed		19200

//LIN接收状态
typedef enum
{
		BREAK_GET = 0,
		SYNCH_GET,
		PID_GET,
		MSG_GET,
		CHECKSUM_GET,
}lin_rxstate_enum;

typedef enum
{
		LIN_OK = 0,		
		FIFO_VOID,		//无数据
		SYNC_ERR,			//同步段错误
		PID_ERR,			//PID错误
		NO_RESPONES,	//无响应
		CYHECK_ERR,		//数据长度错误
		FORMAT_ERR,		//校验和错误	
}lin_error_enum;

#pragma pack (1)
typedef struct
{
		uint8_t	sync;			//同步段：固定值0x55
		uint8_t frameid;	//帧ID
		uint8_t pid;			//PID
		uint8_t datalen;	//LIN数据段有效字节数
		uint8_t data[8];	//数据段（lin规定数据长最多8字节）
		uint8_t checksum;	//校验和
}lin_msg_struct;
#pragma pack()

void lin_init(void);
uint8_t rx_ring_buffer_get_lin_msg(lin_msg_struct * p_lin_msg);
void USART3_IRQHandler(void);
#endif
