#include <stdio.h>
#include <string.h>
#include "compiler.h"
#include "intc.h"
#include "pdca.h"
#include "gpio.h"
#include "lin.h"
Functions | |
static void | lin_int_handler_node0 (void) |
USART LIN interrupt handler: manage ID reception and ERROR. More... | |
static void | lin_pdca_int_rx_handler_node0 (void) |
USART LIN RX PDCA interrupt handler. More... | |
static void | lin_pdca_int_tx_handler_node0 (void) |
LIN TX PDCA interrupt handler. More... | |
Initialization Functions | |
static U8 | lin_rx_response (U8 l_node, U8 l_handle, U8 l_len) |
This function commands the reception of a LIN response, SLAVE task of MASTER or SLAVE node. More... | |
static U8 | lin_tx_response (U8 l_node, U8 l_handle, U8 *l_data, U8 l_len) |
This function commands the sending of a LIN response, SLAVE task of MASTER or SLAVE node. More... | |
static void | lin_get_response (U8 l_node, U8 *l_data) |
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. More... | |
static U8 | lin_tx_header_and_response (U8 l_node, U8 l_handle, U8 l_len) |
This function commands the sending of a LIN header and response, MASTER task only. More... | |
U8 | lin_init (bool master, U8 l_node, U16 b_rate, long pba_hz) |
This function initializes the LIN controller and, if needed, the LIN interrupts. More... | |
U8 | lin_send_cmd (U8 l_node, U8 l_id, U8 l_len) |
This function commands the sending of the LIN header, MASTER task of MASTER node. More... | |
Variables | |
volatile st_lin_message | lin_descript_list_node0 [NUMBER_OF_LIN_FRAMES_NODE0] |
Array of structure of type:'st_lin_message'. Default: 8 elements. More... | |
volatile U16 | lin_error_number_node0 = 0 |
Counter of LIN error. If an error clearly linked to a message (i.e. time-out) the status of this message is written with the error (LINERR). More... | |
volatile U8 | lin_handle_node0 = 0xFF |
Index in lin_descript_list[], 'lin_handle' is set after processing IDOK and verified once RXOK or TXOK rises. More... | |
volatile U16 | lin_last_errors_node0 [LIN_LAST_ERR_LENGHT] |
Last error FIFO: lin_handle | status. Default: 4 elements. More... | |
volatile U8 | lin_rx_buffer_node0 [256] |
U8 | lin_tx_buffer_node0 [256] |
volatile avr32_usart_t * | usart_lin_node0 = &USART_LIN_NODE0_INSTANCE |
Instance of the USART IP used. More... | |
static const gpio_map_t | USART_LIN_NODE0_GPIO_MAP |
Map of the LIN pins used. More... | |
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.
l_node | Node Value |
l_data | Pointer on the data corresponding to the message pointed by the handle in the descriptor list |
References i, lin_rx_buffer_node0, and usart_lin_node0.
Referenced by lin_pdca_int_rx_handler_node0().
|
static |
USART LIN interrupt handler: manage ID reception and ERROR.
References IGNORE, index, st_lin_message::l_status, lin_error_number_node0, lin_handle_node0, LIN_LAST_ERR_LENGHT, lin_last_errors_node0, lin_rx_response(), lin_tx_response(), NUMBER_OF_LIN_FRAMES_NODE0, PUBLISH, SUBSCRIBE, usart_lin_node0, and usart_reset_status().
Referenced by lin_init().
|
static |
USART LIN RX PDCA interrupt handler.
References index, st_lin_message::l_pt_function, lin_get_response(), lin_handle_node0, NUMBER_OF_LIN_FRAMES_NODE0, pdca_disable_interrupt_transfer_complete(), pdca_get_transfer_status(), PDCA_TRANSFER_COMPLETE, and usart_lin_node0.
Referenced by lin_init().
|
static |
LIN TX PDCA interrupt handler.
References index, st_lin_message::l_pt_function, lin_handle_node0, NUMBER_OF_LIN_FRAMES_NODE0, pdca_disable_interrupt_transfer_complete(), pdca_get_transfer_status(), PDCA_TRANSFER_COMPLETE, and usart_lin_node0.
Referenced by lin_init().
This function commands the reception of a LIN response, SLAVE task of MASTER or SLAVE node.
l_node | Node Value |
l_handle | Handle on the descriptor list |
l_len | Message length corresponding to the message pointed by the handle in the descriptor list |
References pdca_channel_options_t::addr, lin_rx_buffer_node0, NULL, pdca_enable(), pdca_enable_interrupt_transfer_complete(), pdca_init_channel(), and PDCA_TRANSFER_SIZE_BYTE.
Referenced by lin_int_handler_node0(), and lin_send_cmd().
This function commands the sending of a LIN header and response, MASTER task only.
l_node | Node Value |
l_handle | Handle on the descriptor list |
l_len | Message length corresponding to the message pointed by the handle in the descriptor list |
Enable Interrupt for Error flags and end ID Reception
References pdca_channel_options_t::addr, st_lin_message::l_id, lin_tx_buffer_node0, NULL, PASS, pdca_enable(), pdca_enable_interrupt_transfer_complete(), pdca_init_channel(), PDCA_TRANSFER_SIZE_BYTE, and usart_lin_node0.
Referenced by lin_send_cmd().
This function commands the sending of a LIN response, SLAVE task of MASTER or SLAVE node.
l_node | Node Value |
l_handle | Handle on the descriptor list |
l_data | Pointer on the data corresponding to the message pointed by the handle in the descriptor list |
l_len | Message length corresponding to the message pointed by the handle in the descriptor list |
References pdca_channel_options_t::addr, lin_tx_buffer_node0, NULL, pdca_enable(), pdca_enable_interrupt_transfer_complete(), pdca_init_channel(), and PDCA_TRANSFER_SIZE_BYTE.
Referenced by lin_int_handler_node0().
volatile U8 lin_rx_buffer_node0[256] |
Referenced by lin_get_response(), and lin_rx_response().
U8 lin_tx_buffer_node0[256] |
Referenced by lin_tx_header_and_response(), and lin_tx_response().
volatile avr32_usart_t* usart_lin_node0 = &USART_LIN_NODE0_INSTANCE |
Instance of the USART IP used.
Referenced by lin_get_response(), lin_init(), lin_int_handler_node0(), lin_pdca_int_rx_handler_node0(), lin_pdca_int_tx_handler_node0(), lin_send_cmd(), and lin_tx_header_and_response().
|
static |
Map of the LIN pins used.