Microchip® Advanced Software Framework

drivers/wdt/unit_tests/unit_test.c File Reference

SAM Watchdog 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"

Functions

static void cdc_uart_init (void)
 Initialize the USART for unit test. More...
 
int main (void)
 Run WDT unit tests. More...
 
static void run_reset_cause_test (const struct test_case *test)
 Test whether last reset was by Watchdog module. More...
 
static void run_wdt_early_warning_test (const struct test_case *test)
 Test Early Warning of Watchdog module. More...
 
static void wait_for_wdt_reset (const struct test_case *test)
 Wait for Watchdog module to reset. More...
 

Variables

struct usart_module cdc_uart_module
 
static volatile bool wdr_flag = false
 

static void cdc_uart_init ( void  )
static

Initialize the USART for unit test.

Initializes the SERCOM USART used for sending the unit test status to the computer via the EDBG CDC gateway.

References usart_config::baudrate, cdc_uart_module, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().

Referenced by main().

static void run_reset_cause_test ( const struct test_case test)
static

Test whether last reset was by Watchdog module.

This function tests whether the last reset was caused by timeout of Watchdog module

Parameters
testCurrent test case.

References test_assert_true, and wdr_flag.

Referenced by main().

static void run_wdt_early_warning_test ( const struct test_case test)
static

Test Early Warning of Watchdog module.

If last reset cause was not Watchdog, following the Watchdog initialization and enabling in the previous test, this function will wait for CONF_WDT_EARLY_WARNING_WAIT_MS and will check if early warning flag is set. Consequently, clear the early warning flag.

Parameters
testCurrent test case.

References delay_ms, test_assert_true, wdr_flag, wdt_clear_early_warning(), and wdt_is_early_warning().

Referenced by main().

static void wait_for_wdt_reset ( const struct test_case test)
static

Wait for Watchdog module to reset.

Wait for CONF_WDT_RESET_WAIT_MS for Watchdog to reset the device

Parameters
testCurrent test case.

References delay_ms, and wdr_flag.

Referenced by main().

struct usart_module cdc_uart_module