![](/media/cache/group/icon1_qbDJ87a.png.50x50_q85.png)
mbed用GPSモジュール利用プログラム for IZU 割り込みを利用し、自動的に内部変数へ座標などのデータが更新されるようになっている。そのため、好きなタイミングで専用関数により値を取得できる。
Dependencies: GPS_interrupt mbed
Revision 3:220b43770a14, committed 2017-02-21
- Comitter:
- Gaku0606
- Date:
- Tue Feb 21 13:42:17 2017 +0000
- Parent:
- 2:c05887794ff5
- Commit message:
- kkk
Changed in this revision
GPS_interrupt.lib | Show annotated file Show diff for this revision Revisions of this file |
Hybrid_interruptGPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r c05887794ff5 -r 220b43770a14 GPS_interrupt.lib --- a/GPS_interrupt.lib Mon Jan 02 18:49:49 2017 +0000 +++ b/GPS_interrupt.lib Tue Feb 21 13:42:17 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/PQ_Hybrid_Electrical_Equipment_Team/code/GPS_interrupt/#7be89bab6db9 +https://developer.mbed.org/teams/PQ_Hybrid_Electrical_Equipment_Team/code/GPS_interrupt/#2f91c71d64b1
diff -r c05887794ff5 -r 220b43770a14 Hybrid_interruptGPS.cpp --- a/Hybrid_interruptGPS.cpp Mon Jan 02 18:49:49 2017 +0000 +++ b/Hybrid_interruptGPS.cpp Tue Feb 21 13:42:17 2017 +0000 @@ -1,12 +1,15 @@ #include "mbed.h" #include "GPS_interrupt.h" -Serial pc(USBTX, USBRX); -RawSerial mygps(p9, p10); +RawSerial pc(USBTX, USBRX); +//RawSerial mygps(p28, p27); -#define FIRST_BAUDRATE 115200 +#define FIRST_BAUDRATE 9600 #define BAUDRATE 115200 -GPS_interrupt gps(&mygps, BAUDRATE, 10, FIRST_BAUDRATE); +//GPS_interrupt *gps; +//GPS_interrupt gps(&mygps, 10); +Serial mygps(D1, D0,115200); +GPS_interrupt gps(&mygps);//, 10); void bootFunction(){ pc.printf("\r\n"); @@ -39,31 +42,37 @@ pc.printf("."); wait(0.5); pc.printf("."); - wait(0.5); - while(1){ - if(gps.gps_readable) break; - } - pc.printf(" -> OK\r\n"); - pc.printf("start!!\r\n\r\n"); + wait(0.5); } int main() { pc.baud(115200); - //mygps.baud(FIRST_BAUDRATE); bootFunction(); - + wait(0.5); + gps.gps_readable = false; + gps.debug(true); + while(!gps.gps_readable){ + if(pc.readable()) break; + } + pc.printf(" -> OK\r\n"); + pc.printf("start!!\r\n\r\n"); while(1){ double xy[2] = {0}; float utc[6] = {0}; - gps.getPosition(xy); - gps.getUTC(utc); - pc.printf("\033[K"); - pc.printf("%d/%d/%d %d:%d:%02.2f ",(int)utc[0],(int)utc[1], (int)utc[2], (int)utc[3], (int)utc[4] ,utc[5]); - pc.printf("(%3.7fe,%3.7fn) ",xy[0], xy[1]); - pc.printf("%d satellites, %.2f[m], %.3f[m/s], %3.2f[degree]\r", gps.Number(), gps.Height(), gps.Knot()*1852/3600, gps.Degree()); - wait(0.1); + if(gps.gps_readable){ + gps.debug(false); + gps.gps_readable = false; + gps.getPosition(xy); + gps.getUTC(utc); + pc.printf("\033[K"); + pc.printf("%d/%d/%d %d:%d:%02.2f ",(int)utc[0],(int)utc[1], (int)utc[2], (int)utc[3], (int)utc[4] ,utc[5]); + pc.printf("(%3.7fe,%3.7fn) ",xy[0], xy[1]); + pc.printf("%d satellites, %.2f[m], %.3f[m/s], %3.2f[degree]\r", gps.Number(), gps.Height(), gps.Knot()*1852.0/3600.0, gps.Degree()); + wait(0.1); + } + else gps.debug(true); } }