code: def _perform_reset(self, reset_type):
          
          if reset_type is Target.ResetType.HW:
              self.session.probe.reset()
          elif reset_type is Target.ResetType.SW_EMULATED:
              self._perform_emulated_reset()
          else:
              if reset_type is Target.ResetType.SW_SYSRESETREQ:
                  mask = CortexM.NVIC_AIRCR_SYSRESETREQ
              elif reset_type is Target.ResetType.SW_VECTRESET:
                  mask = CortexM.NVIC_AIRCR_VECTRESET
              else:
                  raise RuntimeError("internal error, unhandled reset type")
          
              try:
                  self.write_memory(CortexM.NVIC_AIRCR, CortexM.NVIC_AIRCR_VECTKEY | mask)
                  # Without a flush a transfer error can occur
                  self.flush()
              except exceptions.TransferError:
                  self.flush()
docs: ! @brief Perform a reset of the specified type.