LIN service for SAM.
This file contains basic functions for the SAM USART, with support for all modes, settings and clock speeds.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdio.h>
#include <string.h>
#include "compiler.h"
#include "pdc.h"
#include "usart.h"
#include "lin.h"
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... | |