Microchip® Advanced Software Framework

drivers/trng/unit_test/unit_test.c File Reference

SAM True Random Number Generator (TRNG) Unit test.

Copyright (c) 2014-2018 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 TRNG unit tests. More...
 
static void run_trng_callback_read_test (const struct test_case *test)
 TRNG callback mode test function. More...
 
static void run_trng_polling_read_test (const struct test_case *test)
 Test for TRNG polling mode read. More...
 
static void trng_complete_callback (struct trng_module *const module_inst)
 TRNG callback function. More...
 

Variables

struct usart_module cdc_uart_module
 
volatile bool interrupt_flag = false
 
struct trng_module trng_instance
 

static void cdc_uart_init ( void  )
static
int main ( void  )

Run TRNG unit tests.

Initializes the system and serial output, then sets up the TRNG unit test suite and runs it.

References cdc_uart_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_trng_callback_read_test(), run_trng_polling_read_test(), system_init(), and test_suite_run().

static void run_trng_callback_read_test ( const struct test_case test)
static

TRNG callback mode test function.

This test reads three random data in callback mode and check the result.

Parameters
testCurrent test case.

References interrupt_flag, test_assert_true, TRNG_CALLBACK_READ_BUFFER, trng_complete_callback(), trng_disable(), trng_disable_callback(), trng_enable_callback(), trng_instance, trng_read_buffer_job(), and trng_register_callback().

Referenced by main().

static void run_trng_polling_read_test ( const struct test_case test)
static

Test for TRNG polling mode read.

This test reads three random data in polling mode and check the result.

Parameters
testCurrent test case

References i, STATUS_OK, test_assert_true, trng_enable(), trng_get_config_defaults(), trng_init(), trng_instance, and trng_read().

Referenced by main().

static void trng_complete_callback ( struct trng_module *const  module_inst)
static

TRNG callback function.

Called by TRNG driver on interrupt detection.

Parameters
modulePointer to the TRNG module (not used)

References interrupt_flag, and UNUSED.

struct usart_module cdc_uart_module
volatile bool interrupt_flag = false