Match return value to type in available()
Fix idle level when initializing a inverted SoftwareSerial

Previously, when SoftwareSerial was initialized, it would always be set
to an idle level of HIGH, even when inverted logic was enabled. Once a
byte is transmitted, the idle level gets correctly set to LOW instead.
This commit makes sure that the idle level is correct directly after
initialization already.

This fixes #1361.
Merge pull request #2090 from jenscski/master-fix-1361

Bug in SoftwareSerial when using inverse logic
Merge pull request #2057 from zfields/patch-1

Match return value to type in available()
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>
Fix of a bug

Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen():
 
bool Stream::find(char *target)
{
  return findUntil(target, NULL);
}
 
// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
{
  return findUntil(target, strlen(target), terminator, strlen(terminator));
}
Fix of a bug

Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen() :
 
bool Stream::find(char *target)
{
  return findUntil(target, NULL);
}
 
// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
{
  return findUntil(target, strlen(target), terminator, strlen(terminator));
}
USB CDC available() method returns correct number of bytes in buffer.

See #1953
Merge pull request #2104 from amulya349/master

Fix of a bug in Stream.cpp