![](/media/cache/group/icon1_qbDJ87a.png.50x50_q85.png)
mbed用GPSモジュール利用プログラム for IZU 割り込みを利用し、自動的に内部変数へ座標などのデータが更新されるようになっている。そのため、好きなタイミングで専用関数により値を取得できる。
Dependencies: GPS_interrupt mbed
Hybrid_interruptGPS.cpp@3:220b43770a14, 2017-02-21 (annotated)
- Committer:
- Gaku0606
- Date:
- Tue Feb 21 13:42:17 2017 +0000
- Revision:
- 3:220b43770a14
- Parent:
- 2:c05887794ff5
kkk
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gaku0606 | 1:1d1b6b0396d1 | 1 | #include "mbed.h" |
Gaku0606 | 1:1d1b6b0396d1 | 2 | #include "GPS_interrupt.h" |
Gaku0606 | 3:220b43770a14 | 3 | RawSerial pc(USBTX, USBRX); |
Gaku0606 | 3:220b43770a14 | 4 | //RawSerial mygps(p28, p27); |
Gaku0606 | 1:1d1b6b0396d1 | 5 | |
Gaku0606 | 3:220b43770a14 | 6 | #define FIRST_BAUDRATE 9600 |
Gaku0606 | 2:c05887794ff5 | 7 | #define BAUDRATE 115200 |
Gaku0606 | 2:c05887794ff5 | 8 | |
Gaku0606 | 3:220b43770a14 | 9 | //GPS_interrupt *gps; |
Gaku0606 | 3:220b43770a14 | 10 | //GPS_interrupt gps(&mygps, 10); |
Gaku0606 | 3:220b43770a14 | 11 | Serial mygps(D1, D0,115200); |
Gaku0606 | 3:220b43770a14 | 12 | GPS_interrupt gps(&mygps);//, 10); |
Gaku0606 | 2:c05887794ff5 | 13 | |
Gaku0606 | 2:c05887794ff5 | 14 | void bootFunction(){ |
Gaku0606 | 2:c05887794ff5 | 15 | pc.printf("\r\n"); |
Gaku0606 | 2:c05887794ff5 | 16 | pc.printf("start LPC1768 boot phase\r\n"); |
Gaku0606 | 2:c05887794ff5 | 17 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 18 | for(int i = 0;i < 100;i++){ |
Gaku0606 | 2:c05887794ff5 | 19 | pc.printf("Loading... : %3d [%%]\r", i); |
Gaku0606 | 2:c05887794ff5 | 20 | wait(0.025); |
Gaku0606 | 2:c05887794ff5 | 21 | } |
Gaku0606 | 2:c05887794ff5 | 22 | pc.printf("Loading... : %3d [%%]\r\n", 100); |
Gaku0606 | 2:c05887794ff5 | 23 | pc.printf("\t-> finished!!\r\n"); |
Gaku0606 | 2:c05887794ff5 | 24 | pc.printf("System : %d Hz\r\n", SystemCoreClock ); |
Gaku0606 | 2:c05887794ff5 | 25 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 26 | pc.printf("start main program\r\n"); |
Gaku0606 | 2:c05887794ff5 | 27 | wait(0.1); |
Gaku0606 | 2:c05887794ff5 | 28 | pc.printf("initialize"); |
Gaku0606 | 2:c05887794ff5 | 29 | wait(0.75); |
Gaku0606 | 2:c05887794ff5 | 30 | pc.printf(" -> OK\r\n"); |
Gaku0606 | 2:c05887794ff5 | 31 | wait(0.1); |
Gaku0606 | 2:c05887794ff5 | 32 | pc.printf("GPS Connecting"); |
Gaku0606 | 2:c05887794ff5 | 33 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 34 | pc.printf("."); |
Gaku0606 | 2:c05887794ff5 | 35 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 36 | pc.printf("."); |
Gaku0606 | 2:c05887794ff5 | 37 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 38 | pc.printf("."); |
Gaku0606 | 2:c05887794ff5 | 39 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 40 | pc.printf("."); |
Gaku0606 | 2:c05887794ff5 | 41 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 42 | pc.printf("."); |
Gaku0606 | 2:c05887794ff5 | 43 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 44 | pc.printf("."); |
Gaku0606 | 3:220b43770a14 | 45 | |
Gaku0606 | 2:c05887794ff5 | 46 | wait(0.5); |
Gaku0606 | 2:c05887794ff5 | 47 | } |
Gaku0606 | 1:1d1b6b0396d1 | 48 | |
Gaku0606 | 1:1d1b6b0396d1 | 49 | int main() { |
Gaku0606 | 1:1d1b6b0396d1 | 50 | |
Gaku0606 | 1:1d1b6b0396d1 | 51 | pc.baud(115200); |
Gaku0606 | 1:1d1b6b0396d1 | 52 | |
Gaku0606 | 2:c05887794ff5 | 53 | bootFunction(); |
Gaku0606 | 3:220b43770a14 | 54 | wait(0.5); |
Gaku0606 | 3:220b43770a14 | 55 | gps.gps_readable = false; |
Gaku0606 | 3:220b43770a14 | 56 | gps.debug(true); |
Gaku0606 | 3:220b43770a14 | 57 | while(!gps.gps_readable){ |
Gaku0606 | 3:220b43770a14 | 58 | if(pc.readable()) break; |
Gaku0606 | 3:220b43770a14 | 59 | } |
Gaku0606 | 3:220b43770a14 | 60 | pc.printf(" -> OK\r\n"); |
Gaku0606 | 3:220b43770a14 | 61 | pc.printf("start!!\r\n\r\n"); |
Gaku0606 | 1:1d1b6b0396d1 | 62 | while(1){ |
Gaku0606 | 2:c05887794ff5 | 63 | double xy[2] = {0}; |
Gaku0606 | 2:c05887794ff5 | 64 | float utc[6] = {0}; |
Gaku0606 | 3:220b43770a14 | 65 | if(gps.gps_readable){ |
Gaku0606 | 3:220b43770a14 | 66 | gps.debug(false); |
Gaku0606 | 3:220b43770a14 | 67 | gps.gps_readable = false; |
Gaku0606 | 3:220b43770a14 | 68 | gps.getPosition(xy); |
Gaku0606 | 3:220b43770a14 | 69 | gps.getUTC(utc); |
Gaku0606 | 3:220b43770a14 | 70 | pc.printf("\033[K"); |
Gaku0606 | 3:220b43770a14 | 71 | 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]); |
Gaku0606 | 3:220b43770a14 | 72 | pc.printf("(%3.7fe,%3.7fn) ",xy[0], xy[1]); |
Gaku0606 | 3:220b43770a14 | 73 | 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()); |
Gaku0606 | 3:220b43770a14 | 74 | wait(0.1); |
Gaku0606 | 3:220b43770a14 | 75 | } |
Gaku0606 | 3:220b43770a14 | 76 | else gps.debug(true); |
Gaku0606 | 1:1d1b6b0396d1 | 77 | } |
Gaku0606 | 1:1d1b6b0396d1 | 78 | } |