See Quick start guide for the SAM LIN module.
Service driver for the LIN. This driver provides access to the LIN service features of the usart controller.
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the Local Interconnect Network (LIN). | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the Local Interconnect Network (LIN). | |
Macros | |
#define | USART_LIN_CLASSIC_CHECKSUM 1 |
Classic checksum used in the LIN 1.x. More... | |
#define | USART_LIN_DIAGNOSTIC_FRAME_ID 60 |
The frame identifier used to carry diagnostic data. More... | |
#define | USART_LIN_DLM_DLC 0 |
The response data length is defined by the field DLC of DLM. More... | |
#define | USART_LIN_DLM_IDCHR 1 |
The response data length is defined by the bits 5 and 6 of the identifier. More... | |
#define | USART_LIN_ENHANCED_CHECKSUM 0 |
Enhanced checksum used in the LIN 2.x. More... | |
#define | USART_LIN_ERROR_OFFSET 25 |
LIN error offset. More... | |
Functions | |
static void | lin_get_response (uint8_t uc_node, uint8_t *p_data) |
This function reads (empties) the reception data buffer when a LIN response had been received. More... | |
uint8_t | lin_init (Usart *usart_node, bool b_master, uint8_t uc_node, uint16_t us_rate, uint32_t ul_mck) |
This function initializes the LIN controller. More... | |
uint8_t | lin_register_descriptor (uint8_t uc_node, uint8_t uc_frame_id, st_lin_message *lin_desc) |
This function initializes the LIN message descriptor. More... | |
static uint8_t | lin_rx_response (uint8_t uc_node, uint8_t uc_len) |
This function commands the reception of a LIN response, SLAVE task of MASTER or SLAVE node. More... | |
uint8_t | lin_send_cmd (uint8_t uc_node, uint8_t uc_id, uint8_t uc_len) |
This function commands the sending of the LIN header, MASTER task of MASTER node. More... | |
static uint8_t | lin_tx_header_and_response (uint8_t uc_node, uint8_t uc_handle, uint8_t uc_len) |
This function commands the sending of a LIN header and response, MASTER task only. More... | |
static uint8_t | lin_tx_response (uint8_t uc_node, uint8_t *p_data, uint8_t uc_len) |
This function commands the sending of a LIN response, SLAVE task of MASTER or SLAVE node. More... | |
void | usart_lin_handler (uint8_t uc_node) |
USART LIN interrupt handler: manage ID reception. More... | |
Variables | |
Pdc * | g_p_pdc [LIN_NODE_NUM] |
Pointer to PDC register base. More... | |
pdc_packet_t | g_st_packet [LIN_NODE_NUM] |
PDC data packet. More... | |
st_lin_message | lin_descript_list_node [LIN_NODE_NUM][NUMBER_OF_LIN_FRAMES_NODE] |
uint16_t | lin_error_number_node [LIN_NODE_NUM] = {0} |
uint16_t | lin_last_errors_node [LIN_NODE_NUM][LIN_LAST_ERR_LENGHT] |
uint8_t | lin_rx_buffer_node [LIN_NODE_NUM][LIN_BUFF_SIZE] |
uint8_t | lin_tx_buffer_node [LIN_NODE_NUM][LIN_BUFF_SIZE] |
Usart * | usart_lin_node [LIN_NODE_NUM] |
Instance of the USART IP used. More... | |
#define USART_LIN_CLASSIC_CHECKSUM 1 |
Classic checksum used in the LIN 1.x.
Referenced by lin_send_cmd(), and usart_lin_handler().
#define USART_LIN_DIAGNOSTIC_FRAME_ID 60 |
The frame identifier used to carry diagnostic data.
Referenced by lin_send_cmd(), and usart_lin_handler().
#define USART_LIN_DLM_DLC 0 |
The response data length is defined by the field DLC of DLM.
Referenced by lin_send_cmd(), and usart_lin_handler().
#define USART_LIN_DLM_IDCHR 1 |
The response data length is defined by the bits 5 and 6 of the identifier.
Referenced by lin_send_cmd(), and usart_lin_handler().
#define USART_LIN_ENHANCED_CHECKSUM 0 |
Enhanced checksum used in the LIN 2.x.
Referenced by lin_send_cmd(), and usart_lin_handler().
#define USART_LIN_ERROR_OFFSET 25 |
LIN error offset.
Referenced by usart_lin_handler().
|
static |
This function reads (empties) the reception data buffer when a LIN response had been received.
This function is additional of the lin_rx_response() function.
uc_node | Node Value. |
p_data | Pointer on the data corresponding to the message pointed by the handle in the descriptor list. |
Referenced by usart_lin_handler().
uint8_t lin_init | ( | Usart * | usart_node, |
bool | b_master, | ||
uint8_t | uc_node, | ||
uint16_t | us_rate, | ||
uint32_t | ul_mck | ||
) |
This function initializes the LIN controller.
usart_node | Pointer to the usart instance. |
b_master | true for master, false for slave. |
uc_node | Node Value. |
us_rate | Baudrate Value. |
ul_mck | Board MCK. |
References PASS, pdc_enable_transfer(), and usart_get_pdc_base().
Referenced by main(), and run_lin_test().
uint8_t lin_register_descriptor | ( | uint8_t | uc_node, |
uint8_t | uc_frame_id, | ||
st_lin_message * | lin_desc | ||
) |
This function initializes the LIN message descriptor.
uc_node | LIN node id. |
uc_frame_id | Frame node id. |
lin_desc | Specific LIN descriptor. |
References st_lin_message::lin_cmd, PASS, st_lin_message::pt_function, st_lin_message::uc_dlc, st_lin_message::uc_id, st_lin_message::uc_pt_data, and st_lin_message::uc_status.
Referenced by main(), and run_lin_test().
|
static |
This function commands the reception of a LIN response, SLAVE task of MASTER or SLAVE node.
uc_node | Node Value. |
uc_handle | Handle on the descriptor list. |
uc_len | Message length corresponding to the message pointed by the handle in the descriptor list. |
References NULL, PASS, pdc_rx_init(), pdc_packet::ul_addr, pdc_packet::ul_size, and usart_enable_interrupt().
Referenced by lin_send_cmd(), and usart_lin_handler().
uint8_t lin_send_cmd | ( | uint8_t | uc_node, |
uint8_t | uc_id, | ||
uint8_t | uc_len | ||
) |
This function commands the sending of the LIN header, MASTER task of MASTER node.
uc_node | Node Value. |
uc_id | LIN identifier value. In case of `LIN_1X', the coded length is transported into the LIN identifier. |
uc_len | True length (not coded), number of data bytes transported in the response. This information is not used in `LIN_1X' because it is coded in `uc_id'. |
References FAIL, lin_rx_response(), lin_tx_header_and_response(), PASS, PUBLISH, SUBSCRIBE, USART_LIN_CLASSIC_CHECKSUM, USART_LIN_DIAGNOSTIC_FRAME_ID, USART_LIN_DLM_DLC, USART_LIN_DLM_IDCHR, USART_LIN_ENHANCED_CHECKSUM, and usart_reset_status().
Referenced by lin_master_task_ID12().
|
static |
This function commands the sending of a LIN header and response, MASTER task only.
uc_node | Node Value. |
uc_handle | Handle on the descriptor list. |
uc_len | Message length corresponding to the message pointed by the handle in the descriptor list. |
References NULL, PASS, pdc_enable_transfer(), pdc_tx_init(), st_lin_message::uc_id, pdc_packet::ul_addr, pdc_packet::ul_size, and usart_enable_interrupt().
Referenced by lin_send_cmd().
|
static |
This function commands the sending of a LIN response, SLAVE task of MASTER or SLAVE node.
uc_node | Node Value. |
p_data | Pointer on the data corresponding to the message pointed by the handle in the descriptor list. |
uc_len | Message length corresponding to the message pointed by the handle in the descriptor list. |
References NULL, PASS, pdc_enable_transfer(), pdc_tx_init(), pdc_packet::ul_addr, and pdc_packet::ul_size.
Referenced by usart_lin_handler().
void usart_lin_handler | ( | uint8_t | uc_node | ) |
USART LIN interrupt handler: manage ID reception.
uc_node | Node Value. |
References IGNORE, lin_get_response(), LIN_LAST_ERR_LENGHT, lin_rx_response(), lin_tx_response(), NULL, pdc_disable_transfer(), st_lin_message::pt_function, PUBLISH, SUBSCRIBE, st_lin_message::uc_status, US_CSR_LIN_ERROR, usart_get_status(), USART_LIN_CLASSIC_CHECKSUM, USART_LIN_DIAGNOSTIC_FRAME_ID, USART_LIN_DLM_DLC, USART_LIN_DLM_IDCHR, USART_LIN_ENHANCED_CHECKSUM, USART_LIN_ERROR_OFFSET, and usart_reset_status().
Referenced by USART0_Handler().
Pdc* g_p_pdc[LIN_NODE_NUM] |
Pointer to PDC register base.
pdc_packet_t g_st_packet[LIN_NODE_NUM] |
PDC data packet.
st_lin_message lin_descript_list_node[LIN_NODE_NUM][NUMBER_OF_LIN_FRAMES_NODE] |
uint16_t lin_error_number_node[LIN_NODE_NUM] = {0} |
uint16_t lin_last_errors_node[LIN_NODE_NUM][LIN_LAST_ERR_LENGHT] |
uint8_t lin_rx_buffer_node[LIN_NODE_NUM][LIN_BUFF_SIZE] |
uint8_t lin_tx_buffer_node[LIN_NODE_NUM][LIN_BUFF_SIZE] |
Usart* usart_lin_node[LIN_NODE_NUM] |
Instance of the USART IP used.