Microchip® Advanced Software Framework

sam/services/flash_efc/unit_tests/unit_tests.c File Reference

Unit tests for flash efc driver.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include <board.h>
#include <sysclk.h>
#include <flash_efc.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>

Functions

int main (void)
 Run flash efc driver unit tests. More...
 
static void run_flash_configure_test (const struct test_case *test)
 Test flash configure functions. More...
 
static void run_flash_device_id_test (const struct test_case *test)
 Test flash device id interface. More...
 
static void run_flash_gpnvm_test (const struct test_case *test)
 Test flash GPNVM setting. More...
 
static void run_flash_information_test (const struct test_case *test)
 Test get flash information interfaces. More...
 
static void run_flash_lock_test (const struct test_case *test)
 Test flash lock setting. More...
 
static void run_flash_write_test (const struct test_case *test)
 Test flash writing. More...
 

static void run_flash_configure_test ( const struct test_case test)
static

Test flash configure functions.

Note
This test gets the default wait state first, and then it will initialize the flash again and set/adaptively set the wait state.
Parameters
testCurrent test case.

References FLASH_ACCESS_MODE_128, flash_get_wait_state(), flash_init(), flash_set_wait_state(), flash_set_wait_state_adaptively(), sysclk_get_cpu_hz(), and test_assert_true.

Referenced by main().

static void run_flash_device_id_test ( const struct test_case test)
static

Test flash device id interface.

This test gets the device id of the flash.

Parameters
testCurrent test case.

References FLASH_RC_OK, flash_read_unique_id(), and test_assert_true.

Referenced by main().

static void run_flash_gpnvm_test ( const struct test_case test)
static

Test flash GPNVM setting.

This test gets the gpnvm 1 status and then sets and clears the status.

Parameters
testCurrent test case.

References flash_clear_gpnvm(), flash_is_gpnvm_set(), FLASH_RC_NO, FLASH_RC_YES, flash_set_gpnvm(), and test_assert_true.

Referenced by main().

static void run_flash_information_test ( const struct test_case test)
static

Test get flash information interfaces.

Note
This test gets the descriptor first, and then it will read out the page count, page count per region and region count number.
Parameters
testCurrent test case.

References flash_get_descriptor(), flash_get_page_count(), flash_get_page_count_per_region(), flash_get_region_count(), and test_assert_true.

Referenced by main().

static void run_flash_lock_test ( const struct test_case test)
static

Test flash lock setting.

Note
This test gets the lock status of the whole flash space and unlocks/locks the test page for validation.
Parameters
testCurrent test case.

References flash_is_locked(), flash_lock(), flash_unlock(), flash_write(), and test_assert_true.

Referenced by main().

static void run_flash_write_test ( const struct test_case test)
static

Test flash writing.

This test tests the flash writing function in the test page of the flash.

Parameters
testCurrent test case.

References flash_unlock(), flash_write(), and test_assert_true.

Referenced by main().