void svhandler_flash_erase_sector(void) {
  uint8_t sector = _param_1;

  // Verify requested sector is allowed.
  if (!allow_svhandler_flash_sector_num(sector)) return;

  // Unlock flash.
  flash_clear_status_flags();
  flash_unlock();

  // Erase the sector.
  flash_erase_sector(sector, FLASH_CR_PROGRAM_X32);

  // Return flash status.
  _param_1 = !!flash_chk_status();
  _param_2 = 0;
  _param_3 = 0;

  // Wait for any write operation to complete.
  flash_wait_for_last_operation();

  // Disable writes to flash.
  FLASH_CR &= ~FLASH_CR_PG;

  // lock flash register
  FLASH_CR |= FLASH_CR_LOCK;
}
void svhandler_flash_erase_sector(void) {
  uint8_t sector = _param_1;

   
  if (!allow_svhandler_flash_sector_num(sector)) return;

   
  flash_clear_status_flags();
  flash_unlock();

   
  flash_erase_sector(sector, FLASH_CR_PROGRAM_X32);

   
  _param_1 = !!flash_chk_status();
  _param_2 = 0;
  _param_3 = 0;

   
  flash_wait_for_last_operation();

   
  FLASH_CR &= ~FLASH_CR_PG;

   
  FLASH_CR |= FLASH_CR_LOCK;
}