API Reference

Normative

The LIN driver API contract. A conformant driver MUST provide these types and functions with the behavior described. Signatures and member documentation are extracted from the driver headers with Doxygen/Breathe. Keywords per Requirement Keywords; behavioral rules in Lin — Requirements; error codes in Errors.

Data types at a glance

Type

Kind

Purpose

Lin_ConfigType

struct

Root configuration structure (build-time; Lin_Init takes NULL_PTR).

Lin_PduInfoType

struct

Header/response descriptor: pid / cs / reaction / dl / sduPtr.

Lin_PidType

typedef

Protected identifier (6-bit id + 2 parity bits).

Lin_DlType

typedef

Response data length (1…8).

Lin_CsType

enum

Checksum model (classic / enhanced).

Lin_ReactionType

enum

Response reaction (TX / RX / IGNORE).

Lin_ErrorType

enum

Bus error reported via LinIf_OnError.

API at a glance

Function

Group

Purpose

Lin_Init

Initialization and shutdown

Initialize the driver and every channel.

Lin_DeInit

Initialization and shutdown

Abort transfers and de-initialize the driver.

Lin_Wakeup

Power state

Send a wakeup pulse and go operational.

Lin_WakeupInternal

Power state

Go operational without sending a pulse.

Lin_GoToSleepInternal

Power state

Put a channel into sleep.

Lin_PollFunction

Scheduling and interrupt

Service events for polled channels.

Lin_Interrupt

Scheduling and interrupt

Driver interrupt service routine.

Expected interfaces at a glance

Upper-layer / integration interfaces the integrator MUST provide (CHI-LIN-MUST-18); see the Expected interfaces group below.

Function

Kind

Purpose

LinIf_OnHeader

LIN-specific

Reports a received header; the upper layer fills in the reaction.

LinIf_OnReception

LIN-specific

Reports a successfully received response.

LinIf_OnTransmission

LIN-specific

Reports a successfully transmitted response.

LinIf_OnError

LIN-specific

Reports a header/response error.

LinIf_OnWakeup

LIN-specific

Reports a detected wakeup pulse.

LogM_Report

Common

Reports development / runtime errors with a log level.

<Mip>_EnterCriticalSection / <Mip>_ExitCriticalSection

Common (optional)

Bracket sections requiring exclusive access — see critical sections.

Data types
Lin_ConfigType
struct Lin_ConfigType

Configuration structure type.

Configuration variants are selected at build time; Lin_Init currently takes NULL_PTR. Available via: Lin.h

Lin_PduInfoType
struct Lin_PduInfoType

This Type carries the PID, checksum model, data length and SDU pointer. It is used to provide these information from the LIN Interface to the LIN driver.

Public Members

Lin_PidType pid

Protected identifier

Lin_CsType cs

Checksum model type

Lin_ReactionType reaction

Used to indicate the sender/receiver role

Lin_DlType dl

Data length

uint8 *sduPtr

Pointer to the Service Data Unit (SDU) buffer

Available via: LinIf_DriverTypes.h

Lin_PidType
typedef uint8 Lin_PidType

Protected identifier.

Range:

0…0xFE - The LIN identifier (0…0x3F) together with its two parity bits

Available via: LinIf_DriverTypes.h

Lin_DlType
typedef uint8 Lin_DlType

This type is used to specify the number of SDU data bytes to copy.

Range:

1…8 - Data length of a LIN Frame

Available via: LinIf_DriverTypes.h

Lin_CsType
enum Lin_CsType

This type is used to specify the Checksum model to be used for the LIN Frame.

Values:

enumerator LIN_CS_ENHANCED

Enhanced checksum model

enumerator LIN_CS_CLASSIC

Classic checksum model

Available via: LinIf_DriverTypes.h

Lin_ReactionType
enum Lin_ReactionType

This type indicates whether the frame processor is required to transmit the response part of the LIN frame.

Values:

enumerator LIN_REACTION_TX

This node reacts on the received header and sends a response

enumerator LIN_REACTION_RX

Another node sends a response and this node wants to receive it

enumerator LIN_REACTION_IGNORE

Another node sends a response which is irrelevant for this node

Available via: LinIf_DriverTypes.h

Lin_ErrorType
enum Lin_ErrorType

This type represents the Responder Mode error types that are detected during header reception and response transmission/reception.

Values:

enumerator LIN_ERR_SYNC_FIELD_VALUE

Invalid sync frame

enumerator LIN_ERR_HEADER_FRAMING

Stop bit error in received sync byte or PID byte

enumerator LIN_ERR_PID_PARITY

Invalid parity bits in PID (optional depending on hardware capabilities)

enumerator LIN_ERR_MONITORING

Bit error during transmission

enumerator LIN_ERR_FRAMING

Stop bit error in transmitted or received response

enumerator LIN_ERR_CHECKSUM

Invalid checksum error

enumerator LIN_ERR_NO_RESPONSE

Optional depending on hardware capabilities: Response completely missing

enumerator LIN_ERR_INCOMPLETE_RESPONSE

Optional depending on hardware capabilities: Response only partly received

Available via: LinIf_DriverTypes.h

Initialization and shutdown
Lin_Init
void Lin_Init(const Lin_ConfigType *configPtr)

Initializes the driver and HW.

Sync/Async:

Synchronous

Reentrancy:

Non reentrant

Service ID [hex]:

0x00

Development error(s):

Parameters:

configPtr[in] Pointer to the configuration structure. This parameter is intended for future extensions to support runtime-selectable configuration variants, which allow the selection and initialization of specific variants during runtime. As this functionality is not currently supported, a NULL_PTR SHALL be provided.

Returns:

None.

When to call: once, before any other LIN function, with the driver in LIN_DRV_STATE_UNINIT. configPtr MUST be NULL_PTR.

Effect: initialises the driver and hardware; leaves every channel in SLEEP; enables interrupts for channels configured as interrupt. Errors: see Errors. Available via: Lin.h

Lin_DeInit
void Lin_DeInit(void)

Abort on-going transmission and de-initialize LIN hardware.

Sync/Async:

Synchronous

Reentrancy:

Non reentrant

Service ID [hex]:

0x0e

Parameters:

None

Returns:

None.

Effect: aborts any ongoing transmission/reception and de-initialises the driver, returning it to LIN_DRV_STATE_UNINIT. Available via: Lin.h

Power state
Lin_Wakeup
Std_ReturnType Lin_Wakeup(uint8 channelId)

Sends wakeup frame and sets the driver into operational state.

Sync/Async:

Asynchronous

Reentrancy:

Conditionally reentrant (reentrant when called with different channelIds)

Service ID [hex]:

0x07

Development error(s):

Parameters:

channelId[in] The ID of the LIN channel to be addressed

Return values:
  • E_OK – Command has been accepted

  • E_NOT_OK – Command has not been accepted, error occurred (development or production error)

When to call: on a channel in SLEEP. Effect: transmits a wakeup pulse and moves the channel to OPERATIONAL (asynchronous). Errors: LIN_DEVERR_INVALID_CH_STATE if the channel is already operational — see Errors. Available via: Lin.h

Lin_WakeupInternal
Std_ReturnType Lin_WakeupInternal(uint8 channelId)

Sets the driver into operational state without wakeup frame transmission.

Sync/Async:

Synchronous

Reentrancy:

Conditionally reentrant (reentrant when called with different channelIds)

Service ID [hex]:

0x0b

Development error(s):

Parameters:

channelId[in] The ID of the LIN channel to be addressed.

Return values:
  • E_OK – Command has been accepted.

  • E_NOT_OK – Command has not been accepted, error occurred (development or production error).

Effect: moves the channel to OPERATIONAL without transmitting a wakeup pulse — use after an externally detected wakeup. Errors: see Errors. Available via: Lin.h

Lin_GoToSleepInternal
Std_ReturnType Lin_GoToSleepInternal(uint8 channelId)

Sets the driver state into sleep state.

Sync/Async:

Synchronous

Reentrancy:

Conditionally reentrant (reentrant when called with different channelIds)

Service ID [hex]:

0x09

Development error(s):

Parameters:

channelId[in] The ID of the LIN channel to be addressed.

Return values:
  • E_OK – Command has been accepted.

  • E_NOT_OK – Command has not been accepted, development or production error occurred.

Effect: moves the channel to SLEEP (low-power mode / wakeup detection where supported). Errors: see Errors. Available via: Lin.h

Scheduling and interrupt
Lin_PollFunction
void Lin_PollFunction(void)

Handles LIN event by polling instead of interrupt.

Reentrancy:

Non reentrant

Service ID [hex]:

0x0d

Parameters:

None

Returns:

None.

When to call: cyclically, for channels configured for polling. Services header, response, error, and wakeup events. May be empty if all channels are interrupt-driven. Available via: Lin.h

Lin_Interrupt
void Lin_Interrupt<vectorNr>[<VendorSpecificSuffix>](void)

Effect: the driver interrupt service routine; handles header, response, error, and wakeup events. Define it with the ISR() macro (see the general reference). Available via: Lin.h

Expected interfaces

The driver calls back into these upper-layer / integration interfaces, which the integrator MUST provide (CHI-LIN-MUST-18); see the summary table above. LogM_Report and the critical-section services are documented in the general reference.

LinIf_OnHeader
void LinIf_OnHeader(uint8 channelId, Lin_PduInfoType *pduInfoPtr)

The LinDrv will call this function to report a received LIN header.

Sync/Async:

Synchronous

Reentrancy:

Conditionally reentrant (reentrant when called with different channelIds)

Parameters:
  • channelId[in] The ID of the LIN channel which informs the event.

  • pduInfoPtr[inout]

    Pointer to PDU.

    IN (Updated by LinDrv):

    • pid = received PID

    • sduPtr = points to driver internal buffer(max frame length) OUT (Updated by this indication):

    • reaction, cs, dl = corresponding to the PID

    • sduPtr = updated the buffer contents if the frame reaction is LIN_REACTION_TX

Returns:

None.

Available via: LinIf.h

LinIf_OnReception
void LinIf_OnReception(uint8 channelId, uint8 *sduPtr)

The LinDrv will call this function on completion of a successful RX response.

Sync/Async:

Synchronous

Reentrancy:

Conditionally reentrant (reentrant when called with different channelIds)

Parameters:
  • channelId[in] The ID of the LIN channel which informs the event.

  • sduPtr[in] Pointer to the buffer that holds RX response.

Returns:

None.

Available via: LinIf.h

LinIf_OnTransmission
void LinIf_OnTransmission(uint8 channelId)

The LinDrv will call this function on completion of a successful TX response.

Sync/Async:

Synchronous

Reentrancy:

Reentrant

Parameters:

channelId[in] The ID of the LIN channel which informs the event.

Returns:

None.

Available via: LinIf.h

LinIf_OnError
void LinIf_OnError(uint8 channelId, Lin_ErrorType error)

The LinDrv will call this function on error during transaction.

Sync/Async:

Synchronous

Reentrancy:

Reentrant

Parameters:
  • channelId[in] The ID of the LIN channel which informs the event.

  • error[in] Error code.

Returns:

None.

Available via: LinIf.h

LinIf_OnWakeup
void LinIf_OnWakeup(uint8 channelId)

The LinDrv will call this function when wakeup pulse is detected. In case of wakeup pulse is detected, which is sent by own node, the event is also notified by this function.

Sync/Async:

Synchronous

Reentrancy:

Reentrant

Parameters:

channelId[in] The ID of the LIN channel which informs the event.

Returns:

None.

Available via: LinIf.h