Microchip® Advanced Software Framework

xmega/services/timeout/unit_tests/unit_tests.c File Reference

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

Enum with index ID for all timeout channels.

Enumerator
TEST_TIMEOUT_0 
TEST_TIMEOUT_1 
TEST_TIMEOUT_2 

static void mdelay ( uint16_t  ms)
static
static void test_initialization ( const struct test_case test)
static

Run timeout initialization test.

This test verifies that no timeouts are running after initialization

Parameters
testCurrent test case.

References success, test_assert_true, and timeout_test_and_clear_expired().

Referenced by main().

static void test_periodic_timeout ( const struct test_case test)
static

Periodic timeout test.

This test start one periodic timeout and verifies that the timeout occurs as expected 10 times.

Parameters
testCurrent 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 void test_singleshot_timeout ( const struct test_case test)
static

Run timeout singleshot test.

This test start three different singleshot timeouts and verify that they timeout when expected.

Parameters
testCurrent 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().

bool success = false
static

Variable to keep track of test results.

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().