This was a bit scary, particularly once I realised that I wasn't just coughing, I was also having difficulty in breathing. So, I stood up. This wasn't a brilliant idea from a first aid point of view, since a lack of oxygen to the brain could make me dizzy, and cause me to topple over. However, I was basically working on instinct (as mentioned previously), which said "If I'm in trouble, I want to deal with it on my feet."
I made a conscious effort to take a slow, deep, breath, and I got a bit of air that way; less than I normally would, but enough to reassure me that I wasn't in imminent danger of death, so that calmed me down. After a bit more coughing, my breathing settled down to normal.
The top of my mouth and my nose felt a bit raw; particularly for the nose, that's what it feels like if I get water up there when I'm swimming. Meanwhile, my mouth tasted as if I'd thrown up, although there's no sign of vomit anywhere on the bed. There's a phrase I've heard on the internet a few times: "I just threw up in my mouth a little bit." That's normally hyperbole (I assume), but I have had a few cases where I've belched and it tastes a little like vomit. So, my guess is that I started to be sick, then swallowed it again, and blocked my airway in the process. Ah well, it worked out ok in the end.