Raohaël Bresson / Mbed 2 deprecated Nucleo_SerialGPS_to_PC

Dependencies:   SerialGPS_IOT_tracker mbed

Fork of Nucleo_SerialGPS_to_PC by Veysel KARADAG

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SerialGPS.h"
00003 
00004  
00005 Serial pc(USBTX, USBRX); // tx, rx
00006 SerialGPS gps(PA_9,PA_10);  // tx, rx
00007 
00008 
00009 
00010 
00011 /**
00012  * A callback function for logging data.
00013  */
00014 void cbfunc_log(char *s) {
00015 
00016 }
00017 
00018 /**
00019  * A callback function for GGA.
00020  *
00021  * GGA - Global Positioning System Fixed Data.
00022  */
00023 void cbfunc_gga(SerialGPS::gps_gga_t *p) {
00024 
00025         pc.printf("%02d:%02d:%02d(P%d,S%d)\r\n", p->hour, p->min, p->sec, p->position_fix, p->satellites_used);
00026 
00027         pc.printf("%c=%10.4f\r\n", p->ns, p->latitude);
00028 
00029         pc.printf("%c=%10.4f\r\n", p->ew, p->longitude);
00030     
00031 }
00032 
00033 /**
00034  * A callback function for GSA.
00035  *
00036  * GSA - GNSS DOP and Active Satellites.
00037  */
00038 void cbfunc_gsa(SerialGPS::gps_gsa_t *p) {
00039 
00040         pc.printf("SEL:%c FIX:%d\r\n", p->selmode, p->fix);
00041   
00042 }
00043 
00044 /**
00045  * A callback function for GSV.
00046  *
00047  * GSV - GNSS Satellites in View.
00048  */
00049 void cbfunc_gsv(SerialGPS::gps_gsv_t *p) {
00050  
00051         pc.printf("Satellites:%2d\r\n", p->satcnt);
00052 
00053 }
00054 
00055 /**
00056  * A callback function for RMC.
00057  *
00058  * RMC - Recommended Minimum Specific GNSS Data.
00059  */
00060 void cbfunc_rmc(SerialGPS::gps_rmc_t *p) {
00061 
00062         pc.printf("%02d:%02d:%02d(%c)\r\n", p->hour, p->min, p->sec, p->status);
00063 
00064 }
00065 
00066 /**
00067  * Entry point.
00068  */
00069 
00070 
00071 
00072  
00073 int main() {
00074     
00075     pc.baud(9600);
00076     
00077     
00078     pc.printf("TEST\r\n");
00079     wait(0.5);
00080     //wait(0.5);
00081     SerialGPS::gps_callback_t cb;
00082     cb.cbfunc_log = cbfunc_log;
00083     cb.cbfunc_gga = cbfunc_gga;
00084     cb.cbfunc_gsa = cbfunc_gsa;
00085     cb.cbfunc_gsv = cbfunc_gsv;
00086     cb.cbfunc_rmc = cbfunc_rmc;
00087     gps.attach(&cb);
00088     
00089     while(1) {
00090         
00091 
00092         gps.processing();
00093         //wait(0.5);
00094     }
00095 }
00096