📄 user_lin_functions.c
字号:
//****************************************************************************
// @Module User-Module
// @Filename USER_lin_functions.c
// @Project LIN_Protocol
//----------------------------------------------------------------------------
// @Controller Infineon C161CI, Evaluation Kit
//
// @Compiler Keil uVision2 V2.03
//
// @Version 0.1
//
// @Description Includes the functions for user application example. Here
// the LIN-API-functions will be handled and called.
//
//----------------------------------------------------------------------------
// @Date 05/16/2000
//
//****************************************************************************
// USER CODE BEGIN
//----------------------------------------------------------------------------
// @Globals
// <name> <type (In/Out/InOut)> <description>
//
//----------------------------------------------------------------------------
// @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 <LIN_InitNode.H> // LIN initialization header
#include <LIN_driver.H> // LIN-functions
#include <USER_lin_functions.H>// header for User-LIN-functions
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (main,<position>)
//<User local macros definitions>
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
//<User local #define definitions>
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (LIN_function.c, Global Variables)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (<module>,<position>)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN
// The stUserMessage[] buffer should save ID, Data and ID-Types (Rec/Send).
// size of Id Information-buffer depends on number of send- and receive IDs
// spezified in the node (LIN_hLinNode.h).
// in the stUserMessage buffer are a number of MAX_LIN_ID ID-Infos
// to save
// the +1 is the ID for the Sleep-ID
stUSER_MESSAGE stUserMessage[NUM_SEND+NUM_REC+1];
// USER CODE END
//****************************************************************************
// @Function void USER_vCreateBuffer(void)
//
//----------------------------------------------------------------------------
// @Description
// this function creates an array which stores the ID definitions and
// the Data-Bytes of the LIN-Messages of this node.
// And The informations are coming from the header-file
// LINhInitNode.h.
//----------------------------------------------------------------------------
// @Returnvalue
// void
//----------------------------------------------------------------------------
// @Parameters
// void
//----------------------------------------------------------------------------
// @Date 05/17/2000
//
//****************************************************************************
//----------------------------------------------------------------------------
// @Global Variables
// stUserMessage[]: 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: 2-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
//
// !!!Important: The ZERO-ID must be provided eigther as SEND-ID in MASTER
// Mode or as REC-ID in SLAVE-Mode. Otherwise an error can
// occure by receiving or sending an SLEEP-Frame
//****************************************************************************
void USER_vCreateBuffer(void)
{
volatile unsigned char ucLocalCounter = 0;
// set buffer to 0x00 == not defined
while(ucLocalCounter <= NUM_SEND+NUM_REC)
{
stUserMessage[ucLocalCounter++].ucId = 0x00;
}
ucLocalCounter = 0;
// send-message-buffer.
#ifdef SEND_ID0
stUserMessage[ucLocalCounter++].ucId = SEND_ID0;
#endif
#ifdef SEND_ID1
stUserMessage[ucLocalCounter++].ucId = SEND_ID1;
#endif
#ifdef SEND_ID2
stUserMessage[ucLocalCounter++].ucId = SEND_ID2;
#endif
#ifdef SEND_ID3
stUserMessage[ucLocalCounter++].ucId = SEND_ID3;
#endif
#ifdef SEND_ID4
stUserMessage[ucLocalCounter++].ucId = SEND_ID4;
#endif
#ifdef SEND_ID5
stUserMessage[ucLocalCounter++].ucId = SEND_ID5;
#endif
#ifdef SEND_ID6
stUserMessage[ucLocalCounter++].ucId = SEND_ID6;
#endif
#ifdef SEND_ID7
stUserMessage[ucLocalCounter++].ucId = SEND_ID7;
#endif
#ifdef SEND_ID8
stUserMessage[ucLocalCounter++].ucId = SEND_ID8;
#endif
#ifdef SEND_ID9
stUserMessage[ucLocalCounter++].ucId = SEND_ID9;
#endif
#ifdef SEND_ID10
stUserMessage[ucLocalCounter++].ucId = SEND_ID10;
#endif
#ifdef SEND_ID11
stUserMessage[ucLocalCounter++].ucId = SEND_ID11;
#endif
#ifdef SEND_ID12
stUserMessage[ucLocalCounter++].ucId = SEND_ID12;
#endif
#ifdef SEND_ID13
stUserMessage[ucLocalCounter++].ucId = SEND_ID13;
#endif
#ifdef SEND_ID14
stUserMessage[ucLocalCounter++].ucId = SEND_ID14;
#endif
#ifdef SEND_ID15
stUserMessage[ucLocalCounter++].ucId = SEND_ID15;
#endif
#ifdef MASTER
// Important: For the Sleep-Mode
stUserMessage[ucLocalCounter++].ucId = ZERO;
#endif
// receive-message-buffer
#ifdef REC_ID0
stUserMessage[ucLocalCounter++].ucId = REC_ID0;
#endif
#ifdef REC_ID1
stUserMessage[ucLocalCounter++].ucId = REC_ID1;
#endif
#ifdef REC_ID2
stUserMessage[ucLocalCounter++].ucId = REC_ID2;
#endif
#ifdef REC_ID3
stUserMessage[ucLocalCounter++].ucId = REC_ID3;
#endif
#ifdef REC_ID4
stUserMessage[ucLocalCounter++].ucId = REC_ID4;
#endif
#ifdef REC_ID5
stUserMessage[ucLocalCounter++].ucId = REC_ID5;
#endif
#ifdef REC_ID6
stUserMessage[ucLocalCounter++].ucId = REC_ID6;
#endif
#ifdef REC_ID7
stUserMessage[ucLocalCounter++].ucId = REC_ID7;
#endif
#ifdef REC_ID8
stUserMessage[ucLocalCounter++].ucId = REC_ID8;
#endif
#ifdef REC_ID9
stUserMessage[ucLocalCounter++].ucId = REC_ID9;
#endif
#ifdef REC_ID10
stUserMessage[ucLocalCounter++].ucId = REC_ID10;
#endif
#ifdef REC_ID11
stUserMessage[ucLocalCounter++].ucId = REC_ID11;
#endif
#ifdef REC_ID12
stUserMessage[ucLocalCounter++].ucId = REC_ID12;
#endif
#ifdef REC_ID13
stUserMessage[ucLocalCounter++].ucId = REC_ID13;
#endif
#ifdef REC_ID14
stUserMessage[ucLocalCounter++].ucId = REC_ID14;
#endif
#ifdef REC_ID15
stUserMessage[ucLocalCounter++].ucId = REC_ID15;
#endif
#ifdef SLAVE
// Important: For the Sleep-Mode
stUserMessage[ucLocalCounter].ucId = ZERO;
#endif
}
//****************************************************************************
// USER CODE END: void USER_vCreateBuffer()
//****************************************************************************
// @Function stUSER_MESSAGE* USER_pstGetArrayAddress(uchar ucLocalId)
//
//----------------------------------------------------------------------------
// @Description
// this function returns the pointer to structure of the Id
//----------------------------------------------------------------------------
// @Returnvalue pointer to the array structure of the message with the
// cLocalId if ID do not exist a NULL will be returned
//----------------------------------------------------------------------------
// @Parameters char ucLocalId
//
//----------------------------------------------------------------------------
// @Date 04/05/2000
//
//****************************************************************************
//----------------------------------------------------------------------------
// @Global Variables
//
//----------------------------------------------------------------------------
// @AppNote
// With the switch-case statement the correct array-element will be found
// and the address of the array will be returned.
//
// But only the necessary ID will be checkt therefore the #ifdef statements
// had been joined in.
//----------------------------------------------------------------------------
//****************************************************************************
stUSER_MESSAGE* USER_pstGetArrayAddress(unsigned char ucLocalId)
{
unsigned char ucLocCoun;
stUSER_MESSAGE *pstLocalReturnValue;
pstLocalReturnValue = NULL;
for(ucLocCoun = 0;ucLocCoun < (NUM_SEND+NUM_REC+1);ucLocCoun++)
{
if(stUserMessage[ucLocCoun].ucId == ucLocalId)
{
pstLocalReturnValue = &stUserMessage[ucLocCoun];
}
}
return(pstLocalReturnValue);
}
//****************************************************************************
// USER CODE END: pst USER_pstGetArrayAddress(unsigend char ucLocalId)
//****************************************************************************
// @Function void USER_vUCB_TxdId_Received(unsigned char ucLocalId)
//
//----------------------------------------------------------------------------
// @Description
// this function will be called if a new LIN message has been received
// with an ID, defined as Txd-ID.
// The User is able to process on the received message normally following
// function should be called:
// void LIN_vCopy_SendData(unsigned char* pucLocalData)
// with the address of the first data-byte which sould be sent.
//
//----------------------------------------------------------------------------
// @Returnvalue void
//----------------------------------------------------------------------------
// @Parameters uchar ucLocalId: the ID from the received Header
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -