SAM Read While Write EEPROM Emulator.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
struct | _rww_eeprom_master_page |
Structure describing the EEPROM Emulation master page. More... | |
struct | _rww_eeprom_module |
Internal device instance struct. More... | |
struct | _rww_eeprom_page |
Structure describing emulated pages of RWW EEPROM data. More... | |
Macros | |
#define | CONF_LOGICAL_PAGE_NUM_IN_ROW RWWEE_LOGICAL_PAGE_NUM_1 |
Configuration option, one logical page stored in a physical row. More... | |
#define | CONF_PAGE_CHECKSUM_ENABLE false |
Configuration option, page checksum enabled. More... | |
#define | RWW_EEPROM_MAGIC_KEY {0x41744545, 0x50524f4d, 0x456d752d,0x5257572e} |
#define | RWW_EEPROM_MAGIC_KEY_COUNT 4 |
#define | RWW_EEPROM_MAX_LOGICAL_PAGES |
Functions | |
static void | _rww_eeprom_emulator_check_logical_page (void) |
Check if there exist rows with same logical pages due to power drop when writing or erasing page. More... | |
static void | _rww_eeprom_emulator_create_master_page (void) |
Create master emulated RWW EEPROM management page. More... | |
static void | _rww_eeprom_emulator_erase_invalid_page (uint16_t pre_phy_page, uint16_t next_phy_page) |
Erase one invalid page according to two invalid physical page. More... | |
static void | _rww_eeprom_emulator_format_memory (void) |
Initializes the emulated RWW EEPROM memory, destroying the current contents. More... | |
static bool | _rww_eeprom_emulator_is_full_row (uint16_t phy_page) |
Check if a row is a full row because the page is a invalid page, so if two pages have data, it is the full row. More... | |
static bool | _rww_eeprom_emulator_is_page_free_on_row (const uint8_t start_physical_page, uint8_t *const free_physical_page) |
Finds the next free page in the given row if one is available. More... | |
static enum status_code | _rww_eeprom_emulator_move_data_to_spare (const uint8_t row_number, const uint8_t logical_page, const uint8_t *const data) |
Moves data from the specified logical page to the spare row. More... | |
static void | _rww_eeprom_emulator_nvm_commit_cache (const uint16_t physical_page) |
Commits the internal NVM controller page buffer to physical memory. More... | |
static void | _rww_eeprom_emulator_nvm_erase_row (const uint8_t row) |
Erases a given row within the physical RWW EEPROM memory space. More... | |
static void | _rww_eeprom_emulator_nvm_fill_cache (const uint16_t physical_page, const void *const data) |
Fills the internal NVM controller page buffer in physical RWW EEPROM memory space. More... | |
static bool | _rww_eeprom_emulator_nvm_read_page (const uint16_t physical_page, void *const data) |
Reads a page of data stored in physical RWW EEPROM memory space. More... | |
static uint8_t | _rww_eeprom_emulator_page_checksum (const uint8_t *buffer) |
RWW EEPROM Page Checksum. More... | |
static void | _rww_eeprom_emulator_update_page_mapping (void) |
Creates a map in SRAM to translate logical RWW EEPROM pages to physical pages. More... | |
static enum status_code | _rww_eeprom_emulator_verify_master_page (void) |
Verify the contents of a master RWW EEPROM page. More... | |
COMPILER_PACK_RESET () | |
COMPILER_PACK_SET (1) | |
enum status_code | rww_eeprom_emulator_commit_page_buffer (void) |
Commits any cached data to physical non-volatile memory. More... | |
void | rww_eeprom_emulator_erase_memory (void) |
Erases the entire emulated RWW EEPROM memory space. More... | |
enum status_code | rww_eeprom_emulator_get_parameters (struct rww_eeprom_emulator_parameters *const parameters) |
Retrieves the parameters of the RWW EEPROM Emulator memory layout. More... | |
enum status_code | rww_eeprom_emulator_init (void) |
Initializes the RWW EEPROM Emulator service. More... | |
enum status_code | rww_eeprom_emulator_read_buffer (const uint16_t offset, uint8_t *const data, const uint16_t length) |
Reads a buffer of data from the emulated RWW EEPROM memory space. More... | |
enum status_code | rww_eeprom_emulator_read_page (const uint8_t logical_page, uint8_t *const data) |
Reads a page of data from an emulated RWW EEPROM memory page. More... | |
enum status_code | rww_eeprom_emulator_write_buffer (const uint16_t offset, const uint8_t *const data, const uint16_t length) |
Writes a buffer of data to the emulated RWW EEPROM memory space. More... | |
enum status_code | rww_eeprom_emulator_write_page (const uint8_t logical_page, const uint8_t *const data) |
Writes a page of data to an emulated RWW EEPROM memory page. More... | |
Variables | |
static struct _rww_eeprom_module | _eeprom_instance |
Internal RWW EEPROM emulator instance. More... | |
#define CONF_LOGICAL_PAGE_NUM_IN_ROW RWWEE_LOGICAL_PAGE_NUM_1 |
Configuration option, one logical page stored in a physical row.
Referenced by _rww_eeprom_emulator_format_memory(), _rww_eeprom_emulator_is_full_row(), _rww_eeprom_emulator_move_data_to_spare(), and rww_eeprom_emulator_init().
#define CONF_PAGE_CHECKSUM_ENABLE false |
Configuration option, page checksum enabled.
Referenced by _rww_eeprom_emulator_erase_invalid_page(), _rww_eeprom_emulator_nvm_fill_cache(), and _rww_eeprom_emulator_nvm_read_page().
#define RWW_EEPROM_MAGIC_KEY {0x41744545, 0x50524f4d, 0x456d752d,0x5257572e} |
Magic key is the sequence "AtEEPROMEmu_RWW." in ASCII. The key is encoded as a sequence of 32-bit values to speed up checking of the key, which can be implemented as a number of simple integer comparisons,
Referenced by _rww_eeprom_emulator_create_master_page(), and _rww_eeprom_emulator_verify_master_page().
#define RWW_EEPROM_MAGIC_KEY_COUNT 4 |
Length of the magic key, in 32-bit elements.
Referenced by _rww_eeprom_emulator_create_master_page(), and _rww_eeprom_emulator_verify_master_page().
#define RWW_EEPROM_MAX_LOGICAL_PAGES |
RWW EEPROM max logical page num.
Referenced by rww_eeprom_emulator_init().
|
static |
Check if there exist rows with same logical pages due to power drop when writing or erasing page.
when existed same logical page, if the new row checksums is valid, the old(full) row will be erased, or the new row will be erased. If page checksum disabled, the old(full) row will be erased.
References _rww_eeprom_emulator_erase_invalid_page(), _rww_eeprom_page::header, i, j, _rww_eeprom_page::logical_page, _rww_eeprom_module::physical_pages, and _rww_eeprom_module::rwwee_addr.
Referenced by _rww_eeprom_emulator_update_page_mapping().
|
static |
Create master emulated RWW EEPROM management page.
Creates a new master page in emulated RWW EEPROM, giving information on the emulator used to store the RWW EEPROM data.
References _rww_eeprom_emulator_nvm_commit_cache(), _rww_eeprom_emulator_nvm_erase_row(), _rww_eeprom_emulator_nvm_fill_cache(), c, _rww_eeprom_master_page::emulator_id, _rww_eeprom_master_page::magic_key, _rww_eeprom_master_page::major_version, _rww_eeprom_master_page::minor_version, _rww_eeprom_master_page::revision, RWW_EEPROM_EMULATOR_ID, RWW_EEPROM_MAGIC_KEY, RWW_EEPROM_MAGIC_KEY_COUNT, RWW_EEPROM_MAJOR_VERSION, RWW_EEPROM_MINOR_VERSION, and RWW_EEPROM_REVISION.
Referenced by rww_eeprom_emulator_erase_memory().
|
static |
Erase one invalid page according to two invalid physical page.
[in] | pre_phy_page | One physical invalid page |
[in] | next_phy_page | Another physical invalid page |
References _rww_eeprom_emulator_is_full_row(), _rww_eeprom_emulator_nvm_erase_row(), _rww_eeprom_emulator_nvm_read_page(), CONF_PAGE_CHECKSUM_ENABLE, and flag.
Referenced by _rww_eeprom_emulator_check_logical_page().
|
static |
Initializes the emulated RWW EEPROM memory, destroying the current contents.
References _rww_eeprom_emulator_nvm_commit_cache(), _rww_eeprom_emulator_nvm_erase_row(), _rww_eeprom_emulator_nvm_fill_cache(), CONF_LOGICAL_PAGE_NUM_IN_ROW, _rww_eeprom_page::header, _rww_eeprom_page::logical_page, _rww_eeprom_module::physical_pages, and _rww_eeprom_module::spare_row.
Referenced by rww_eeprom_emulator_erase_memory().
|
static |
Check if a row is a full row because the page is a invalid page, so if two pages have data, it is the full row.
[in] | phy_page | Physical page that in a row |
References CONF_LOGICAL_PAGE_NUM_IN_ROW, _rww_eeprom_page::header, _rww_eeprom_page::logical_page, _rww_eeprom_module::rwwee_addr, and RWWEE_LOGICAL_PAGE_NUM_1.
Referenced by _rww_eeprom_emulator_erase_invalid_page().
|
static |
Finds the next free page in the given row if one is available.
[in] | start_physical_page | Physical page index of the row to search |
[out] | free_physical_page | Index of the physical page that is currently free (if one was found) |
\c | true If a free page was found |
\c | false If the specified row was full and needs an erase |
References c, _rww_eeprom_page::header, _rww_eeprom_page::logical_page, and _rww_eeprom_module::rwwee_addr.
Referenced by rww_eeprom_emulator_write_page().
|
static |
Moves data from the specified logical page to the spare row.
Moves the contents of the specified row into the spare row, so that the original row can be erased and re-used. The contents of the given logical page is replaced with a new buffer of data.
[in] | row_number | Physical row to examine |
[in] | logical_page | Logical RWW EEPROM page number in the row to update |
[in] | data | New data to replace the old in the logical page |
References _rww_eeprom_emulator_nvm_erase_row(), _rww_eeprom_emulator_nvm_fill_cache(), _rww_eeprom_emulator_nvm_read_page(), c, _rww_eeprom_module::cache, _rww_eeprom_module::cache_active, CONF_LOGICAL_PAGE_NUM_IN_ROW, _rww_eeprom_page::data, for(), header, _rww_eeprom_page::header, i, _rww_eeprom_page::logical_page, _rww_eeprom_module::page_map, rww_eeprom_emulator_commit_page_buffer(), RWW_EEPROM_PAGE_SIZE, _rww_eeprom_module::rwwee_addr, _rww_eeprom_module::spare_row, and STATUS_OK.
Referenced by rww_eeprom_emulator_write_page().
|
static |
Commits the internal NVM controller page buffer to physical memory.
[in] | physical_page | Physical page in RWW EEPROM space to commit |
References NVM_COMMAND_RWWEE_WRITE_PAGE, nvm_execute_command(), _rww_eeprom_module::rwwee_addr, STATUS_BUSY, and STATUS_OK.
Referenced by _rww_eeprom_emulator_create_master_page(), _rww_eeprom_emulator_format_memory(), and rww_eeprom_emulator_commit_page_buffer().
|
static |
Erases a given row within the physical RWW EEPROM memory space.
[in] | row | Physical row in RWW EEPROM space to erase |
References nvm_erase_row(), _rww_eeprom_module::rwwee_addr, STATUS_BUSY, and STATUS_OK.
Referenced by _rww_eeprom_emulator_create_master_page(), _rww_eeprom_emulator_erase_invalid_page(), _rww_eeprom_emulator_format_memory(), and _rww_eeprom_emulator_move_data_to_spare().
|
static |
Fills the internal NVM controller page buffer in physical RWW EEPROM memory space.
[in] | physical_page | Physical page in RWW EEPROM space to fill |
[in] | data | Data to write to the physical memory page |
References _rww_eeprom_emulator_page_checksum(), CONF_PAGE_CHECKSUM_ENABLE, _rww_eeprom_page::data, _rww_eeprom_page::header, _rww_eeprom_module::initialized, nvm_write_buffer(), _rww_eeprom_page::page_checksum, _rww_eeprom_module::rwwee_addr, STATUS_BUSY, and STATUS_OK.
Referenced by _rww_eeprom_emulator_create_master_page(), _rww_eeprom_emulator_format_memory(), _rww_eeprom_emulator_move_data_to_spare(), and rww_eeprom_emulator_write_page().
|
static |
Reads a page of data stored in physical RWW EEPROM memory space.
[in] | physical_page | Physical page in RWW EEPROM space to read |
[out] | data | Destination buffer to fill with the read data |
\c | true The page data checksum is correct |
\c | false The page data checksum is wrong |
References _rww_eeprom_emulator_page_checksum(), CONF_PAGE_CHECKSUM_ENABLE, _rww_eeprom_page::data, _rww_eeprom_page::header, _rww_eeprom_module::initialized, nvm_read_buffer(), _rww_eeprom_page::page_checksum, _rww_eeprom_module::rwwee_addr, STATUS_BUSY, and STATUS_OK.
Referenced by _rww_eeprom_emulator_erase_invalid_page(), _rww_eeprom_emulator_move_data_to_spare(), _rww_eeprom_emulator_verify_master_page(), and rww_eeprom_emulator_read_page().
|
static |
RWW EEPROM Page Checksum.
[in] | buffer | Pointer of page data |
References i, and RWW_EEPROM_PAGE_SIZE.
Referenced by _rww_eeprom_emulator_nvm_fill_cache(), and _rww_eeprom_emulator_nvm_read_page().
|
static |
Creates a map in SRAM to translate logical RWW EEPROM pages to physical pages.
References _rww_eeprom_emulator_check_logical_page(), c, _rww_eeprom_page::header, _rww_eeprom_page::logical_page, _rww_eeprom_module::logical_pages, _rww_eeprom_module::page_map, _rww_eeprom_module::physical_pages, _rww_eeprom_module::rwwee_addr, and _rww_eeprom_module::spare_row.
Referenced by rww_eeprom_emulator_erase_memory(), and rww_eeprom_emulator_init().
|
static |
Verify the contents of a master RWW EEPROM page.
Verify the contents of a master RWW EEPROM page to ensure that it contains the correct information for this version of the RWW EEPROM emulation service.
STATUS_OK | Given master page contents is valid |
STATUS_ERR_BAD_FORMAT | Master page contents was invalid |
STATUS_ERR_IO | Master page indicates the data is incompatible with this version of the RWW EEPROM emulator |
References _rww_eeprom_emulator_nvm_read_page(), c, _rww_eeprom_master_page::emulator_id, _rww_eeprom_master_page::magic_key, _rww_eeprom_master_page::major_version, _rww_eeprom_master_page::minor_version, RWW_EEPROM_EMULATOR_ID, RWW_EEPROM_MAGIC_KEY, RWW_EEPROM_MAGIC_KEY_COUNT, RWW_EEPROM_MAJOR_VERSION, RWW_EEPROM_MINOR_VERSION, STATUS_ERR_BAD_FORMAT, STATUS_ERR_IO, and STATUS_OK.
Referenced by rww_eeprom_emulator_init().
COMPILER_PACK_RESET | ( | ) |
COMPILER_PACK_SET | ( | 1 | ) |
Item structure for faster search of item
< Id of an item.
< Location of the this item.
|
static |
Internal RWW EEPROM emulator instance.