Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions externs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifndef EXTERNS_H
#define EXTERNS_H
extern I2C i2c;
#if MBED_MAJOR_VERSION == 6
extern UnbufferedSerial pc;
#elif MBED_MAJOR_VERSION == 5
extern Serial pc;
#endif
#endif
20 changes: 9 additions & 11 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,32 @@
#include "src/SparkFun_I2C_GPS_Reading_and_Control/SparkFun_I2C_GPS_Arduino_Library.h"
#include "externs.h"

I2C i2c(I2C1_SDA, I2C1_SCL);
Serial pc(USBTX, USBRX, 115200);
I2C i2c(I2C_SDA, I2C_SCL);
//Serial pc(USBTX, USBRX, 115200); //Line not needed in Mbed OS V6, uncomment if using Mbed OS V5
I2CGPS myI2CGPS;
string configString;


// main() runs in its own thread in the OS
int main() {

while (myI2CGPS.begin(i2c, 400000) == false) {
pc.printf("Module failed to respond. Please check wiring.\n");
printf("Module failed to respond. Please check wiring.\n");
ThisThread::sleep_for(500);
}
pc.printf("GPS module found!\n");
printf("GPS module found!\n");

/* if GPS module is found let us configure it */
// setup PPS LED
configString = myI2CGPS.createMTKpacket(285, ",4,25");
myI2CGPS.sendMTKpacket(configString);


while (true) {
while (myI2CGPS.available()) // available() returns the number of new bytes
// available from the GPS module
while (myI2CGPS.available()) // available() returns the number of new bytes available from the GPS module
{
uint8_t incoming = myI2CGPS.read(); //Read the latest byte from Qwiic GPS
if(incoming == '$') pc.printf("\n"); //Break the sentences onto new lines
pc.printf("%c", incoming); //Print this character
uint8_t incoming = myI2CGPS.read(); // Read the latest byte from Qwiic GPS
if (incoming == '$')
printf("\n"); // Break the sentences onto new lines
printf("%c", incoming); // Print this character
}
}
return 0;
Expand Down
Loading