sample for GPS (used by nucleo_STM-F303K8)
Dependencies: mbed
Fork of Nucleo_GPS by
main.cpp
- Committer:
- mikawataru
- Date:
- 2016-10-24
- Revision:
- 1:91f4ae33e6ac
- Parent:
- 0:8889ed33c550
- Child:
- 2:59b33f158822
File content as of revision 1:91f4ae33e6ac:
/* 説明 Nucleo-F303K8とGPSモジュールを使ったサンプルプログラム 参考 http://www.hiramine.com/physicalcomputing/general/gps_nmeaformat.html 以下ピン配置 Nucleo GPSモジュール GND-----GND-----------0V 5v------VIN D0------TX D1------RX */ #include "mbed.h" Serial gps(D1, D0); // tx, rx Serial pc(PA_2, PA_3); // tx, rx int main() { unsigned char c; int i,rlock; char gps_data[256],gps2_data[256]; char ns,ew; float world_time,hokui,tokei; float g_hokui,g_tokei; float d_hokui,m_hokui,d_tokei,m_tokei; pc.baud(115200); gps.baud(9600); pc.printf("*** GPS GT-720F ***"); while (1) { i=0; while(gps.getc()!='$'){ } while((gps_data[i]=gps.getc()) != '\r'){ i++; if(i==256){ pc.printf("*** Div Error! ***\n"); i=255; break; } } gps_data[i]='\0'; // pc.printf("%s",gps_data); if( sscanf(gps_data, "$GPGGA,%f,%f,%c,%f,%c,%d",&world_time,&hokui,&ns,&tokei,&ew,&rlock) >= 1){ if(rlock==1){ pc.printf("Status:Lock(%d)\n\r",rlock); //logitude d_tokei= int(tokei/100); m_tokei= (tokei-d_tokei*100)/60; g_tokei= d_tokei+m_tokei; pc.printf("Log:%4.5f,",g_tokei); //Latitude d_hokui=int(hokui/100); m_hokui=(hokui-d_hokui*100)/60; g_hokui=d_hokui+m_hokui; pc.printf("Lat:%4.5f\n\r",g_hokui); } else{ pc.printf("\n\rStatus:unLock(%d)\n\r",rlock); for(i=0;i<40;i++){ pc.printf("%c",gps_data[i]); } } }//if }//while }//main