Fixed Leo Locus examples
Restored interrupt to leo_locus examples, since this is required for locus logging to work.
This commit is contained in:
parent
cdcfd289ef
commit
0028238a03
|
|
@ -36,10 +36,11 @@ HardwareSerial mySerial = Serial1;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
// while (!Serial); // Leonardo will wait till serial connects
|
||||||
|
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// connect at 115200 so we can read the GPS fast enuf and
|
||||||
// also spit it out
|
// also spit it out
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(2000);
|
|
||||||
Serial.println("Adafruit GPS logging start test!");
|
Serial.println("Adafruit GPS logging start test!");
|
||||||
|
|
||||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||||
|
|
@ -58,8 +59,16 @@ void setup()
|
||||||
|
|
||||||
void loop() // run over and over again
|
void loop() // run over and over again
|
||||||
{
|
{
|
||||||
|
// If using hardware serial (e.g. Arduino Mega), change this to Serial1, etc.
|
||||||
if (mySerial.available()) {
|
if (mySerial.available()) {
|
||||||
Serial.write(mySerial.read());
|
char c = mySerial.read();
|
||||||
|
if (c) {
|
||||||
|
#ifdef UDR0
|
||||||
|
UDR0 = c;
|
||||||
|
#else
|
||||||
|
Serial.print(c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,33 @@
|
||||||
Adafruit_GPS GPS(&Serial1);
|
Adafruit_GPS GPS(&Serial1);
|
||||||
HardwareSerial mySerial = Serial1;
|
HardwareSerial mySerial = Serial1;
|
||||||
|
|
||||||
|
// Set GPSECHO to 'false' to turn off echoing the GPS data to the Serial console
|
||||||
|
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||||
|
#define GPSECHO false
|
||||||
|
|
||||||
|
// 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()
|
void setup()
|
||||||
{
|
{
|
||||||
|
while (!Serial) ; //wait for serial port on Leonardo
|
||||||
|
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// connect at 115200 so we can read the GPS fast enuf and
|
||||||
// also spit it out
|
// also spit it out
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(2000);
|
|
||||||
Serial.println("Adafruit GPS erase FLASH!");
|
Serial.println("Adafruit GPS erase FLASH!");
|
||||||
|
|
||||||
// 9600 NMEA is the default baud rate for MTK
|
// 9600 NMEA is the default baud rate for MTK
|
||||||
GPS.begin(9600);
|
GPS.begin(9600);
|
||||||
|
|
||||||
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_OFF);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!");
|
Serial.println("This code will ERASE the data log stored in the FLASH - Permanently!");
|
||||||
Serial.print("Are you sure you want to do this? [Y/N]: ");
|
Serial.print("Are you sure you want to do this? [Y/N]: ");
|
||||||
|
|
@ -62,3 +76,34 @@ void loop() // run over and over again
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,18 @@ HardwareSerial mySerial = Serial1;
|
||||||
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
// Set to 'true' if you want to debug and listen to the raw GPS sentences
|
||||||
#define GPSECHO false
|
#define GPSECHO false
|
||||||
|
|
||||||
|
// 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()
|
void setup()
|
||||||
{
|
{
|
||||||
|
while (!Serial); // the Leonardo will 'wait' until the USB plug is connected
|
||||||
|
|
||||||
// connect at 115200 so we can read the GPS fast enuf and
|
// connect at 115200 so we can read the GPS fast enuf and
|
||||||
// also spit it out
|
// also spit it out
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(5000);
|
|
||||||
Serial.println("Adafruit GPS logging start test!");
|
Serial.println("Adafruit GPS logging start test!");
|
||||||
|
|
||||||
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
// 9600 NMEA is the default baud rate for MTK - some use 4800
|
||||||
|
|
@ -55,6 +61,11 @@ void setup()
|
||||||
// Default is 1 Hz update rate
|
// Default is 1 Hz update rate
|
||||||
GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
|
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);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
Serial.print("Starting logging....");
|
Serial.print("Starting logging....");
|
||||||
if (GPS.LOCUS_StartLogger()) {
|
if (GPS.LOCUS_StartLogger()) {
|
||||||
|
|
@ -110,4 +121,35 @@ void loop() // run over and over again
|
||||||
}//loop
|
}//loop
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************/
|
||||||
|
// 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.
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue