Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
NVM driver example functions

Macros

#define EEPROM_ERASED   0xff
 
#define TEST_ATOMIC_WRITE_PAGE   2
 
#define TEST_ERASE_BYTES_PAGE_1   4
 
#define TEST_ERASE_BYTES_PAGE_2   5
 
#define TEST_ERASE_PAGE   2
 
#define TEST_SPLIT_WRITE_PAGE   3
 
#define TEST_WRITE_PAGE   1
 

Functions

static bool is_eeprom_page_equal_to_buffer (uint8_t page_addr, uint8_t *buffer)
 Check if an EEPROM page is equal to a memory buffer. More...
 
int main (void)
 
static void set_buffer (uint8_t *buffer, uint8_t value)
 Set all values of a memory buffer to a given value. More...
 
static status_code_t test_atomic_write (void)
 Test nvm_eeprom_load_byte_to_buffer(), nvm_eeprom_flush_buffer() and nvm_eeprom_atomic_write_page() More...
 
static status_code_t test_erase (void)
 Test nvm_eeprom_erase_all(). More...
 
static status_code_t test_erase_bytes (void)
 Test nvm_eeprom_erase_bytes_in_page() and nvm_eeprom_erase_bytes_in_all_pages() More...
 
static status_code_t test_split_write (void)
 Test nvm_eeprom_split_write_page() More...
 
static status_code_t test_write (void)
 Test nvm_eeprom_erase_page() and nvm_eeprom_write_byte(). More...
 

Variables

uint8_t buffer [EEPROM_PAGE_SIZE]
 Memory buffer to use during testing. More...
 

#define EEPROM_ERASED   0xff
#define TEST_ATOMIC_WRITE_PAGE   2

Referenced by test_atomic_write().

#define TEST_ERASE_BYTES_PAGE_1   4

Referenced by test_erase_bytes().

#define TEST_ERASE_BYTES_PAGE_2   5

Referenced by test_erase_bytes().

#define TEST_ERASE_PAGE   2

Referenced by test_erase().

#define TEST_SPLIT_WRITE_PAGE   3

Referenced by test_split_write().

#define TEST_WRITE_PAGE   1

Referenced by test_write().

static bool is_eeprom_page_equal_to_buffer ( uint8_t  page_addr,
uint8_t *  buffer 
)
static

Check if an EEPROM page is equal to a memory buffer.

References EEPROM_PAGE_SIZE, and nvm_eeprom_read_byte().

Referenced by test_atomic_write(), test_erase(), test_erase_bytes(), test_split_write(), and test_write().

static void set_buffer ( uint8_t *  buffer,
uint8_t  value 
)
static

Set all values of a memory buffer to a given value.

References EEPROM_PAGE_SIZE.

Referenced by test_atomic_write(), test_erase(), test_erase_bytes(), test_split_write(), and test_write().

static status_code_t test_atomic_write ( void  )
static

Test nvm_eeprom_load_byte_to_buffer(), nvm_eeprom_flush_buffer() and nvm_eeprom_atomic_write_page()

Test procedure:

  • Erase the TEST_ATOMIC_WRITE_PAGE page.
  • Load byte and then flush the buffer at one location.
  • Load two more bytes at a different location.
  • Write the page.
  • Verify that only two bytes are written and the rest of the page is erased.
Returns
STATUS_OK if test succeeded, otherwise ERR_BAD_DATA

References buffer, EEPROM_ERASED, ERR_BAD_DATA, is_eeprom_page_equal_to_buffer(), nvm_eeprom_atomic_write_page(), nvm_eeprom_erase_page(), nvm_eeprom_flush_buffer(), nvm_eeprom_load_byte_to_buffer(), set_buffer(), STATUS_OK, and TEST_ATOMIC_WRITE_PAGE.

Referenced by main().

static status_code_t test_erase ( void  )
static

Test nvm_eeprom_erase_all().

Test procedure:

  • Write one byte to the TEST_ERASE_PAGE page.
  • Erase all memory locations
  • Verify that the EEPROM is erased by a spot test on the TEST_ERASE_PAGE page.
Returns
STATUS_OK if test succeeded, otherwise ERR_BAD_DATA

References buffer, EEPROM_ERASED, EEPROM_PAGE_SIZE, ERR_BAD_DATA, is_eeprom_page_equal_to_buffer(), nvm_eeprom_erase_all(), nvm_eeprom_write_byte(), set_buffer(), STATUS_OK, and TEST_ERASE_PAGE.

Referenced by main().

static status_code_t test_erase_bytes ( void  )
static

Test nvm_eeprom_erase_bytes_in_page() and nvm_eeprom_erase_bytes_in_all_pages()

Test procedure:

  • Write two bytes into page TEST_ERASE_BYTES_PAGE_1 and TEST_ERASE_BYTES_PAGE_2
  • Load value to page buffer in the address of the first byte
  • Erase first byte of TEST_ERASE_BYTES_PAGE_1
  • Verify that first byte is deleted in TEST_ERASE_BYTES_PAGE_1
  • Load value to page buffer in the address of the first byte
  • Erase first byte of all pages
  • Verify that first byte is deleted in TEST_ERASE_BYTES_PAGE_2
Returns
STATUS_OK if test succeeded, otherwise ERR_BAD_DATA

References buffer, EEPROM_ERASED, EEPROM_PAGE_SIZE, ERR_BAD_DATA, is_eeprom_page_equal_to_buffer(), nvm_eeprom_erase_bytes_in_all_pages(), nvm_eeprom_erase_bytes_in_page(), nvm_eeprom_load_byte_to_buffer(), nvm_eeprom_write_byte(), set_buffer(), STATUS_OK, TEST_ERASE_BYTES_PAGE_1, and TEST_ERASE_BYTES_PAGE_2.

Referenced by main().

static status_code_t test_split_write ( void  )
static

Test nvm_eeprom_split_write_page()

Test procedure:

  • Erase TEST_SPLIT_WRITE_PAGE page and then write 2 bytes to TEST_SPLIT_WRITE_PAGE by using an atomic write
  • Write 1 additional byte at another location using a split write
  • Verify that all 3 bytes written correctly and that the rest of the page is erased.
Returns
STATUS_OK if test succeeded, otherwise ERR_BAD_DATA

References buffer, EEPROM_ERASED, ERR_BAD_DATA, is_eeprom_page_equal_to_buffer(), nvm_eeprom_atomic_write_page(), nvm_eeprom_load_byte_to_buffer(), nvm_eeprom_split_write_page(), set_buffer(), STATUS_OK, and TEST_SPLIT_WRITE_PAGE.

Referenced by main().

static status_code_t test_write ( void  )
static

Test nvm_eeprom_erase_page() and nvm_eeprom_write_byte().

Test procedure:

  • Erase TEST_WRITE_PAGE
  • Write one byte
  • Verify that the byte is written and that all other bytes are erased.
Returns
STATUS_OK if test succeeded, otherwise ERR_BAD_DATA

References buffer, EEPROM_ERASED, EEPROM_PAGE_SIZE, ERR_BAD_DATA, is_eeprom_page_equal_to_buffer(), nvm_eeprom_erase_page(), nvm_eeprom_write_byte(), set_buffer(), STATUS_OK, and TEST_WRITE_PAGE.

Referenced by main().

uint8_t buffer[EEPROM_PAGE_SIZE]

Memory buffer to use during testing.

Referenced by test_atomic_write(), test_erase(), test_erase_bytes(), test_split_write(), and test_write().