AT45dbx DataFlash Component Unit Test.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <asf.h>
#include <string.h>
#include "at45dbx.h"
#include "conf_test.h"
Macros | |
Byte pattern generator | |
#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 | BYTE_PATTERN3(x) ((uint8_t) (((x) * 7 + 3) & 0xff)) |
Generates byte pattern 3 for a given address. More... | |
Functions | |
int | main (void) |
Run DataFlash component unit tests. More... | |
static void | run_byte_access_test (const struct test_case *test) |
Test the read and write byte operations on the DataFlash. More... | |
static void | run_memory_check_test (const struct test_case *test) |
Performs a memory check on all DataFlash memories. More... | |
static void | run_memory_range_check_test (const struct test_case *test) |
Performs out of range memory test on DataFlash memory. More... | |
static void | run_multiple_sector_access_test (const struct test_case *test) |
Test the read and write multiple sector operations on the DataFlash. More... | |
static void | run_sector_access_test (const struct test_case *test) |
Test the read and write sector operations on the DataFlash. More... | |
Variables | |
static uint8_t | sector_buf [AT45DBX_SECTOR_SIZE] |
A DataFlash sector-sized buffer for processing data in ram memory. More... | |
#define BYTE_PATTERN1 | ( | x | ) | ((uint8_t) (((x) * 5 + 1) & 0xff)) |
Generates byte pattern 1 for a given address.
Referenced by run_byte_access_test().
#define BYTE_PATTERN2 | ( | x | ) | ((uint8_t) (((x) * 3) & 0xff)) |
Generates byte pattern 2 for a given address.
Referenced by run_sector_access_test().
#define BYTE_PATTERN3 | ( | x | ) | ((uint8_t) (((x) * 7 + 3) & 0xff)) |
Generates byte pattern 3 for a given address.
Referenced by run_multiple_sector_access_test().
int main | ( | void | ) |
Run DataFlash component unit tests.
Initializes the clock system, board, serial output and DataFlash, then sets up the DataFlash unit test suite and runs it.
References at45dbx_init(), usart_rs232_options::baudrate, board_init(), CONF_TEST_BAUDRATE, CONF_TEST_CHARLENGTH, CONF_TEST_PARITY, CONF_TEST_STOPBITS, CONF_TEST_USART, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, run_byte_access_test(), run_memory_check_test(), run_memory_range_check_test(), run_multiple_sector_access_test(), run_sector_access_test(), stdio_serial_init(), sysclk_init(), and test_suite_run().
|
static |
Test the read and write byte operations on the DataFlash.
This function will test the read and write functionalities of the DataFlash using byte access. It will first write a known pattern on the 2 first consecutive sectors and read it back by testing each value read.
In addition to test the data integrity and the byte read / write functions, this will also test the continuity of the sectors as well as the auto-incrementation of the DataFlash address.
test | Current test case. |
References at45dbx_read_byte(), at45dbx_read_byte_open(), at45dbx_read_close(), AT45DBX_SECTOR_SIZE, at45dbx_write_byte(), at45dbx_write_byte_open(), at45dbx_write_close(), BYTE_PATTERN1, and test_assert_true.
Referenced by main().
|
static |
Performs a memory check on all DataFlash memories.
This function will simply test the output of the function at45dbx_mem_check and returns an error in case of failure.
test | Current test case. |
References at45dbx_mem_check(), and test_assert_true.
Referenced by main().
|
static |
Performs out of range memory test on DataFlash memory.
This function will simply test the output of the function at45dbx_mem_check and returns an error in case of failure.
test | Current test case. |
References AT45DBX_MEM_CNT, AT45DBX_MEM_SIZE, at45dbx_read_byte_open(), and test_assert_true.
Referenced by main().
|
static |
Test the read and write multiple sector operations on the DataFlash.
This function will test the read and write functionalities of the DataFlash using multiple sector access. It will first fill the 10 first DataFlash sectors with a known pattern and read it back to test each value.
test | Current test case. |
References at45dbx_read_close(), at45dbx_read_sector_open(), at45dbx_read_sector_to_ram(), AT45DBX_SECTOR_SIZE, at45dbx_write_close(), at45dbx_write_sector_from_ram(), at45dbx_write_sector_open(), BYTE_PATTERN3, sector_buf, and test_assert_true.
Referenced by main().
|
static |
Test the read and write sector operations on the DataFlash.
This function will test the read and write functionalities of the DataFlash using sector access. It will first fill a sector with a known pattern and read it back by testing each value read.
test | Current test case. |
References at45dbx_read_close(), at45dbx_read_sector_open(), at45dbx_read_sector_to_ram(), AT45DBX_SECTOR_SIZE, at45dbx_write_close(), at45dbx_write_sector_from_ram(), at45dbx_write_sector_open(), BYTE_PATTERN2, sector_buf, and test_assert_true.
Referenced by main().
|
static |
A DataFlash sector-sized buffer for processing data in ram memory.
Referenced by run_multiple_sector_access_test(), and run_sector_access_test().