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 |
|---|---|---|
struct |
Root configuration structure (build-time; |
|
struct |
Header/response descriptor: |
|
typedef |
Protected identifier (6-bit id + 2 parity bits). |
|
typedef |
Response data length (1…8). |
|
enum |
Checksum model (classic / enhanced). |
|
enum |
Response reaction (TX / RX / IGNORE). |
|
enum |
Bus error reported via |
API at a glance
Function |
Group |
Purpose |
|---|---|---|
Initialization and shutdown |
Initialize the driver and every channel. |
|
Initialization and shutdown |
Abort transfers and de-initialize the driver. |
|
Power state |
Send a wakeup pulse and go operational. |
|
Power state |
Go operational without sending a pulse. |
|
Power state |
Put a channel into sleep. |
|
Scheduling and interrupt |
Service events for polled channels. |
|
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 |
|---|---|---|
LIN-specific |
Reports a received header; the upper layer fills in the reaction. |
|
LIN-specific |
Reports a successfully received response. |
|
LIN-specific |
Reports a successfully transmitted response. |
|
LIN-specific |
Reports a header/response error. |
|
LIN-specific |
Reports a detected wakeup pulse. |
|
Common |
Reports development / runtime errors with a log level. |
|
|
Common (optional) |
Bracket sections requiring exclusive access — see critical sections. |
Data types
-
struct Lin_ConfigType
Configuration structure type.
Configuration variants are selected at build time; Lin_Init currently takes NULL_PTR.
Available via: Lin.h
-
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
-
Lin_PidType pid
Available via: LinIf_DriverTypes.h
-
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
-
enumerator LIN_REACTION_TX
Available via: LinIf_DriverTypes.h
-
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
-
enumerator LIN_ERR_SYNC_FIELD_VALUE
Available via: LinIf_DriverTypes.h
Initialization and shutdown
-
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):
LIN_DEVERR_INVALID_CH_STATE LinDrv is NOT in LIN_DRV_STATE_UNINIT
LIN_DEVERR_PARAM_POINTER configPtr is NOT null pointer
- 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
-
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
-
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):
LIN_DEVERR_PARAM_CHANNELID ChannelId is out of range from configured channelIds.
LIN_DEVERR_UNINIT State is LIN_CH_UNINIT
LIN_DEVERR_INVALID_CH_STATE State is LIN_CH_STATE_OPERATIONAL
- 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
-
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):
LIN_DEVERR_PARAM_CHANNELID ChannelId is out of range from configured channelIds.
LIN_DEVERR_UNINIT State is LIN_CH_UNINIT
- 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
-
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):
LIN_DEVERR_PARAM_CHANNELID channelId is out of range from configured channelIds.
LIN_DEVERR_UNINIT Called when the internal state is LIN_CH_UNINIT
- 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
-
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
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.
-
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
-
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
-
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
-
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