SAM NVM Unit test.
Copyright (c) 2013-2020 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | BYTE_PATTERN1(x) ((uint8_t)(((x) * 5 + 1) & 0xff)) |
Generates byte pattern 1 for a given address. More... | |
#define | BYTE_PATTERN2(x) ((uint8_t)(((x) * 3) & 0xff)) |
Generates byte pattern 2 for a given address. More... | |
#define | TEST_PAGE_ADDR (FLASH_NB_OF_PAGES - 8) * NVMCTRL_PAGE_SIZE |
Functions | |
static void | cdc_uart_init (void) |
Initialize USART for unit tests. More... | |
int | main (void) |
Run NVM unit tests. More... | |
static void | run_nvm_erase_test (const struct test_case *test) |
Test NVM erasing. More... | |
static void | run_nvm_init_test (const struct test_case *test) |
Test NVM initialization. More... | |
static void | run_nvm_parameter_test (const struct test_case *test) |
Test get flash parameter function. More... | |
static void | run_nvm_read_and_write_test (const struct test_case *test) |
Test NVM writing. More... | |
static void | run_nvm_update_test (const struct test_case *test) |
Test NVM update. More... | |
Variables | |
struct usart_module | cdc_uart_module |
static volatile bool | nvm_init_success = false |
#define BYTE_PATTERN1 | ( | x | ) | ((uint8_t)(((x) * 5 + 1) & 0xff)) |
Generates byte pattern 1 for a given address.
Referenced by run_nvm_read_and_write_test(), and run_nvm_update_test().
#define BYTE_PATTERN2 | ( | x | ) | ((uint8_t)(((x) * 3) & 0xff)) |
Generates byte pattern 2 for a given address.
Referenced by run_nvm_update_test().
#define TEST_PAGE_ADDR (FLASH_NB_OF_PAGES - 8) * NVMCTRL_PAGE_SIZE |
Referenced by run_nvm_erase_test(), run_nvm_read_and_write_test(), and run_nvm_update_test().
|
static |
Initialize USART for unit tests.
Initializes the USART used by the unit test. The USART connected to embedded debugger is used for outputting the results.
References usart_config::baudrate, cdc_uart_module, CONF_STDIO_BAUDRATE, CONF_STDIO_MUX_SETTING, CONF_STDIO_PINMUX_PAD0, CONF_STDIO_PINMUX_PAD1, CONF_STDIO_PINMUX_PAD2, CONF_STDIO_PINMUX_PAD3, 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().
int main | ( | void | ) |
Run NVM unit tests.
Initializes the system and serial output, then sets up the NVM unit test suite and runs it.
References cdc_uart_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_nvm_erase_test(), run_nvm_init_test(), run_nvm_parameter_test(), run_nvm_read_and_write_test(), run_nvm_update_test(), system_init(), and test_suite_run().
|
static |
Test NVM erasing.
This test erases test row and verifies it
test | Current test case. |
References nvm_erase_row(), nvm_init_success, status, STATUS_OK, test_assert_true, and TEST_PAGE_ADDR.
Referenced by main().
|
static |
Test NVM initialization.
This function will write the default configuration to NVM and returns an error in case of failure.
test | Current test case. |
References nvm_config::manual_page_write, nvm_get_config_defaults(), nvm_init_success, nvm_set_config(), status, STATUS_OK, test_assert_true, and nvm_config::wait_states.
Referenced by main().
|
static |
Test get flash parameter function.
This test gets the nvm parameters from the function and checks the NVM page count and NVM page size
test | Current test case. |
References nvm_get_parameters(), nvm_parameters::nvm_number_of_pages, nvm_parameters::page_size, and test_assert_true.
Referenced by main().
|
static |
Test NVM writing.
This test writes erased test page with a pattern, reads it back and checks the integrity
test | Current test case. |
References buffer, BYTE_PATTERN1, i, nvm_init_success, nvm_read_buffer(), nvm_write_buffer(), status, STATUS_OK, test_assert_true, and TEST_PAGE_ADDR.
Referenced by main().
|
static |
Test NVM update.
This test modifies first half of the test page with different pattern, reads it back and checks whether the values are updated
test | Current test case. |
References buffer, BYTE_PATTERN1, BYTE_PATTERN2, i, nvm_init_success, nvm_read_buffer(), nvm_update_buffer(), status, STATUS_OK, test_assert_true, and TEST_PAGE_ADDR.
Referenced by main().
struct usart_module cdc_uart_module |
Referenced by run_nvm_erase_test(), run_nvm_init_test(), run_nvm_read_and_write_test(), and run_nvm_update_test().