S32 SDK
lin.h File Reference
#include "lin_types.h"
#include "lin_cfg.h"
#include "lin_driver.h"

Go to the source code of this file.

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]