Microchip® Advanced Software Framework

sam/drivers/flashcalw/unit_tests/unit_tests.c File Reference

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)
#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)
#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

Referenced by main(), and time_tick_calc_delay().

static void configure_console ( void  )
static

Configure serial console.

References uart_rs232_options::baudrate, and stdio_serial_init().

Referenced by main().

static uint32_t recfibo ( uint32_t  n)
static

Recursively calculate the nth Fibonacci number.

Parameters
nIndicates which (positive) Fibonacci number to compute.
Returns
The nth Fibonacci number.

Referenced by run_flashcalw_picocache_test().

static void run_flashcalw_control_test ( const struct test_case 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.

Parameters
testCurrent test case.

References flashcalw_get_wait_state(), flashcalw_set_wait_state(), and test_assert_true.

Referenced by main().

static void run_flashcalw_page_access_test ( const struct test_case test)
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.

Parameters
testCurrent 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 void run_flashcalw_picocache_test ( const struct test_case test)
static

Test flashcalw PicoCache feature.

PicoCache test shows how much the PicoCache feature can improve the execution speed.

Parameters
testCurrent 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 void run_flashcalw_properties_test ( const struct test_case test)
static

Test flashcalw preperties interfaces.

This test gets the flashcalw size of the flashcalw. Other properties interfaces are based this function.

Parameters
testCurrent test case.

References flashcalw_get_flash_size(), and test_assert_true.

Referenced by main().

static void run_flashcalw_protection_test ( const struct test_case test)
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.

Parameters
testCurrent 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 uint32_t time_tick_calc_delay ( uint32_t  tick_start,
uint32_t  tick_end 
)
static
static uint32_t time_tick_get ( void  )
static

volatile uint32_t g_ms_ticks = 0

Counts for 1ms time ticks.

Referenced by main(), SysTick_Handler(), time_tick_get(), and time_tick_init().