S32 SDK

Detailed Description

Low level layer consists of functions that call LIN driver API.

This layer contains the implementation of LIN hardware initialization and deinitialization, getting LIN node's current state, sending wakeup signals, enabling and disabling interrupts, sending frame data from a buffer, receiving frame data into a buffer, handling timeout and callbacks from LIN driver.

Data Structures

struct  lin_word_status_str_t
 status of LIN bus Implements : lin_word_status_str_t_Class More...
 
struct  lin_serial_number_t
 Serial number Implements : lin_serial_number_t_Class. More...
 
struct  lin_node_attribute_t
 Attributes of LIN node Implements : lin_node_attribute_t_Class. More...
 
struct  lin_associate_frame_t
 Informations of associated frame Implements : lin_associate_frame_t_Class. More...
 
struct  lin_frame_t
 Frame description structure Implements : lin_frame_t_Class. More...
 
struct  lin_schedule_data_t
 LIN schedule structure Implements : lin_schedule_data_t_Class. More...
 
struct  lin_schedule_t
 Schedule table description Implements : lin_schedule_t_Class. More...
 
struct  lin_transport_layer_queue_t
 Transport layer queue Implements : lin_transport_layer_queue_t_Class. More...
 
struct  lin_tl_descriptor_t
 Transport layer description Implements : lin_tl_descriptor_t_Class. More...
 
struct  lin_protocol_user_config_t
 Configuration structure Implements : lin_protocol_user_config_t_Class. More...
 
struct  lin_master_data_t
 LIN master configuration structure Implements : lin_master_data_t_Class. More...
 
struct  lin_protocol_state_t
 LIN protocol status structure Implements : lin_protocol_state_t_Class. More...
 

Macros

#define SERVICE_ASSIGN_NAD   0xB0U
 
#define SERVICE_ASSIGN_FRAME_ID   0xB1U
 
#define SERVICE_READ_BY_IDENTIFY   0xB2U
 
#define SERVICE_CONDITIONAL_CHANGE_NAD   0xB3U
 
#define SERVICE_SAVE_CONFIGURATION   0xB6U
 
#define SERVICE_ASSIGN_FRAME_ID_RANGE   0xB7U
 
#define SERVICE_READ_DATA_BY_IDENTIFY   0x22U
 
#define SERVICE_WRITE_DATA_BY_IDENTIFY   0x2EU
 
#define SERVICE_SESSION_CONTROL   0x10U
 
#define SERVICE_IO_CONTROL_BY_IDENTIFY   0x2FU
 
#define SERVICE_FAULT_MEMORY_READ   0x19U
 
#define SERIVCE_FAULT_MEMORY_CLEAR   0x14U
 
#define PCI_SAVE_CONFIGURATION   0x01U
 
#define PCI_RES_READ_BY_IDENTIFY   0x06U
 
#define PCI_RES_SAVE_CONFIGURATION   0x01U
 
#define PCI_RES_ASSIGN_FRAME_ID_RANGE   0x01U
 
#define LIN_READ_USR_DEF_MIN   32U
 
#define LIN_READ_USR_DEF_MAX   63U
 
#define LD_ID_NO_RESPONSE   0x52U
 
#define LD_NEGATIVE_RESPONSE   0x53U
 
#define LD_POSITIVE_RESPONSE   0x54U
 
#define LIN_LLD_OK   0x00U
 
#define LIN_LLD_ERROR   0xFFU
 
#define LIN_SLAVE   0
 Mode of LIN node (master or slave) More...
 
#define LIN_MASTER   1
 
#define LIN_TL_CALLBACK_HANDLER(iii, tl_event_id, id)   lin_tl_callback_handler((iii), (tl_event_id), (id))
 
#define INTERLEAVE_MAX_TIMEOUT   (l_u16)(1000000U/TIME_OUT_UNIT_US)
 
#define CALLBACK_HANDLER(iii, event_id, id)   lin_pid_resp_callback_handler((iii), (event_id), (id))
 CALLBACK_HANDLER. More...
 

Typedefs

typedef l_u8 lin_tl_pdu_data_t[8]
 PDU data. Implements : lin_tl_pdu_data_t_Class. More...
 
typedef l_u8 lin_tl_queue_t[8]
 LIN transport layer queue Implements : lin_tl_queue_t_Class. More...
 

Enumerations

enum  lin_lld_event_id_t {
  LIN_LLD_PID_OK = 0x00U, LIN_LLD_TX_COMPLETED = 0x01U, LIN_LLD_RX_COMPLETED = 0x02U, LIN_LLD_PID_ERR = 0x03U,
  LIN_LLD_FRAME_ERR = 0x04U, LIN_LLD_CHECKSUM_ERR = 0x05U, LIN_LLD_READBACK_ERR = 0x06U, LIN_LLD_NODATA_TIMEOUT = 0x07U,
  LIN_LLD_BUS_ACTIVITY_TIMEOUT = 0x08U
}
 Event id Implements : lin_lld_event_id_t_Class. More...
 
enum  lin_protocol_handle_t { LIN_PROTOCOL_21 = 0x00U, LIN_PROTOCOL_J2602 = 0x01U }
 List of protocols Implements : lin_protocol_handle_t_Class. More...
 
enum  lin_diagnostic_class_t { LIN_DIAGNOSTIC_CLASS_I = 0x01U, LIN_DIAGNOSTIC_CLASS_II = 0x02U, LIN_DIAGNOSTIC_CLASS_III = 0x03U }
 List of diagnostic classes Implements : lin_diagnostic_class_t_Class. More...
 
enum  lin_frame_type_t { LIN_FRM_UNCD = 0x00U, LIN_FRM_EVNT = 0x01U, LIN_FRM_SPRDC = 0x10U, LIN_FRM_DIAG = 0x11U }
 Types of frame Implements : lin_frame_type_t_Class. More...
 
enum  lin_frame_response_t { LIN_RES_PUB = 0x00U, LIN_RES_SUB = 0x01U }
 LIN frame response Implements : lin_frame_response_t_Class. More...
 
enum  lin_sch_tbl_type_t {
  LIN_SCH_TBL_NULL = 0x00U, LIN_SCH_TBL_NORM = 0x01U, LIN_SCH_TBL_DIAG = 0x02U, LIN_SCH_TBL_GO_TO_SLEEP = 0x03U,
  LIN_SCH_TBL_COLL_RESOLV = 0x04U
}
 Types of schedule tables Implements : lin_sch_tbl_type_t_Class. More...
 
enum  l_diagnostic_mode_t { DIAG_NONE = 0x00U, DIAG_INTERLEAVE_MODE = 0x01U, DIAG_ONLY_MODE = 0x02U }
 Diagnostic mode Implements : l_diagnostic_mode_t_Class. More...
 
enum  lin_service_status_t { LD_SERVICE_BUSY = 0x00U, LD_REQUEST_FINISHED = 0x01U, LD_SERVICE_IDLE = 0x02U, LD_SERVICE_ERROR = 0x03U }
 Status of the last configuration call for LIN 2.1 Implements : lin_service_status_t_Class. More...
 
enum  lin_last_cfg_result_t { LD_SUCCESS = 0x00U, LD_NEGATIVE = 0x01U, LD_NO_RESPONSE = 0x02U, LD_OVERWRITTEN = 0x03U }
 Status of the last configuration call completed Implements : lin_last_cfg_result_t_Class. More...
 
enum  lin_tl_event_id_t {
  TL_MAKE_RES_DATA = 0x00U, TL_SLAVE_GET_ACTION = 0x01U, TL_TX_COMPLETED = 0x02U, TL_RX_COMPLETED = 0x03U,
  TL_ERROR = 0x04U, TL_TIMEOUT_SERVICE = 0x05U, TL_HANDLER_INTERLEAVE_MODE = 0x06U, TL_RECEIVE_MESSAGE = 0x07U
}
 Transport layer event IDs Implements : lin_tl_event_id_t_Class. More...
 
enum  lin_tl_callback_return_t { TL_ACTION_NONE = 0x00U, TL_ACTION_ID_IGNORE = 0x01U }
 Transport layer event IDs Implements : lin_tl_callback_return_t_Class. More...
 
enum  ld_queue_status_t {
  LD_NO_DATA = 0x00U, LD_DATA_AVAILABLE = 0x01U, LD_RECEIVE_ERROR = 0x02U, LD_QUEUE_FULL = 0x03U,
  LD_QUEUE_AVAILABLE = 0x04U, LD_QUEUE_EMPTY = 0x05U, LD_TRANSMIT_ERROR = 0x06U, LD_TRANSFER_ERROR = 0x07U
}
 Status of queue Implements : ld_queue_status_t_Class. More...
 
enum  lin_message_status_t {
  LD_NO_MSG = 0x00U, LD_IN_PROGRESS = 0x01U, LD_COMPLETED = 0x02U, LD_FAILED = 0x03U,
  LD_N_AS_TIMEOUT = 0x04U, LD_N_CR_TIMEOUT = 0x05U, LD_WRONG_SN = 0x06U
}
 Status of LIN message Implements : lin_message_status_t_Class. More...
 
enum  lin_diagnostic_state_t {
  LD_DIAG_IDLE = 0x01U, LD_DIAG_TX_PHY = 0x02U, LD_DIAG_TX_FUNCTIONAL = 0x03U, LD_DIAG_TX_INTERLEAVED = 0x04U,
  LD_DIAG_RX_PHY = 0x05U, LD_DIAG_RX_FUNCTIONAL = 0x06U, LD_DIAG_RX_INTERLEAVED = 0x07U
}
 LIN diagnostic state Implements : lin_diagnostic_state_t_Class. More...
 
enum  lin_message_timeout_type_t { LD_NO_CHECK_TIMEOUT = 0x00U, LD_CHECK_N_AS_TIMEOUT = 0x01U, LD_CHECK_N_CR_TIMEOUT = 0x02U }
 Types of message timeout Implements : lin_message_timeout_type_t_Class. More...
 
enum  diag_interleaved_state_t { DIAG_NOT_START = 0x00U, DIAG_NO_RESPONSE = 0x01U, DIAG_RESPONSE = 0x02U }
 State of diagnostic interleaved mode Implements : diag_interleaved_state_t_Class. More...
 

Functions

lin_tl_callback_return_t lin_tl_callback_handler (l_ifc_handle iii, lin_tl_event_id_t tl_event_id, l_u8 id)
 
l_u8 ld_read_by_id_callout (l_ifc_handle iii, l_u8 id, l_u8 *data)
 
static l_u16 lin_calc_max_header_timeout_cnt (l_u32 baudRate)
 Computes maximum header timeout. More...
 
static l_u16 lin_calc_max_res_timeout_cnt (l_u32 baudRate, l_u8 size)
 Computes the maximum response timeout. More...
 
l_u8 lin_process_parity (l_u8 pid, l_u8 typeAction)
 Makes or checks parity bits. If action is checking parity, the function returns ID value if parity bits are correct or 0xFF if parity bits are incorrect. If action is making parity bits, then from input value of ID, the function returns PID. More...
 
void lin_pid_resp_callback_handler (l_ifc_handle iii, const lin_lld_event_id_t event_id, l_u8 id)
 Callback handler for low level events. More...
 
l_bool lin_lld_init (l_ifc_handle iii)
 This function initializes a LIN hardware instance for operation. This function will initialize the run-time state structure to keep track of the on-going transfers, initialize the module to user defined settings and default settings, configure the IRQ state structure and enable the module-level interrupt to the core, and enable the LIN hardware module transmitter and receiver. More...
 
l_u8 lin_lld_deinit (l_ifc_handle iii)
 This function disconnect the node from the cluster and free all hardware used. More...
 
l_u8 lin_lld_int_enable (l_ifc_handle iii)
 Enable the interrupt related to the interface. More...
 
l_u8 lin_lld_int_disable (l_ifc_handle iii)
 Disable the interrupt related to the interface. More...
 
l_u8 lin_lld_get_state (l_ifc_handle iii)
 This function gets current state of an interface. More...
 
l_u8 lin_lld_tx_header (l_ifc_handle iii, l_u8 id)
 This function sends frame header for the input PID. More...
 
l_u8 lin_lld_tx_wake_up (l_ifc_handle iii)
 This function send a wakeup signal. More...
 
l_u8 lin_lld_ignore_response (l_ifc_handle iii)
 This function terminates an on-going data transmission/reception. More...
 
l_u8 lin_lld_set_low_power_mode (l_ifc_handle iii)
 Let the low level driver go to low power mode. More...
 
l_u8 lin_lld_set_response (l_ifc_handle iii, l_u8 response_length)
 This function sends frame data that is contained in LIN_lld_response_buffer[iii]. More...
 
l_u8 lin_lld_rx_response (l_ifc_handle iii, l_u8 response_length)
 This function receives frame data into the LIN_lld_response_buffer[iii] buffer. More...
 
void lin_lld_timeout_service (l_ifc_handle iii)
 Callback function for Timer Interrupt Handler In timer IRQ handler, call this function. Used to check if frame timeout has occurred during frame data transmission and reception, to check for N_As and N_Cr timeout for LIN 2.1 and above. This function also check if there is no LIN bus communication (no headers and no frame data transferring) for Idle timeout (s), then put LIN node to Sleep mode. Users may initialize a timer (for example FTM)with period of Timeout unit (default: 500 micro seconds) to call lin_lld_timeout_service(). For an interface iii, Idle timeout (s) = max_idle_timeout_cnt * Timeout unit (us) frame timeout (us) = frame_timeout_cnt * Timeout unit (us) N_As timeout (us) = N_As_timeout * Timeout unit (us) N_Cr timeout (us) = N_Cr_timeout * Timeout unit (us) More...
 

Variables

const lin_node_attribute_t g_lin_node_attribute_array [LIN_NUM_OF_SLAVE_IFCS]
 
lin_master_data_t g_lin_master_data_array [LIN_NUM_OF_MASTER_IFCS]
 
lin_tl_descriptor_t g_lin_tl_descriptor_array [LIN_NUM_OF_IFCS]
 
const lin_protocol_user_config_t g_lin_protocol_user_cfg_array [LIN_NUM_OF_IFCS]
 
lin_protocol_state_t g_lin_protocol_state_array [LIN_NUM_OF_IFCS]
 
l_u8 g_lin_frame_data_buffer [LIN_FRAME_BUF_SIZE]
 
l_u8 g_lin_flag_handle_tbl [LIN_FLAG_BUF_SIZE]
 
l_bool g_lin_frame_flag_handle_tbl [LIN_NUM_OF_FRMS]
 
const l_u32 g_lin_virtual_ifc [LIN_NUM_OF_IFCS]
 
const l_ifc_handle g_lin_hardware_ifc [HARDWARE_INSTANCE_COUNT]
 
const lin_timer_get_time_interval_t timerGetTimeIntervalCallbackArr [LIN_NUM_OF_IFCS]
 

Macro Definition Documentation

#define CALLBACK_HANDLER (   iii,
  event_id,
  id 
)    lin_pid_resp_callback_handler((iii), (event_id), (id))

CALLBACK_HANDLER.

Note
call lin_pid_resp_callback_handler() function in MASTER mode

Definition at line 685 of file lin.h.

#define INTERLEAVE_MAX_TIMEOUT   (l_u16)(1000000U/TIME_OUT_UNIT_US)

Slave node interleaved diagnostic response timeout

Definition at line 447 of file lin.h.

#define LD_ID_NO_RESPONSE   0x52U

Positive response

Definition at line 87 of file lin.h.

#define LD_NEGATIVE_RESPONSE   0x53U

Negative response

Definition at line 88 of file lin.h.

#define LD_POSITIVE_RESPONSE   0x54U

Positive response

Definition at line 89 of file lin.h.

#define LIN_LLD_ERROR   0xFFU

Return value is ERROR

Definition at line 93 of file lin.h.

#define LIN_LLD_OK   0x00U

Return value is OK

Definition at line 92 of file lin.h.

#define LIN_MASTER   1

Master node

Definition at line 168 of file lin.h.

#define LIN_READ_USR_DEF_MAX   63U

Max user defined

Definition at line 84 of file lin.h.

#define LIN_READ_USR_DEF_MIN   32U

Min user defined

Definition at line 83 of file lin.h.

#define LIN_SLAVE   0

Mode of LIN node (master or slave)

Slave node

Definition at line 167 of file lin.h.

#define LIN_TL_CALLBACK_HANDLER (   iii,
  tl_event_id,
  id 
)    lin_tl_callback_handler((iii), (tl_event_id), (id))

Definition at line 374 of file lin.h.

#define PCI_RES_ASSIGN_FRAME_ID_RANGE   0x01U

PCI response value assign frame id range

Definition at line 80 of file lin.h.

#define PCI_RES_READ_BY_IDENTIFY   0x06U

PCI response value read by identify

Definition at line 78 of file lin.h.

#define PCI_RES_SAVE_CONFIGURATION   0x01U

PCI response value save configuration

Definition at line 79 of file lin.h.

#define PCI_SAVE_CONFIGURATION   0x01U

PCI value save configuration

Definition at line 75 of file lin.h.

#define SERIVCE_FAULT_MEMORY_CLEAR   0x14U

Service fault memory clear

Definition at line 72 of file lin.h.

#define SERVICE_ASSIGN_FRAME_ID   0xB1U

Assign frame id service

Definition at line 61 of file lin.h.

#define SERVICE_ASSIGN_FRAME_ID_RANGE   0xB7U

Assign frame id range service

Definition at line 65 of file lin.h.

#define SERVICE_ASSIGN_NAD   0xB0U

Assign NAD service

Definition at line 60 of file lin.h.

#define SERVICE_CONDITIONAL_CHANGE_NAD   0xB3U

Conditional change NAD service

Definition at line 63 of file lin.h.

#define SERVICE_FAULT_MEMORY_READ   0x19U

Service fault memory read

Definition at line 71 of file lin.h.

#define SERVICE_IO_CONTROL_BY_IDENTIFY   0x2FU

Service I/O control

Definition at line 70 of file lin.h.

#define SERVICE_READ_BY_IDENTIFY   0xB2U

Read by identify service

Definition at line 62 of file lin.h.

#define SERVICE_READ_DATA_BY_IDENTIFY   0x22U

Service read data by identifier

Definition at line 67 of file lin.h.

#define SERVICE_SAVE_CONFIGURATION   0xB6U

Save configuration service

Definition at line 64 of file lin.h.

#define SERVICE_SESSION_CONTROL   0x10U

Service session control

Definition at line 69 of file lin.h.

#define SERVICE_WRITE_DATA_BY_IDENTIFY   0x2EU

Service write data by identifier

Definition at line 68 of file lin.h.

Typedef Documentation

typedef l_u8 lin_tl_pdu_data_t[8]

PDU data. Implements : lin_tl_pdu_data_t_Class.

Definition at line 99 of file lin.h.

typedef l_u8 lin_tl_queue_t[8]

LIN transport layer queue Implements : lin_tl_queue_t_Class.

Definition at line 269 of file lin.h.

Enumeration Type Documentation

State of diagnostic interleaved mode Implements : diag_interleaved_state_t_Class.

Enumerator
DIAG_NOT_START 

Not into slave response schedule with interleaved mode

DIAG_NO_RESPONSE 

Master send 0x3D but slave does not response

DIAG_RESPONSE 

Response receive

Definition at line 453 of file lin.h.

Diagnostic mode Implements : l_diagnostic_mode_t_Class.

Enumerator
DIAG_NONE 

None

DIAG_INTERLEAVE_MODE 

Interleave mode

DIAG_ONLY_MODE 

Diagnostic only mode

Definition at line 313 of file lin.h.

Status of queue Implements : ld_queue_status_t_Class.

Enumerator
LD_NO_DATA 

Rx Queue is empty, has no data

LD_DATA_AVAILABLE 

Data in queue is available

LD_RECEIVE_ERROR 

Receive data is error for LIN21 and above

LD_QUEUE_FULL 

The queue is full

LD_QUEUE_AVAILABLE 

Queue is available for insert data for LIN21 and above

LD_QUEUE_EMPTY 

Tx Queue is empty

LD_TRANSMIT_ERROR 

Error while transmitting for LIN21 and above

LD_TRANSFER_ERROR 

Error while transmitting/receiving for LIN20 and J2602

Definition at line 380 of file lin.h.

List of diagnostic classes Implements : lin_diagnostic_class_t_Class.

Enumerator
LIN_DIAGNOSTIC_CLASS_I 

LIN Diagnostic Class 1

LIN_DIAGNOSTIC_CLASS_II 

LIN Diagnostic Class 2

LIN_DIAGNOSTIC_CLASS_III 

LIN Diagnostic Class 3

Definition at line 139 of file lin.h.

LIN diagnostic state Implements : lin_diagnostic_state_t_Class.

Enumerator
LD_DIAG_IDLE 

IDLE

LD_DIAG_TX_PHY 

Diagnostic transmit physical

LD_DIAG_TX_FUNCTIONAL 

Diagnostic transmit active

LD_DIAG_TX_INTERLEAVED 

Diagnostic transmit in interleave mode

LD_DIAG_RX_PHY 

Diagnostic receive in physical

LD_DIAG_RX_FUNCTIONAL 

Diagnostic receive functional request

LD_DIAG_RX_INTERLEAVED 

Diagnostic receive in interleave mode

Definition at line 411 of file lin.h.

LIN frame response Implements : lin_frame_response_t_Class.

Enumerator
LIN_RES_PUB 

Publisher response

LIN_RES_SUB 

Subscriber response

Definition at line 230 of file lin.h.

Types of frame Implements : lin_frame_type_t_Class.

Enumerator
LIN_FRM_UNCD 

Unconditional frame

LIN_FRM_EVNT 

Event triggered frame

LIN_FRM_SPRDC 

Sporadic frame

LIN_FRM_DIAG 

Diagnostic frame

Definition at line 218 of file lin.h.

Status of the last configuration call completed Implements : lin_last_cfg_result_t_Class.

Enumerator
LD_SUCCESS 

The service was successfully carried out

LD_NEGATIVE 

The service failed, more information can be found by parsing error_code

LD_NO_RESPONSE 

No response was received on the request

LD_OVERWRITTEN 

The slave response frame has been overwritten by another operation

Definition at line 336 of file lin.h.

Event id Implements : lin_lld_event_id_t_Class.

Enumerator
LIN_LLD_PID_OK 

LIN_LLD_PID_OK

LIN_LLD_TX_COMPLETED 

LIN_LLD_TX_COMPLETED

LIN_LLD_RX_COMPLETED 

LIN_LLD_RX_COMPLETED

LIN_LLD_PID_ERR 

LIN_LLD_PID_ERR

LIN_LLD_FRAME_ERR 

LIN_LLD_FRAME_ERR

LIN_LLD_CHECKSUM_ERR 

LIN_LLD_CHECKSUM_ERR

LIN_LLD_READBACK_ERR 

LIN_LLD_READBACK_ERR

LIN_LLD_NODATA_TIMEOUT 

No data timeout or received part of data but not completed

LIN_LLD_BUS_ACTIVITY_TIMEOUT 

LIN_LLD_BUS_ACTIVITY_TIMEOUT

Definition at line 109 of file lin.h.

Status of LIN message Implements : lin_message_status_t_Class.

Enumerator
LD_NO_MSG 

No message

LD_IN_PROGRESS 

In progress

LD_COMPLETED 

Completed

LD_FAILED 

Failed

LD_N_AS_TIMEOUT 

N_As timeout

LD_N_CR_TIMEOUT 

N_Cr timeout

LD_WRONG_SN 

Wrong sequence number

Definition at line 396 of file lin.h.

Types of message timeout Implements : lin_message_timeout_type_t_Class.

Enumerator
LD_NO_CHECK_TIMEOUT 

No check timeout

LD_CHECK_N_AS_TIMEOUT 

check N_As timeout

LD_CHECK_N_CR_TIMEOUT 

check N_Cr timeout

Definition at line 426 of file lin.h.

List of protocols Implements : lin_protocol_handle_t_Class.

Enumerator
LIN_PROTOCOL_21 

LIN protocol version 2.1

LIN_PROTOCOL_J2602 

J2602 protocol

Definition at line 129 of file lin.h.

Types of schedule tables Implements : lin_sch_tbl_type_t_Class.

Enumerator
LIN_SCH_TBL_NULL 

Run nothing

LIN_SCH_TBL_NORM 

Normal schedule table

LIN_SCH_TBL_DIAG 

Diagnostic schedule table

LIN_SCH_TBL_GO_TO_SLEEP 

Goto sleep schedule table

LIN_SCH_TBL_COLL_RESOLV 

Collision resolving schedule table

Definition at line 275 of file lin.h.

Status of the last configuration call for LIN 2.1 Implements : lin_service_status_t_Class.

Enumerator
LD_SERVICE_BUSY 

Service is ongoing

LD_REQUEST_FINISHED 

The configuration request has been completed

LD_SERVICE_IDLE 

The configuration request/response combination has been completed

LD_SERVICE_ERROR 

The configuration request or response experienced an error

Definition at line 324 of file lin.h.

Transport layer event IDs Implements : lin_tl_callback_return_t_Class.

Enumerator
TL_ACTION_NONE 

Default return value of call back function

TL_ACTION_ID_IGNORE 

Ignore this ID

Definition at line 364 of file lin.h.

Transport layer event IDs Implements : lin_tl_event_id_t_Class.

Enumerator
TL_MAKE_RES_DATA 

Make master request data

TL_SLAVE_GET_ACTION 

Get slave action

TL_TX_COMPLETED 

Transmit completed

TL_RX_COMPLETED 

Receive completed

TL_ERROR 

Transport error

TL_TIMEOUT_SERVICE 

Transmit timeout

TL_HANDLER_INTERLEAVE_MODE 

Interleave mode

TL_RECEIVE_MESSAGE 

Return data for ld_receive_message function

Definition at line 348 of file lin.h.

Function Documentation

l_u8 ld_read_by_id_callout ( l_ifc_handle  iii,
l_u8  id,
l_u8 data 
)
static l_u16 lin_calc_max_header_timeout_cnt ( l_u32  baudRate)
inlinestatic

Computes maximum header timeout.

Theader_Maximum = 1.4 * THeader_Nominal, THeader_Nominal = 34 * TBit, (13 nominal bits of break; 1 nominal bit of break delimiter; 10 bits for SYNC and 10 bits of PID) TIME_OUT_UNIT_US is in micro second

Parameters
[in]baudRateLIN network baud rate
Returns
maximum timeout for the selected baud rate

Implements : lin_calc_max_header_timeout_cnt_Activity

Definition at line 627 of file lin.h.

static l_u16 lin_calc_max_res_timeout_cnt ( l_u32  baudRate,
l_u8  size 
)
inlinestatic

Computes the maximum response timeout.

TResponse_Maximum = 1.4 * TResponse_Nominal, TResponse_Nominal = 10 * (NData+ 1) * TBit

Parameters
[in]baudRateLIN network baud rate
[in]sizeframe size in bytes
Returns
maximum response timeout for the given baud rate and frame size

Implements : lin_calc_max_res_timeout_cnt_Activity

Definition at line 643 of file lin.h.

l_u8 lin_lld_deinit ( l_ifc_handle  iii)

This function disconnect the node from the cluster and free all hardware used.

Parameters
[in]iiiLIN interface that is being handled
Returns
Zero for success
Non-zero for error

Definition at line 157 of file lin.c.

l_u8 lin_lld_get_state ( l_ifc_handle  iii)

This function gets current state of an interface.

Parameters
[in]iiiLIN interface that is being handled
Returns
current LIN node state

Definition at line 180 of file lin.c.

l_u8 lin_lld_ignore_response ( l_ifc_handle  iii)

This function terminates an on-going data transmission/reception.

Parameters
[in]iiiLIN interface that is being handled
Returns
Zero for success
Non-zero for error

Definition at line 310 of file lin.c.

l_bool lin_lld_init ( l_ifc_handle  iii)

This function initializes a LIN hardware instance for operation. This function will initialize the run-time state structure to keep track of the on-going transfers, initialize the module to user defined settings and default settings, configure the IRQ state structure and enable the module-level interrupt to the core, and enable the LIN hardware module transmitter and receiver.

Parameters
[in]iiiLIN interface that is being handled
Returns
zero if the initialization was successful and non-zero if failed

Definition at line 91 of file lin.c.

l_u8 lin_lld_int_disable ( l_ifc_handle  iii)

Disable the interrupt related to the interface.

Parameters
[in]iiiLIN interface that is being handled
Returns
Zero for success
Non-zero for error

Definition at line 287 of file lin.c.

l_u8 lin_lld_int_enable ( l_ifc_handle  iii)

Enable the interrupt related to the interface.

Parameters
[in]iiiLIN interface that is being handled
Returns
Zero for success
Non-zero for error

Definition at line 264 of file lin.c.

l_u8 lin_lld_rx_response ( l_ifc_handle  iii,
l_u8  response_length 
)

This function receives frame data into the LIN_lld_response_buffer[iii] buffer.

This function will prepare LIN interface to receive data and then return. Data bytes will be received to the buffer in the interrupt handler of LIN interface. This function returns zero if preparation of receiving data was successful.

Parameters
[in]iiiLIN interface that is being handled
[in]response_lengthLength of response
Returns
Zero for success
Non-zero for error

Definition at line 397 of file lin.c.

l_u8 lin_lld_set_low_power_mode ( l_ifc_handle  iii)

Let the low level driver go to low power mode.

Parameters
[in]iiiLIN interface that is being handled
Returns
Zero for success
Non-zero for error

Definition at line 333 of file lin.c.

l_u8 lin_lld_set_response ( l_ifc_handle  iii,
l_u8  response_length 
)

This function sends frame data that is contained in LIN_lld_response_buffer[iii].

This function will send the first data byte in the buffer and then return. Next data bytes will be sent in the interrupt handler of LIN interface. This function returns zero if sending of first data byte was successful.

Parameters
[in]iiiLIN interface that is being handled
[in]response_lengthLength of response
Returns
Zero for success
Non-zero for error

Definition at line 356 of file lin.c.

void lin_lld_timeout_service ( l_ifc_handle  iii)

Callback function for Timer Interrupt Handler In timer IRQ handler, call this function. Used to check if frame timeout has occurred during frame data transmission and reception, to check for N_As and N_Cr timeout for LIN 2.1 and above. This function also check if there is no LIN bus communication (no headers and no frame data transferring) for Idle timeout (s), then put LIN node to Sleep mode. Users may initialize a timer (for example FTM)with period of Timeout unit (default: 500 micro seconds) to call lin_lld_timeout_service(). For an interface iii, Idle timeout (s) = max_idle_timeout_cnt * Timeout unit (us) frame timeout (us) = frame_timeout_cnt * Timeout unit (us) N_As timeout (us) = N_As_timeout * Timeout unit (us) N_Cr timeout (us) = N_Cr_timeout * Timeout unit (us)

Parameters
[in]iiiLIN interface that is being handled
Returns
void

Definition at line 433 of file lin.c.

l_u8 lin_lld_tx_header ( l_ifc_handle  iii,
l_u8  id 
)

This function sends frame header for the input PID.

This function only initializes the sending of break field and then return. Then the sync byte and PID will be sent in the interrupt handler of LIN interface.

Parameters
[in]iiiLIN interface that is being handled
[in]idID of the header to be sent
Returns
Zero for success
Non-zero for error

Definition at line 203 of file lin.c.

l_u8 lin_lld_tx_wake_up ( l_ifc_handle  iii)

This function send a wakeup signal.

Parameters
[in]iiiLIN interface that is being handled
Returns
Zero for success
Non-zero for error

Definition at line 236 of file lin.c.

void lin_pid_resp_callback_handler ( l_ifc_handle  iii,
const lin_lld_event_id_t  event_id,
l_u8  id 
)

Callback handler for low level events.

This callback handler is being called from the LIN driver callback

Parameters
[in]iiiLIN interface that is being handled
[in]event_idLow level event id lin_lld_event_id_t
[in]idCurrent protected identifier under processing by driver

Definition at line 69 of file lin_common_proto.c.

l_u8 lin_process_parity ( l_u8  pid,
l_u8  typeAction 
)

Makes or checks parity bits. If action is checking parity, the function returns ID value if parity bits are correct or 0xFF if parity bits are incorrect. If action is making parity bits, then from input value of ID, the function returns PID.

Parameters
pidPID byte in case of checking parity bits or ID byte in case of making parity bits.
typeActionTRUE for Checking parity bits, FALSE for making parity bits
Returns
0xFF if parity bits are incorrect, ID in case of checking parity bits and they are correct. Function returns PID in case of making parity bits.

Definition at line 74 of file lin.c.

lin_tl_callback_return_t lin_tl_callback_handler ( l_ifc_handle  iii,
lin_tl_event_id_t  tl_event_id,
l_u8  id 
)

Definition at line 86 of file lin_commontl_proto.c.

Variable Documentation

l_u8 g_lin_flag_handle_tbl[LIN_FLAG_BUF_SIZE]
l_u8 g_lin_frame_data_buffer[LIN_FRAME_BUF_SIZE]
l_bool g_lin_frame_flag_handle_tbl[LIN_NUM_OF_FRMS]
const l_ifc_handle g_lin_hardware_ifc[HARDWARE_INSTANCE_COUNT]
lin_master_data_t g_lin_master_data_array[LIN_NUM_OF_MASTER_IFCS]

Global array for storing the master interfaces configurations

Definition at line 52 of file lin.c.

const lin_node_attribute_t g_lin_node_attribute_array[LIN_NUM_OF_SLAVE_IFCS]
lin_protocol_state_t g_lin_protocol_state_array[LIN_NUM_OF_IFCS]

Global array for storing the protocol state for each interface

Definition at line 50 of file lin.c.

const lin_protocol_user_config_t g_lin_protocol_user_cfg_array[LIN_NUM_OF_IFCS]
lin_tl_descriptor_t g_lin_tl_descriptor_array[LIN_NUM_OF_IFCS]

Global array for storing transport configuration for each interface

Definition at line 49 of file lin.c.

const l_u32 g_lin_virtual_ifc[LIN_NUM_OF_IFCS]
const lin_timer_get_time_interval_t timerGetTimeIntervalCallbackArr[LIN_NUM_OF_IFCS]