Microchip® Advanced Software Framework

sam/services/network/lin/unit_tests/unit_tests.c File Reference

Unit tests for LIN service.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <lin.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>

Macros

#define LIN_FIRST_BYTE   0x55
 First byte for test. More...
 
#define LIN_FRAME_ID_12   0x12
 LIN frame number. More...
 
#define LIN_MASTER_NODE_NUM   0
 LIN master node number. More...
 
#define TC_CHANNEL   0
 Timer counter channel used. More...
 
#define TC_FREQ   20
 Timer counter frequency in Hz. More...
 

Functions

static void configure_tc (void)
 Configure Timer Counter 0 (TC0) to generate an interrupt every 200ms. More...
 
static void delay_ms (uint32_t ul_dly_ticks)
 Delay number of tick Systicks (happens every 1 ms). More...
 
static void lin_master_task_ID12 (void)
 lin_master_task_ID12. More...
 
int main (void)
 Run LIN service unit tests. More...
 
static void run_lin_test (const struct test_case *test)
 Test LIN transmit. More...
 
void SysTick_Handler (void)
 SysTick handler. More...
 
void TC0_Handler (void)
 Interrupt handler for TC0. More...
 
void USART0_Handler (void)
 Interrupt handler for USART. More...
 

Variables

static volatile uint32_t gs_ul_ms_ticks = 0U
 Systick Counter. More...
 
uint8_t lin_data_node [8]
 Local Buffer for emission. More...
 
static uint32_t ul_LIN_int_flag =0
 LIN interrupt received flag. More...
 

#define LIN_FIRST_BYTE   0x55

First byte for test.

Referenced by lin_master_task_ID12().

#define LIN_FRAME_ID_12   0x12

LIN frame number.

Referenced by lin_master_task_ID12(), and run_lin_test().

#define LIN_MASTER_NODE_NUM   0

LIN master node number.

Referenced by lin_master_task_ID12(), and run_lin_test().

#define TC_CHANNEL   0

Timer counter channel used.

#define TC_FREQ   20

Timer counter frequency in Hz.

Referenced by configure_tc().

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 run_lin_test().

static void delay_ms ( uint32_t  ul_dly_ticks)
static

Delay number of tick Systicks (happens every 1 ms).

References gs_ul_ms_ticks.

Referenced by run_lin_test().

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().

void SysTick_Handler ( void  )

SysTick handler.

References gs_ul_ms_ticks.

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 ul_LIN_int_flag, usart_disable_interrupt(), and usart_get_status().

volatile uint32_t gs_ul_ms_ticks = 0U
static

Systick Counter.

Referenced by delay_ms(), and SysTick_Handler().

uint8_t lin_data_node[8]

Local Buffer for emission.

Referenced by lin_master_task_ID12(), main(), and run_lin_test().

uint32_t ul_LIN_int_flag =0
static

LIN interrupt received flag.

Referenced by run_lin_test(), and USART0_Handler().