📄 lin_driver.c
字号:
//****************************************************************************
// @Module LIN
// @Filename LIN_driver.c
// @Project LIN_Protocol
//----------------------------------------------------------------------------
// @Controller Infineon C161CI, Evaluation Kit
//
// @Compiler Keil uVision2 V2.03
//
// @Version 0.1
//
// @Description Includes general functions, that needed in the Master- and
// in the Slave-Tasks.
//
//----------------------------------------------------------------------------
// @Date 08/01/2000
//
//****************************************************************************
// USER CODE BEGIN
//----------------------------------------------------------------------------
// @Error
// <description of possible errors and error handling>
//
//----------------------------------------------------------------------------
// @AppNote
// <general description of the appnote specific user code within this module>
//
//----------------------------------------------------------------------------
// <else descriptions>
//
//----------------------------------------------------------------------------
// @Copyright (C) 2000 INFINEON TECHNOLOGIES AG. All rights reserved.
//
// Systems Engineering Automotive AI SM SEA
// Juergen Ketterer
//****************************************************************************
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
// USER CODE BEGIN (main,<position>)
#include <REG164ci.H> // register definitions C161
//#include <reg161_more.H> // headerfile with added register definitions
#include <LIN_InitNode.H> // LIN Initialization header
#include <LIN_driver.H> // headerfile for this file
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (main,<position>)
//<User local macros definitions>
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
//<User external declarations of imported global variables>
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN
// Status-words
TRANSCEIVER_STATUS nTRANSCEIVER_STATUS;
NODE_STATUS nNODE_STATUS;
PENDING_STATUS nPENDING_STATUS;
ERROR_STATUS nERROR_STATUS;
// is needed for checksum calculation
// it's impossible to define this in the checksum-calculation function
unsigned char bdata bucIdField;
sbit fb_id0 = bucIdField ^ 0;
sbit fb_id1 = bucIdField ^ 1;
sbit fb_id2 = bucIdField ^ 2;
sbit fb_id3 = bucIdField ^ 3;
sbit fb_id4 = bucIdField ^ 4;
sbit fb_id5 = bucIdField ^ 5;
sbit fb_p0 = bucIdField ^ 6;
sbit fb_p1 = bucIdField ^ 7;
// this varibale indicates a transmitted message by 1 otherwise a 0.
unsigned char ucMessageSent;
// uiBusIdleTimeOutBuffer
// with receiving a new message the timer-value will be saved in this buffer
// when the "fb_no_bus_activity_error"-bit is NOT set.
// if the message is NOT valid, the timer would be reloaded with this saved
// value and the timer go on.
// if the message is valid then this buffer will be set to 0 and the timer
// go on with the current value.
unsigned int uiBusIdleTimeOutBuffer;
// The stLinIdInfo[] buffer should save ID infos and ID-Types.
// size of Id Information-buffer depends on number of send- and receive IDs
// spezified in the node (LIN_hLinNode.h).
// in the LinIdInfo buffer are a number of MAX_LIN_ID ID-Infos
// to save
// the +1 is the ID for the Sleep-ID
// changed by HK
//stLIN_ID_INFO stLinIdInfo[MAX_LIN_ID+1];
stLIN_ID_INFO stLinIdInfo[MAX_LIN_ID];
// stLinTransceiveBuffer[] : The LIN-Transceive-Buffer, this buffer is
// used by the LIN-Functions to send and receive messages. If a message
// should be sent then all data and Id must be saved in this buffer first.
// And if a message has been received, the ID and the data will be saved
// in this buffer, too.
stLIN_MESSAGE stLinTransceiveBuffer[1];
//****************************************************************************
// @Declarations
//****************************************************************************
// global declaration of pointer at User-Call-Back-functions
// see Functions below in this file:
// LIN_vDefineUCBFunctionTxd(...)
// LIN_vDefineUCBFunctionRxd(...)
void (*pvfUcbTxdId)(unsigned char);
void (*pvfUcbRxdId)(unsigned char);
void LIN_vHandleCapCom(unsigned int uiLocalCCReg, \
unsigned int uiLocalCCTimerReg);
//****************************************************************************
// @Function void LIN_vCreateIdInfo(void)
//
//----------------------------------------------------------------------------
// @Description
// this function creates an array which stores the ID definitions
// of this node. The informations are coming from the header-file
// LINhInitNode.h.
//----------------------------------------------------------------------------
// @Returnvalue
// void
//----------------------------------------------------------------------------
// @Parameters
// void
//----------------------------------------------------------------------------
// @Date 05/17/2000
//
//****************************************************************************
//----------------------------------------------------------------------------
// @Global Variables
// stLinIdInfo[] : is the LIN buffer which saves the defined IDs and Types
// of the messages
//----------------------------------------------------------------------------
// @AppNote
// size of message-buffer depends on number of send IDs spezified
// in the node-header (LIN_hLinNode.h).
//
// writes the defined IDs in the struct-variables
// also the Type of the ID: 3-Types are possible
// 1) SEND-TYPE: by receiving an ID defined as SEND-Type: this node
// should send the DATA to the bus
// 2) REC-TYPE: by receiving an ID defined as REC_Type: this node
// should receive the DATA comming on the bus
// 3) MON-TYPE: by receiving an ID defined as MON-Type: this node
// should only MONITOR the DATA (for Failer-Detection)
//
//****************************************************************************
void LIN_vCreateIdInfo(void)
{
volatile unsigned char ucLocalCounter = 0;
// set buffer to ZERO (0x00) == not defined
// changed by HK
//while(ucLocalCounter <= MAX_LIN_ID)
while(ucLocalCounter < MAX_LIN_ID)
{
stLinIdInfo[ucLocalCounter++].ucId = ZERO;
}
ucLocalCounter = 0;
// send-message-buffer.
#ifdef SEND_ID0
stLinIdInfo[ucLocalCounter].ucId = SEND_ID0;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID1
stLinIdInfo[ucLocalCounter].ucId = SEND_ID1;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID2
stLinIdInfo[ucLocalCounter].ucId = SEND_ID2;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID3
stLinIdInfo[ucLocalCounter].ucId = SEND_ID3;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID4
stLinIdInfo[ucLocalCounter].ucId = SEND_ID4;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID5
stLinIdInfo[ucLocalCounter].ucId = SEND_ID5;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID6
stLinIdInfo[ucLocalCounter].ucId = SEND_ID6;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID7
stLinIdInfo[ucLocalCounter].ucId = SEND_ID7;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID8
stLinIdInfo[ucLocalCounter].ucId = SEND_ID8;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID9
stLinIdInfo[ucLocalCounter].ucId = SEND_ID9;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID10
stLinIdInfo[ucLocalCounter].ucId = SEND_ID10;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID11
stLinIdInfo[ucLocalCounter].ucId = SEND_ID11;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID12
stLinIdInfo[ucLocalCounter].ucId = SEND_ID12;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID13
stLinIdInfo[ucLocalCounter].ucId = SEND_ID13;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID14
stLinIdInfo[ucLocalCounter].ucId = SEND_ID14;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
#ifdef SEND_ID15
stLinIdInfo[ucLocalCounter].ucId = SEND_ID15;
stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
#endif
// changed by HK
//#ifdef MASTER
// stLinIdInfo[ucLocalCounter].ucId = ZERO;
// stLinIdInfo[ucLocalCounter++].ucType = SEND_TYPE;
//#endif
// receive-message-buffer
#ifdef REC_ID0
stLinIdInfo[ucLocalCounter].ucId = REC_ID0;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID1
stLinIdInfo[ucLocalCounter].ucId = REC_ID1;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID2
stLinIdInfo[ucLocalCounter].ucId = REC_ID2;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID3
stLinIdInfo[ucLocalCounter].ucId = REC_ID3;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID4
stLinIdInfo[ucLocalCounter].ucId = REC_ID4;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID5
stLinIdInfo[ucLocalCounter].ucId = REC_ID5;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID6
stLinIdInfo[ucLocalCounter].ucId = REC_ID6;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID7
stLinIdInfo[ucLocalCounter].ucId = REC_ID7;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID8
stLinIdInfo[ucLocalCounter].ucId = REC_ID8;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID9
stLinIdInfo[ucLocalCounter].ucId = REC_ID9;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID10
stLinIdInfo[ucLocalCounter].ucId = REC_ID10;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID11
stLinIdInfo[ucLocalCounter].ucId = REC_ID11;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID12
stLinIdInfo[ucLocalCounter].ucId = REC_ID12;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID13
stLinIdInfo[ucLocalCounter].ucId = REC_ID13;
stLinIdInfo[ucLocalCounter++].ucType = REC_TYPE;
#endif
#ifdef REC_ID14
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -