Backported Print class from ide-1.5.x branch

Close #1951
improved USB write speeds
Fix race condition in USB CDC transmit

If the Start of Frame interrupt triggers just after the call
to USB_SendSpace in USB_Send then we can get data loss.
When the first bank is full and the second partially full,
the SOF handler will release the second bank via USB_Flush.
Data is then lost due to overflow as USB_Send continues writing data
to the now-closed bank.

Fix this by re-checking the FIFO status inside LockEP, immediately before
doing the data write.

Signed-off-by: Paul Brook <paul@nowt.org>
Improve CDC read code

Read CDC data from USB FIFO on demand instead of in ISR.
Remove superfluous ring buffer.

Signed-off-by: Paul Brook <paul@nowt.org>
Merge branch 'usbcdc-improved' into ide-1.5.x
USB CDC available() method returns correct number of bytes in buffer.

See #1953
Merge branch 'master' into HEAD