RA Flexible Software Package Documentation  Release v5.3.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 information frame transfer.
uint8_t * p_information Pointer to rx or tx buffer associated with the information frame transfer.
uint8_t num_bytes Length of buffer pointed to by p_information, in bytes.
lin_checksum_type_t checksum_type Checksum type to use for checksum generation (when writing frame) or validation (when reading frame). 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_INFORMATION_FRAME_COMPLETE
  • LIN_EVENT_ERR_FRAMING
  • LIN_EVENT_ERR_INVALID_CHECKSUM

Contains the number of information bytes received for an information frame 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_INFORMATION_FRAME_COMPLETE
  • LIN_EVENT_ERR_INVALID_CHECKSUM.
void const * 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)
 
uint8_t rxi_ipl
 Receive interrupt priority.
 
IRQn_Type rxi_irq
 Receive interrupt IRQ number.
 
uint8_t txi_ipl
 Transmit interrupt priority.
 
IRQn_Type txi_irq
 Transmit interrupt IRQ number.
 
uint8_t tei_ipl
 Transmit end interrupt priority.
 
IRQn_Type tei_irq
 Transmit end interrupt IRQ number.
 
uint8_t eri_ipl
 Error interrupt priority.
 
IRQn_Type eri_irq
 Error interrupt IRQ number.
 
void(* p_callback )(lin_callback_args_t *p_args)
 Pointer to callback function.
 
void const * 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(* 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)
 
fsp_err_t(* informationFrameRead )(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 *const p_context, lin_callback_args_t *const p_callback_memory)
 
fsp_err_t(* close )(lin_ctrl_t *const p_ctrl)
 

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.

◆ startFrameWrite

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

Begin non-blocking transmission of the LIN start frame. The start frame consists of the break pattern, sync word, and protected frame identifier (PID). The unprotected identifier should be supplied. The driver will compute the PID.

When the start frame has been transmitted, the callback is called with event LIN_EVENT_TX_START_FRAME_COMPLETE.

Parameters
[in,out]p_ctrlPointer to the LIN control block.
[in]idUnprotected frame identifier

◆ informationFrameWrite

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

Begin non-blocking transmission of the LIN information frame.

The write buffer is used until the write is complete. When the write completes successfully (all bytes are fully transmitted on the wire) the callback is called with event LIN_EVENT_TX_INFORMATION_FRAME_COMPLETE.

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

◆ informationFrameRead

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

Begin non-blocking read of information frame bytes.

When a read completes successfully, the callback is called with event LIN_EVENT_RX_INFORMATION_FRAME_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 *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.

◆ 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.

◆ 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 information bytes only

LIN_CHECKSUM_TYPE_ENHANCED 

8 bit LIN enhanced checksum over information 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 

Start frame received event.

LIN_EVENT_RX_INFORMATION_FRAME_COMPLETE 

Information frame received event.

LIN_EVENT_TX_START_FRAME_COMPLETE 

Start frame transmission complete event.

LIN_EVENT_TX_INFORMATION_FRAME_COMPLETE 

Information transmission complete event.

LIN_EVENT_ERR_INVALID_CHECKSUM 

Information frame received successfully, but checksum was invalid.

LIN_EVENT_ERR_BUS_COLLISION_DETECTED 

Bus collision detection event.

LIN_EVENT_ERR_FRAMING 

Framing error event.

LIN_EVENT_ERR_COUNTER_OVERFLOW 

Counter overflow event.

LIN_EVENT_ERR_OVERRUN 

Overrun error event.

LIN_EVENT_ERR_PARITY 

Parity error event (start frame only, LIN information is sent without parity)