RA Flexible Software Package Documentation  Release v6.0.0

 
LIN Interface

Detailed Description

Interface for LIN communications.

Summary

The LIN interface provides common APIs for LIN HAL drivers. The LIN interface supports the following features:

Data Structures

struct  lin_transfer_params_t
 
struct  lin_callback_args_t
 
struct  lin_cfg_t
 
struct  lin_api_t
 
struct  lin_instance_t
 

Typedefs

typedef void lin_ctrl_t
 

Enumerations

enum  lin_mode_t
 
enum  lin_checksum_type_t
 
enum  lin_event_t
 

Data Structure Documentation

◆ lin_transfer_params_t

struct lin_transfer_params_t

LIN Transfer Parameters

Data Fields
uint8_t id The unprotected frame ID associated with the data transfer.
union lin_transfer_params_t __unnamed__
uint8_t num_bytes Length of buffer pointed to by p_data, in bytes.
lin_checksum_type_t checksum_type Checksum type to use for checksum generation (when writing data) or validation (when reading data). See lin_checksum_type_t.

◆ lin_callback_args_t

struct lin_callback_args_t

LIN Callback Arguments

Data Fields
uint32_t channel Channel number.
lin_event_t event Event code.
uint8_t bytes_received

Valid for the following events:

  • LIN_EVENT_RX_DATA_COMPLETE
  • LIN_EVENT_ERR_FRAMING
  • LIN_EVENT_ERR_INVALID_CHECKSUM

Contains the number of data bytes received for a data reception.

uint8_t pid

For LIN slave: Contains the most recently received protected identifier For LIN master: Contains the most recently transmitted protected identifier.

uint8_t checksum

Received checksum. Valid for the following events:

  • LIN_EVENT_RX_DATA_COMPLETE
  • LIN_EVENT_ERR_INVALID_CHECKSUM.
void * p_context Context provided to user during callback.

◆ lin_cfg_t

struct lin_cfg_t

LIN configuration block

Data Fields

uint8_t channel
 Select a channel corresponding to the channel number of the hardware.
 
lin_mode_t mode
 Driver mode (master or slave)
 
void(* p_callback )(lin_callback_args_t *p_args)
 Pointer to callback function.
 
void * p_context
 User defined context passed into callback function.
 
void const * p_extend
 LIN hardware dependent configuration.
 

◆ lin_api_t

struct lin_api_t

Interface definition for LIN

Data Fields

fsp_err_t(* open )(lin_ctrl_t *const p_ctrl, lin_cfg_t const *const p_cfg)
 
fsp_err_t(* write )(lin_ctrl_t *const p_ctrl, const lin_transfer_params_t *const p_transfer_params)
 
fsp_err_t(* read )(lin_ctrl_t *const p_ctrl, lin_transfer_params_t *const p_transfer_params)
 
fsp_err_t(* communicationAbort )(lin_ctrl_t *const p_ctrl)
 
fsp_err_t(* callbackSet )(lin_ctrl_t *const p_ctrl, void(*p_callback)(lin_callback_args_t *), void *const p_context, lin_callback_args_t *const p_callback_memory)
 
fsp_err_t(* wakeupSend )(lin_ctrl_t *const p_ctrl)
 
fsp_err_t(* sleepEnter )(lin_ctrl_t *const p_ctrl)
 
fsp_err_t(* sleepExit )(lin_ctrl_t *const p_ctrl)
 
fsp_err_t(* close )(lin_ctrl_t *const p_ctrl)
 
fsp_err_t(* informationFrameRead )(lin_ctrl_t *const p_ctrl, lin_transfer_params_t *const p_transfer_params)
 
fsp_err_t(* startFrameWrite )(lin_ctrl_t *const p_ctrl, uint8_t const id)
 
fsp_err_t(* informationFrameWrite )(lin_ctrl_t *const p_ctrl, const lin_transfer_params_t *const p_transfer_params)
 

Field Documentation

◆ open

fsp_err_t(* lin_api_t::open) (lin_ctrl_t *const p_ctrl, lin_cfg_t const *const p_cfg)

Open LIN device. Transmission and reception of LIN frames is enabled upon successful return from this function.

Parameters
[in,out]p_ctrlPointer to the LIN control block. Must be declared by user. Value set here.
[in]p_cfgPointer to LIN configuration structure. All elements of this structure must be set by user.

◆ write

fsp_err_t(* lin_api_t::write) (lin_ctrl_t *const p_ctrl, const lin_transfer_params_t *const p_transfer_params)

Begin non-blocking transmission of a LIN frame.

If the node is a LIN master, the LIN header is transmitted before data, if present.

For header-only transmissions (master mode), when the header transmission completes successfully, the callback is called with the event LIN_EVENT_TX_HEADER_COMPLETE.

For header+data (master mode) or data-only transmission (slave mode), when the data transmission completes successfully, the callback is called with event LIN_EVENT_TX_DATA_COMPLETE.

Parameters
[in,out]p_ctrlPointer to the LIN control block.
[in]p_transfer_paramsPointer to parameters required for the write transaction.

◆ read

fsp_err_t(* lin_api_t::read) (lin_ctrl_t *const p_ctrl, lin_transfer_params_t *const p_transfer_params)

Begin non-blocking read of data bytes.

When a read completes successfully, the callback is called with event LIN_EVENT_RX_DATA_COMPLETE.

Parameters
[in]p_ctrlPointer to the LIN control block for the channel.
[in]p_transfer_paramsPointer to parameters required for the read transaction.

◆ communicationAbort

fsp_err_t(* lin_api_t::communicationAbort) (lin_ctrl_t *const p_ctrl)

Abort ongoing transfer.

Parameters
[in]p_ctrlPointer to the LIN control block.

◆ callbackSet

fsp_err_t(* lin_api_t::callbackSet) (lin_ctrl_t *const p_ctrl, void(*p_callback)(lin_callback_args_t *), void *const p_context, lin_callback_args_t *const p_callback_memory)

Specify callback function and optional context pointer and working memory pointer.

Parameters
[in]p_ctrlPointer to the LIN control block.
[in]p_callbackCallback function
[in]p_contextPointer to send to callback function
[in]p_working_memoryPointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback.

◆ wakeupSend

fsp_err_t(* lin_api_t::wakeupSend) (lin_ctrl_t *const p_ctrl)

Send wakeup signal for LIN device.

Parameters
[in]p_ctrlPointer to the LIN control block.

◆ sleepEnter

fsp_err_t(* lin_api_t::sleepEnter) (lin_ctrl_t *const p_ctrl)

Place the LIN node in bus sleep mode.

Parameters
[in]p_ctrlPointer to the LIN control block.

◆ sleepExit

fsp_err_t(* lin_api_t::sleepExit) (lin_ctrl_t *const p_ctrl)

Exit the bus sleep mode for LIN device.

Parameters
[in]p_ctrlPointer to the LIN control block.

◆ close

fsp_err_t(* lin_api_t::close) (lin_ctrl_t *const p_ctrl)

Close LIN device.

Parameters
[in]p_ctrlPointer to the LIN control block.

◆ informationFrameRead

fsp_err_t(* lin_api_t::informationFrameRead) (lin_ctrl_t *const p_ctrl, lin_transfer_params_t *const p_transfer_params)

[DEPRECATED] Use lin_api_t::read

◆ startFrameWrite

fsp_err_t(* lin_api_t::startFrameWrite) (lin_ctrl_t *const p_ctrl, uint8_t const id)

[DEPRECATED] Use lin_api_t::write

◆ informationFrameWrite

fsp_err_t(* lin_api_t::informationFrameWrite) (lin_ctrl_t *const p_ctrl, const lin_transfer_params_t *const p_transfer_params)

[DEPRECATED] Use lin_api_t::write

◆ lin_instance_t

struct lin_instance_t

This structure encompasses everything that is needed to use an instance of this interface.

Data Fields
lin_ctrl_t * p_ctrl Pointer to the control structure for this instance.
lin_cfg_t const * p_cfg Pointer to the configuration structure for this instance.
lin_api_t const * p_api Pointer to the API structure for this instance.

Typedef Documentation

◆ lin_ctrl_t

typedef void lin_ctrl_t

LIN control block. Allocate an instance specific control block to pass into the LIN API calls.

Enumeration Type Documentation

◆ lin_mode_t

enum lin_mode_t

LIN driver mode

Enumerator
LIN_MODE_SLAVE 

Slave mode.

LIN_MODE_MASTER 

Master mode.

◆ lin_checksum_type_t

LIN checksum type

Enumerator
LIN_CHECKSUM_TYPE_CLASSIC 

8 bit LIN classic checksum over data bytes only

LIN_CHECKSUM_TYPE_ENHANCED 

8 bit LIN enhanced checksum over data bytes and PID

LIN_CHECKSUM_TYPE_NONE 

Skip driver checksum generation/validation.

◆ lin_event_t

LIN Event codes

Enumerator
LIN_EVENT_NONE 

No event present.

LIN_EVENT_RX_START_FRAME_COMPLETE 

DEPRECATED, do not use.

LIN_EVENT_RX_INFORMATION_FRAME_COMPLETE 

DEPRECATED, do not use.

LIN_EVENT_TX_START_FRAME_COMPLETE 

DEPRECATED, do not use.

LIN_EVENT_TX_INFORMATION_FRAME_COMPLETE 

DEPRECATED, do not use.

LIN_EVENT_RX_HEADER_COMPLETE 

Header received event.

LIN_EVENT_RX_DATA_COMPLETE 

Data received event.

LIN_EVENT_TX_HEADER_COMPLETE 

Header transmission complete event.

LIN_EVENT_TX_DATA_COMPLETE 

Data transmission complete event.

LIN_EVENT_ERR_INVALID_CHECKSUM 

Data received successfully, but checksum was invalid.

LIN_EVENT_TX_WAKEUP_COMPLETE 

Transmit wake up complete event.

LIN_EVENT_RX_WAKEUP_COMPLETE 

Receive wake up complete event.

LIN_EVENT_ERR_BUS_COLLISION_DETECTED 

Bus collision detection event.

LIN_EVENT_ERR_COUNTER_OVERFLOW 

Counter overflow event.

LIN_EVENT_ERR_OVERRUN 

Overrun error event.

LIN_EVENT_ERR_PARITY 

Parity error event (header only, LIN data is sent without parity)

LIN_EVENT_ERR_FRAMING 

Framing error event.