Initial Publish Leaning GPS/SDCARD

Dependencies:   FileManager GPSGms6 SDFileSystem mbed

Fork of 2545_SD_Card by Craig Evans

Committer:
Lucyjungz
Date:
Tue May 10 09:24:20 2016 +0000
Revision:
10:43fc07923c7f
Parent:
9:4d0c81290638
Update to Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eencae 0:5448330e1a33 1 #include "mbed.h"
eencae 0:5448330e1a33 2 #include "SDFileSystem.h"
Lucyjungz 1:f911149acd35 3 #include "GPSGms6.h"
Lucyjungz 2:c96b02fcb98e 4 #include "FileManager.h"
Lucyjungz 1:f911149acd35 5
eencae 0:5448330e1a33 6
eencae 0:5448330e1a33 7 // Connections to SD card holder on K64F (SPI interface)
Lucyjungz 10:43fc07923c7f 8 SDFileSystem sd(PA_7, PA_6, PA_5, PA_0, DEVICE_NAME); // MOSI, MISO, SCK, CS
eencae 0:5448330e1a33 9 Serial serial(USBTX, USBRX); // for PC debug
Lucyjungz 1:f911149acd35 10 GPSGms6 gps;
Lucyjungz 1:f911149acd35 11 Timeout t1;
Lucyjungz 1:f911149acd35 12 DigitalOut myled(LED1);
Lucyjungz 1:f911149acd35 13
Lucyjungz 2:c96b02fcb98e 14 float gps_interval = 3;
Lucyjungz 2:c96b02fcb98e 15
Lucyjungz 2:c96b02fcb98e 16
Lucyjungz 6:a05ec997c496 17 void t1out(void)
Lucyjungz 6:a05ec997c496 18 {
Lucyjungz 6:a05ec997c496 19 myled = !myled;
Lucyjungz 1:f911149acd35 20 printf("\r\nGps header = %s", gps.latestGPRMC().header);
Lucyjungz 1:f911149acd35 21 printf("\r\nGps status = %s", gps.latestGPRMC().status);
Lucyjungz 1:f911149acd35 22 printf("\r\nGps time = %s", gps.latestGPRMC().time);
Lucyjungz 1:f911149acd35 23 printf("\r\nGps date = %s", gps.latestGPRMC().date);
Lucyjungz 1:f911149acd35 24 printf("\r\nGps lat = %s", gps.latestGPRMC().latitude);
Lucyjungz 1:f911149acd35 25 printf("\r\nGps long = %s", gps.latestGPRMC().longitude);
Lucyjungz 1:f911149acd35 26 printf("\r\nGps indicator = %s", gps.latestGPRMC().indicator);
Lucyjungz 6:a05ec997c496 27
Lucyjungz 10:43fc07923c7f 28 time_t seconds = time(NULL);
Lucyjungz 10:43fc07923c7f 29 logGPSData( (long) seconds,gps.latestGPRMC().date, gps.latestGPRMC().time);
Lucyjungz 4:aa7ac2ac6913 30 serial.printf("\r\n#### Restart Timer #####");
Lucyjungz 7:ffaa90a12f00 31
Lucyjungz 9:4d0c81290638 32 tm t = gps.UTCTime();
Lucyjungz 9:4d0c81290638 33 printf("\r\n UTC Time is %d/%d/%d %d:%d", t.tm_mday , t.tm_mon , t.tm_year , t.tm_hour, t.tm_min);
Lucyjungz 9:4d0c81290638 34
Lucyjungz 10:43fc07923c7f 35
Lucyjungz 8:8d26ce37febc 36 printf("\r\nTime as a basic string = %s", ctime(&seconds));
Lucyjungz 10:43fc07923c7f 37 struct tm * ptm;
Lucyjungz 10:43fc07923c7f 38
Lucyjungz 10:43fc07923c7f 39 time ( &seconds );
Lucyjungz 10:43fc07923c7f 40
Lucyjungz 10:43fc07923c7f 41 ptm = localtime ( &seconds );
Lucyjungz 10:43fc07923c7f 42 printf ("\r\nCurrent time around the World:");
Lucyjungz 10:43fc07923c7f 43 printf ("\r\nPhoenix, AZ (U.S.) : %2d:%02d\n %d-%d-%d", (ptm->tm_hour)%24, ptm->tm_min, t.tm_mday , t.tm_mon , t.tm_year);
Lucyjungz 2:c96b02fcb98e 44 t1.attach(&t1out,gps_interval);
Lucyjungz 1:f911149acd35 45 }
eencae 0:5448330e1a33 46
eencae 0:5448330e1a33 47 int main()
eencae 0:5448330e1a33 48 {
Lucyjungz 1:f911149acd35 49 serial.baud(9600); // full-speed!
Lucyjungz 8:8d26ce37febc 50 serial.printf("\r\n#### SD Card Initialization #####");
Lucyjungz 9:4d0c81290638 51 wait(1);
eencae 0:5448330e1a33 52
Lucyjungz 2:c96b02fcb98e 53 ////////////////////// read Setup File //////////////////////////
Lucyjungz 2:c96b02fcb98e 54 readSetupFile();
Lucyjungz 2:c96b02fcb98e 55 gps_interval = (float)GPSInterval()/1000;
Lucyjungz 6:a05ec997c496 56
Lucyjungz 4:aa7ac2ac6913 57 Variable_Data_TypeDef * var_list = readVarFile();
Lucyjungz 2:c96b02fcb98e 58 logSystemData(gps_interval);
Lucyjungz 6:a05ec997c496 59
Lucyjungz 5:07aaa6e3784c 60 unsigned int amount = getAmountVarList();
Lucyjungz 6:a05ec997c496 61 for (int i = 0; i < amount ; i++) {
Lucyjungz 5:07aaa6e3784c 62 serial.printf("\r\n var name = %s ",var_list[i].varName);
Lucyjungz 4:aa7ac2ac6913 63 serial.printf("\r\n first addr name = %s ",var_list[i].varAddress);
Lucyjungz 4:aa7ac2ac6913 64 }
Lucyjungz 6:a05ec997c496 65
Lucyjungz 10:43fc07923c7f 66 delete_file("/sd/2009-09-28.rtl.csv");
eencae 0:5448330e1a33 67 ///////////////////////////////////////////////////
Lucyjungz 8:8d26ce37febc 68 serial.printf("\r\n#### End of SD Card Initialization #####");
Lucyjungz 4:aa7ac2ac6913 69 gps.start_GPS();
Lucyjungz 2:c96b02fcb98e 70 t1.attach(&t1out,gps_interval);
Lucyjungz 10:43fc07923c7f 71 set_time(1460279787); // Set RTC time to Sun, 10 Apr 2016 09:16:27 GMT
Lucyjungz 7:ffaa90a12f00 72
Lucyjungz 10:43fc07923c7f 73
Lucyjungz 10:43fc07923c7f 74 while(1){
Lucyjungz 10:43fc07923c7f 75
Lucyjungz 10:43fc07923c7f 76 wait(5);
Lucyjungz 10:43fc07923c7f 77 time_t seconds = time(NULL);
Lucyjungz 10:43fc07923c7f 78 seconds = time(NULL);
Lucyjungz 10:43fc07923c7f 79 float varList[] = { 1.0,2.2,3.1};
Lucyjungz 10:43fc07923c7f 80 logRMSData(seconds,varList, 3);
Lucyjungz 10:43fc07923c7f 81
Lucyjungz 10:43fc07923c7f 82 }
eencae 0:5448330e1a33 83 }
eencae 0:5448330e1a33 84
Lucyjungz 2:c96b02fcb98e 85