This example establishes a transparent link between the mbed serial port and the gps I2C on the C027. You can use it to use the standard u-blox tools such as u-center. These tools can then connect to the serial port and talk directly to the GPS receiver. Baudrate should be set to 9600 baud and is fixed. m-center can be downloaded from u-blox website following this link: http://www.u-blox.com/en/evaluation-tools-a-software/u-center/u-center.html
Fork of C027_GPSTransparentI2C by
Diff: main.cpp
- Revision:
- 2:832530e30120
- Parent:
- 1:0d32baf4a645
- Child:
- 3:a985a125f9fa
--- a/main.cpp Fri Oct 25 20:36:35 2013 +0000 +++ b/main.cpp Fri Oct 25 21:02:16 2013 +0000 @@ -6,21 +6,29 @@ C027 c027; c027.gpsPower(true); - // open the gps serial port - Serial gps(GPSTXD, GPSRXD); - gps.baud(GPSBAUD); + // open the gps i2c port + I2C gps(GPSSDA, GPSSCL); // open the PC serial port and (use the same baudrate) Serial pc(USBTX, USBRX); pc.baud(GPSBAUD); + char buf[2]; + buf[0] = 0xFF/*REGSTREAM*/; + while (gps.write(GPSADR,buf,1,false)) + { + wait_ms(200); + printf("$GPTXT,no GPS found\r\n"); + } while (1) { // transfer data from pc to gps - if (pc.readable() && gps.writeable()) - gps.putc(pc.getc()); - // transfer data from gps to pc - if (gps.readable() && pc.writeable()) - pc.putc(gps.getc()); + if (pc.readable()) + { + buf[1] = pc.getc(); + gps.write(GPSADR,buf,2,false); + } + if (pc.writeable() && !gps.read(GPSADR,&buf[1],sizeof(buf[1]),false)) + pc.putc(buf[1]); } }