Ejemplo n.º 1
0
status_code_t nvm_write(mem_type_t mem, uint32_t address, void *buffer,
		uint32_t len)
{
	switch (mem) {
	case INT_FLASH:
	case INT_USERPAGE:
		flash_api_memcpy((volatile void *)address, (const void *)buffer,
				len, true);
		break;

#if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX)
	case AT45DBX:
	{
		uint32_t sector = address / AT45DBX_SECTOR_SIZE;
		if (!at45dbx_write_sector_open(sector)) {
			return ERR_BAD_ADDRESS;
		}

		at45dbx_write_sector_from_ram((const void *)buffer);
		at45dbx_write_close();
	}
	break;
#endif

	default:
		return ERR_INVALID_ARG;
	}

	return STATUS_OK;
}
Ejemplo n.º 2
0
status_code_t nvm_write_char(mem_type_t mem, uint32_t address, uint8_t data)
{
	switch (mem) {
	case INT_FLASH:
	case INT_USERPAGE:
		flash_api_memcpy((volatile void *)address, (const void *)&data,
				1, true);
		break;

#if defined(USE_EXTMEM) && defined(CONF_BOARD_AT45DBX)
	case AT45DBX:
		if (!at45dbx_write_byte_open(address)) {
			return ERR_BAD_ADDRESS;
		}

		at45dbx_write_byte(data);
		at45dbx_write_close();
#endif

	default:
		return ERR_INVALID_ARG;
	}

	return STATUS_OK;
}
Ejemplo n.º 3
0
Archivo: isp.c Proyecto: kerichsen/asf
void isp_force_boot_isp(bool force)
{
	uint32_t tempo;
	uint8_t crc8 = 0;
	uint8_t i;

	// Read the config word1 and set the ISP_FORCE bit to force.
	tempo = (BOOT_CFG1 & ~BOOT_CFG1_FORCE_MASK)
		| ((force << BOOT_CFG1_FORCE_OFFSET) & BOOT_CFG1_FORCE_MASK);
	// Compute the CRC8 on the 3 upper Bytes of the word1.
	for (i = 24; i; i -= 8)
		crc8 = isp_crc8(crc8, tempo >> i);
	// Write CRC8 in word1.
	tempo = (tempo & ~BOOT_CFG1_CRC8_MASK)
		| ((crc8 << BOOT_CFG1_CRC8_OFFSET) & BOOT_CFG1_CRC8_MASK);
	// Write the config word1 in user flash.
	flash_api_memcpy((volatile void*) BOOT_CFG1_ADDRESS, &tempo, 4, true);
}
Ejemplo n.º 4
0
Archivo: isp.c Proyecto: kerichsen/asf
/**
 * \brief  Copy a RAM buffer to a user page memory section
 *
 * \param dst    Pointer to user page destination.
 * \param src    Pointer to source data.
 * \param nbytes Number of bytes to transfer.
 */
static void mem_user_write(isp_addr_t dst, const void *src, uint16_t nbytes)
{
	flash_api_memcpy(FLASH_API_USER_PAGE + dst, src, nbytes, true);
}
Ejemplo n.º 5
0
Archivo: isp.c Proyecto: kerichsen/asf
/**
 * \brief  Copy a RAM buffer to a flash memory section
 *
 * \param dst    Pointer to flash destination.
 * \param src    Pointer to source data.
 * \param nbytes Number of bytes to transfer.
 */
static void mem_flash_write(isp_addr_t dst, const void *src, uint16_t nbytes)
{
	flash_api_memcpy(FLASH_API_BASE_ADDRESS + dst, src, nbytes, false);
}