Microchip® Advanced Software Framework

drivers/tcc/unit_test/unit_test.c File Reference

SAM TCC 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"
#include "conf_clocks.h"

Functions

static void cdc_uart_init (void)
 Initialize the USART for unit test. More...
 
int main (void)
 Run TCC unit tests. 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_capture_and_compare_test (const struct test_case *test)
 Test capture and compare. More...
 
static void run_faultn_test (const struct test_case *test)
 Test Recoverable Fault (FAULTn) More...
 
static void run_faultx_test (const struct test_case *test)
 Test Non-Recoverable Fault (FAULTx) More...
 
static void run_init_test (const struct test_case *test)
 Test of tcc_init() and tcc_get_config_defaults() More...
 
static void run_reset_test (const struct test_case *test)
 Test initializing and resetting TCC and reinitialize. More...
 
static void tcc_callback_function (struct tcc_module *const module_inst)
 Function used to test callback API. More...
 

Variables

static volatile bool basic_functionality_test_passed = false
 
static volatile uint32_t callback_function_entered = 0
 
static struct usart_module cdc_uart_module
 
static bool tcc_init_success = 0
 
static struct tcc_config tcc_test0_config
 
static struct tcc_module tcc_test0_module
 
static struct tcc_config tcc_test1_config
 
static struct tcc_module tcc_test1_module
 

static void cdc_uart_init ( void  )
static
static void run_basic_functionality_test ( const struct test_case test)
static
static void run_capture_and_compare_test ( const struct test_case test)
static
static void run_init_test ( const struct test_case test)
static

Test of tcc_init() and tcc_get_config_defaults()

This test is used to initialize the tccx_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, tcc_get_config_defaults(), tcc_init(), tcc_init_success, tcc_test0_config, tcc_test0_module, tcc_test1_config, tcc_test1_module, and test_assert_true.

Referenced by main().

static void run_reset_test ( const struct test_case test)
static

Test initializing and resetting TCC and reinitialize.

This test tests the software reset of a TCC by the use of the tcc_reset().

Parameters
testCurrent test case.

References tcc_module::hw, tcc_enable(), tcc_get_config_defaults(), tcc_init(), tcc_init_success, tcc_is_syncing(), tcc_reset(), tcc_test0_config, tcc_test0_module, test_assert_false, and test_assert_true.

Referenced by main().

static void tcc_callback_function ( struct tcc_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_callback_test(), and run_capture_and_compare_test().

volatile bool basic_functionality_test_passed = false
static
volatile uint32_t callback_function_entered = 0
static
struct usart_module cdc_uart_module
static
struct tcc_config tcc_test1_config
static
struct tcc_module tcc_test1_module
static