tugboat project
Dependencies: HMC5883L MMA8451Q PwmIn TinyGPS2 mbed
Fork of tugboat by
Revision 2:db76adcdf799, committed 2013-07-31
- Comitter:
- bclaus
- Date:
- Wed Jul 31 15:35:44 2013 +0000
- Parent:
- 1:1cbd833a8be5
- Child:
- 3:c348ce854b4c
- Commit message:
- changed gps library to tinygps parser. gps is read in through serial interupt. raw data is spat back over rf serial link.
Changed in this revision
--- a/GPS.lib Mon Jul 29 23:00:34 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/tylerjw/code/GPS/#39d75e44b214
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TinyGPS.lib Wed Jul 31 15:35:44 2013 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/shimniok/code/TinyGPS/#a3dad2769ed7
--- a/main.cpp Mon Jul 29 23:00:34 2013 +0000 +++ b/main.cpp Wed Jul 31 15:35:44 2013 +0000 @@ -1,6 +1,6 @@ #include "mbed.h" #include "MMA8451Q.h" -#include "GPS.h" +#include "TinyGPS.h" #include "HMC5883L.h" #define MMA8451_I2C_ADDRESS (0x1d<<1) @@ -11,27 +11,34 @@ Serial pc(USBTX, USBRX); Serial radio(PTC4, PTC3); Timer t; -GPS gps(PTD3,PTD2); +TinyGPS gps; +Serial gpsSerial(PTD3,PTD2); + + +void gpsSerialRecvInterrupt (void); int main(void) { pc.baud(115200); - radio.baud(115200); + radio.baud(57600); int16_t dCompass[3]; float dAcc[3]; compass.init(); - + pc.printf("inited\r\n"); + gpsSerial.attach (&gpsSerialRecvInterrupt, gpsSerial.RxIrq); // Recv interrupt handler + gps.reset_ready(); while (true) { - if(gps.sample()){ - pc.printf("lat: %.8f, lon: %.8f\r\n", gps.get_nmea_longitude(), gps.get_nmea_latitude()); - radio.printf("lat: %.8f, lon: %.8f\r\n", gps.get_nmea_longitude(), gps.get_nmea_latitude()); + if(gps.gga_ready()){ + + pc.printf("lat: %.8f, lon: %.8f\r\n", gps.f_lat(), gps.f_lon()); + radio.printf("lat: %.8f, lon: %.8f\r\n", gps.f_lat(), gps.f_lon()); } acc.getAccAllAxis(dAcc); @@ -42,4 +49,19 @@ radio.printf("xC: %4d, yC: %4d, zC: %4d\r\n", dCompass[0], dCompass[1], dCompass[2]); wait(0.5); } +} + +//***************************************************************************** +// serial receive interrupt handler +//***************************************************************************** + +void gpsSerialRecvInterrupt (void) +{ + + + // while(gpsSerial.readable()){ + gps.encode(gpsSerial.getc()); + //} + + } \ No newline at end of file