Ejemplo n.º 1
0
void Internal_EE_Erase8(uint16_t position){
	DATA_EEPROM_Unlock();
	/* Clear all pending flags */      
  FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR
                  | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR | FLASH_FLAG_OPTVERRUSR);	
	DATA_EEPROM_EraseByte(INTERNAL_8BIT_START_ADDRESS+position);
	DATA_EEPROM_Lock();
}
Ejemplo n.º 2
0
void Internal_EE_EraseM8(uint16_t start_position, uint16_t NbrOfPositions){
	uint16_t i = 0;
	DATA_EEPROM_Unlock();
	/* Clear all pending flags */      
  FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR
                  | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR | FLASH_FLAG_OPTVERRUSR);	
	for(i=0; i<NbrOfPositions; i++){
		DATA_EEPROM_EraseByte(INTERNAL_8BIT_START_ADDRESS+start_position+i);
	}
	DATA_EEPROM_Lock();
}
Ejemplo n.º 3
0
/**
  * @brief  Writes selected block of option structure memory to EEPROM.
  * @param  offset: beginning of block to write, length of block.
  * @retval void
  */
void WriteBlock(uint16_t offset, uint8_t len)
{
   uint8_t i;
   uint32_t eeprom_addr = DATA_EEPROM_START_ADDR + offset;
   uint8_t* ram_addr    = (uint8_t*)&options + offset;

   DATA_EEPROM_Unlock();
   for (i=0; i<len; i++)                                 // Erase
     DATA_EEPROM_EraseByte(eeprom_addr+i);
   for (i=0; i<len; i++)                                 // Program
     DATA_EEPROM_ProgramByte(eeprom_addr+i, *ram_addr++);
   DATA_EEPROM_Lock();
}
Ejemplo n.º 4
0
/**
  * @brief  Function stores all options in EEPROM memory.
  * @param  void
  * @retval verification status
  */
uint8_t WriteOptions(void)
{
   uint16_t i;
   uint32_t eeprom_addr = DATA_EEPROM_START_ADDR;
   uint8_t* ram_addr    = (uint8_t*)&options;
   uint8_t  options_len = sizeof(options);
   uint8_t  ver_status  = 0;
   //FLASH_Status FLASHStatus = FLASH_COMPLETE;

   DATA_EEPROM_Unlock();                                                   // Unlock the FLASH PECR register and Data EEPROM memory
   FLASH_ClearFlag(FLASH_FLAG_EOP|FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR    // Clear all pending flags
                  | FLASH_FLAG_SIZERR | FLASH_FLAG_OPTVERR | FLASH_FLAG_OPTVERRUSR);

   for (i=0; i<options_len; i++)                                           // Erase
     DATA_EEPROM_EraseByte(eeprom_addr+i);
   for (i=0; i<options_len; i++)                                           // Program
     DATA_EEPROM_ProgramByte(eeprom_addr+i, *ram_addr++);
   ram_addr = (uint8_t*)&options;
   for (i=0; i<options_len; i++)                                           // Verify
   { if (*ram_addr++ != *(uint8_t*)(eeprom_addr+i)) ver_status = 1; }

   DATA_EEPROM_Lock();
   return ver_status;
}