Unit tests for common clock service.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <compiler.h>
#include <asf.h>
#include "conf_test.h"
Functions | |
int | main (void) |
Run Common Clock service unit tests. More... | |
Common Clock unit test functions | |
static void | run_osc_test (const struct test_case *test) |
Test Oscillator 0/1. More... | |
static void | cleanup_osc_test (const struct test_case *test) |
cleanup oscillator test More... | |
static void | run_osc32_test (const struct test_case *test) |
Test 32KHz oscillator. More... | |
static void | cleanup_osc32_test (const struct test_case *test) |
cleanup 32KHz oscillator test More... | |
static void | run_pll_dfll_test (const struct test_case *test) |
Test Pll and DFLL (if have) More... | |
static void | cleanup_pll_dfll_test (const struct test_case *test) |
cleanup pll/dfll test More... | |
static void | run_sync_clock_test (const struct test_case *test) |
Test Synchronous clock. More... | |
static void | run_generic_clock_test (const struct test_case *test) |
Test Generic clock. More... | |
static void | cleanup_generic_clock_test (const struct test_case *test) |
cleanup generic clock test More... | |
Variables | |
int(* | ptr_put )(void volatile *, char) |
Pointer to the external low level write function. More... | |
int | usart_ready = 0 |
USART initialize with the CONFIG_PBA_HZ. More... | |
|
static |
cleanup generic clock test
test | Current test case. |
References genclk_disable().
Referenced by main().
|
static |
cleanup 32KHz oscillator test
test | Current test case. |
References osc_disable(), and OSC_ID_OSC32.
Referenced by main().
|
static |
cleanup oscillator test
test | Current test case. |
References osc_disable(), OSC_ID_OSC0, OSC_ID_RC1M, OSC_ID_RC80M, and OSC_ID_RCFAST.
Referenced by main().
|
static |
cleanup pll/dfll test
test | Current test case. |
References dfll_disable_closed_loop(), osc_disable(), OSC_ID_RCSYS, and pll_disable().
Referenced by main().
int main | ( | void | ) |
Run Common Clock service unit tests.
Initializes board, serial output, then sets up the clock unit test suite and runs it.
References uart_rs232_options::baudrate, board_init(), cleanup_generic_clock_test(), cleanup_osc32_test(), cleanup_osc_test(), cleanup_pll_dfll_test(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, ptr_put, run_generic_clock_test(), run_osc32_test(), run_osc_test(), run_pll_dfll_test(), run_sync_clock_test(), stdio_serial_init(), test_suite_run(), and usart_serial_options.
|
static |
Test Generic clock.
This test enables the generic clock, sets its source and division factor, and then check if it's set correctly.
test | Current test case. |
References genclk_config_defaults(), genclk_config_set_divider(), genclk_config_set_source(), genclk_enable(), status, and test_assert_true.
Referenced by main().
|
static |
Test 32KHz oscillator.
This test enables the 32KHz oscillator, and then check if they can be used after startup time
test | Current test case. |
References osc_enable(), OSC_ID_OSC32, osc_is_ready(), OSC_RCSYS_NOMINAL_HZ, status, test_assert_true, and wait().
Referenced by main().
|
static |
Test Oscillator 0/1.
This test enables the oscillator 0 and 1 (if have), and then check if they can be stable and ready for main clock after startup time
test | Current test case. |
References OSC0_STARTUP_TIMEOUT, osc_enable(), OSC_ID_OSC0, OSC_ID_RC1M, OSC_ID_RC80M, OSC_ID_RCFAST, osc_is_ready(), status, test_assert_true, UNUSED, and wait().
Referenced by main().
|
static |
Test Pll and DFLL (if have)
This test enables pll/dfll source clock, sets its mul and div factor, and then enables it. Check if it's locked after max startup time.
test | Current test case. |
References dfll_config_defaults, dfll_enable_closed_loop(), dfll_is_fine_locked(), osc_enable(), OSC_ID_RCSYS, osc_wait_ready(), pll_config_defaults, pll_enable(), pll_enable_source(), pll_is_locked(), PLL_MAX_STARTUP_CYCLES, status, test_assert_true, UNUSED, and wait().
Referenced by main().
|
static |
Test Synchronous clock.
This test enables source clock for main clock, sets CPU/HSB, PBA,PBB,PBC(if have), PBD(if have) division factor, and then check if the chip is set correctly.
test | Current test case. |
References status, sysclk_get_cpu_hz(), sysclk_get_pba_hz(), sysclk_get_pbb_hz(), sysclk_get_pbc_hz(), sysclk_get_pbd_hz(), sysclk_init(), test_assert_true, UNUSED, and usart_ready.
Referenced by main().
int usart_ready = 0 |
USART initialize with the CONFIG_PBA_HZ.
Referenced by run_sync_clock_test().