Initial Publish Leaning GPS/SDCARD
Dependencies: FileManager GPSGms6 SDFileSystem mbed
Fork of 2545_SD_Card by
main.cpp
- Committer:
- Lucyjungz
- Date:
- 2016-05-06
- Revision:
- 2:c96b02fcb98e
- Parent:
- 1:f911149acd35
- Child:
- 3:78eaf4291b84
File content as of revision 2:c96b02fcb98e:
/* 2545_SD_Card Example Example of writing data to SD card. Based on FTF2014_lab4 Example https://developer.mbed.org/teams/Freescale/wiki/FTF2014_workshop Craig A. Evans, University of Leeds, Mar 2016 */ #include "mbed.h" #include "SDFileSystem.h" #include "GPSGms6.h" #include "FileManager.h" // Connections to SD card holder on K64F (SPI interface) SDFileSystem sd(PA_7, PA_6, PA_5, PA_0, "sd"); // MOSI, MISO, SCK, CS Serial serial(USBTX, USBRX); // for PC debug GPSGms6 gps; Timeout t1; DigitalOut myled(LED1); float gps_interval = 3; void t1out(void) { myled = !myled; printf("\r\nGps header = %s", gps.latestGPRMC().header); printf("\r\nGps status = %s", gps.latestGPRMC().status); printf("\r\nGps time = %s", gps.latestGPRMC().time); printf("\r\nGps date = %s", gps.latestGPRMC().date); printf("\r\nGps lat = %s", gps.latestGPRMC().latitude); printf("\r\nGps long = %s", gps.latestGPRMC().longitude); printf("\r\nGps indicator = %s", gps.latestGPRMC().indicator); logGPSData( gps.latestGPRMC().date, gps.latestGPRMC().time); serial.printf("\n#### Restart Timer #####"); t1.attach(&t1out,gps_interval); } int main() { serial.baud(9600); // full-speed! serial.printf("\n#### SD Card Initialization #####"); wait(1); // comment this line out if you don't want to delete the file! delete_file("/sd/test.txt"); ////////////////////// Simple writing example ////////////////////////// // open file for writing ('w') - creates file if it doesn't exist and overwrites // if it does. If you wish to add a score onto a list, then you can // append instead 'a'. This will open the file if it exists and start // writing at the end. It will create the file if it doesn't exist. ////////////////////// read Setup File ////////////////////////// readSetupFile(); gps_interval = (float)GPSInterval()/1000; logSystemData(gps_interval); /////////////////////////////////////////////////// serial.printf("\n End of SD Card Initialization "); t1.attach(&t1out,gps_interval); while(1); }