fix bad commit

This commit is contained in:
driverblock 2014-06-08 16:36:39 -04:00
parent bdf1b838a7
commit cdcfd289ef
3 changed files with 45 additions and 36 deletions

32
Adafruit_GPS.cpp Normal file → Executable file
View File

@ -168,24 +168,12 @@ char Adafruit_GPS::read(void) {
if(gpsSwSerial) {
if(!gpsSwSerial->available()) return c;
c = gpsSwSerial->read();
<<<<<<< HEAD
} else
#endif
=======
}
else
>>>>>>> FETCH_HEAD
{
if(!gpsHwSerial->available()) return c;
c = gpsHwSerial->read();
}
#else
// if(!gpsHwSerial->available()) return c;
// c = gpsHwSerial->read();
if(!Serial1.available()) return c;
c = Serial1.read();
#endif
//Serial.print(c);
@ -231,6 +219,7 @@ Adafruit_GPS::Adafruit_GPS(NewSoftSerial *ser)
}
#endif
// Constructor when using HardwareSerial
Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) {
common_init(); // Set everything to common state, then...
gpsHwSerial = ser; // ...override gpsHwSerial with value passed.
@ -238,13 +227,10 @@ Adafruit_GPS::Adafruit_GPS(HardwareSerial *ser) {
// Initialization code used by all constructor types
void Adafruit_GPS::common_init(void) {
<<<<<<< HEAD
#ifdef __AVR__
gpsSwSerial = NULL; // Set both to NULL, then override correct
#endif
gpsHwSerial = NULL; // port pointer in corresponding constructor
=======
>>>>>>> FETCH_HEAD
recvdflag = false;
paused = false;
lineidx = 0;
@ -267,12 +253,6 @@ void Adafruit_GPS::begin(uint16_t baud)
gpsSwSerial->begin(baud);
else
gpsHwSerial->begin(baud);
<<<<<<< HEAD
=======
#else
// gpsHwSerial->begin(baud);
Serial1.begin(baud);
>>>>>>> FETCH_HEAD
#endif
delay(10);
@ -282,19 +262,9 @@ void Adafruit_GPS::sendCommand(char *str) {
#ifdef __AVR__
if(gpsSwSerial)
gpsSwSerial->println(str);
<<<<<<< HEAD
else
#endif
gpsHwSerial->println(str);
=======
else
gpsHwSerial->println(str);
#else
// gpsHwSerial->println(str);
Serial1.println(str);
#endif
>>>>>>> FETCH_HEAD
}
boolean Adafruit_GPS::newNMEAreceived(void) {

0
Adafruit_GPS.h Normal file → Executable file
View File

View File

@ -37,12 +37,18 @@ HardwareSerial mySerial = Serial1;
// Set to 'true' if you want to debug and listen to the raw GPS sentences
#define GPSECHO true
// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy
void setup()
{
// connect at 115200 so we can read the GPS fast enuf and
// also spit it out
Serial.begin(115200);
delay(2000);
while (!Serial);
delay(1000);
Serial.println("Adafruit GPS logging start test!");
// 9600 NMEA is the default baud rate for MTK - some use 4800
@ -54,6 +60,10 @@ void setup()
// Default is 1 Hz update rate
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
// the nice thing about this code is you can have a timer0 interrupt go off
// every 1 millisecond, and read data from the GPS for you. that makes the
// loop code a heck of a lot easier!
useInterrupt(true);
delay(500);
Serial.print("\nSTARTING LOGGING....");
if (GPS.LOCUS_StartLogger())
@ -65,9 +75,38 @@ void setup()
void loop() // run over and over again
{
char c = GPS.read();
// if you want to debug, this is a good time to do it!
if ((c) && (GPSECHO))
Serial.write(c);
// do nothing! all reading and printing is done in the interrupt
}
/******************************************************************/
// Interrupt is called once a millisecond, looks for any new GPS data, and stores it
SIGNAL(TIMER0_COMPA_vect) {
char c = GPS.read();
// if you want to debug, this is a good time to do it!
if (GPSECHO && c) {
#ifdef UDR0
UDR0 = c;
// writing direct to UDR0 is much much faster than Serial.print
// but only one character can be written at a time.
#else
Serial.write(c);
#endif
}
}
void useInterrupt(boolean v) {
if (v) {
// Timer0 is already used for millis() - we'll just interrupt somewhere
// in the middle and call the "Compare A" function above
OCR0A = 0xAF;
TIMSK0 |= _BV(OCIE0A);
usingInterrupt = true;
} else {
// do not call the interrupt function COMPA anymore
TIMSK0 &= ~_BV(OCIE0A);
usingInterrupt = false;
}
}