/* Returns the write protection status of user flash area.  */
uint16_t FLASH_If_GetWriteProtectionStatus(void)
/* Returns the write protection status of user flash area.  */
uint16_t FLASH_If_GetWriteProtectionStatus(void)
{
  uint32_t ProtectedSECTOR = 0xFFF;
  FLASH_OBProgramInitTypeDef OptionsBytesStruct;
  HAL_FLASH_Unlock();
  HAL_FLASHEx_OBGetConfig(&OptionsBytesStruct);
  HAL_FLASH_Lock();
  ProtectedSECTOR = ~(OptionsBytesStruct.WRPSector) & FLASH_SECTOR_TO_BE_PROTECTED;
  if(ProtectedSECTOR != 0)
  {
    return FLASHIF_PROTECTION_WRPENABLED;
  }
  else
  {
    return FLASHIF_PROTECTION_NONE;
  }
}