/* Reads a page of data from an emulated RWW EEPROM memory page. 
Reads an emulated RWW EEPROM page of data from the emulated RWW EEPROM memory space. */
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. 
Reads an emulated RWW EEPROM page of data from the emulated RWW EEPROM memory space. */
enum status_code rww_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, RWW_EEPROM_PAGE_SIZE);
	} else {
		struct _rww_eeprom_page temp;
		if (_rww_eeprom_emulator_nvm_read_page(
				_eeprom_instance.page_map[logical_page], &temp)){
			memcpy(data, temp.data, RWW_EEPROM_PAGE_SIZE);
		}else{
			memcpy(data, temp.data, RWW_EEPROM_PAGE_SIZE);
			return STATUS_ERR_BAD_FORMAT;
		}
	}
	return STATUS_OK;
}