Microchip® Advanced Software Framework

drivers/tc/unit_test/unit_test.c File Reference

SAM TC Unit test.

Copyright (c) 2013-2020 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <stdio_serial.h>
#include <string.h>
#include "conf_test.h"

Functions

static void cdc_uart_init (void)
 Initialize the USART for unit test. More...
 
int main (void)
 Run TC unit tests. More...
 
static void run_16bit_capture_and_compare_test (const struct test_case *test)
 Test capture and compare. More...
 
static void run_basic_functionality_test (const struct test_case *test)
 Test basic functionality. More...
 
static void run_callback_test (const struct test_case *test)
 Test the callback API. More...
 
static void run_init_test (const struct test_case *test)
 Test of tc_init() and tc_get_config_defaults() More...
 
static void run_reset_32bit_master_test (const struct test_case *test)
 Test initializing and resetting 32-bit TC and reinitialize. More...
 
static void tc_callback_function (struct tc_module *const module_inst)
 Function used to test callback API. More...
 

Variables

bool basic_functionality_test_passed = false
 
volatile uint32_t callback_function_entered = 0
 
struct usart_module cdc_uart_module
 
bool tc_init_success = 0
 
struct tc_config tc_test0_config
 
struct tc_module tc_test0_module
 
struct tc_config tc_test1_config
 
struct tc_module tc_test1_module
 

static void cdc_uart_init ( void  )
static
static void run_16bit_capture_and_compare_test ( const struct test_case test)
static
static void run_basic_functionality_test ( const struct test_case test)
static

Test basic functionality.

This test tests the basic functionality for the TC. It tests the following functions:

Parameters
testCurrent test case.

References basic_functionality_test_passed, tc_enable(), tc_get_config_defaults(), tc_get_count_value(), tc_init(), tc_init_success, tc_reset(), tc_set_count_value(), tc_start_counter(), tc_stop_counter(), tc_test0_config, tc_test0_module, and test_assert_true.

Referenced by main().

static void run_init_test ( const struct test_case test)
static

Test of tc_init() and tc_get_config_defaults()

This test is used to initialize the tcx_module structs and associate the given hw module with the struct. This test should be run at the very beginning of testing as other tests depend on the result of this test.

References STATUS_OK, tc_get_config_defaults(), tc_init(), tc_init_success, tc_test0_config, tc_test0_module, tc_test1_config, tc_test1_module, and test_assert_true.

Referenced by main().

static void run_reset_32bit_master_test ( const struct test_case test)
static

Test initializing and resetting 32-bit TC and reinitialize.

This test tests the software reset of a 32-bit TC by the use of the tc_reset(). It also test re-enabling the two TC modules used in the 32-bit TC into two separate 16-bit TC's.

Parameters
testCurrent test case.

References tc_config::counter_size, TC_COUNTER_SIZE_16BIT, TC_COUNTER_SIZE_32BIT, tc_enable(), tc_get_config_defaults(), tc_init(), tc_init_success, tc_is_syncing(), tc_reset(), tc_test0_config, tc_test0_module, tc_test1_config, tc_test1_module, test_assert_false, and test_assert_true.

Referenced by main().

static void tc_callback_function ( struct tc_module *const  module_inst)
static

Function used to test callback API.

This function indicates that the callback function has been invoked.

References callback_function_entered.

Referenced by run_16bit_capture_and_compare_test(), and run_callback_test().

bool basic_functionality_test_passed = false
struct usart_module cdc_uart_module