Unit tests for XMEGA timeout service.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <compiler.h>
#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_timeout.h>
#include <timeout.h>
Enumerations | |
enum | { TEST_TIMEOUT_0, TEST_TIMEOUT_1, TEST_TIMEOUT_2 } |
Enum with index ID for all timeout channels. More... | |
Functions | |
int | main (void) |
Run XMEGA timeout service unit tests. More... | |
static void | mdelay (uint16_t ms) |
static void | test_initialization (const struct test_case *test) |
Run timeout initialization test. More... | |
static void | test_periodic_timeout (const struct test_case *test) |
Periodic timeout test. More... | |
static void | test_singleshot_timeout (const struct test_case *test) |
Run timeout singleshot test. More... | |
Variables | |
static bool | success = false |
Variable to keep track of test results. More... | |
const float | TIMEOUT_ACCURACY = 1.3 |
Accuracy of timeout clock source (due to 32kHz ULP oscillator) More... | |
anonymous enum |
int main | ( | void | ) |
Run XMEGA timeout service unit tests.
References usart_rs232_options::baudrate, board_init(), cpu_irq_enable, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, pmic_init(), stdio_serial_init(), sysclk_init(), test_initialization(), test_periodic_timeout(), test_singleshot_timeout(), test_suite_run(), timeout_init(), and usart_serial_options.
|
static |
References sysclk_get_cpu_hz().
Referenced by test_periodic_timeout(), and test_singleshot_timeout().
|
static |
Run timeout initialization test.
This test verifies that no timeouts are running after initialization
test | Current test case. |
References success, test_assert_true, and timeout_test_and_clear_expired().
Referenced by main().
|
static |
Periodic timeout test.
This test start one periodic timeout and verifies that the timeout occurs as expected 10 times.
test | Current test case. |
References mdelay(), success, test_assert_true, TEST_TIMEOUT_0, TIMEOUT_ACCURACY, timeout_start_periodic(), and timeout_test_and_clear_expired().
Referenced by main().
|
static |
Run timeout singleshot test.
This test start three different singleshot timeouts and verify that they timeout when expected.
test | Current test case. |
References mdelay(), success, test_assert_true, TEST_TIMEOUT_0, TEST_TIMEOUT_1, TEST_TIMEOUT_2, TIMEOUT_ACCURACY, timeout_start_singleshot(), and timeout_test_and_clear_expired().
Referenced by main().
const float TIMEOUT_ACCURACY = 1.3 |
Accuracy of timeout clock source (due to 32kHz ULP oscillator)
Referenced by test_periodic_timeout(), and test_singleshot_timeout().