4.16. LIN Module
4.16.1. Acronyms and Definitions
Abbreviation/Term |
Explanation |
---|---|
AUTOSAR |
Automotive Open System Architecture |
BSW |
Basic Software |
MCAL |
Micro Controller Abstraction Layer |
DET |
Default Error Tracer |
HW |
Hardware |
SW |
Software |
EcuM |
ECU Manager |
LIN |
Local Interconnect Network |
MCU |
Micro Controller Unit |
OS |
Operating System |
4.16.2. Introduction
This document describes the functionality and configuration of the AUTOSAR BSW module LIN.
Supported AUTOSAR Release |
4.3.1 |
---|---|
Supported Configuration Variants |
Pre-Compile, Post-build |
Vendor ID |
LIN_VENDOR_ID (44) |
Module ID |
LIN_MODULE_ID (82) |
Supported Platform |
AM263Px |
The LIN module initializes and controls the Lin peripheral. It provides services to send, receive data, sleep and wakeup of the Lin peripheral.
4.16.3. Functional Overview
4.16.3.1. Initialization
Lin_Init () must be called to initialize the LIN driver at power on and sets controller independent init values. This will also set the Lin controllers to IDLE state.
4.16.3.2. States
Refer Chapter 7.3.3 State Diagrams in AUTOSAR_SWS_LINDriver for more details.
4.16.3.3. Assumptions
Only one LIN channel of an ECU is allowed to connect to a particular LIN cluster.
4.16.3.4. Limitations
Abort of current ongoing transmission [SWS_Lin_00021].
Automatic transmission of Goto Sleep command [SWS_Lin_00089].
4.16.3.5. Design overview
Will be updated in future release
4.16.4. Hardware Features
4.16.4.1. IP Supported Features
Compatibility with LIN 1.3 protocols
Configurable baud rate up to 20 kpbs
Two external pins: LINRX and LINTX.
Multibuffered receive and transmit units
Identification masks for message filtering
Automatic commander header generation
Wake up on LINRX dominant level from transceiver
Automatic wake up support
Error detection
2 interrupt lines with priority encoding
Support for LIN 2.0 checksum
Enhanced baud rate generator
4.16.4.2. AUTOSAR Supported Features
Conformance to LIN 2.1 protocol; operation in Master Mode only.
Support of upto 5 Lin Channels
Sleep / wakeup functionality
Enhanced and Classic checksum model
Transmission / Reception of upto 8 bytes of Data
PDU Directions supported : LIN_MASTER_RESPONSE, LIN_SLAVE_RESPONSE, LIN_SLAVE_TO_SLAVE
Use of EcuM wakeup source
Use of Det for reporting of development errors
4.16.4.3. Not supported Features
Abort of ongoing transmission
Automatic transmission of Goto Sleep command
4.16.4.4. Non compliance
4.16.4.4.1. Deviations to requirements (Requirement Traceability)
4.16.4.4.1.1. Deviation of requirements against AUTOSAR specification requirements
Will be updated in next release
4.16.5. Source files
Static source C Files are defined below
📦AM263Px
┣ 📂build
┣ 📂mcal
┃ ┣ 📂Lin
┃ ┃ ┣ 📂include
┃ ┃ ┃ ┣ 📜Lin.h : Contains interface header for Lin Drv functions.
┃ ┃ ┃ ┣ 📜Lin_Irq.h : Contains ISR function declarations for LIN Drv.
┃ ┃ ┣ 📂src
┃ ┃ ┃ ┣ 📜Lin.c : Contains interface for Lin Drv functions.
┃ ┃ ┃ ┣ 📜Lin_Irq.c : Contains Interrupt Service Routines for Lin Drv.
┃ ┃ ┣ 📂V0
┃ ┃ ┃ ┗ 📜cslr_lin.h : Contains Register definitions required for accessing Lin peripherals.
┃ ┃ ┃ ┣ 📜Lin_Priv.c : Contains controller dependent local functions and private functions to be used in Lin.c
┃ ┃ ┃ ┗ 📜Lin_Priv.h : Contains interface header for Lin private functions.
┃ ┃ ┗ 📜Makefile
┃ 📂mcal_config
┃ 📂mcal_docs
┃ 📜README.txt
Plugin files are defined below in the table.
Plugin Files |
Description |
---|---|
Lin_Cfg.h |
Contains the Precompile switches, Macros for LIN channels etc. |
Lin_PBcfg.c |
Contains all channels Post-Build Configuration parameters |
Lin_Cfg.c |
Contains all channels Pre-Compile Configuration parameters |

Fig. 4.78 Lin header file include structure
4.16.6. Module requirements
Please refer Software Product Specification document provided as part of CSP.
4.16.6.1. Memory Mapping
Memory Mapping Sections |
LIN_CODE |
LIN_CODE_ISR |
LIN_VAR_NO_INIT |
LIN_VAR |
LIN_CONST |
LIN_PBCFG |
---|---|---|---|---|---|---|
LIN_START_SEC_VAR_INIT_UNSPECIFIED(.bss) |
x |
|||||
LIN_STOP_SEC_VAR_INIT_UNSPECIFIED |
x |
|||||
LIN_START_SEC_CONFIG_DATA (.const) |
x |
|||||
LIN_STOP_SEC_CONFIG_DATA |
x |
|||||
LIN_START_SEC_CODE(.text) |
x |
|||||
LIN_STOP_SEC_CODE |
x |
|||||
LIN_START_SEC_VAR_INIT_32(.bss) |
x |
|||||
LIN_STOP_SEC_VAR_INIT_32 |
x |
|||||
LIN_START_SEC_VAR_NO_INIT_UNSPECIFIED(.data) |
x |
|||||
LIN_STOP_SEC_VAR_NO_INIT_UNSPECIFIED |
x |
|||||
LIN_START_SEC_ISR_CODE |
x |
|||||
LIN_STOP_SEC_ISR_CODE |
x |
4.16.6.2. Scheduling
4.16.6.2.1. SchM
Beside the OS the BSW Scheduler provides functions that module LIN calls at begin and end of critical sections.
4.16.6.2.2. Critical Sections
There is only one critical section in this driver. Within these sections all read/ modify/ write accesses to internal Lin status variables must be protected. Therefore, switching to tasks that also access LIN must be avoided and all LIN interrupts must be suspended. This is managed internally by Lin Driver.
4.16.6.3. Error handling
4.16.6.3.1. DET Errors
The errors reported to DET module are described in the following table:
Type of Error |
Related Error code |
Value (Hex) |
---|---|---|
API service used without module initialization |
LIN_E_UNINIT |
0x00 |
API service used with an invalid or inactive channel parameter |
LIN_E_INVALID_CHANNEL |
0x02 |
API service called with invalid configuration pointer |
LIN_E_INVALID_POINTER |
0x03 |
Invalid state transition for the current state |
LIN_E_STATE_TRANSITION |
0x04 |
API service called with a NULL pointer |
LIN_E_PARAM_POINTER |
0x05 |
4.16.6.3.2. Runtime Errors
None
4.16.7. Used resources
4.16.7.1. Interrupt Handling
The Driver doesn’t register any interrupts handler (ISR), it’s expected that consumer of this driver registers the required interrupt handler.
AUTOSAR_SWS_LINDriver section: 10 Configuration specification, details the expected behavior and control flow for ISR implementation, please refer the same.
Lin driver provides ISR for wakeup detection. The interrupt vector lines to be used is configurable in Lin driver. The interrupt category must be configured in Lin Driver and OS modules. The ISR’s are implemented in the file Lin_Irq.c.
Respective ISRs for each Lin Instances in AM263Px are as follows:
Lin Instances |
ISR Routines |
---|---|
LIN0 Wakeup Line 0 (IE0) |
Lin_0_Int0ISR() |
LIN0 Wakeup Line 1 (IE1) |
Lin_0_Int1ISR() |
LIN1 Wakeup Line 0 (IE0) |
Lin_1_Int0ISR() |
LIN1 Wakeup Line 1 (IE1) |
Lin_1_Int1ISR() |
LIN2 Wakeup Line 0 (IE0) |
Lin_2_Int0ISR() |
LIN2 Wakeup Line 1 (IE1) |
Lin_2_Int1ISR() |
LIN3 Wakeup Line 0 (IE0) |
Lin_3_Int0ISR() |
LIN3 Wakeup Line 1 (IE1) |
Lin_3_Int1ISR() |
LIN4 Wakeup Line 0 (IE0) |
Lin_4_Int0ISR() |
LIN4 Wakeup Line 1 (IE1) |
Lin_4_Int1ISR() |
Lin_0_Int0ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 0 for the LIN0 controller.
Lin_0_Int1ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 1 for the LIN0 controller
Lin_1_Int0ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 0 for the LIN1 controller.
Lin_1_Int1ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 1 for the LIN1 controller.
Lin_2_Int0ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 0 for the LIN2 controller.
Lin_2_Int1ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 1 for the LIN2 controller.
Lin_3_Int0ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 0 for the LIN3 controller.
Lin_3_Int1ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 1 for the LIN3 controller.
Lin_4_Int0ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 0 for the LIN4 controller.
Lin_4_Int1ISR For AM263Px device, this ISR is called on detection of wakeup event on interrupt line 1 for the LIN4 controller.
4.16.8. Integration description
4.16.8.1. Dependent modules
4.16.8.1.1. MCU
The hardware of the internal LIN hardware unit depends on the system clock, prescaler(s) and PLL. Hence, the length of the LIN bit timing depends on the clock settings made in module MCU. The LIN driver module will not take care of setting the registers that configure the clock, prescaler(s) and PLL (e.g. switching on/off the PLL) in its init functions. The MCU module must do this.
4.16.8.1.2. PORT
The Port driver configures the port pins used for the LIN driver as input or output. Hence, the Port driver has to be initialized prior to the use of LIN functions. Otherwise, LIN driver functions will exhibit undefined behavior.
4.16.8.1.3. OS
The LIN driver uses interrupts and therefore there is a dependency on the OS, which configures the interrupt sources.
4.16.8.1.4. LIN Driver Users
The LIN Interface is the only user of the LIN driver services.
4.16.8.1.5. DET
In development mode, the Lin module reports development error through the Det_ReportError function of module DET.
AUTOSAR requires that API functions shall check the validity of their respective parameters. These checks are for development error reporting and can be enabled or disabled.
4.16.8.1.6. Callback Notification
None
4.16.8.2. Multi-core and Resource allocator
Will be updated in the next release
4.16.9. Configuration
The LIN is configured through GUI in Post-Build and Pre-Compile Variants.
Variants |
Configured Files |
---|---|
PostBuild |
Lin_PBcfg.c , Lin_Cfg.h |
Pre-Compile |
Lin_Cfg.c , Lin_Cfg.h |
4.16.9.1. Parameter Description
4.16.9.1.1. Standard Configuration
Standard Parameters |
Description |
Default Value |
Range |
Unit/Datatype |
---|---|---|---|---|
LinDevErrorDetect |
Switches the development error detection and notification on or off. |
FALSE |
TRUE FALSE |
BOOLEAN |
LinIndex |
Specifies the InstanceId of this module instance. If only one instance is present it shall have the Id 0. |
0 |
0..255 |
INTEGER |
LinTimeoutDuration |
Specifies the maximum number of loops for blocking function until a timeout is raised in short term wait loops |
0 |
0..65535 |
INTEGER |
LinVersionInfoApi |
Switches the Lin_GetVersionInfo function ON or OFF. |
FALSE |
TRUE FALSE |
BOOLEAN |
LinChannelBaudRate |
Specifies the baud rate of the LIN channel |
0 |
1000..20000 |
|
LinChannelId |
Identifies the LIN channel. Replaces LIN_CHANNEL_INDEX_NAME from the LIN SWS. |
0 |
0..65535 |
INTEGER |
LinChannelWakeupSupport |
Specifies if the LIN hardware channel supports wake up functionality |
FALSE |
TRUE FALSE |
BOOLEAN |
LinChannelEcuMWakeupSource |
This parameter contains a reference to the Wakeup Source for this controller as defined in the ECU State Manager. |
NA |
NA |
NA |
LIN_E_TIMEOUT |
Reference to the DemEventParameter which shall be issued when the error “Timeout caused by hardware error” has occurred. If the reference is not configured the error shall be reported as DET error |
FALSE |
0..1 |
BOOLEAN |
4.16.9.1.2. IP Specific Configuration
Standard Parameters |
Description |
Default Value |
Range |
Unit/DataType |
---|---|---|---|---|
LinEnableRegisterReadbackApi |
Switch to indicate that the Lin_RegisterReadBack is supported |
TRUE |
TRUE FALSE |
BOOLEAN |
LinInstance |
Selects Lin Instance |
LIN_INSTANCE_0 |
LIN_INSTANCE_0 LIN_INSTANCE_1 LIN_INSTANCE_2 LIN_INSTANCE_3 LIN_INSTANCE_4 |
ENUMERATION |
LinLoopbackMode |
Select loopback mode to be used for this Lin instance |
LIN_LOOPBACK_DISABLED |
LIN_LOOPBACK_DISABLED LIN_LOOPBACK_INTERNAL LIN_LOOPBACK_EXTERNAL |
ENUMERATION |
LinISRType |
Select ISR type to be used for this Lin instance |
LIN_ISR_CAT2 |
LIN_ISR_VOID LIN_ISR_CAT1 LIN_ISR_CAT2 |
ENUMERATION |
LinInterruptLineSelect |
Select interrupt line to be used for this Lin instance |
LIN_INTERRUPT_LINE_NUM_0 |
LIN_INTERRUPT_LINE_NUM_0 LIN_INTERRUPT_LINE_NUM_1 |
ENUMERATION |
LinChannelPrescalar |
Prescalar to derive LINCLK from VCLK |
155 |
0..16777215 |
INTEGER |
LinChannelFractionalDivider |
The M field of the BRSR register modifies the integer prescaler P for fine tuning of the baud rate. The M value adds in increments of 1/16 of the P value |
4 |
0..15 |
INTEGER |
4.16.9.1.3. Symbolic Names deviations
None
4.16.9.2. Configuration rules and constraints to enable plausibility checks
None
4.16.10. Examples
4.16.10.1. Overview
Will be updated in the next release
4.16.10.2. Hardware Software Setup and Tools
Locate SW9 on the board and set it to ON.
Locate the LIN, LIN-GND and VBat-LIN pins on both the PLIN device and the board. Refer to the documentation or user manual for both the PLIN device and the board to find the correct pins.
Select appropriate cables with the necessary connectors to connect between the PLIN device and the board. Ensure the cables have the correct connectors to fit securely into both the PCAN device and board’s connectors.
Fig. 4.79 LIN Hardware Connectivity with PLIN USB
Open the PLIN configuration software on your PC. The software is usually provided by the manufacturer of the PLIN device.
Locate the settings for baud rate configuration.
Set the baud rate to 19200 and select mode as Slave.
Apply the changes and save the configuration.
Ensure all connections are secure and properly plugged into their respective connectors on both the PLIN device and the board.
Before powering on the system, double-check all connections to ensure they are correctly made, and there are no loose or improperly connected cables.
After making the connections and configuring the PLIN device, power on both the board and the PLIN device.
Once the system is powered on, verify that the LIN communication is established between the board and the PLIN device.
If Slave to Slave mode example needs to be run; we would need 2 PLIN channels to be connected to the same LIN bus.
Reference PLIN configs are placed at path (mcal/examples/Lin/Peak_PLIN_Config); these can be loaded for ease of use.
4.16.10.3. Steps to build and run example
LIN example application demonstrating the MCAL LIN driver features is in folder <MCAL_ROOT>/examples/Lin.
This application can be built from the build folder by giving “gmake –s lin_app PLATFORM=am263px.”
Once the build is completed we get a binary file, which is loaded in our controller and executed.
4.16.10.4. Flow of the example application
PMIC Settings should be initialized for AM263Px CC board.
For AM263Px “PROC110E2A” board:
LIN1 pins are exposed and LIN1 is configured with a 19200 baud.
While running the example code :
First, it asks to select the example to run.
For Master Response example 8 Lin Frames are transmitted with varying PIDs, length and data.
For Slave Response example LIN1 will transmit header with PID (0x20h) and slave will respond with data. Received data will be printed on screen and user can confirm if the data is correct.
For Slave to Slave example LIN1 will transmit header with PID (0x30h); then one of the slaves will send response with data which should be received by the other slave connected on same cluster. User can confirm if the second slave receives the data.
User can also select ‘a’ in console to run all examples sequentially.
4.16.10.5. Configuration used to test this example
LIN1 instance is configured as Channel_1.
Baudrate of 19200 is configured.
4.16.10.6. Example Logs
LIN_APP: Sample Application - STARTS !!!
LIN_APP: LIN MCAL Version Info
---------------------
LIN_APP: Vendor ID: 44
LIN_APP: Module ID: 124
LIN_APP: SW Major Version: 9
LIN_APP: SW Minor Version: 1
LIN_APP: SW Patch Version: 0
LIN_APP: Variant - Post Build being used !!!
LIN_APP: Using LinChannel_1 -> LIN_INSTANCE_1
LIN_APP: Waking LinChannel_1 from sleep
LIN_APP: LinChannel_1 Wakeup Successful
LIN_APP: Enter one of the following
LIN_APP: m - Send Master Response Lin Request
LIN_APP: s - Send Slave Response Lin Request
LIN_APP: x - Send Slave to Slave Lin Request
LIN_APP: a - Send all types Lin Request
LIN_APP: q - to quit the application
LIN_APP: LinChannel_1 operating in Master Response mode
LIN_APP: LinChannel_1 Transmission successful for 0 data frame
LIN_APP: LinChannel_1 Transmission successful for 1 data frame
LIN_APP: LinChannel_1 Transmission successful for 2 data frame
LIN_APP: LinChannel_1 Transmission successful for 3 data frame
LIN_APP: LinChannel_1 Transmission successful for 4 data frame
LIN_APP: LinChannel_1 Transmission successful for 5 data frame
LIN_APP: LinChannel_1 Transmission successful for 6 data frame
LIN_APP: LinChannel_1 Transmission successful for 7 data frame
LIN_APP: LinChannel_1 operating in Slave Response mode
LIN_APP: Received Data : 0xa5 0x55 0xaa 0x55 0xaa 0x55 0xaa 0x55
LIN_APP: Does the data received match the data sent by the Slave? (y/n)
LIN_APP: LinChannel_1 Reception successful
LIN_APP: LinChannel_1 operating in Slave to Slave mode
LIN_APP: Did Slave to Slave communication happen? (y/n)
LIN_APP: LinChannel_1 Slave to Slave communication successful
LIN_APP: Enter one of the following
LIN_APP: m - Send Master Response Lin Request
LIN_APP: s - Send Slave Response Lin Request
LIN_APP: x - Send Slave to Slave Lin Request
LIN_APP: a - Send all types Lin Request
LIN_APP: q - to quit the application
LIN_APP:All sample test case pass
4.16.10.7. File Structure
📦AM263Px
┣ 📂build
┣ 📂mcal
┃ ┣ 📂examples
┃ ┃ ┣ 📂Lin
┃ ┃ ┃ ┣ 📂Peak_PLIN_Config
┃ ┃ ┃ ┣ 📂soc
┃ ┃ ┃ ┣ 📜LinApp.c : Contains LIN test example.
┃ ┃ ┃ ┣ 📜LinApp.h : Contains LIN test example headers.
┃ ┃ ┃ ┣ 📜Makefile
┃ ┣ 📂examples_config
┃ ┃ ┣ 📂Lin_Demo_Cfg
┃ ┃ ┃ ┣ 📂soc
┃ ┃ ┃ ┃ ┣ 📂am263px
┃ ┃ ┃ ┃ ┃ ┣ 📂r5f0_0
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂include
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Lin_Cfg.h : Contains the Precompile switches, Macros for LIN controllers, Hardware Objects etc.
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂src
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Lin_Cfg.c : Contains all controllers Pre-Compile Configuration parameters
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Lin_PBcfg.c : Contains all controllers Post-Build Configuration parameters
┃ 📂mcal_config
┃ 📂mcal_docs
┣ 📜README.txt
4.16.11. FAQ’s
None
4.16.12. Test Report
Please refer AM26x LIN Driver Test Case Report as part of CSP provided in the release package.