📄 lindriver.h
字号:
#ifndef _08QY4_LIN_SLAVE_DRV
#define _08QY4_LIN_SLAVE_DRV
#pragma MESSAGE DISABLE C1106
/* Defs */
//defines needed for the types used in the project
#define U8 unsigned char
#define VU8 volatile unsigned char
#define U16 unsigned short
#define VU16 volatile unsigned short
#define U32 unsigned long
#define VU32 volatile unsigned long
//Driver states
#define Unsyncronized 0
#define Idle 1
#define PossibleSynk 2
#define Syncbreak 3
#define Syncronised 4
#define ReceiveId 8
#define Receiving 9
#define ReceivingWFS 10 // Waiting for start bit while receiving
#define Sending 12
#define SLEEP 0x80
#define SyncBitCount 33
#define DefaultBitTimeH 1
#define DefaultBitTimeL 0xaa
typedef unsigned char byte;
typedef union {
U8 Byte;
struct {
byte Bit :1; /* BitError */
byte Bit2 :1; /* BitError latch */
byte Checksum :1; /* Checksumerror */
byte FTO :1; /* FrametimeOut = No traffic on the bus for FrameTimeOutLimit x 0xFFFF clocks */
byte NRIDD :1; /* RelevantIdTimeOutLimit amount of valid ID's detected without detecting a ID relevant to this slave */
byte Sleep :1; /* */
byte Wake :1; /* Not used at the moment */
byte spare7 :1; /* */
} Bits;
} LINERRORSTR;
#define LinERROR _LinERROR.Byte
#define BitERROR _LinERROR.Bits.Bit
#define BitERROR2 _LinERROR.Bits.Bit2
#define ChecksumERROR _LinERROR.Bits.Checksum
//#define FrameTimeOutERROR _LinERROR.Bits.FTO //not used at the moment
#define NoRelIDDetected _LinERROR.Bits.NRIDD
#define LINSleep _LinERROR.Bits.Sleep
//#define LINWake _LinERROR.Bits.Wake //not used at the moment
#pragma DATA_SEG SHORT _DATA_ZEROPAGE
extern volatile LINERRORSTR _LinERROR;
#pragma DATA_SEG DEFAULT
/* Function Prototype */
/* API */
void LIN_Init(void);
U8 LIN_GetMsg(U8 msgId, U8 *msgData );
U8 LIN_PutMsg(U8 msgId, U8 *msgData);
U8 LIN_MsgStatus(U8 msgId );
void LIN_GotoRun( void );
U8 LIN_Wakeup( void );
/* LIN message declarations */
extern U8 volatile * MessagePointerTbl[];
extern U8 const near IdTbl[];
extern U8 const near MessageCountTbl[];
extern U8 volatile LinMsgStatus[];
extern U8 const No_of_Ids;
#pragma DATA_SEG SHORT _DATA_ZEROPAGE
extern U8 volatile near LinState; //state of the driver
extern U8 volatile near BitTimeH, BitTimeL; //bit time value
extern U8 volatile near BreakH, BreakL; //used for calculating length of breakpulse
#pragma DATA_SEG DEFAULT
/*----------------------------------------------------------------------*/
/* LINStatusType Constant Definition */
#define LIN_OK 0x00 /* No error, service call has succeeded. */
#define LIN_MSG_NOCHANGE 0x02 /* The message data has not changed since last read. */
#define LIN_MSG_OVERRUN 0x04 /* The message data has not been read and was overwritten. */
#define LIN_INVALID_MODE 0x16 /* The service could not be called in the current driver state */
#define LIN_INVALID_ID 0x80 /* The message identifier is invalid, i.e. the message */
/* direction differs from the configured one. */
#define LIN_NO_ID 0x7F /* The message identifier is absent, i.e. there is no such */
/* identifier configured on this node. */
/* Message state */
/* The message data buffer is empty (data has not been initialized or received yet) */
#define LIN_MSG_NODATA 0x01u
/* The message data buffer has been updated by the user */
#define LIN_MSG_UPDATED 0x20u
#define LIN_MSG_OK 0x10u
#endif /* _08QY4_LIN_SLAVE_DRV */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -