?? lin_ai.c
字號:
/************************* (c) 2000 STMicroelectronics *************************
PROJECT :
COMPILER : ST7 COSMIC C v4.3a
MODULE : lin_ai.c
VERSION : v2.0
LIN PROTOCOL SPECIFICATION REVISION: 1.2
CREATION DATE : august 2001
AUTHOR : Central Europe 8bit Micro Application Group
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
DESCRIPTION : LIN (Local Interconnect Network) routines - Application Interface
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
MODIFICATIONS :
*******************************************************************************
THE SOFTWARE INCLUDED IN THIS FILE IS FOR GUIDANCE ONLY. ST MICROELECTRONICS
SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES
WITH RESPECT TO ANY CLAIMS ARISING FROM USE OF THIS SOFTWARE.
******************************************************************************/
#include "lin.h"
#include "lin_config.h"
#include "ports.h" /* application example */
/*
ID_Table
========
*/
const t_id_list ID_Table[]=
{
{0x03, ID_DATASENT, 2}, /* application example */
{0x20, ID_DATAREQUEST, 4}, /* application example */
{0x80, ID_DATASENT, 2} /* LIN v1.1 */ /* application example */
// {0x3C, ID_DATASENT, 8} /* LIN v1.2 */ /* application example */
};
#if (sizeof(ID_Table)/3) != ID_TABLE_SIZE
#error "ID_TABLE_SIZE(lin_config.h) should be equal to the number of identifiers in ID_Table"
#endif
/*-----------------------------------------------------------------------------
ROUTINE NAME : DataRequest_Notification
INPUT/OUTPUT : pointer to a LIN header/pointer to an array
DESCRIPTION : Notify the application that the master is requesting data. The
corresponding frame identifier can be read from "header". The
function has to return a pointer to an array, from which the LIN
software will read the data to be sent.
COMMENTS : This function is a notification function automatically called
by the LIN software upon a data request. The user needs to fill
it to define the application LIN communication
-----------------------------------------------------------------------------*/
extern uByte slave_data[]; /* application example */
uByte * DataRequest_Notification(@tiny t_header *header)
{
if(header->identifier == ID_Table[1].id){ /* application example */
return(slave_data); /* application example */
} /* application example */
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : DataReceived_Notification
INPUT/OUTPUT : pointers to a LIN header and response/none
DESCRIPTION : Notify the application that the master has sent data. The
received LIN frame can be read from "header" and "response".
COMMENTS : This function is a notification function automatically called
by the LIN software upon a data reception. The user needs to fill
it to define the application LIN communication. In this case to
handle the received data (for example saving them up).
-----------------------------------------------------------------------------*/
extern uByte master_data[]; /* application example */
void DataReceived_Notification(@tiny t_header *header, @tiny t_response *response)
{
if(header->identifier == ID_Table[0].id){ /* application example */
master_data[0]=response->data[0]; /* application example */
master_data[1]=response->data[1]; /* application example */
} /* application example */
else if(header->identifier == ID_Table[2].id){ /* application example */
PORTS_WakeUp_On(); /* application example */
// if(response->data[0]==0){ /* LIN v1.2 */ /* application example */
// _asm("halt\n"); /* LIN v1.2 */ /* application example */
// } /* LIN v1.2 */ /* application example */
_asm("halt\n"); /* LIN v1.1 */ /* application example */
} /* application example */
}
/*-----------------------------------------------------------------------------
ROUTINE NAME : Error_Notification
INPUT/OUTPUT : error code/none
DESCRIPTION : Notify the application that an error occured. The corresponding
error code can be read in "error_code".
COMMENTS : This function is a notification function automatically called
by the LIN software upon an error. The user needs to fill
it to define the application LIN communication.
-----------------------------------------------------------------------------*/
void Error_Notification(t_error error_code)
{
}
/***** (c) 2001 STMicroelectronics GmbH ****************** END OF FILE *****/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -