/* Configure the write protection status of user flash area.  */
HAL_StatusTypeDef FLASH_If_WriteProtectionConfig(uint32_t modifier)
/* Configure the write protection status of user flash area.  */
HAL_StatusTypeDef FLASH_If_WriteProtectionConfig(uint32_t modifier)
{
  uint32_t ProtectedSECTOR = 0xFFF;
  FLASH_OBProgramInitTypeDef config_new, config_old;
  HAL_StatusTypeDef result = HAL_OK;
  HAL_FLASHEx_OBGetConfig(&config_old);
  config_new.WRPState = modifier;
  config_new.OptionType = OPTIONBYTE_WRP;
  config_new.RDPLevel = OB_RDP_LEVEL_0;
  config_new.USERConfig = config_old.USERConfig;  
  ProtectedSECTOR = config_old.WRPSector | FLASH_SECTOR_TO_BE_PROTECTED;
  HAL_FLASH_Unlock();
  HAL_FLASH_OB_Unlock();
  config_new.WRPSector    = ProtectedSECTOR;
  result = HAL_FLASHEx_OBProgram(&config_new);
  return result;
}