LIN example for SAM.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "led.h"
Macros | |
#define | LIN_FIRST_BYTE 0x55 |
First byte for test. More... | |
#define | LIN_FRAME_ID_12 0x12 |
LIN frame number. More... | |
#define | LIN_LED0_WAIT_COUNTER 10 |
LED0 wait count. More... | |
#define | LIN_MASTER_NODE_NUM 0 |
LIN master node number. More... | |
#define | LIN_SLAVE_NODE_NUM 0 |
LIN slave node number. More... | |
#define | STRING_EOL "\r" |
#define | STRING_HEADER |
#define | TC_CHANNEL 0 |
Timer counter channel used. More... | |
#define | TC_FREQ 20 |
Timer counter frequency in Hz. More... | |
Functions | |
static void | configure_console (void) |
Configure UART console. More... | |
static void | configure_tc (void) |
Configure Timer Counter 0 (TC0) to generate an interrupt every 200ms. More... | |
static void | display_menu (void) |
Display the user menu on the UART. More... | |
static void | lin_master_task_ID12 (void) |
lin_master_task_ID12 More... | |
static void | lin_slave_task_ID12 (uint8_t *uc_buf) |
lin_slave_task_ID12 More... | |
int | main (void) |
This is an example demonstrating the LIN mode of USART IP functionalities using a dedicated USART LIN driver. More... | |
void | TC0_Handler (void) |
Interrupt handler for TC0. More... | |
void | USART0_Handler (void) |
Interrupt handler for USART. More... | |
Variables | |
uint8_t | lin_data_node [8] |
Local Buffer for emission. More... | |
static uint32_t | lin_led1_counter = 0 |
#define LIN_FIRST_BYTE 0x55 |
First byte for test.
Referenced by lin_master_task_ID12(), and lin_slave_task_ID12().
#define LIN_FRAME_ID_12 0x12 |
LIN frame number.
Referenced by lin_master_task_ID12(), and main().
#define LIN_LED0_WAIT_COUNTER 10 |
LED0 wait count.
Referenced by lin_slave_task_ID12().
#define LIN_MASTER_NODE_NUM 0 |
LIN master node number.
Referenced by lin_master_task_ID12(), and main().
#define LIN_SLAVE_NODE_NUM 0 |
LIN slave node number.
Referenced by main(), and USART0_Handler().
#define STRING_EOL "\r" |
#define STRING_HEADER |
Referenced by main().
#define TC_CHANNEL 0 |
Timer counter channel used.
#define TC_FREQ 20 |
Timer counter frequency in Hz.
Referenced by configure_tc().
|
static |
Configure UART console.
References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
Configure Timer Counter 0 (TC0) to generate an interrupt every 200ms.
This interrupt will be used to flush USART input and echo back.
References pmc_enable_periph_clk(), sysclk_get_cpu_hz(), tc_enable_interrupt(), tc_find_mck_divisor(), TC_FREQ, tc_init(), and tc_write_rc().
Referenced by main().
|
static |
Display the user menu on the UART.
Referenced by main().
|
static |
lin_master_task_ID12
References lin_data_node, LIN_FIRST_BYTE, LIN_FRAME_ID_12, LIN_MASTER_NODE_NUM, and lin_send_cmd().
Referenced by TC0_Handler().
|
static |
lin_slave_task_ID12
References LIN_FIRST_BYTE, LIN_LED0_WAIT_COUNTER, and lin_led1_counter.
Referenced by main().
int main | ( | void | ) |
This is an example demonstrating the LIN mode of USART IP functionalities using a dedicated USART LIN driver.
References board_init(), configure_console(), configure_tc(), display_menu(), gpio_set_pin_high, st_lin_message::lin_cmd, lin_data_node, LIN_FRAME_ID_12, lin_init(), LIN_MASTER_NODE_NUM, lin_register_descriptor(), LIN_SLAVE_NODE_NUM, lin_slave_task_ID12(), pmc_enable_periph_clk(), st_lin_message::pt_function, PUBLISH, STRING_HEADER, SUBSCRIBE, sysclk_get_cpu_hz(), sysclk_init(), tc_start(), uart_read(), st_lin_message::uc_dlc, st_lin_message::uc_id, st_lin_message::uc_pt_data, st_lin_message::uc_status, and usart_enable_interrupt().
void TC0_Handler | ( | void | ) |
Interrupt handler for TC0.
Record the number of bytes received, and then restart a read transfer on the USART if the transfer was stopped.
References lin_master_task_ID12(), and tc_get_status().
void USART0_Handler | ( | void | ) |
Interrupt handler for USART.
Echo the bytes received and start the next receive.
References LIN_SLAVE_NODE_NUM, and usart_lin_handler().
uint8_t lin_data_node[8] |
Local Buffer for emission.
|
static |
Referenced by lin_slave_task_ID12().