/* Write a block of words to eeprom. 
Writes a block of words to EEPROM at the requested address, erasing if necessary, and locking afterwards. Only wordwise writing is safe for writing any value */
void eeprom_program_words(uint32_t address, uint32_t *data, int length_in_words)
/* Write a block of words to eeprom. 
Writes a block of words to EEPROM at the requested address, erasing if necessary, and locking afterwards. Only wordwise writing is safe for writing any value */
void eeprom_program_words(uint32_t address, uint32_t *data, int length_in_words)
{
	int i;
	flash_unlock_pecr();
	while (FLASH_SR & FLASH_SR_BSY);
	FLASH_PECR &= ~FLASH_PECR_FTDW;
	for (i = 0; i < length_in_words; i++) {
		MMIO32(address + (i * sizeof(uint32_t))) = *(data+i);
		while (FLASH_SR & FLASH_SR_BSY);
	}
	flash_lock_pecr();
}