MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

The MCUXpresso SDK provides a peripheral driver for the Local Interconnect Network (LIN) module of MCUXpresso SDK devices.

Typical use case

LIN Operation

For an example of Local Interconnect Network, see the driver example lin_master or lin_slave.

Data Structures

struct  lin_user_config_t
 LIN hardware configuration structure. More...
 
struct  lin_state_t
 Runtime state of the LIN driver. More...
 
struct  lin_baudrate_values_t
 Structure of baudrate properties. More...
 
struct  lin_frame_struct
 Informations of frame. More...
 
struct  lin_protocol_user_config_t
 Protocol configuration structure. More...
 
struct  lin_product_id
 Product id structure. More...
 
struct  lin_serial_number
 Serial number. More...
 
struct  lin_protocol_state_t
 Protocol state structure. More...
 
struct  lin_node_attribute
 Attributes of LIN node. More...
 
struct  lin_master_data_t
 LIN master data structure. More...
 

Variables

uint8_t lin_user_config_t::hardware_instance
 interface instance number
 
uint32_t lin_user_config_t::baudRate
 baudrate of LIN Hardware Interface to configure
 
bool lin_user_config_t::nodeFunction
 Node function as Master or Slave.
 
bool lin_user_config_t::autobaudEnable
 Enable Autobaud feature.
 
lin_timer_get_time_interval_t lin_user_config_t::timerGetTimeIntervalCallback
 Callback function to get time interval in nano seconds.
 
const uint8_t * lin_state_t::txBuff
 The buffer of data being sent. More...
 
uint8_t * lin_state_t::rxBuff
 The buffer of received data. More...
 
uint8_t lin_state_t::cntByte
 To count number of bytes already transmitted or received. More...
 
volatile uint8_t lin_state_t::txSize
 The remaining number of bytes to be received. More...
 
volatile uint8_t lin_state_t::rxSize
 The remaining number of bytes to be received. More...
 
uint8_t lin_state_t::checkSum
 Checksum byte. More...
 
volatile bool lin_state_t::isTxBusy
 True if the LIN interface is transmitting frame data. More...
 
volatile bool lin_state_t::isRxBusy
 True if the LIN interface is receiving frame data. More...
 
volatile bool lin_state_t::isBusBusy
 True if there are data, frame headers being transferred on bus.
 
volatile bool lin_state_t::isTxBlocking
 True if transmit is blocking transaction. More...
 
volatile bool lin_state_t::isRxBlocking
 True if receive is blocking transaction. More...
 
lin_callback_t lin_state_t::Callback
 Callback function to invoke after receiving a byte or transmitting a byte. More...
 
uint8_t lin_state_t::currentId
 Current ID.
 
uint8_t lin_state_t::currentPid
 Current PID.
 
volatile lin_event_id_t lin_state_t::currentEventId
 Current ID Event.
 
volatile lin_node_state_t lin_state_t::currentNodeState
 Current Node state.
 
volatile uint32_t lin_state_t::timeoutCounter
 Value of the timeout counter.
 
volatile bool lin_state_t::timeoutCounterFlag
 Timeout counter flag.
 
volatile bool lin_state_t::baudrateEvalEnable
 Baudrate Evaluation Process Enable.
 
volatile uint8_t lin_state_t::fallingEdgeInterruptCount
 Falling Edge count of a sync byte.
 
uint32_t lin_state_t::linSourceClockFreq
 Frequency of the source clock for LIN.
 
volatile bool lin_state_t::txCompleted
 Used to wait for LIN interface ISR to complete transmission. More...
 
volatile bool lin_state_t::rxCompleted
 Used to wait for LIN interface ISR to complete reception.
 
lin_frame_type lin_frame_struct::frm_type
 Frame information (unconditional or event triggered..)
 
uint8_t lin_frame_struct::frm_len
 Length of the frame.
 
lin_frame_response lin_frame_struct::frm_response
 Action response when received PID.
 
uint8_t lin_frame_struct::frm_offset
 Frame byte offset in frame buffer.
 
uint8_t lin_frame_struct::flag_offset
 Flag byte offset in flag buffer.
 
uint8_t lin_frame_struct::flag_size
 Flag size in flag buffer.
 
uint32_t lin_frame_struct::delay
 Frame delay.
 
const uint8_t * lin_frame_struct::frame_data_ptr
 List of Signal to which the frame is associated and its offset.
 
lin_protocol_handle lin_protocol_user_config_t::protocol_version
 Protocol version.
 
lin_protocol_handle lin_protocol_user_config_t::language_version
 Language version.
 
uint8_t lin_protocol_user_config_t::number_of_configurable_frames
 Number of frame except diagnostic frames.
 
uint8_t lin_protocol_user_config_t::frame_start
 Start index of frame list.
 
const lin_frame_structlin_protocol_user_config_t::frame_tbl_ptr
 Frame list except diagnostic frames.
 
const uint16_t * lin_protocol_user_config_t::list_identifiers_ROM_ptr
 Configuration in ROM.
 
uint8_t * lin_protocol_user_config_t::list_identifiers_RAM_ptr
 Configuration in RAM.
 
uint16_t lin_protocol_user_config_t::max_idle_timeout_cnt
 Max Idle timeout counter.
 
uint16_t lin_protocol_user_config_t::max_message_length
 Max message length.
 
uint16_t lin_product_id::supplier_id
 Supplier ID.
 
uint16_t lin_product_id::function_id
 Function ID.
 
uint8_t lin_product_id::variant
 Variant value.
 
uint8_t lin_serial_number::serial_0
 Serial 0.
 
uint8_t lin_serial_number::serial_1
 Serial 1.
 
uint8_t lin_serial_number::serial_2
 Serial 2.
 
uint8_t lin_serial_number::serial_3
 Serial 3.
 
uint16_t lin_protocol_state_t::baud_rate
 Adjusted baud rate.
 
uint8_t * lin_protocol_state_t::response_buffer_ptr
 Response buffer.
 
uint8_t lin_protocol_state_t::response_length
 Response length.
 
uint8_t lin_protocol_state_t::successful_transfer
 Transfer flag.
 
uint8_t lin_protocol_state_t::error_in_response
 Error response.
 
uint8_t lin_protocol_state_t::timeout_in_response
 Error response.
 
bool lin_protocol_state_t::go_to_sleep_flg
 Go to sleep flag.
 
uint8_t lin_protocol_state_t::current_id
 Current PID.
 
uint8_t lin_protocol_state_t::num_of_processed_frame
 Number of processed frames.
 
uint8_t lin_protocol_state_t::num_of_successfull_frame
 Number of processed frames.
 
uint8_t lin_protocol_state_t::next_transmit_tick
 Used to count the next transmit tick.
 
bool lin_protocol_state_t::save_config_flg
 Set when save configuration request has been received.
 
lin_diagnostic_mode lin_protocol_state_t::diagnostic_mode
 Diagnostic mode.
 
uint16_t lin_protocol_state_t::frame_timeout_cnt
 Frame timeout counter.
 
uint16_t lin_protocol_state_t::idle_timeout_cnt
 Idle timeout counter.
 
bool lin_protocol_state_t::transmit_error_resp_sig_flg
 Flag indicates that the error reponse signal is going to be sent.
 
bool lin_protocol_state_t::event_trigger_collision_flg
 Flag indicates collision on bus.
 
uint8_t * lin_node_attribute::configured_NAD_ptr
 NAD value used in configuration command.
 
uint8_t lin_node_attribute::initial_NAD
 Initial NAD.
 
lin_product_id lin_node_attribute::product_id
 Product ID.
 
lin_serial_number lin_node_attribute::serial_number
 Serial number.
 
uint8_t * lin_node_attribute::resp_err_frm_id_ptr
 List index of frame contain response error signal.
 
uint8_t lin_node_attribute::num_frame_have_esignal
 Number of frame contain error signal.
 
uint8_t lin_node_attribute::response_error_byte_offset
 Byte offset of response error signal.
 
uint8_t lin_node_attribute::response_error_bit_offset
 Bit offset of response error signal.
 
uint8_t lin_node_attribute::num_of_fault_state_signal
 Number of Fault state signal.
 
uint16_t lin_node_attribute::P2_min
 P2 min.
 
uint16_t lin_node_attribute::ST_min
 ST min.
 
uint16_t lin_node_attribute::N_As_timeout
 N_As_timeout.
 
uint16_t lin_node_attribute::N_Cr_timeout
 N_Cr_timeout.
 
uint8_t lin_master_data_t::active_schedule_id
 Active schedule table id.
 
uint8_t lin_master_data_t::previous_schedule_id
 Previous schedule table id.
 
uint8_t * lin_master_data_t::schedule_start_entry_ptr
 Start entry of each schedule table.
 
uint8_t lin_master_data_t::data_buffer [8]
 Master data buffer.
 

Driver version

enum  lin_frame_type {
  LIN_FRM_UNCD = 0x00U,
  LIN_FRM_EVNT = 0x01U,
  LIN_FRM_SPRDC = 0x10U,
  LIN_FRM_DIAG = 0x11U
}
 List of LIN frame types. More...
 
enum  lin_frame_response {
  LIN_RES_NOTHING = 0x00U,
  LIN_RES_PUB = 0x01U,
  LIN_RES_SUB = 0x10U
}
 List of LIN frame response types. More...
 
enum  lin_diagnostic_mode {
  DIAG_NONE = 0x00U,
  DIAG_INTERLEAVE_MODE = 0x01U,
  DIAG_ONLY_MODE = 0x02U
}
 Diagnostic mode. More...
 
enum  lin_event_id_t {
  LIN_NO_EVENT = 0x00U,
  LIN_WAKEUP_SIGNAL = 0x01U,
  LIN_BAUDRATE_ADJUSTED = 0x02U,
  LIN_RECV_BREAK_FIELD_OK = 0x03U,
  LIN_SYNC_OK = 0x04U,
  LIN_SYNC_ERROR = 0x05U,
  LIN_PID_OK = 0x06U,
  LIN_PID_ERROR = 0x07U,
  LIN_FRAME_ERROR = 0x08U,
  LIN_READBACK_ERROR = 0x09U,
  LIN_CHECKSUM_ERROR = 0x0AU,
  LIN_TX_COMPLETED = 0x0BU,
  LIN_RX_COMPLETED = 0x0CU,
  LIN_NO_DATA_TIMEOUT = 0x0DU,
  LIN_BUS_ACTIVITY_TIMEOUT = 0x0EU,
  LIN_TIMEOUT_ERROR = 0x0FU,
  LIN_NO_EVENT = 0x00U,
  LIN_WAKEUP_SIGNAL = 0x01U,
  LIN_BAUDRATE_ADJUSTED = 0x02U,
  LIN_RECV_BREAK_FIELD_OK = 0x03U,
  LIN_SYNC_OK = 0x04U,
  LIN_SYNC_ERROR = 0x05U,
  LIN_PID_OK = 0x06U,
  LIN_PID_ERROR = 0x07U,
  LIN_FRAME_ERROR = 0x08U,
  LIN_READBACK_ERROR = 0x09U,
  LIN_CHECKSUM_ERROR = 0x0AU,
  LIN_TX_COMPLETED = 0x0BU,
  LIN_RX_COMPLETED = 0x0CU,
  LIN_RX_OVERRUN = 0x0DU
}
 Defines types for an enumerating event related to an Identifier. More...
 
enum  lin_status_t {
  LIN_IFC_NOT_SUPPORT = 0x00U,
  LIN_INITIALIZED = 0x01U,
  LIN_SUCCESS = 0x02U,
  LIN_ERROR = 0x03U,
  LIN_TX_BUSY = 0x04U,
  LIN_RX_BUSY = 0x05U,
  LIN_BUS_BUSY = 0x06U,
  LIN_NO_TRANSFER_IN_PROGRESS = 0x07U,
  LIN_TIMEOUT = 0x08U,
  LIN_LPUART_STAT_CLOCK_GATED_OFF = 0x09U,
  LIN_IFC_NOT_SUPPORT = 0x00U,
  LIN_INITIALIZED = 0x01U,
  LIN_SUCCESS = 0x02U,
  LIN_ERROR = 0x03U,
  LIN_TX_BUSY = 0x04U,
  LIN_RX_BUSY = 0x05U,
  LIN_BUS_BUSY = 0x06U,
  LIN_NO_TRANSFER_IN_PROGRESS = 0x07U,
  LIN_TIMEOUT = 0x08U,
  LIN_LPUART_STAT_CLOCK_GATED_OFF = 0x09U
}
 Defines Error codes of the LIN driver. More...
 
enum  lin_node_state_t {
  LIN_NODE_STATE_UNINIT = 0x00U,
  LIN_NODE_STATE_SLEEP_MODE = 0x01U,
  LIN_NODE_STATE_IDLE = 0x02U,
  LIN_NODE_STATE_SEND_BREAK_FIELD = 0x03U,
  LIN_NODE_STATE_RECV_SYNC = 0x04U,
  LIN_NODE_STATE_SEND_PID = 0x05U,
  LIN_NODE_STATE_RECV_PID = 0x06U,
  LIN_NODE_STATE_RECV_DATA = 0x07U,
  LIN_NODE_STATE_RECV_DATA_COMPLETED = 0x08U,
  LIN_NODE_STATE_SEND_DATA = 0x09U,
  LIN_NODE_STATE_SEND_DATA_COMPLETED = 0x0AU,
  LIN_NODE_STATE_UNINIT = 0x00U,
  LIN_NODE_STATE_SLEEP_MODE = 0x01U,
  LIN_NODE_STATE_IDLE = 0x02U,
  LIN_NODE_STATE_SEND_BREAK_FIELD = 0x03U,
  LIN_NODE_STATE_RECV_SYNC = 0x04U,
  LIN_NODE_STATE_SEND_PID = 0x05U,
  LIN_NODE_STATE_RECV_PID = 0x06U,
  LIN_NODE_STATE_RECV_DATA = 0x07U,
  LIN_NODE_STATE_RECV_DATA_COMPLETED = 0x08U,
  LIN_NODE_STATE_SEND_DATA = 0x09U,
  LIN_NODE_STATE_SEND_DATA_COMPLETED = 0x0AU
}
 Define type for an enumerating LIN Node state. More...
 
enum  lin_protocol_handle {
  LIN_PROTOCOL_21 = 0x00U,
  LIN_PROTOCOL_J2602 = 0x01U
}
 List of protocols. More...
 
enum  lin_supported_baudrates_t
 List of supported baudrates for autobaud feature.
 
typedef void(* lin_timer_get_time_interval_t )(uint32_t *nanoSeconds)
 Callback function to get time interval in nano seconds.
 
typedef void(* lin_callback_t )(uint32_t instance, void *linState)
 LIN Driver callback function type.
 
LPUART_Type *const g_linLpuartBase [FSL_FEATURE_SOC_LPUART_COUNT]
 Table of base addresses for LPUART instances. More...
 
const IRQn_Type g_linLpuartRxTxIrqId [FSL_FEATURE_SOC_LPUART_COUNT]
 Table to save LPUART IRQ enumeration numbers defined in the CMSIS header file.
 
lin_baudrate_values_t g_linConfigBaudrates [LIN_NUM_OF_SUPP_BAUDRATES]
 Table to save LIN user config buadrate values.
 
lin_state_tg_linStatePtr [FSL_FEATURE_SOC_LPUART_COUNT]
 Pointers to LPUART bases for each instance. More...
 
lin_user_config_tg_linUserconfigPtr [FSL_FEATURE_SOC_LPUART_COUNT]
 Table to save LIN user config structure pointers.
 
#define FSL_LIN_DRIVER_VERSION   (MAKE_VERSION(2, 1, 1))
 LIN driver version 2.1.1.
 
#define LIN_SLAVE   0U
 
#define LIN_MASTER   1U
 
#define MAKE_PARITY   0U
 
#define CHECK_PARITY   1U
 
#define LIN_TIME_OUT_UNIT_US   500U
 
#define LIN_MAKE_UNCONDITIONAL_FRAME   0U
 
#define LIN_UPDATE_UNCONDITIONAL_FRAME   1U
 
#define LIN_NUM_OF_SUPP_BAUDRATES   5U
 

LIN DRIVER

uint32_t LIN_CalcMaxHeaderTimeoutCnt (uint32_t baudRate)
 Calculates maximal header time lenght. More...
 
uint32_t LIN_CalcMaxResTimeoutCnt (uint32_t baudRate, uint8_t size)
 Calculates maximal header time lenght. More...
 
lin_status_t LIN_SetResponse (uint8_t instance, uint8_t *response_buff, uint8_t response_length, uint8_t max_frame_res_timeout)
 Forwards a response to a lower level. More...
 
lin_status_t LIN_RxResponse (uint8_t instance, uint8_t *response_buff, uint8_t response_length, uint8_t max_frame_res_timeout)
 Forwards a response to a higher level. More...
 
lin_status_t LIN_IgnoreResponse (uint8_t instance)
 Put a node into idle state. More...
 
void LIN_GetSlaveDefaultConfig (lin_user_config_t *linUserConfig)
 Initializes linUserConfig variable for a slave node. More...
 
void LIN_GetMasterDefaultConfig (lin_user_config_t *linUserConfig)
 Initializes linUserConfig variable for a master node. More...
 
void LIN_CalculateBaudrate (uint32_t instance, uint32_t baudRate_Bps, uint32_t srcClock_Hz, uint32_t *osr, uint16_t *sbr)
 Calculates baudrate registers values for given baudrate. More...
 
void LIN_SetBaudrate (uint32_t instance, uint32_t osr, uint16_t sbr)
 Set baudrate registers values. More...
 
lin_status_t LIN_Init (uint32_t instance, lin_user_config_t *linUserConfig, lin_state_t *linCurrentState, uint32_t clockSource)
 Initializes an instance LIN Hardware Interface for LIN Network. More...
 
lin_status_t LIN_Deinit (uint32_t instance)
 Shuts down the LIN Hardware Interface by disabling interrupts and transmitter/receiver. More...
 
lin_callback_t LIN_InstallCallback (uint32_t instance, lin_callback_t function)
 Installs callback function that is used for LIN_DRV_IRQHandler. More...
 
lin_status_t LIN_SendFrameDataBlocking (uint32_t instance, const uint8_t *txBuff, uint8_t txSize, uint32_t timeoutMSec)
 Sends Frame data out through the LIN Hardware Interface using blocking method. More...
 
lin_status_t LIN_SendFrameData (uint32_t instance, const uint8_t *txBuff, uint8_t txSize)
 Sends frame data out through the LIN Hardware Interface using non-blocking method. More...
 
lin_status_t LIN_GetTransmitStatus (uint32_t instance, uint8_t *bytesRemaining)
 Get status of an on-going non-blocking transmission While sending frame data using non-blocking method, users can use this function to get status of that transmission. More...
 
lin_status_t LIN_ReceiveFrameDataBlocking (uint32_t instance, uint8_t *rxBuff, uint8_t rxSize, uint32_t timeoutMSec)
 Receives frame data through the LIN Hardware Interface using blocking method. More...
 
lin_status_t LIN_ReceiveFrameData (uint32_t instance, uint8_t *rxBuff, uint8_t rxSize)
 Receives frame data through the LIN Hardware Interface using non- blocking method. More...
 
lin_status_t LIN_AbortTransferData (uint32_t instance)
 Aborts an on-going non-blocking transmission/reception. More...
 
lin_status_t LIN_GetReceiveStatus (uint32_t instance, uint8_t *bytesRemaining)
 Get status of an on-going non-blocking reception While receiving frame data using non-blocking method, users can use this function to get status of that receiving. More...
 
lin_status_t LIN_GoToSleepMode (uint32_t instance)
 Puts current LIN node to sleep mode This function changes current node state to LIN_NODE_STATE_SLEEP_MODE. More...
 
lin_status_t LIN_GotoIdleState (uint32_t instance)
 Puts current LIN node to Idle state This function changes current node state to LIN_NODE_STATE_IDLE. More...
 
lin_status_t LIN_SendWakeupSignal (uint32_t instance)
 Sends a wakeup signal through the LIN Hardware Interface. More...
 
lin_node_state_t LIN_GetCurrentNodeState (uint32_t instance)
 Get the current LIN node state. More...
 
void LIN_TimeoutService (uint32_t instance)
 Callback function for Timer Interrupt Handler Users may use (optional, not required) LIN_TimeoutService to check if timeout has occurred during non-blocking frame data transmission and reception. More...
 
void LIN_SetTimeoutCounter (uint32_t instance, uint32_t timeoutValue)
 Set Value for Timeout Counter that is used in LIN_TimeoutService. More...
 
lin_status_t LIN_MasterSendHeader (uint32_t instance, uint8_t id)
 Sends frame header out through the LIN Hardware Interface using a non-blocking method. More...
 
lin_status_t LIN_EnableIRQ (uint32_t instance)
 Enables LIN hardware interrupts. More...
 
lin_status_t LIN_DisableIRQ (uint32_t instance)
 Disables LIN hardware interrupts. More...
 
void LIN_IRQHandler (uint8_t instance)
 Interrupt handler for LIN Hardware Interface. More...
 
lin_status_t LIN_AutoBaudCapture (uint32_t instance)
 This function capture bits time to detect break char, calculate baudrate from sync bits and enable transceiver if autobaud successful. More...
 
uint8_t LIN_ProcessParity (uint8_t PID, uint8_t typeAction)
 Makes or checks parity bits. More...
 
uint8_t LIN_MakeChecksumByte (const uint8_t *buffer, uint8_t sizeBuffer, uint8_t PID)
 Makes the checksum byte for a frame. More...
 

Driver version

enum  lin_event_id_t {
  LIN_NO_EVENT = 0x00U,
  LIN_WAKEUP_SIGNAL = 0x01U,
  LIN_BAUDRATE_ADJUSTED = 0x02U,
  LIN_RECV_BREAK_FIELD_OK = 0x03U,
  LIN_SYNC_OK = 0x04U,
  LIN_SYNC_ERROR = 0x05U,
  LIN_PID_OK = 0x06U,
  LIN_PID_ERROR = 0x07U,
  LIN_FRAME_ERROR = 0x08U,
  LIN_READBACK_ERROR = 0x09U,
  LIN_CHECKSUM_ERROR = 0x0AU,
  LIN_TX_COMPLETED = 0x0BU,
  LIN_RX_COMPLETED = 0x0CU,
  LIN_NO_DATA_TIMEOUT = 0x0DU,
  LIN_BUS_ACTIVITY_TIMEOUT = 0x0EU,
  LIN_TIMEOUT_ERROR = 0x0FU,
  LIN_NO_EVENT = 0x00U,
  LIN_WAKEUP_SIGNAL = 0x01U,
  LIN_BAUDRATE_ADJUSTED = 0x02U,
  LIN_RECV_BREAK_FIELD_OK = 0x03U,
  LIN_SYNC_OK = 0x04U,
  LIN_SYNC_ERROR = 0x05U,
  LIN_PID_OK = 0x06U,
  LIN_PID_ERROR = 0x07U,
  LIN_FRAME_ERROR = 0x08U,
  LIN_READBACK_ERROR = 0x09U,
  LIN_CHECKSUM_ERROR = 0x0AU,
  LIN_TX_COMPLETED = 0x0BU,
  LIN_RX_COMPLETED = 0x0CU,
  LIN_RX_OVERRUN = 0x0DU
}
 Defines types for an enumerating event related to an Identifier. More...
 
enum  lin_status_t {
  LIN_IFC_NOT_SUPPORT = 0x00U,
  LIN_INITIALIZED = 0x01U,
  LIN_SUCCESS = 0x02U,
  LIN_ERROR = 0x03U,
  LIN_TX_BUSY = 0x04U,
  LIN_RX_BUSY = 0x05U,
  LIN_BUS_BUSY = 0x06U,
  LIN_NO_TRANSFER_IN_PROGRESS = 0x07U,
  LIN_TIMEOUT = 0x08U,
  LIN_LPUART_STAT_CLOCK_GATED_OFF = 0x09U,
  LIN_IFC_NOT_SUPPORT = 0x00U,
  LIN_INITIALIZED = 0x01U,
  LIN_SUCCESS = 0x02U,
  LIN_ERROR = 0x03U,
  LIN_TX_BUSY = 0x04U,
  LIN_RX_BUSY = 0x05U,
  LIN_BUS_BUSY = 0x06U,
  LIN_NO_TRANSFER_IN_PROGRESS = 0x07U,
  LIN_TIMEOUT = 0x08U,
  LIN_LPUART_STAT_CLOCK_GATED_OFF = 0x09U
}
 Defines Error codes of the LIN driver. More...
 
enum  lin_node_state_t {
  LIN_NODE_STATE_UNINIT = 0x00U,
  LIN_NODE_STATE_SLEEP_MODE = 0x01U,
  LIN_NODE_STATE_IDLE = 0x02U,
  LIN_NODE_STATE_SEND_BREAK_FIELD = 0x03U,
  LIN_NODE_STATE_RECV_SYNC = 0x04U,
  LIN_NODE_STATE_SEND_PID = 0x05U,
  LIN_NODE_STATE_RECV_PID = 0x06U,
  LIN_NODE_STATE_RECV_DATA = 0x07U,
  LIN_NODE_STATE_RECV_DATA_COMPLETED = 0x08U,
  LIN_NODE_STATE_SEND_DATA = 0x09U,
  LIN_NODE_STATE_SEND_DATA_COMPLETED = 0x0AU,
  LIN_NODE_STATE_UNINIT = 0x00U,
  LIN_NODE_STATE_SLEEP_MODE = 0x01U,
  LIN_NODE_STATE_IDLE = 0x02U,
  LIN_NODE_STATE_SEND_BREAK_FIELD = 0x03U,
  LIN_NODE_STATE_RECV_SYNC = 0x04U,
  LIN_NODE_STATE_SEND_PID = 0x05U,
  LIN_NODE_STATE_RECV_PID = 0x06U,
  LIN_NODE_STATE_RECV_DATA = 0x07U,
  LIN_NODE_STATE_RECV_DATA_COMPLETED = 0x08U,
  LIN_NODE_STATE_SEND_DATA = 0x09U,
  LIN_NODE_STATE_SEND_DATA_COMPLETED = 0x0AU
}
 Define type for an enumerating LIN Node state. More...
 
typedef void(* lin_timer_get_time_interval_t )(uint32_t *nanoSeconds)
 Callback function to get time interval in nano seconds.
 
typedef void(* lin_callback_t )(uint32_t instance, void *linState)
 LIN Driver callback function type.
 
LPUART_Type *const g_linLpuartBase [FSL_FEATURE_SOC_LPUART_COUNT]
 Table of base addresses for LPUART instances. More...
 
const IRQn_Type g_linLpuartRxTxIrqId [FSL_FEATURE_SOC_LPUART_COUNT]
 Table to save LPUART IRQ enumeration numbers defined in the CMSIS header file.
 
lin_state_tg_linStatePtr [FSL_FEATURE_SOC_LPUART_COUNT]
 Table to save LPUART state structure pointers.
 
lin_user_config_tg_linUserconfigPtr [FSL_FEATURE_SOC_LPUART_COUNT]
 Table to save LIN user config structure pointers.
 
#define FSL_LIN_DRIVER_VERSION   (MAKE_VERSION(2, 1, 1))
 LIN stack driver version 2.1.1.
 
#define LIN_TIME_OUT_UNIT_US   500U
 

LIN DRIVER

lin_status_t LIN_DRV_SetResponse (uint8_t instance, uint8_t *response_buff, uint8_t response_length, uint8_t max_frame_res_timeout)
 Forwards a response to a lower level. More...
 
lin_status_t LIN_DRV_RxResponse (uint8_t instance, uint8_t *response_buff, uint8_t response_length, uint8_t max_frame_res_timeout)
 Forwards a response to a higher level. More...
 
lin_status_t LIN_DRV_IgnoreResponse (uint8_t instance)
 Put a node into idle state. More...
 
void LIN_DRV_CalculateBaudrate (uint32_t instance, uint32_t baudRate_Bps, uint32_t srcClock_Hz, uint32_t *osr, uint16_t *sbr)
 Calculates baudrate registers values for given baudrate. More...
 
void LIN_DRV_SetBaudrate (uint32_t instance, uint32_t osr, uint16_t sbr)
 Set baudrate registers values. More...
 
lin_status_t LIN_DRV_Init (uint32_t instance, lin_user_config_t *linUserConfig, lin_state_t *linCurrentState)
 Initializes an instance LIN Hardware Interface for LIN Network. More...
 
lin_status_t LIN_DRV_Deinit (uint32_t instance)
 Shuts down the LIN Hardware Interface by disabling interrupts and transmitter/receiver. More...
 
lin_callback_t LIN_DRV_InstallCallback (uint32_t instance, lin_callback_t function)
 Installs callback function that is used for LIN_DRV_IRQHandler. More...
 
lin_status_t LIN_DRV_SendFrameDataBlocking (uint32_t instance, const uint8_t *txBuff, uint8_t txSize, uint32_t timeoutMSec)
 Sends Frame data out through the LIN Hardware Interface using blocking method. More...
 
lin_status_t LIN_DRV_SendFrameData (uint32_t instance, const uint8_t *txBuff, uint8_t txSize)
 Sends frame data out through the LIN Hardware Interface using non-blocking method. More...
 
lin_status_t LIN_DRV_GetTransmitStatus (uint32_t instance, uint8_t *bytesRemaining)
 Get status of an on-going non-blocking transmission While sending frame data using non-blocking method, users can use this function to get status of that transmission. More...
 
lin_status_t LIN_DRV_ReceiveFrameDataBlocking (uint32_t instance, uint8_t *rxBuff, uint8_t rxSize, uint32_t timeoutMSec)
 Receives frame data through the LIN Hardware Interface using blocking method. More...
 
lin_status_t LIN_DRV_ReceiveFrameData (uint32_t instance, uint8_t *rxBuff, uint8_t rxSize)
 Receives frame data through the LIN Hardware Interface using non- blocking method. More...
 
lin_status_t LIN_DRV_AbortTransferData (uint32_t instance)
 Aborts an on-going non-blocking transmission/reception. More...
 
lin_status_t LIN_DRV_GetReceiveStatus (uint32_t instance, uint8_t *bytesRemaining)
 Get status of an on-going non-blocking reception While receiving frame data using non-blocking method, users can use this function to get status of that receiving. More...
 
lin_status_t LIN_DRV_GoToSleepMode (uint32_t instance)
 Puts current LIN node to sleep mode This function changes current node state to LIN_NODE_STATE_SLEEP_MODE. More...
 
lin_status_t LIN_DRV_GotoIdleState (uint32_t instance)
 Puts current LIN node to Idle state This function changes current node state to LIN_NODE_STATE_IDLE. More...
 
lin_status_t LIN_DRV_SendWakeupSignal (uint32_t instance)
 Sends a wakeup signal through the LIN Hardware Interface. More...
 
lin_node_state_t LIN_DRV_GetCurrentNodeState (uint32_t instance)
 Get the current LIN node state. More...
 
void LIN_DRV_TimeoutService (uint32_t instance)
 Callback function for Timer Interrupt Handler Users may use (optional, not required) LIN_TimeoutService to check if timeout has occurred during non-blocking frame data transmission and reception. More...
 
static void LIN_DRV_SetTimeoutCounter (uint32_t instance, uint32_t timeoutValue)
 Set Value for Timeout Counter that is used in LIN_TimeoutService. More...
 
lin_status_t LIN_DRV_MasterSendHeader (uint32_t instance, uint8_t id)
 Sends frame header out through the LIN Hardware Interface using a non-blocking method. More...
 
lin_status_t LIN_DRV_EnableIRQ (uint32_t instance)
 Enables LIN hardware interrupts. More...
 
lin_status_t LIN_DRV_DisableIRQ (uint32_t instance)
 Disables LIN hardware interrupts. More...
 
void LIN_DRV_IRQHandler (uint8_t instance)
 Interrupt handler for LIN Hardware Interface. More...
 
static lin_status_t LIN_DRV_AutoBaudCapture (uint32_t instance)
 This function capture bits time to detect break char. More...
 
static uint8_t LIN_DRV_ProcessParity (uint8_t PID, uint8_t typeAction)
 Makes or checks parity bits. More...
 
static uint8_t LIN_DRV_MakeChecksumByte (const uint8_t *buffer, uint8_t sizeBuffer, uint8_t PID)
 Makes the checksum byte for a frame. More...
 

Data Structure Documentation

struct lin_user_config_t

Data Fields

uint8_t hardware_instance
 interface instance number
 
uint32_t baudRate
 baudrate of LIN Hardware Interface to configure
 
bool nodeFunction
 Node function as Master or Slave.
 
bool autobaudEnable
 Enable Autobaud feature.
 
lin_timer_get_time_interval_t timerGetTimeIntervalCallback
 Callback function to get time interval in nano seconds.
 
struct lin_state_t

Note that the caller provides memory for the driver state structures during initialization because the driver does not statically allocate memory.

Data Fields

const uint8_t * txBuff
 The buffer of data being sent. More...
 
uint8_t * rxBuff
 The buffer of received data. More...
 
uint8_t cntByte
 To count number of bytes already transmitted or received. More...
 
volatile uint8_t txSize
 The remaining number of bytes to be received. More...
 
volatile uint8_t rxSize
 The remaining number of bytes to be received. More...
 
uint8_t checkSum
 Checksum byte. More...
 
volatile bool isTxBusy
 True if the LIN interface is transmitting frame data. More...
 
volatile bool isRxBusy
 True if the LIN interface is receiving frame data. More...
 
volatile bool isBusBusy
 True if there are data, frame headers being transferred on bus.
 
volatile bool isTxBlocking
 True if transmit is blocking transaction. More...
 
volatile bool isRxBlocking
 True if receive is blocking transaction. More...
 
lin_callback_t Callback
 Callback function to invoke after receiving a byte or transmitting a byte. More...
 
uint8_t currentId
 Current ID.
 
uint8_t currentPid
 Current PID.
 
volatile lin_event_id_t currentEventId
 Current ID Event.
 
volatile lin_node_state_t currentNodeState
 Current Node state.
 
volatile uint32_t timeoutCounter
 Value of the timeout counter.
 
volatile bool timeoutCounterFlag
 Timeout counter flag.
 
volatile bool baudrateEvalEnable
 Baudrate Evaluation Process Enable.
 
volatile uint8_t fallingEdgeInterruptCount
 Falling Edge count of a sync byte.
 
uint32_t linSourceClockFreq
 Frequency of the source clock for LIN.
 
volatile bool txCompleted
 Used to wait for LIN interface ISR to complete transmission. More...
 
volatile bool rxCompleted
 Used to wait for LIN interface ISR to complete reception.
 
struct lin_baudrate_values_t
struct lin_frame_struct

Data Fields

lin_frame_type frm_type
 Frame information (unconditional or event triggered..)
 
uint8_t frm_len
 Length of the frame.
 
lin_frame_response frm_response
 Action response when received PID.
 
uint8_t frm_offset
 Frame byte offset in frame buffer.
 
uint8_t flag_offset
 Flag byte offset in flag buffer.
 
uint8_t flag_size
 Flag size in flag buffer.
 
uint32_t delay
 Frame delay.
 
const uint8_t * frame_data_ptr
 List of Signal to which the frame is associated and its offset.
 
struct lin_protocol_user_config_t

Data Fields

lin_protocol_handle protocol_version
 Protocol version.
 
lin_protocol_handle language_version
 Language version.
 
uint8_t number_of_configurable_frames
 Number of frame except diagnostic frames.
 
uint8_t frame_start
 Start index of frame list.
 
const lin_frame_structframe_tbl_ptr
 Frame list except diagnostic frames.
 
const uint16_t * list_identifiers_ROM_ptr
 Configuration in ROM.
 
uint8_t * list_identifiers_RAM_ptr
 Configuration in RAM.
 
uint16_t max_idle_timeout_cnt
 Max Idle timeout counter.
 
uint16_t max_message_length
 Max message length.
 
struct lin_product_id

Data Fields

uint16_t supplier_id
 Supplier ID.
 
uint16_t function_id
 Function ID.
 
uint8_t variant
 Variant value.
 
struct lin_serial_number

Data Fields

uint8_t serial_0
 Serial 0.
 
uint8_t serial_1
 Serial 1.
 
uint8_t serial_2
 Serial 2.
 
uint8_t serial_3
 Serial 3.
 
struct lin_protocol_state_t

Data Fields

uint16_t baud_rate
 Adjusted baud rate.
 
uint8_t * response_buffer_ptr
 Response buffer.
 
uint8_t response_length
 Response length.
 
uint8_t successful_transfer
 Transfer flag.
 
uint8_t error_in_response
 Error response.
 
uint8_t timeout_in_response
 Error response.
 
bool go_to_sleep_flg
 Go to sleep flag.
 
uint8_t current_id
 Current PID.
 
uint8_t num_of_processed_frame
 Number of processed frames.
 
uint8_t num_of_successfull_frame
 Number of processed frames.
 
uint8_t next_transmit_tick
 Used to count the next transmit tick.
 
bool save_config_flg
 Set when save configuration request has been received.
 
lin_diagnostic_mode diagnostic_mode
 Diagnostic mode.
 
uint16_t frame_timeout_cnt
 Frame timeout counter.
 
uint16_t idle_timeout_cnt
 Idle timeout counter.
 
bool transmit_error_resp_sig_flg
 Flag indicates that the error reponse signal is going to be sent.
 
bool event_trigger_collision_flg
 Flag indicates collision on bus.
 
struct lin_node_attribute

Data Fields

uint8_t * configured_NAD_ptr
 NAD value used in configuration command.
 
uint8_t initial_NAD
 Initial NAD.
 
lin_product_id product_id
 Product ID.
 
lin_serial_number serial_number
 Serial number.
 
uint8_t * resp_err_frm_id_ptr
 List index of frame contain response error signal.
 
uint8_t num_frame_have_esignal
 Number of frame contain error signal.
 
uint8_t response_error_byte_offset
 Byte offset of response error signal.
 
uint8_t response_error_bit_offset
 Bit offset of response error signal.
 
uint8_t num_of_fault_state_signal
 Number of Fault state signal.
 
uint16_t P2_min
 P2 min.
 
uint16_t ST_min
 ST min.
 
uint16_t N_As_timeout
 N_As_timeout.
 
uint16_t N_Cr_timeout
 N_Cr_timeout.
 
struct lin_master_data_t

Data Fields

uint8_t active_schedule_id
 Active schedule table id.
 
uint8_t previous_schedule_id
 Previous schedule table id.
 
uint8_t * schedule_start_entry_ptr
 Start entry of each schedule table.
 
uint8_t data_buffer [8]
 Master data buffer.
 

Enumeration Type Documentation

Enumerator
LIN_FRM_UNCD 

unconditional frame

LIN_FRM_EVNT 

event triggered frame

LIN_FRM_SPRDC 

sporadic frame

LIN_FRM_DIAG 

diagnostic frame

Enumerator
LIN_RES_NOTHING 

node is neither publisher nor subscriber

LIN_RES_PUB 

node is publisher

LIN_RES_SUB 

node is subscriber

Enumerator
DIAG_NONE 

None.

DIAG_INTERLEAVE_MODE 

Interleave mode.

DIAG_ONLY_MODE 

Diagnostic only mode.

Enumerator
LIN_NO_EVENT 

No event yet.

LIN_WAKEUP_SIGNAL 

Received a wakeup signal.

LIN_BAUDRATE_ADJUSTED 

Indicate that baudrate was adjusted to Master's baudrate.

LIN_RECV_BREAK_FIELD_OK 

Indicate that correct Break Field was received.

LIN_SYNC_OK 

Sync byte is correct.

LIN_SYNC_ERROR 

Sync byte is incorrect.

LIN_PID_OK 

PID correct.

LIN_PID_ERROR 

PID incorrect.

LIN_FRAME_ERROR 

Framing Error.

LIN_READBACK_ERROR 

Readback data is incorrect.

LIN_CHECKSUM_ERROR 

Checksum byte is incorrect.

LIN_TX_COMPLETED 

Sending data completed.

LIN_RX_COMPLETED 

Receiving data completed.

LIN_NO_DATA_TIMEOUT 

No data timeout.

LIN_BUS_ACTIVITY_TIMEOUT 

Bus activity timeout.

LIN_TIMEOUT_ERROR 

Indicate that timeout has occurred.

LIN_NO_EVENT 

No event yet.

LIN_WAKEUP_SIGNAL 

Received a wakeup signal.

LIN_BAUDRATE_ADJUSTED 

Indicate that baudrate was adjusted to Master's baudrate.

LIN_RECV_BREAK_FIELD_OK 

Indicate that correct Break Field was received.

LIN_SYNC_OK 

Sync byte is correct.

LIN_SYNC_ERROR 

Sync byte is incorrect.

LIN_PID_OK 

PID correct.

LIN_PID_ERROR 

PID incorrect.

LIN_FRAME_ERROR 

Framing Error.

LIN_READBACK_ERROR 

Readback data is incorrect.

LIN_CHECKSUM_ERROR 

Checksum byte is incorrect.

LIN_TX_COMPLETED 

Sending data completed.

LIN_RX_COMPLETED 

Receiving data completed.

LIN_RX_OVERRUN 

Rx overrun flag.

Enumerator
LIN_IFC_NOT_SUPPORT 

This interface is not supported.

LIN_INITIALIZED 

LIN Hardware has been initialized.

LIN_SUCCESS 

Successfully done.

LIN_ERROR 

Error.

LIN_TX_BUSY 

Transmitter is busy.

LIN_RX_BUSY 

Receiver is busy.

LIN_BUS_BUSY 

Bus is busy.

LIN_NO_TRANSFER_IN_PROGRESS 

No data transfer is in progress.

LIN_TIMEOUT 

Timeout.

LIN_LPUART_STAT_CLOCK_GATED_OFF 

LPUART is gated from clock manager.

LIN_IFC_NOT_SUPPORT 

This interface is not supported.

LIN_INITIALIZED 

LIN Hardware has been initialized.

LIN_SUCCESS 

Successfully done.

LIN_ERROR 

Error.

LIN_TX_BUSY 

Transmitter is busy.

LIN_RX_BUSY 

Receiver is busy.

LIN_BUS_BUSY 

Bus is busy.

LIN_NO_TRANSFER_IN_PROGRESS 

No data transfer is in progress.

LIN_TIMEOUT 

Timeout.

LIN_LPUART_STAT_CLOCK_GATED_OFF 

LPUART is gated from clock manager.

Enumerator
LIN_NODE_STATE_UNINIT 

Uninitialized state.

LIN_NODE_STATE_SLEEP_MODE 

Sleep mode state.

LIN_NODE_STATE_IDLE 

Idle state.

LIN_NODE_STATE_SEND_BREAK_FIELD 

Send break field state.

LIN_NODE_STATE_RECV_SYNC 

Receive the synchronization byte state.

LIN_NODE_STATE_SEND_PID 

Send PID state.

LIN_NODE_STATE_RECV_PID 

Receive PID state.

LIN_NODE_STATE_RECV_DATA 

Receive data state.

LIN_NODE_STATE_RECV_DATA_COMPLETED 

Receive data completed state.

LIN_NODE_STATE_SEND_DATA 

Send data state.

LIN_NODE_STATE_SEND_DATA_COMPLETED 

Send data completed state.

LIN_NODE_STATE_UNINIT 

Uninitialized state.

LIN_NODE_STATE_SLEEP_MODE 

Sleep mode state.

LIN_NODE_STATE_IDLE 

Idle state.

LIN_NODE_STATE_SEND_BREAK_FIELD 

Send break field state.

LIN_NODE_STATE_RECV_SYNC 

Receive the synchronization byte state.

LIN_NODE_STATE_SEND_PID 

Send PID state.

LIN_NODE_STATE_RECV_PID 

Receive PID state.

LIN_NODE_STATE_RECV_DATA 

Receive data state.

LIN_NODE_STATE_RECV_DATA_COMPLETED 

Receive data completed state.

LIN_NODE_STATE_SEND_DATA 

Send data state.

LIN_NODE_STATE_SEND_DATA_COMPLETED 

Send data completed state.

Enumerator
LIN_PROTOCOL_21 

LIN protocol version 2.1.

LIN_PROTOCOL_J2602 

J2602 protocol.

Enumerator
LIN_NO_EVENT 

No event yet.

LIN_WAKEUP_SIGNAL 

Received a wakeup signal.

LIN_BAUDRATE_ADJUSTED 

Indicate that baudrate was adjusted to Master's baudrate.

LIN_RECV_BREAK_FIELD_OK 

Indicate that correct Break Field was received.

LIN_SYNC_OK 

Sync byte is correct.

LIN_SYNC_ERROR 

Sync byte is incorrect.

LIN_PID_OK 

PID correct.

LIN_PID_ERROR 

PID incorrect.

LIN_FRAME_ERROR 

Framing Error.

LIN_READBACK_ERROR 

Readback data is incorrect.

LIN_CHECKSUM_ERROR 

Checksum byte is incorrect.

LIN_TX_COMPLETED 

Sending data completed.

LIN_RX_COMPLETED 

Receiving data completed.

LIN_NO_DATA_TIMEOUT 

No data timeout.

LIN_BUS_ACTIVITY_TIMEOUT 

Bus activity timeout.

LIN_TIMEOUT_ERROR 

Indicate that timeout has occurred.

LIN_NO_EVENT 

No event yet.

LIN_WAKEUP_SIGNAL 

Received a wakeup signal.

LIN_BAUDRATE_ADJUSTED 

Indicate that baudrate was adjusted to Master's baudrate.

LIN_RECV_BREAK_FIELD_OK 

Indicate that correct Break Field was received.

LIN_SYNC_OK 

Sync byte is correct.

LIN_SYNC_ERROR 

Sync byte is incorrect.

LIN_PID_OK 

PID correct.

LIN_PID_ERROR 

PID incorrect.

LIN_FRAME_ERROR 

Framing Error.

LIN_READBACK_ERROR 

Readback data is incorrect.

LIN_CHECKSUM_ERROR 

Checksum byte is incorrect.

LIN_TX_COMPLETED 

Sending data completed.

LIN_RX_COMPLETED 

Receiving data completed.

LIN_RX_OVERRUN 

Rx overrun flag.

Enumerator
LIN_IFC_NOT_SUPPORT 

This interface is not supported.

LIN_INITIALIZED 

LIN Hardware has been initialized.

LIN_SUCCESS 

Successfully done.

LIN_ERROR 

Error.

LIN_TX_BUSY 

Transmitter is busy.

LIN_RX_BUSY 

Receiver is busy.

LIN_BUS_BUSY 

Bus is busy.

LIN_NO_TRANSFER_IN_PROGRESS 

No data transfer is in progress.

LIN_TIMEOUT 

Timeout.

LIN_LPUART_STAT_CLOCK_GATED_OFF 

LPUART is gated from clock manager.

LIN_IFC_NOT_SUPPORT 

This interface is not supported.

LIN_INITIALIZED 

LIN Hardware has been initialized.

LIN_SUCCESS 

Successfully done.

LIN_ERROR 

Error.

LIN_TX_BUSY 

Transmitter is busy.

LIN_RX_BUSY 

Receiver is busy.

LIN_BUS_BUSY 

Bus is busy.

LIN_NO_TRANSFER_IN_PROGRESS 

No data transfer is in progress.

LIN_TIMEOUT 

Timeout.

LIN_LPUART_STAT_CLOCK_GATED_OFF 

LPUART is gated from clock manager.

Enumerator
LIN_NODE_STATE_UNINIT 

Uninitialized state.

LIN_NODE_STATE_SLEEP_MODE 

Sleep mode state.

LIN_NODE_STATE_IDLE 

Idle state.

LIN_NODE_STATE_SEND_BREAK_FIELD 

Send break field state.

LIN_NODE_STATE_RECV_SYNC 

Receive the synchronization byte state.

LIN_NODE_STATE_SEND_PID 

Send PID state.

LIN_NODE_STATE_RECV_PID 

Receive PID state.

LIN_NODE_STATE_RECV_DATA 

Receive data state.

LIN_NODE_STATE_RECV_DATA_COMPLETED 

Receive data completed state.

LIN_NODE_STATE_SEND_DATA 

Send data state.

LIN_NODE_STATE_SEND_DATA_COMPLETED 

Send data completed state.

LIN_NODE_STATE_UNINIT 

Uninitialized state.

LIN_NODE_STATE_SLEEP_MODE 

Sleep mode state.

LIN_NODE_STATE_IDLE 

Idle state.

LIN_NODE_STATE_SEND_BREAK_FIELD 

Send break field state.

LIN_NODE_STATE_RECV_SYNC 

Receive the synchronization byte state.

LIN_NODE_STATE_SEND_PID 

Send PID state.

LIN_NODE_STATE_RECV_PID 

Receive PID state.

LIN_NODE_STATE_RECV_DATA 

Receive data state.

LIN_NODE_STATE_RECV_DATA_COMPLETED 

Receive data completed state.

LIN_NODE_STATE_SEND_DATA 

Send data state.

LIN_NODE_STATE_SEND_DATA_COMPLETED 

Send data completed state.

Function Documentation

uint32_t LIN_CalcMaxHeaderTimeoutCnt ( uint32_t  baudRate)

Theader_Maximum = 1.4 * THeader_Nominal, THeader_Nominal = 34 * TBit, ( 13 nominal bits of breack; 1 nominal bit of break delimiter; 10 bits for SYNC and 10 bits of PID) The function is not include time for conveying break and break delimeter TIME_OUT_UNIT is in micro second

Parameters
baudRatebaudrate
uint32_t LIN_CalcMaxResTimeoutCnt ( uint32_t  baudRate,
uint8_t  size 
)

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

Parameters
baudRateBaudrate
sizeFrame size
lin_status_t LIN_SetResponse ( uint8_t  instance,
uint8_t *  response_buff,
uint8_t  response_length,
uint8_t  max_frame_res_timeout 
)
Parameters
instanceLPUART instance
response_buffresponse message
response_lengthlength of response
max_frame_res_timeoutmaximal timeout duration for message
Returns
An error code or lin_status_t
lin_status_t LIN_RxResponse ( uint8_t  instance,
uint8_t *  response_buff,
uint8_t  response_length,
uint8_t  max_frame_res_timeout 
)
Parameters
instanceLPUART instance
response_buffresponse message
response_lengthlength of response
max_frame_res_timeoutmaximal timeout duration for message
Returns
An error code or lin_status_t
lin_status_t LIN_IgnoreResponse ( uint8_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
void LIN_GetSlaveDefaultConfig ( lin_user_config_t linUserConfig)
Parameters
linUserConfigPointer to LIN user config structure
void LIN_GetMasterDefaultConfig ( lin_user_config_t linUserConfig)
Parameters
linUserConfigPointer to LIN user config structure
void LIN_CalculateBaudrate ( uint32_t  instance,
uint32_t  baudRate_Bps,
uint32_t  srcClock_Hz,
uint32_t *  osr,
uint16_t *  sbr 
)
Parameters
instanceLPUART instance
instancebaudRate_Bps LPUART baudrate
instancesrcClock_Hz LPUART clock frequency
instanceosr LPUART baudrate OSR value, return value
instancesbr LPUART baudrate SBR value, return value
void LIN_SetBaudrate ( uint32_t  instance,
uint32_t  osr,
uint16_t  sbr 
)
Parameters
instanceLPUART instance
instanceosr LPUART baudrate OSR value
instancesbr LPUART baudrate SBR value
lin_status_t LIN_Init ( uint32_t  instance,
lin_user_config_t linUserConfig,
lin_state_t linCurrentState,
uint32_t  clockSource 
)

The caller provides memory for the driver state structures during initialization. The user must select the LIN Hardware Interface clock source in the application to initialize the LIN Hardware Interface.

Parameters
instanceLPUART instance
linUserConfiguser configuration structure of type lin_user_config_t
linCurrentStatepointer to the LIN Hardware Interface driver state structure
Returns
An error code or lin_status_t
lin_status_t LIN_Deinit ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
lin_callback_t LIN_InstallCallback ( uint32_t  instance,
lin_callback_t  function 
)
Note
After a callback is installed, it bypasses part of the LIN Hardware Interface IRQHandler logic. Therefore, the callback needs to handle the indexes of txBuff and txSize.
Parameters
instanceLPUART instance.
functionthe LIN receive callback function.
Returns
Former LIN callback function pointer.
lin_status_t LIN_SendFrameDataBlocking ( uint32_t  instance,
const uint8_t *  txBuff,
uint8_t  txSize,
uint32_t  timeoutMSec 
)

This function will calculate the checksum byte and send it with the frame data. Blocking means that the function does not return until the transmission is complete.

Parameters
instanceLPUART instance
txBuffsource buffer containing 8-bit data chars to send
txSizethe number of bytes to send
timeoutMSectimeout value in milli seconds
Returns
An error code or lin_status_t LIN_BUS_BUSY if the bus is currently busy, transmission cannot be started.
lin_status_t LIN_SendFrameData ( uint32_t  instance,
const uint8_t *  txBuff,
uint8_t  txSize 
)

This enables an a-sync method for transmitting data. Non-blocking means that the function returns immediately. The application has to get the transmit status to know when the transmit is complete. This function will calculate the checksum byte and send it with the frame data.

Note
If users use LIN_TimeoutService in a timer interrupt handler, then before using this function, users have to set timeout counter to an appropriate value by using LIN_SetTimeoutCounter(instance, timeoutValue). The timeout value should be big enough to complete the transmission. Timeout in real time is (timeoutValue) * (time period that LIN_TimeoutService is called). For example, if LIN_TimeoutService is called in an timer interrupt with period of 500 micro seconds, then timeout in real time is timeoutValue * 500 micro seconds.
Parameters
instanceLPUART instance
txBuffsource buffer containing 8-bit data chars to send
txSizethe number of bytes to send
Returns
An error code or lin_status_t LIN_BUS_BUSY if the bus is currently busy, transmission cannot be started. LIN_SUCCESS if the transmission was completed.
lin_status_t LIN_GetTransmitStatus ( uint32_t  instance,
uint8_t *  bytesRemaining 
)

The bytesRemaining shows number of bytes that still needed to transmit.

Parameters
instanceLPUART instance
bytesRemainingNumber of bytes still needed to transmit
Returns
lin_status_t LIN_TX_BUSY if the transmission is still in progress. LIN_TIMEOUT if timeout occurred and transmission was not completed. LIN_SUCCESS if the transmission was successful.
lin_status_t LIN_ReceiveFrameDataBlocking ( uint32_t  instance,
uint8_t *  rxBuff,
uint8_t  rxSize,
uint32_t  timeoutMSec 
)

This function will check the checksum byte. If the checksum is correct, it will receive the frame data. Blocking means that the function does not return until the reception is complete.

Parameters
instanceLPUART instance
rxBuffbuffer containing 8-bit received data
rxSizethe number of bytes to receive
timeoutMSectimeout value in milli seconds
Returns
An error code or lin_status_t
lin_status_t LIN_ReceiveFrameData ( uint32_t  instance,
uint8_t *  rxBuff,
uint8_t  rxSize 
)

This function will check the checksum byte. If the checksum is correct, it will receive it with the frame data. Non-blocking means that the function returns immediately. The application has to get the receive status to know when the reception is complete.

Note
If users use LIN_TimeoutService in a timer interrupt handler, then before using this function, users have to set timeout counter to an appropriate value by using LIN_SetTimeoutCounter(instance, timeoutValue). The timeout value should be big enough to complete the reception. Timeout in real time is (timeoutValue) * (time period that LIN_TimeoutService is called). For example, if LIN_TimeoutService is called in an timer interrupt with period of 500 micro seconds, then timeout in real time is timeoutValue * 500 micro seconds.
Parameters
instanceLPUART instance
rxBuffbuffer containing 8-bit received data
rxSizethe number of bytes to receive
Returns
An error code or lin_status_t
lin_status_t LIN_AbortTransferData ( uint32_t  instance)

While performing a non-blocking transferring data, users can call this function to terminate immediately the transferring.

Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
lin_status_t LIN_GetReceiveStatus ( uint32_t  instance,
uint8_t *  bytesRemaining 
)

This function return the current event ID, LIN_RX_BUSY while receiving and return LIN_SUCCESS, or timeout (LIN_TIMEOUT) when the reception is complete. The bytesRemaining shows number of bytes that still needed to receive.

Parameters
instanceLPUART instance
bytesRemainingNumber of bytes still needed to receive
Returns
lin_status_t LIN_RX_BUSY, LIN_TIMEOUT or LIN_SUCCESS
lin_status_t LIN_GoToSleepMode ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
lin_status_t LIN_GotoIdleState ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
lin_status_t LIN_SendWakeupSignal ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
lin_node_state_t LIN_GetCurrentNodeState ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
current LIN node state
void LIN_TimeoutService ( uint32_t  instance)

User may initialize a timer (for example FTM) in Output Compare Mode with period of 500 micro seconds (recommended). In timer IRQ handler, call this function.

Parameters
instanceLPUART instance
Returns
void
void LIN_SetTimeoutCounter ( uint32_t  instance,
uint32_t  timeoutValue 
)
Parameters
instanceLPUART instance
timeoutValueTimeout Value to be set
Returns
void
lin_status_t LIN_MasterSendHeader ( uint32_t  instance,
uint8_t  id 
)

This function sends LIN Break field, sync field then the ID with correct parity.

Parameters
instanceLPUART instance
idFrame Identifier
Returns
An error code or lin_status_t
lin_status_t LIN_EnableIRQ ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
lin_status_t LIN_DisableIRQ ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
void LIN_IRQHandler ( uint8_t  instance)
Parameters
instanceLPUART instance
Returns
void
lin_status_t LIN_AutoBaudCapture ( uint32_t  instance)

This function should only be used in Slave. The timer should be in mode input capture of both rising and falling edges. The timer input capture pin should be externally connected to RXD pin.

Parameters
instanceLPUART instance
Returns
lin_status_t

This function should only be used in Slave. The timer should be in mode input capture of both rising and falling edges. The timer input capture pin should be externally connected to RXD pin.

Parameters
instanceLPUART instance
Returns
Operation status.
uint8_t LIN_ProcessParity ( uint8_t  PID,
uint8_t  typeAction 
)

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. This is not a public API as it is called by other API functions.

Parameters
PIDPID byte in case of checking parity bits or ID byte in case of making parity bits.
typeAction,:1 for Checking parity bits, 0 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.
uint8_t LIN_MakeChecksumByte ( const uint8_t *  buffer,
uint8_t  sizeBuffer,
uint8_t  PID 
)
Parameters
bufferPointer to Tx buffer
sizeBufferNumber of bytes that are contained in the buffer.
PIDProtected Identifier byte.
Returns
the checksum byte.
lin_status_t LIN_DRV_SetResponse ( uint8_t  instance,
uint8_t *  response_buff,
uint8_t  response_length,
uint8_t  max_frame_res_timeout 
)
Parameters
instanceLPUART instance
response_buffresponse message
response_lengthlength of response
max_frame_res_timeoutmaximal timeout duration for message
Returns
An error code or lin_status_t
lin_status_t LIN_DRV_RxResponse ( uint8_t  instance,
uint8_t *  response_buff,
uint8_t  response_length,
uint8_t  max_frame_res_timeout 
)
Parameters
instanceLPUART instance
response_buffresponse message
response_lengthlength of response
max_frame_res_timeoutmaximal timeout duration for message
Returns
An error code or lin_status_t
lin_status_t LIN_DRV_IgnoreResponse ( uint8_t  instance)
Parameters
instanceLPUART instance
Returns
An error code or lin_status_t
void LIN_DRV_CalculateBaudrate ( uint32_t  instance,
uint32_t  baudRate_Bps,
uint32_t  srcClock_Hz,
uint32_t *  osr,
uint16_t *  sbr 
)
Parameters
instanceLPUART instance
instancebaudRate_Bps LPUART baudrate
instancesrcClock_Hz LPUART clock frequency
instanceosr LPUART baudrate OSR value, return value
instancesbr LPUART baudrate SBR value, return value
void LIN_DRV_SetBaudrate ( uint32_t  instance,
uint32_t  osr,
uint16_t  sbr 
)
Parameters
instanceLPUART instance
instanceosr LPUART baudrate OSR value
instancesbr LPUART baudrate SBR value
lin_status_t LIN_DRV_Init ( uint32_t  instance,
lin_user_config_t linUserConfig,
lin_state_t linCurrentState 
)

The caller provides memory for the driver state structures during initialization. The user must select the LIN Hardware Interface clock source in the application to initialize the LIN Hardware Interface.

Parameters
instanceLPUART instance
linUserConfiguser configuration structure of type lin_user_config_t
linCurrentStatepointer to the LIN Hardware Interface driver state structure
Returns
operation status:
  • kStatus_Success : Operation was successful.
  • kStatus_Fail : Operation failed due to the initialization not complete.
lin_status_t LIN_DRV_Deinit ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
Operation status.
lin_callback_t LIN_DRV_InstallCallback ( uint32_t  instance,
lin_callback_t  function 
)
Note
After a callback is installed, it bypasses part of the LIN Hardware Interface IRQHandler logic. Therefore, the callback needs to handle the indexes of txBuff and txSize.
Parameters
instanceLPUART instance.
functionthe LIN receive callback function.
Returns
Former LIN callback function pointer.
lin_status_t LIN_DRV_SendFrameDataBlocking ( uint32_t  instance,
const uint8_t *  txBuff,
uint8_t  txSize,
uint32_t  timeoutMSec 
)

This function will calculate the checksum byte and send it with the frame data. Blocking means that the function does not return until the transmission is complete.

Parameters
instanceLIN instance
txBuffsource buffer containing 8-bit data chars to send
txSizethe number of bytes to send
timeoutMSectimeout value in milli seconds
Returns
Operation status.
lin_status_t LIN_DRV_SendFrameData ( uint32_t  instance,
const uint8_t *  txBuff,
uint8_t  txSize 
)

This enables an a-sync method for transmitting data. Non-blocking means that the function returns immediately. The application has to get the transmit status to know when the transmit is complete. This function will calculate the checksum byte and send it with the frame data.

Note
If users use LIN_TimeoutService in a timer interrupt handler, then before using this function, users have to set timeout counter to an appropriate value by using LIN_SetTimeoutCounter(instance, timeoutValue). The timeout value should be big enough to complete the transmission. Timeout in real time is (timeoutValue) * (time period that LIN_TimeoutService is called). For example, if LIN_TimeoutService is called in an timer interrupt with period of 500 micro seconds, then timeout in real time is timeoutValue * 500 micro seconds.
Parameters
instanceLPUART instance
txBuffsource buffer containing 8-bit data chars to send
txSizethe number of bytes to send
Returns
Operation status.
lin_status_t LIN_DRV_GetTransmitStatus ( uint32_t  instance,
uint8_t *  bytesRemaining 
)

The bytesRemaining shows number of bytes that still needed to transmit.

Parameters
instanceLIN instance
bytesRemainingNumber of bytes still needed to transmit
Returns
Operation status.
lin_status_t LIN_DRV_ReceiveFrameDataBlocking ( uint32_t  instance,
uint8_t *  rxBuff,
uint8_t  rxSize,
uint32_t  timeoutMSec 
)

This function will check the checksum byte. If the checksum is correct, it will receive the frame data. Blocking means that the function does not return until the reception is complete.

Parameters
instanceLPUART instance
rxBuffbuffer containing 8-bit received data
rxSizethe number of bytes to receive
timeoutMSectimeout value in milli seconds
Returns
Operation status.
lin_status_t LIN_DRV_ReceiveFrameData ( uint32_t  instance,
uint8_t *  rxBuff,
uint8_t  rxSize 
)

This function will check the checksum byte. If the checksum is correct, it will receive it with the frame data. Non-blocking means that the function returns immediately. The application has to get the receive status to know when the reception is complete.

Note
If users use LIN_TimeoutService in a timer interrupt handler, then before using this function, users have to set timeout counter to an appropriate value by using LIN_SetTimeoutCounter(instance, timeoutValue). The timeout value should be big enough to complete the reception. Timeout in real time is (timeoutValue) * (time period that LIN_TimeoutService is called). For example, if LIN_TimeoutService is called in an timer interrupt with period of 500 micro seconds, then timeout in real time is timeoutValue * 500 micro seconds.
Parameters
instanceLPUART instance
rxBuffbuffer containing 8-bit received data
rxSizethe number of bytes to receive
Returns
Operation status.
lin_status_t LIN_DRV_AbortTransferData ( uint32_t  instance)

While performing a non-blocking transferring data, users can call this function to terminate immediately the transferring.

Parameters
instanceLIN instance
Returns
Operation status.
lin_status_t LIN_DRV_GetReceiveStatus ( uint32_t  instance,
uint8_t *  bytesRemaining 
)

This function return the current event ID, LIN_RX_BUSY while receiving and return LIN_SUCCESS, or timeout (LIN_TIMEOUT) when the reception is complete. The bytesRemaining shows number of bytes that still needed to receive.

Parameters
instanceLPUART instance
bytesRemainingNumber of bytes still needed to receive
Returns
Operation status.
lin_status_t LIN_DRV_GoToSleepMode ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
Operation status.
lin_status_t LIN_DRV_GotoIdleState ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
Operation status.
lin_status_t LIN_DRV_SendWakeupSignal ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
Operation status.
lin_node_state_t LIN_DRV_GetCurrentNodeState ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
current LIN node state
void LIN_DRV_TimeoutService ( uint32_t  instance)

User may initialize a timer (for example FTM) in Output Compare Mode with period of 500 micro seconds (recommended). In timer IRQ handler, call this function.

Parameters
instanceLPUART instance
Returns
void
static void LIN_DRV_SetTimeoutCounter ( uint32_t  instance,
uint32_t  timeoutValue 
)
inlinestatic
Parameters
instanceLPUART instance
timeoutValueTimeout Value to be set
Returns
void
lin_status_t LIN_DRV_MasterSendHeader ( uint32_t  instance,
uint8_t  id 
)

This function sends LIN Break field, sync field then the ID with correct parity.

Parameters
instanceLPUART instance
idFrame Identifier
Returns
Operation status.
lin_status_t LIN_DRV_EnableIRQ ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
Operation status.
lin_status_t LIN_DRV_DisableIRQ ( uint32_t  instance)
Parameters
instanceLPUART instance
Returns
Operation status.
void LIN_DRV_IRQHandler ( uint8_t  instance)
Parameters
instanceLPUART instance
Returns
void
static lin_status_t LIN_DRV_AutoBaudCapture ( uint32_t  instance)
inlinestatic
   Adding this API is just for providing interface for LIN Stack.
Parameters
instanceLPUART instance
Returns
Operation status.
static uint8_t LIN_DRV_ProcessParity ( uint8_t  PID,
uint8_t  typeAction 
)
inlinestatic

This fucntion is the same with LIN_ProcessParity(). Adding this function is just to provide the interface for LIN Stack.

Parameters
PIDPID byte in case of checking parity bits or ID byte in case of making parity bits.
typeAction,:1 for Checking parity bits, 0 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.
static uint8_t LIN_DRV_MakeChecksumByte ( const uint8_t *  buffer,
uint8_t  sizeBuffer,
uint8_t  PID 
)
inlinestatic
   This function is the same with LIN_MakeChecksumByte(), And this API is just
   to provide interface for LIN Stack.
Parameters
bufferPointer to Tx buffer
sizeBufferNumber of bytes that are contained in the buffer.
PIDProtected Identifier byte.
Returns
the checksum byte.

Variable Documentation

const uint8_t * lin_state_t::txBuff
uint8_t * lin_state_t::rxBuff
uint8_t lin_state_t::cntByte
volatile uint8_t lin_state_t::txSize
volatile uint8_t lin_state_t::rxSize
uint8_t lin_state_t::checkSum
volatile bool lin_state_t::isTxBusy
volatile bool lin_state_t::isRxBusy
volatile bool lin_state_t::isTxBlocking
volatile bool lin_state_t::isRxBlocking
lin_callback_t lin_state_t::Callback
volatile bool lin_state_t::txCompleted
LPUART_Type* const g_linLpuartBase[FSL_FEATURE_SOC_LPUART_COUNT]
lin_state_t* g_linStatePtr[FSL_FEATURE_SOC_LPUART_COUNT]

Table to save LPUART state structure pointers

LPUART_Type* const g_linLpuartBase[FSL_FEATURE_SOC_LPUART_COUNT]