RA Flexible Software Package Documentation
Release v5.7.0
|
|
Interface for LIN communications.
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 |
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. |
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:
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:
|
void const * | p_context | Context provided to user during callback. |
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 const * | p_context |
User defined context passed into callback function. | |
void const * | p_extend |
LIN hardware dependent configuration. | |
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) |
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.
[in,out] | p_ctrl | Pointer to the LIN control block. Must be declared by user. Value set here. |
[in] | p_cfg | Pointer to LIN configuration structure. All elements of this structure must be set by user. |
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.
[in,out] | p_ctrl | Pointer to the LIN control block. |
[in] | id | Unprotected frame identifier |
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.
[in,out] | p_ctrl | Pointer to the LIN control block. |
[in] | p_transfer_params | Pointer to parameters required for the write transaction. |
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.
[in] | p_ctrl | Pointer to the LIN control block for the channel. |
[in] | p_transfer_params | Pointer to parameters required for the read transaction. |
fsp_err_t(* lin_api_t::communicationAbort) (lin_ctrl_t *const p_ctrl) |
Abort ongoing transfer.
[in] | p_ctrl | Pointer to the LIN control block. |
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.
[in] | p_ctrl | Pointer to the LIN control block. |
[in] | p_callback | Callback function |
[in] | p_context | Pointer to send to callback function |
[in] | p_working_memory | Pointer to volatile memory where callback structure can be allocated. Callback arguments allocated here are only valid during the callback. |
fsp_err_t(* lin_api_t::close) (lin_ctrl_t *const p_ctrl) |
Close LIN device.
[in] | p_ctrl | Pointer to the LIN control block. |
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 void lin_ctrl_t |
LIN control block. Allocate an instance specific control block to pass into the LIN API calls.
enum lin_mode_t |
enum lin_checksum_type_t |
enum lin_event_t |
LIN Event codes