📄 lin.h
字号:
/////////////////////////////////////////////////////////////////////////////////////////
//
// LIN Sample for Freescale EVB9S08DZ60
// LIN communication data from master to slave
//
// --------------------------------------------------------------------------------------
//
// Copyright (c) 2006 SofTec Microsystems
// http://www.softecmicro.com/
//
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
//
// NOTES:
//
// - LIN bus communication is set to work about at 20Kb/s.
// - Only standard checksum is used.
//
/////////////////////////////////////////////////////////////////////////////////////////
#include <hidef.h>
/////////////////////////////////////////////////////////////////////////////////////////
// Defines
/////////////////////////////////////////////////////////////////////////////////////////
#define MAX_DATA 1 // Max bytes lin frame data
#define SCI_BAUDRATE 19200 // SCI baud rate
#define SCI_CLOCK 2000000 // Bus clock in Hz
#define BIT(A,B) ((A>>B)&0x01) // A is the variable while
// B is the bit number
enum lin_state { IDLE, _BREAK, SYNCH, PROTECTED_IDENTIFIER, DATA_0, DATA_1,
DATA_2, DATA_3, DATA_4, DATA_5, DATA_6, DATA_7, CHECKSUM };
struct message {
unsigned char identifier;
unsigned char data_field[MAX_DATA];
};
struct frame {
unsigned char protected_id;
unsigned char data[MAX_DATA];
unsigned char check;
enum lin_state state;
unsigned char error;
};
/////////////////////////////////////////////////////////////////////////////////////////
// Functions
/////////////////////////////////////////////////////////////////////////////////////////
void LINInit(void);
Bool LINGetMsg(Bool get_data, struct message *msg);
Bool LINSendMsg(Bool master, Bool send_data, struct message msg);
enum lin_state LINCheckState(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -