iLLD_TC27xC  1.0
How to use the ASCLIN LIN Interface driver?
Collaboration diagram for How to use the ASCLIN LIN Interface driver?:

The LIN interface driver provides a default ASCLIN configuration for asynchronous serial communication in 8bit mode, and a set of data transfer routines. It supports all four elementary LIN transactions TxH - Transmission of Header TxR - Transmission of Response RxH - Reception of Header RxR - Reception of Response

In the following sections it will be described, how to integrate the driver into the application framework.

Preparation

Include Files

Include following header file into your C code:

Variables

Declare the LIN handle as global variable in your C code:

// used globally
static IfxAsclin_Lin lin;

Module Initialisation

The module initialisation can be done in the same function. Here an example:

// create module config
IfxAsclin_Lin_initModuleConfig(&linConfig, &MODULE_ASCLIN1);
// set the lin mode of operation
// set the desired baudrate
linConfig.btc.prescaler = 4;
linConfig.brg.baudrate = 19200; // FDR values will be calculated in initModule
// pin configuration
const IfxAsclin_Lin_Pins pins = {
};
linConfig.pins = &pins;
// initialize module
//IfxAsclin_Lin lin; // defined globally
IfxAsclin_Lin_initModule(&lin, &linConfig);

The LIN is ready for use now!

Data Transfers

Master Transfers

The LIN driver provides all three master elemnatry tranfers.

This means: you can send a header and based on the id byte, after transmission of header you can send or receive response and also can ignore the header based on the id:

// set the id bytes
uint8 txId = 0x80 // for sending respose after header
uint8 rxId = 0xC1 // for receiving respose after header
// prepare transmit bytes incase of sending response
uint8 txData[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
// prepare receive buffer incase of receiving response
uint8 rxData[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint32 size = 8;
//send response case
if (lin.acknowledgmentFlags.txHeaderEnd == 1) // if the header is been transmitted succesfully
{
IfxAsclin_Lin_sendResponse(&lin, txData, size);
}
//receive response case
if (lin.acknowledgmentFlags.txHeaderEnd == 1) // if the header is been transmitted succesfully
{
IfxAsclin_Lin_receiveResponse(&lin, rxData, size);
}

Slave Transfers

Same as master the LIN driver provides all three slave elemnatry tranfers.

This means: you can receive a header and based on the id byte received, you can send or receive response and can also ignore the header based on the id:

uint8 id; // for storing received id byte
// prepare transmit bytes incase of sending response
uint8 txData[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
// prepare receive buffer incase of receiving response
uint8 rxData[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint32 size = 8;
// receive header
// if data is requsted by master
if(id == txId)
{
IfxAsclin_Lin_sendResponse(&lin, txData, size); // send response
}
// if header is follwed by response
else if(id == rxId)
{
IfxAsclin_Lin_receiveResponse(&lin, rxData, size); // receive response
}
// if header is not for this slave
else
{
}