User | Revision | Line number | New contents of line |
gbeardall |
0:928e10388a1b
|
1
|
/*
|
gbeardall |
0:928e10388a1b
|
2
|
* gps1
|
gbeardall |
0:928e10388a1b
|
3
|
*
|
gbeardall |
0:928e10388a1b
|
4
|
* http://www.sparkfun.com/products/9133
|
gbeardall |
0:928e10388a1b
|
5
|
* http://www.sparkfun.com/datasheets/GPS/Modules/Skytraq-Venus634FLPx_DS_v051.pdf
|
gbeardall |
0:928e10388a1b
|
6
|
* http://www.sparkfun.com/datasheets/GPS/Modules/AN0003_v1.4.14_FlashOnly.pdf
|
gbeardall |
0:928e10388a1b
|
7
|
*
|
gbeardall |
0:928e10388a1b
|
8
|
*/
|
gbeardall |
0:928e10388a1b
|
9
|
|
gbeardall |
0:928e10388a1b
|
10
|
#include "mbed.h"
|
gbeardall |
0:928e10388a1b
|
11
|
|
gbeardall |
0:928e10388a1b
|
12
|
DigitalOut myled(LED1);
|
gbeardall |
0:928e10388a1b
|
13
|
|
gbeardall |
0:928e10388a1b
|
14
|
Serial pc(USBTX,USBRX);
|
gbeardall |
0:928e10388a1b
|
15
|
Serial gps(p9,p10); // tx, rx
|
gbeardall |
0:928e10388a1b
|
16
|
|
gbeardall |
0:928e10388a1b
|
17
|
|
gbeardall |
0:928e10388a1b
|
18
|
volatile unsigned char buff[128];
|
gbeardall |
0:928e10388a1b
|
19
|
volatile int bx = 0;
|
gbeardall |
0:928e10388a1b
|
20
|
volatile int rdy = 0;
|
gbeardall |
0:928e10388a1b
|
21
|
|
gbeardall |
0:928e10388a1b
|
22
|
unsigned char chk = 0;
|
gbeardall |
0:928e10388a1b
|
23
|
|
gbeardall |
0:928e10388a1b
|
24
|
void rxgps(void) {
|
gbeardall |
0:928e10388a1b
|
25
|
//while(gps.readable()) {
|
gbeardall |
0:928e10388a1b
|
26
|
int c = gps.getc();
|
gbeardall |
0:928e10388a1b
|
27
|
pc.putc(c);
|
gbeardall |
0:928e10388a1b
|
28
|
if(c == '$') {
|
gbeardall |
0:928e10388a1b
|
29
|
bx = 0;
|
gbeardall |
0:928e10388a1b
|
30
|
chk = 0;
|
gbeardall |
0:928e10388a1b
|
31
|
}
|
gbeardall |
0:928e10388a1b
|
32
|
else {
|
gbeardall |
0:928e10388a1b
|
33
|
if(c == '*') {
|
gbeardall |
0:928e10388a1b
|
34
|
pc.printf("%02X=", chk);
|
gbeardall |
0:928e10388a1b
|
35
|
}
|
gbeardall |
0:928e10388a1b
|
36
|
else {
|
gbeardall |
0:928e10388a1b
|
37
|
chk ^= (unsigned char)c;
|
gbeardall |
0:928e10388a1b
|
38
|
}
|
gbeardall |
0:928e10388a1b
|
39
|
}
|
gbeardall |
0:928e10388a1b
|
40
|
buff[bx++] = c;
|
gbeardall |
0:928e10388a1b
|
41
|
if(c == '\n') rdy = 1;
|
gbeardall |
0:928e10388a1b
|
42
|
//if(c == '\n') pc.putc('\r');
|
gbeardall |
0:928e10388a1b
|
43
|
//if(c == '\r') pc.putc('\n');
|
gbeardall |
0:928e10388a1b
|
44
|
//} // while
|
gbeardall |
0:928e10388a1b
|
45
|
} // rxgps
|
gbeardall |
0:928e10388a1b
|
46
|
|
gbeardall |
0:928e10388a1b
|
47
|
int main() {
|
gbeardall |
0:928e10388a1b
|
48
|
|
gbeardall |
0:928e10388a1b
|
49
|
// pc.baud must be >= gps.baud
|
gbeardall |
0:928e10388a1b
|
50
|
pc.baud(115200);
|
gbeardall |
0:928e10388a1b
|
51
|
|
gbeardall |
0:928e10388a1b
|
52
|
pc.printf("gps1\n\r");
|
gbeardall |
0:928e10388a1b
|
53
|
|
gbeardall |
0:928e10388a1b
|
54
|
gps.baud(38400); // 9600, 19200, 38400, 57600, 115200
|
gbeardall |
0:928e10388a1b
|
55
|
gps.format(8,Serial::None,1);
|
gbeardall |
0:928e10388a1b
|
56
|
|
gbeardall |
0:928e10388a1b
|
57
|
gps.attach(&rxgps, Serial::RxIrq);
|
gbeardall |
0:928e10388a1b
|
58
|
|
gbeardall |
0:928e10388a1b
|
59
|
// GGA - Global Positioning System Fix Data
|
gbeardall |
0:928e10388a1b
|
60
|
// GPGGA,hhmmss.sss,ddmm.mmmm,a,dddmm.mmmm,a,x,xx,x.x, x.x,M,,,, xxxx*hh<CR><LF>
|
gbeardall |
0:928e10388a1b
|
61
|
// $GPGGA,184538.245,5105.0363,N,00109.9405,W,1,09,1.1,90.4,M,48.7,M,,0000*76
|
gbeardall |
0:928e10388a1b
|
62
|
|
gbeardall |
0:928e10388a1b
|
63
|
// GLL – Latitude/Longitude
|
gbeardall |
0:928e10388a1b
|
64
|
// GPGLL,ddmm.mmmm,a,dddmm.mmmm,a,hhmmss.sss,A,a*hh<CR><LF>
|
gbeardall |
0:928e10388a1b
|
65
|
// $GPGLL,5105.0363,N,00109.9405,W,184538.245,A,A*4C
|
gbeardall |
0:928e10388a1b
|
66
|
|
gbeardall |
0:928e10388a1b
|
67
|
// GSA – GNSS DOP and Active Satellites
|
gbeardall |
0:928e10388a1b
|
68
|
// GPGSA,A,x,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,xx,x.x,x.x,x.x*hh<CR><LF>
|
gbeardall |
0:928e10388a1b
|
69
|
// $GPGSA,A,3,19,08,06,18,16,22,24,07,11, , , ,2.0,1.1,1.7*3F
|
gbeardall |
0:928e10388a1b
|
70
|
|
gbeardall |
0:928e10388a1b
|
71
|
// GSV – GNSS Satellites in View
|
gbeardall |
0:928e10388a1b
|
72
|
// GPGSV,x,x,xx,xx,xx,xxx,xx,…,xx,xx,xxx,xx *hh<CR><LF>
|
gbeardall |
0:928e10388a1b
|
73
|
// $GPGSV,3,1,12,19,77,295,20,03,66,137,14,22,55,098,32,06,53,125,33*79
|
gbeardall |
0:928e10388a1b
|
74
|
// $GPGSV,3,2,12,18,31,053,19,11,30,261,32,16,27,183,24,24,19,246,24*7F
|
gbeardall |
0:928e10388a1b
|
75
|
// $GPGSV,3,3,12,08,15,301,36,07,10,275,27,21,06,069,09,15,05,019,*78
|
gbeardall |
0:928e10388a1b
|
76
|
|
gbeardall |
0:928e10388a1b
|
77
|
// RMC – Recommended Minimum Specific GNSS Data
|
gbeardall |
0:928e10388a1b
|
78
|
// time date
|
gbeardall |
0:928e10388a1b
|
79
|
// GPRMC,hhmmss.sss,A,dddmm.mmmm,a,dddmm.mmmm,a,x.x,x. x, ddmmyy,,,a*hh<CR><LF>
|
gbeardall |
0:928e10388a1b
|
80
|
// $GPRMC,184538.245,A,5105.0363, N,00109.9405,W,000.0,243.1,210811,,,A*74
|
gbeardall |
0:928e10388a1b
|
81
|
|
gbeardall |
0:928e10388a1b
|
82
|
// VTG – Course Over Ground and Ground Speed
|
gbeardall |
0:928e10388a1b
|
83
|
// GPVTG,x.x, T,,M,x.x, N,x.x, K,a*hh<CR><LF>
|
gbeardall |
0:928e10388a1b
|
84
|
// $GPVTG,243.1,T,,M,000.0,N,000.0,K,A*09
|
gbeardall |
0:928e10388a1b
|
85
|
|
gbeardall |
0:928e10388a1b
|
86
|
|
gbeardall |
0:928e10388a1b
|
87
|
for(;;) {
|
gbeardall |
0:928e10388a1b
|
88
|
//int c = gps.
|
gbeardall |
0:928e10388a1b
|
89
|
//wait_us(10);
|
gbeardall |
0:928e10388a1b
|
90
|
|
gbeardall |
0:928e10388a1b
|
91
|
int px = 0;
|
gbeardall |
0:928e10388a1b
|
92
|
while(!rdy); // wait for gps buffer
|
gbeardall |
0:928e10388a1b
|
93
|
|
gbeardall |
0:928e10388a1b
|
94
|
} // for - ever
|
gbeardall |
0:928e10388a1b
|
95
|
|
gbeardall |
0:928e10388a1b
|
96
|
} // main
|