/* This function does an erase of all user flash area.  */
uint32_t FLASH_If_Erase(uint32_t StartSector)
/* This function does an erase of all user flash area.  */
uint32_t FLASH_If_Erase(uint32_t StartSector)
{
  uint32_t UserStartSector;
  uint32_t SectorError;
  FLASH_EraseInitTypeDef pEraseInit;
  FLASH_If_Init();
  UserStartSector = GetSector(APPLICATION_ADDRESS);
  pEraseInit.TypeErase = TYPEERASE_SECTORS;
  pEraseInit.Sector = UserStartSector;
  pEraseInit.NbSectors = 10;
  pEraseInit.VoltageRange = VOLTAGE_RANGE_3;
  if (HAL_FLASHEx_Erase(&pEraseInit, &SectorError) != HAL_OK)
  {
     return (1);
  }
  return (0);
}