20220630

Dependencies:   mbed

Committer:
sashida_h
Date:
Fri Jul 01 04:38:08 2022 +0000
Revision:
0:ab3cf2891663
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sashida_h 0:ab3cf2891663 1 #include "mbed.h"
sashida_h 0:ab3cf2891663 2
sashida_h 0:ab3cf2891663 3 DigitalOut myled(LED1);
sashida_h 0:ab3cf2891663 4
sashida_h 0:ab3cf2891663 5 Serial gps(p13,p14);
sashida_h 0:ab3cf2891663 6 Serial twe(p9,p10);
sashida_h 0:ab3cf2891663 7 Serial usb(USBTX,USBRX);
sashida_h 0:ab3cf2891663 8
sashida_h 0:ab3cf2891663 9 float t,hokui,tokei,data2;
sashida_h 0:ab3cf2891663 10 char ns,ew;
sashida_h 0:ab3cf2891663 11 int quality,num;
sashida_h 0:ab3cf2891663 12 char gps_data[256];
sashida_h 0:ab3cf2891663 13 int gps_cnt=0,sw=0;
sashida_h 0:ab3cf2891663 14 float w_time,hokui2,tokei2;
sashida_h 0:ab3cf2891663 15
sashida_h 0:ab3cf2891663 16 int main() {
sashida_h 0:ab3cf2891663 17 gps.baud(38400);
sashida_h 0:ab3cf2891663 18 twe.baud(38400);
sashida_h 0:ab3cf2891663 19 wait(1.0);
sashida_h 0:ab3cf2891663 20 twe.printf("Hello\r\n");
sashida_h 0:ab3cf2891663 21 usb.printf("Hello\r\n");
sashida_h 0:ab3cf2891663 22 while(1){
sashida_h 0:ab3cf2891663 23 gps_data[gps_cnt] = gps.getc();
sashida_h 0:ab3cf2891663 24 if(gps_data[gps_cnt] == '$'){
sashida_h 0:ab3cf2891663 25 gps_cnt = 0;
sashida_h 0:ab3cf2891663 26 sw = 1;
sashida_h 0:ab3cf2891663 27 usb.printf("$\r\n");
sashida_h 0:ab3cf2891663 28 }
sashida_h 0:ab3cf2891663 29 if(sw == 1){
sashida_h 0:ab3cf2891663 30 //usb.putc(gps_data[gps_cnt]);
sashida_h 0:ab3cf2891663 31 if(gps_data[gps_cnt] == '\n'){
sashida_h 0:ab3cf2891663 32 gps_data[gps_cnt-1] = '\0';
sashida_h 0:ab3cf2891663 33 sscanf(gps_data, "$GPGGA,%f,%f,%c,%f,%c,%d,%d,%f,",&w_time,&hokui,&ns,&tokei,&ew,&quality,&num,&data2);
sashida_h 0:ab3cf2891663 34 //usb.printf("RF:%f,%f,%c,%f,%c,%d,%d,%f\r\n",w_time,hokui,ns,tokei,ew,quality,num,data2);
sashida_h 0:ab3cf2891663 35
sashida_h 0:ab3cf2891663 36 hokui2 = hokui/100.0f;
sashida_h 0:ab3cf2891663 37 hokui = int(hokui2) + (hokui2 - int(hokui2))*100.0f/60.0f;
sashida_h 0:ab3cf2891663 38 tokei2 = tokei/100.0f;
sashida_h 0:ab3cf2891663 39 tokei = int(tokei2) + (tokei2 - int(tokei2))*100.0f/60.0f;
sashida_h 0:ab3cf2891663 40
sashida_h 0:ab3cf2891663 41 twe.printf("%d,%f,%f,%c,%d,%d\r\n",int(w_time),hokui,tokei,ew,quality,num);
sashida_h 0:ab3cf2891663 42 gps_cnt = 0;
sashida_h 0:ab3cf2891663 43 sw = 0;
sashida_h 0:ab3cf2891663 44 }
sashida_h 0:ab3cf2891663 45 }
sashida_h 0:ab3cf2891663 46 gps_cnt++;
sashida_h 0:ab3cf2891663 47
sashida_h 0:ab3cf2891663 48 }
sashida_h 0:ab3cf2891663 49 }
sashida_h 0:ab3cf2891663 50
sashida_h 0:ab3cf2891663 51
sashida_h 0:ab3cf2891663 52