Michael Ernst Peter / Mbed OS Test_GPS

Dependencies:   Eigen

Revision:
47:c74d09a252d4
Parent:
45:5d65b27c9293
Child:
48:77009dca23a8
--- a/main.cpp	Wed Jun 01 13:03:38 2022 +0000
+++ b/main.cpp	Thu Jun 02 07:43:14 2022 +0000
@@ -2,10 +2,10 @@
 
 // GNSS and Compass test programm for Mateksys GNSS&Compass M9N-5883
 
-// #include "PM2_Libary.h"
 // #include "Eigen/Dense.h"
 #include "QMC5883L.h"
 #include "LinearCharacteristics.h"
+#include "NEOM9N.h"
 
 // logical variable main task
 bool do_execute_main_task = true;  // this variable will be toggled via the user button (blue button) to or not to execute the main task
@@ -19,20 +19,24 @@
 int main()
 {
     // while loop gets executed every main_task_period_ms milliseconds
-    const int main_task_period_ms = 6;   // define main task period time in ms e.g. 50 ms -> main task runns 20 times per second
+    const int main_task_period_ms = 100;  // define main task period time in ms e.g. 50 ms -> main task runns 20 times per second
     Timer main_task_timer;                // create Timer object which we use to run the main task every main task period time in ms
 
     // led on nucleo board
     DigitalOut user_led(LED1);      // create DigitalOut object to command user led
 
     // create QMC5883L compass object
-    I2C i2c(PB_9, PB_8);
+    I2C i2c(PB_9, PB_8); // I2C1
     QMC5883L mag(i2c);
     LinearCharacteristics raw_mx2mx, raw_my2my, raw_mz2mz;
     raw_mx2mx.setup(0.9991f, 0.0088f);
     raw_my2my.setup(0.9982f, 0.2092f);
     raw_mz2mz.setup(1.0027f, -0.0903f);
     float mag_val[3] = {0.0f, 0.0f, 0.0f};
+    
+    // create object for GNSS Sensor NEO-M9N
+    //NEOM9N neom9n(PA_9, PA_10); // UART1
+    NEOM9N neom9n(PA_2, PA_3); // UART2
 
     // attach button fall and rise functions to user button object
     user_button.fall(&user_button_pressed_fcn);
@@ -64,7 +68,8 @@
         user_led = !user_led;
 
         // do only output via serial what's really necessary (this makes your code slow)
-        printf("%f, %f, %f\r\n", mag_val[0], mag_val[1], mag_val[2]);
+        //printf("%f, %f, %f\r\n", mag_val[0], mag_val[1], mag_val[2]);
+        printf("GPS time: %d, num sat: %d, lat: %d, lon: %d, speed: %d, heading: %d\r\n", neom9n.actualPVT.itow, neom9n.actualPVT.numSV, neom9n.actualPVT.lat, neom9n.actualPVT.lon, neom9n.actualPVT.speed, neom9n.actualPVT.headMot);
 
         // read timer and make the main thread sleep for the remaining time span (non blocking)
         int main_task_elapsed_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(main_task_timer.elapsed_time()).count();