Initial Publish Leaning GPS/SDCARD
Dependencies: FileManager GPSGms6 SDFileSystem mbed
Fork of 2545_SD_Card by
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 #include "GPSGms6.h" 00004 #include "FileManager.h" 00005 00006 00007 // Connections to SD card holder on K64F (SPI interface) 00008 SDFileSystem sd(PA_7, PA_6, PA_5, PA_0, DEVICE_NAME); // MOSI, MISO, SCK, CS 00009 Serial serial(USBTX, USBRX); // for PC debug 00010 GPSGms6 gps; 00011 Timeout t1; 00012 DigitalOut myled(LED1); 00013 00014 float gps_interval = 3; 00015 00016 00017 void t1out(void) 00018 { 00019 myled = !myled; 00020 printf("\r\nGps header = %s", gps.latestGPRMC().header); 00021 printf("\r\nGps status = %s", gps.latestGPRMC().status); 00022 printf("\r\nGps time = %s", gps.latestGPRMC().time); 00023 printf("\r\nGps date = %s", gps.latestGPRMC().date); 00024 printf("\r\nGps lat = %s", gps.latestGPRMC().latitude); 00025 printf("\r\nGps long = %s", gps.latestGPRMC().longitude); 00026 printf("\r\nGps indicator = %s", gps.latestGPRMC().indicator); 00027 00028 time_t seconds = time(NULL); 00029 logGPSData( (long) seconds,gps.latestGPRMC().date, gps.latestGPRMC().time); 00030 serial.printf("\r\n#### Restart Timer #####"); 00031 00032 tm t = gps.UTCTime(); 00033 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); 00034 00035 00036 printf("\r\nTime as a basic string = %s", ctime(&seconds)); 00037 struct tm * ptm; 00038 00039 time ( &seconds ); 00040 00041 ptm = localtime ( &seconds ); 00042 printf ("\r\nCurrent time around the World:"); 00043 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); 00044 t1.attach(&t1out,gps_interval); 00045 } 00046 00047 int main() 00048 { 00049 serial.baud(9600); // full-speed! 00050 serial.printf("\r\n#### SD Card Initialization #####"); 00051 wait(1); 00052 00053 ////////////////////// read Setup File ////////////////////////// 00054 readSetupFile(); 00055 gps_interval = (float)GPSInterval()/1000; 00056 00057 Variable_Data_TypeDef * var_list = readVarFile(); 00058 logSystemData(gps_interval); 00059 00060 unsigned int amount = getAmountVarList(); 00061 for (int i = 0; i < amount ; i++) { 00062 serial.printf("\r\n var name = %s ",var_list[i].varName); 00063 serial.printf("\r\n first addr name = %s ",var_list[i].varAddress); 00064 } 00065 00066 delete_file("/sd/2009-09-28.rtl.csv"); 00067 /////////////////////////////////////////////////// 00068 serial.printf("\r\n#### End of SD Card Initialization #####"); 00069 gps.start_GPS(); 00070 t1.attach(&t1out,gps_interval); 00071 set_time(1460279787); // Set RTC time to Sun, 10 Apr 2016 09:16:27 GMT 00072 00073 00074 while(1){ 00075 00076 wait(5); 00077 time_t seconds = time(NULL); 00078 seconds = time(NULL); 00079 float varList[] = { 1.0,2.2,3.1}; 00080 logRMSData(seconds,varList, 3); 00081 00082 } 00083 } 00084 00085
Generated on Sat Jul 16 2022 02:26:13 by 1.7.2