/* Finds the next free page in the given row if one is available.  */
static bool _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.  */
static bool _eeprom_emulator_is_page_free_on_row(const uint8_t start_physical_page, uint8_t *const free_physical_page)
{
	uint8_t row         = (start_physical_page / NVMCTRL_ROW_PAGES);
	uint8_t page_in_row = (start_physical_page % NVMCTRL_ROW_PAGES);
	for (uint8_t c = page_in_row; c < NVMCTRL_ROW_PAGES; c++) {
		uint8_t page = (row * NVMCTRL_ROW_PAGES) + c;
		if (_eeprom_instance.flash[page].header.logical_page ==
				EEPROM_INVALID_PAGE_NUMBER) {
			*free_physical_page = page;
			return true;
		}
	}
	return false;
}