“To swoon” is to faint, and the narrator faints because he is frightened and being held prisoner.
This story is about a man who is being tortured. He has been condemned by the Spanish Inquisition. At first, he is just kept in the dark. He is so scared and lacking in nutrition that sometimes he just faints.
I had swooned; but still will not say that all of consciousness was lost. What of it there remained I will not attempt to define, or even to describe; yet all was not lost. In the deepest slumber—no! In delirium—no! In a swoon—no! In death—no! even in the grave all is not lost.
When the narrator says he swoons without losing consciousness, he is saying that he faints but not completely. When you faint it is almost like instantly falling asleep. Usually a person will faint due to bad health or fear. In this case, both situations apply.
When the narrator faints, he has brief periods of lucidity upon regaining consciousness when he remembers what happened to him.
And now a full memory of the trial, of the judges, of the sable draperies, of the sentence, of the sickness, of the swoon. Then entire forgetfulness of all that followed; of all that a later day and much earnestness of endeavor have enabled me vaguely to recall.
Unfortunately for the narrator, things are only about to get worse. He is being held prisoner under a giant pendulum. As the pendulum swings back and forth, it gains momentum and gets closer to killing him. Fortunately, in the end he is rescued just as he is about to die.
This story is very suspenseful, and some of the suspense comes from the narrator going in and out of consciousness. He is in a dream-like state and not lucid enough to fully describe his situation.