Unit tests for flashcalw driver.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "conf_test.h"
Macros | |
#define | FIBONACCI_NUM 20 |
Fibonacci number. More... | |
#define | FLASHCALW_ALL_REGION_LOCK (0xffff) |
#define | FLASHCALW_TEST_PAGE_NUM (FLASH_SIZE / FLASH_PAGE_SIZE - 16) |
Test the functions provided by the flashcalw driver. More... | |
#define | GP_FUSE_ALL_DATA (0xFFFF12345678FFFFULL) |
#define | GP_FUSE_BIT_POS (20) |
#define | GP_FUSE_BITFIELD_DATA (0x1234) |
#define | GP_FUSE_BITFIELD_POS (28) |
#define | GP_FUSE_BITFIELD_WIDTH (16) |
#define | GP_FUSE_BYTE_DATA (0x5a) |
#define | GP_FUSE_BYTE_NUM (5) |
#define | TICK_US 1000 |
Functions | |
static void | configure_console (void) |
Configure serial console. More... | |
int | main (void) |
main function : do init and loop (poll if configured so). More... | |
static uint32_t | recfibo (uint32_t n) |
Recursively calculate the nth Fibonacci number. More... | |
static void | run_flashcalw_control_test (const struct test_case *test) |
Test flashcalw configure functions. More... | |
static void | run_flashcalw_gp_fuse_test (const struct test_case *test) |
Test flashcalw general purpose fuse interface group. More... | |
static void | run_flashcalw_page_access_test (const struct test_case *test) |
Test flashcalw page access and get flashcalw command interfaces. More... | |
static void | run_flashcalw_picocache_test (const struct test_case *test) |
Test flashcalw PicoCache feature. More... | |
static void | run_flashcalw_properties_test (const struct test_case *test) |
Test flashcalw preperties interfaces. More... | |
static void | run_flashcalw_protection_test (const struct test_case *test) |
Test flashcalw protection. More... | |
void | SysTick_Handler (void) |
Handler for Sytem Tick interrupt. More... | |
static uint32_t | time_tick_calc_delay (uint32_t tick_start, uint32_t tick_end) |
static uint32_t | time_tick_get (void) |
Variables | |
volatile uint32_t | g_ms_ticks = 0 |
Counts for 1ms time ticks. More... | |
#define FIBONACCI_NUM 20 |
Fibonacci number.
Referenced by run_flashcalw_picocache_test().
#define FLASHCALW_ALL_REGION_LOCK (0xffff) |
Referenced by run_flashcalw_protection_test().
#define FLASHCALW_TEST_PAGE_NUM (FLASH_SIZE / FLASH_PAGE_SIZE - 16) |
Test the functions provided by the flashcalw driver.
Referenced by run_flashcalw_page_access_test(), and run_flashcalw_protection_test().
#define GP_FUSE_ALL_DATA (0xFFFF12345678FFFFULL) |
Referenced by run_flashcalw_gp_fuse_test().
#define GP_FUSE_BIT_POS (20) |
Referenced by run_flashcalw_gp_fuse_test().
#define GP_FUSE_BITFIELD_DATA (0x1234) |
Referenced by run_flashcalw_gp_fuse_test().
#define GP_FUSE_BITFIELD_POS (28) |
Referenced by run_flashcalw_gp_fuse_test().
#define GP_FUSE_BITFIELD_WIDTH (16) |
Referenced by run_flashcalw_gp_fuse_test().
#define GP_FUSE_BYTE_DATA (0x5a) |
Referenced by run_flashcalw_gp_fuse_test().
#define GP_FUSE_BYTE_NUM (5) |
Referenced by run_flashcalw_gp_fuse_test().
#define TICK_US 1000 |
Referenced by main(), and time_tick_calc_delay().
|
static |
Configure serial console.
References uart_rs232_options::baudrate, and stdio_serial_init().
Referenced by main().
int main | ( | void | ) |
main function : do init and loop (poll if configured so).
References Assert, board_init(), configure_console(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, g_ms_ticks, NULL, run_flashcalw_control_test(), run_flashcalw_gp_fuse_test(), run_flashcalw_page_access_test(), run_flashcalw_picocache_test(), run_flashcalw_properties_test(), run_flashcalw_protection_test(), sysclk_get_cpu_hz(), sysclk_init(), test_suite_run(), and TICK_US.
|
static |
Recursively calculate the nth Fibonacci number.
n | Indicates which (positive) Fibonacci number to compute. |
Referenced by run_flashcalw_picocache_test().
|
static |
Test flashcalw configure functions.
This test gets the default wait state first, then it will reset the wait state and validate the result.
test | Current test case. |
References flashcalw_get_wait_state(), flashcalw_set_wait_state(), and test_assert_true.
Referenced by main().
|
static |
Test flashcalw general purpose fuse interface group.
This test tests the gp fuse read, write and erase functions, including bit, bitfield, byte and all fuses groups.
test | Current test case. |
References flashcalw_erase_all_gp_fuses(), flashcalw_erase_gp_fuse_bit(), flashcalw_erase_gp_fuse_bitfield(), flashcalw_erase_gp_fuse_byte(), flashcalw_read_all_gp_fuses(), flashcalw_read_gp_fuse_bit(), flashcalw_read_gp_fuse_bitfield(), flashcalw_read_gp_fuse_byte(), flashcalw_write_all_gp_fuses(), flashcalw_write_gp_fuse_bit(), flashcalw_write_gp_fuse_bitfield(), flashcalw_write_gp_fuse_byte(), GP_FUSE_ALL_DATA, GP_FUSE_BIT_POS, GP_FUSE_BITFIELD_DATA, GP_FUSE_BITFIELD_POS, GP_FUSE_BITFIELD_WIDTH, GP_FUSE_BYTE_DATA, GP_FUSE_BYTE_NUM, and test_assert_true.
Referenced by main().
|
static |
Test flashcalw page access and get flashcalw command interfaces.
This test tests the flashcalw memset and memcpy function in the specific page of the flash. The flashcalw command control interfaces will be also validated.
test | Current test case. |
References FLASH_PAGE_SIZE, flashcalw_get_command(), flashcalw_lock_page_region(), flashcalw_memcpy(), flashcalw_memset, FLASHCALW_TEST_PAGE_NUM, and test_assert_true.
Referenced by main().
|
static |
Test flashcalw PicoCache feature.
PicoCache test shows how much the PicoCache feature can improve the execution speed.
test | Current test case. |
References FIBONACCI_NUM, flashcalw_picocache_disable(), flashcalw_picocache_disable_monitor(), flashcalw_picocache_enable(), flashcalw_set_wait_state(), recfibo(), test_assert_true, time_tick_calc_delay(), and time_tick_get().
Referenced by main().
|
static |
Test flashcalw preperties interfaces.
This test gets the flashcalw size of the flashcalw. Other properties interfaces are based this function.
test | Current test case. |
References flashcalw_get_flash_size(), and test_assert_true.
Referenced by main().
|
static |
Test flashcalw protection.
This test backups the region protection status, then validates the 3 types of region protection interface and restores the default protection status.
test | Current test case. |
References FLASH_NB_OF_REGIONS, FLASHCALW_ALL_REGION_LOCK, flashcalw_get_page_region(), flashcalw_is_page_region_locked(), flashcalw_is_region_locked(), flashcalw_lock_all_regions(), flashcalw_lock_page_region(), flashcalw_lock_region(), FLASHCALW_TEST_PAGE_NUM, and test_assert_true.
Referenced by main().
void SysTick_Handler | ( | void | ) |
Handler for Sytem Tick interrupt.
Process System Tick Event Increments the g_ms_ticks counter.
References g_ms_ticks.
|
static |
References TICK_US.
Referenced by flash_picocache_example(), main_test_memory(), and run_flashcalw_picocache_test().
|
static |
References g_ms_ticks.
Referenced by flash_picocache_example(), main_test_memory(), and run_flashcalw_picocache_test().
volatile uint32_t g_ms_ticks = 0 |
Counts for 1ms time ticks.
Referenced by main(), SysTick_Handler(), time_tick_get(), and time_tick_init().