Ejemplo n.º 1
0
status_code_t nvm_page_erase(mem_type_t mem, uint32_t page_number)
{
	switch (mem) {
	case INT_FLASH:
		if ((page_number >= 0) &&
				(page_number <
				(BOOT_SECTION_START / FLASH_PAGE_SIZE))) {
			nvm_flash_erase_app_page((flash_addr_t)(page_number *
					FLASH_PAGE_SIZE));
		} else if ((page_number >= 0) &&
				(page_number <
				(BOOT_SECTION_END / FLASH_PAGE_SIZE))) {
			nvm_flash_erase_boot_page((flash_addr_t)(page_number *
					FLASH_PAGE_SIZE));
		} else {
			return ERR_INVALID_ARG;
		}

		break;

	case INT_USERPAGE:
		nvm_flash_erase_user_section();
		break;

	case INT_EEPROM:
		nvm_eeprom_erase_page((uint8_t)page_number);
		break;

	default:
		return ERR_INVALID_ARG;
	}

	return STATUS_OK;
}
Ejemplo n.º 2
0
/* New function declarations used for the NVM-workaround */
void EraseApplicationPage(uint32_t address)
{
   /*Set the correct settings and store critical registers before NVM-workaround*/
#ifdef WORKAROUND
   Prepare_to_Sleep();
#endif
   /*Assembly "function" to preform page erase*/
    nvm_flash_erase_app_page(address);
}
Ejemplo n.º 3
0
/**
 * Test nvm_flash_load_word_to_buffer(), nvm_flash_erase_app_page() and
 * nvm_flash_split_write_app_page().
 *
 * Test procedure:
 * - Erase page in application table section.
 * - Verify the page is erased by comparing each word in flash.
 * - Write page to application table section
 * - Verify each byte written correctly by comparing each word in flash
 *
 * \return STATUS_OK if test succeeded, otherwise ERR_BAD_DATA
 */
static status_code_t test_split_write_app_table(void)
{
	flash_addr_t page_addr;

	page_addr = APPTABLE_SECTION_START + 3 * FLASH_PAGE_SIZE;

	set_buffer(buffer, FLASH_ERASED);
	nvm_flash_erase_app_page(page_addr);

	if (!is_flash_page_equal_to_buffer(page_addr, buffer)) {
		return ERR_BAD_DATA;
	}

	fill_flash_page_buffer(buffer, 0x317A);

	nvm_flash_split_write_app_page(page_addr);
	if (!is_flash_page_equal_to_buffer(page_addr, buffer)) {
		return ERR_BAD_DATA;
	}

	return STATUS_OK;
}