/* Reads a page of data from an emulated EEPROM memory page. 
Reads an emulated EEPROM page of data from the emulated EEPROM memory space. */
enum status_code eeprom_emulator_read_page(const uint8_t logical_page, uint8_t *const data)
/* Reads a page of data from an emulated EEPROM memory page. 
Reads an emulated EEPROM page of data from the emulated EEPROM memory space. */
enum status_code eeprom_emulator_read_page(const uint8_t logical_page, uint8_t *const data)
{
	if (_eeprom_instance.initialized == false) {
		return STATUS_ERR_NOT_INITIALIZED;
	}
	if (logical_page >= _eeprom_instance.logical_pages) {
		return STATUS_ERR_BAD_ADDRESS;
	}
	if ((_eeprom_instance.cache_active == true) &&
		 (_eeprom_instance.cache.header.logical_page == logical_page)) {
		memcpy(data, _eeprom_instance.cache.data, EEPROM_PAGE_SIZE);
	} else {
		struct _eeprom_page temp;
		_eeprom_emulator_nvm_read_page(
				_eeprom_instance.page_map[logical_page], &temp);
		memcpy(data, temp.data, EEPROM_PAGE_SIZE);
	}
	return STATUS_OK;
}