Unit tests for PMC driver.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <pmc.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>
Macros | |
#define | PMC_PCK_PRES_CLK_1 PMC_PCK_PRES(0) |
Functions | |
static uint32_t | is_serial_output_done (void) |
Check if serial output is done. More... | |
int | main (void) |
Run PMC driver unit tests. More... | |
static void | run_periph_clk_cfg_test (const struct test_case *test) |
Enable and disable peripheral clock test. More... | |
static void | run_sleep_mode_test (const struct test_case *test) |
Test entering and exiting sleep mode. More... | |
static void | run_switch_mainck_as_mck_test (const struct test_case *test) |
Switch main clock as MCK and enable PCK output, and check if it can be used. More... | |
static void | run_switch_pllack_as_mck_test (const struct test_case *test) |
Switch PLLA clock as MCK and enable PCK output, and check if it can be used. More... | |
static void | run_switch_slck_as_mck_test (const struct test_case *test) |
Switch slow clock as MCK and enable PCK output, and check if it can be used. More... | |
static void | switch_mck_to_default (void) |
Switch MCK to default as startup. More... | |
void | SysTick_Handler (void) |
SysTick handler. More... | |
Variables | |
volatile uint32_t | g_ul_sleep_wake_up = 0 |
#define PMC_PCK_PRES_CLK_1 PMC_PCK_PRES(0) |
Referenced by main(), run_switch_mainck_as_mck_test(), run_switch_pllack_as_mck_test(), and run_switch_slck_as_mck_test().
|
static |
Check if serial output is done.
0 | - Not done. |
1 | - Done. |
References uart_is_tx_empty(), and usart_is_tx_empty().
Referenced by run_switch_mainck_as_mck_test(), run_switch_pllack_as_mck_test(), and run_switch_slck_as_mck_test().
int main | ( | void | ) |
Run PMC driver unit tests.
References uart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, ioport_disable_pin(), ioport_set_pin_mode(), NULL, pmc_disable_pck(), pmc_enable_pck(), PMC_PCK_0, PMC_PCK_PRES_CLK_1, pmc_switch_pck_to_mainck(), run_periph_clk_cfg_test(), run_sleep_mode_test(), run_switch_mainck_as_mck_test(), run_switch_pllack_as_mck_test(), run_switch_slck_as_mck_test(), stdio_serial_init(), sysclk_enable_peripheral_clock(), sysclk_init(), and test_suite_run().
|
static |
Enable and disable peripheral clock test.
Enable peripheral clocks, and then check if the clocks are enabled. Disable peripheral clocks, and then check if the clocks are disabled.
test | Current test case. |
References pmc_disable_periph_clk(), pmc_enable_periph_clk(), and test_assert_true.
Referenced by main().
|
static |
Test entering and exiting sleep mode.
test | Current test case. |
References g_ul_sleep_wake_up, pmc_enable_sleepmode(), sysclk_get_cpu_hz(), and test_assert_true.
Referenced by main().
|
static |
Switch main clock as MCK and enable PCK output, and check if it can be used.
test | Current test case. |
References BOARD_OSC_STARTUP_US, is_serial_output_done(), OSC_SLCK_32K_RC_HZ, pmc_disable_pck(), pmc_enable_pck(), PMC_PCK_0, PMC_PCK_PRES_CLK_1, pmc_switch_mainck_to_fastrc(), pmc_switch_mainck_to_xtal(), pmc_switch_mck_to_mainck(), pmc_switch_mck_to_sclk(), pmc_switch_pck_to_mainck(), pmc_us_to_moscxtst, switch_mck_to_default(), and test_assert_true.
Referenced by main().
|
static |
Switch PLLA clock as MCK and enable PCK output, and check if it can be used.
test | Current test case. |
References is_serial_output_done(), pmc_disable_pck(), pmc_enable_pck(), pmc_enable_pllack(), PMC_PCK_0, PMC_PCK_PRES_CLK_1, pmc_switch_mck_to_mainck(), pmc_switch_mck_to_pllack(), pmc_switch_pck_to_pllack(), switch_mck_to_default(), and test_assert_true.
Referenced by main().
|
static |
Switch slow clock as MCK and enable PCK output, and check if it can be used.
test | Current test case. |
References is_serial_output_done(), pmc_disable_pck(), pmc_enable_pck(), PMC_PCK_0, PMC_PCK_PRES_CLK_1, pmc_switch_mck_to_sclk(), pmc_switch_pck_to_sclk(), switch_mck_to_default(), and test_assert_true.
Referenced by main().
|
static |
Switch MCK to default as startup.
References pmc_switch_mck_to_mainck(), and sysclk_init().
Referenced by run_switch_mainck_as_mck_test(), run_switch_pllack_as_mck_test(), and run_switch_slck_as_mck_test().
void SysTick_Handler | ( | void | ) |
SysTick handler.
References g_ul_sleep_wake_up.
volatile uint32_t g_ul_sleep_wake_up = 0 |
Referenced by run_sleep_mode_test(), and SysTick_Handler().