mbed-GPS(nucleo)

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kosukesuzuki
Date:
Wed Aug 03 09:15:06 2022 +0000
Commit message:
mbed-GPS(nucleo);

Changed in this revision

Tera Term.lnk Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 01188f8d5d7c Tera Term.lnk
Binary file Tera Term.lnk has changed
diff -r 000000000000 -r 01188f8d5d7c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 03 09:15:06 2022 +0000
@@ -0,0 +1,66 @@
+#include "mbed.h"
+
+#include "math.h"
+
+#define TIME_GAP      6.0
+
+Serial        gps(PA_9,PA_10);
+
+Timer timer_open;
+Timer timer_log;
+Ticker tic_open;
+Ticker tic_log;
+
+float    _DMS2DEG(float raw_data);
+int      _imput(char cha);
+
+float Time;
+char gps_data[256];
+int cnt_gps;
+int Cnt_GPS=0;
+
+int main(){
+    while(1){
+        if(gps.readable()){
+            gps_data[cnt_gps]=gps.getc();
+            if(gps_data[cnt_gps]=='$' || cnt_gps==256){
+                cnt_gps=0;
+                memset(gps_data,'\0',256);
+         }else if (gps_data[cnt_gps]=='\r'){
+            float world_time, lon_east, lat_north;
+            int rlock, sat_num;
+            char lat,lon;
+            if(sscanf(gps_data,
+            "GPGGA,%f,%f,%c,%f,%c,%d,%d"
+            ,&world_time,&lat_north,&lat,
+            &lon_east,&lon,
+            &rlock,&sat_num)>=1){
+                if(rlock==1){
+                    lat_north=_DMS2DEG(lat_north);
+                    lon_east=_DMS2DEG(lon_east);
+                    printf("Lat:%f,Lon:%f\r\ntime:%f,sat_num:%d\r\n",
+                    lat_north,lon_east,world_time,sat_num);
+                    }else{
+                        printf("%s\r\n",gps_data);
+                    }
+            }
+        }else{
+              cnt_gps++;
+        }
+    }
+    if(timer_log.read()>=30.0*60.0)timer_log.reset();
+    }
+    }
+    float _DMS2DEG(float raw_data){
+            int d=(int)(raw_data/100);
+            float m=(raw_data-(float)d*100);
+            return (float)d+m/60;
+}
+            
+            
+            
+            
+            
+            
+            
+            
\ No newline at end of file
diff -r 000000000000 -r 01188f8d5d7c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Aug 03 09:15:06 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file