Microchip® Advanced Software Framework

lin_mngt_example.c File Reference

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
Value:
"-- LIN Example --\r\n" \
"-- "BOARD_NAME " --\r\n" \
"-- Compiled: "__DATE__ " "__TIME__ " --"STRING_EOL
#define STRING_EOL
Definition: lin_mngt_example.c:86
#define BOARD_NAME
Definition: fatfs_access_example.c:112

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 void configure_console ( void  )
static

Configure UART console.

References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().

Referenced by main().

static void configure_tc ( void  )
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 void display_menu ( void  )
static

Display the user menu on the UART.

Referenced by main().

static void lin_master_task_ID12 ( void  )
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 void lin_slave_task_ID12 ( uint8_t *  uc_buf)
static

lin_slave_task_ID12

References LIN_FIRST_BYTE, LIN_LED0_WAIT_COUNTER, and lin_led1_counter.

Referenced by main().

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.

uint32_t lin_led1_counter = 0
static

Referenced by lin_slave_task_ID12().