Sat Oct 20 14:55:14 EDT 2012

Next: console on USB SERIAL

The problem is flow control.  Monitor is written in terms of blocking
read, so some inversion is necessary.

The big question is: do we want tasks?  It's easy enough in PIC18 as
long as the hardware stack is deep enough, but it's quite a pain if it
is not.  One more reason to switch to a different arch.

The other approach is to just use interrupts.  This requires some
thinking as I do need the high-priority interrupt for the audio stuff.

Let's do this then.
0x18 is LPIV

Section 17.5 “USB Interrupts”.
Low priority interrupts:
PIR2 USBIF : USB interrupt flag
IPR2 USBIP : USB interrupt priority
UIE        : Propagate USB interrupts to microcontroller

From Figure 9-1, this is the configuration that enables USBIF to
interrupt the CPU to the Low Pri 0018h vector.

GIEL/PEIE = 1  : peripheral interrupt enable
GIE/GEIH = 1   : global interrupt enable
IPEN = 1

Also, not to forget from UIR -> USBIF there is UIE
UIE = 7F