Files
Frame-rate-optimization/Bsp/bsp_lin.h
2026-04-09 10:14:20 +08:00

43 lines
810 B
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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