adafruit/Adafruit-GPS-Library — pull request #35 by pepijndevos (2014-11-20 21:27:22+00:00)
Title: Use USART interrupt

The current recommended approach to parse NMEA messages is to use a timer interrupt that polls the hardware serial for data.
While I did not observe any real problem with this approach, it seems wasteful.

This patch breaks everything, but avoids HardwareSerial entirely, using its own USART interrupt.
Since Arduino 1.5.x, not referring to `SerialN` means the buffer and interrupt are not instantiated.
So this frees up a few CPU cycles and 128 bytes of SRAM.

Usage on the Mega is as follows

```C++
// copy from HardwareSerialN.cpp
Adafruit_GPS GPS(&UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2);

ISR(USART2_RX_vect)
{
GPS.read();
}

ISR(USART2_UDRE_vect)
{
GPS.write();
}

void setup()
{
GPS.begin(9600);
}
```