GPS Data Logger with SD File system. Logger can save RMC & GGA data from GPS and five channels of analog data. Based on http://mbed.org/users/prf/ "GPS_Logger_01" by Peter Forden
SDFileSystem.h
00001 /* mbed Microcontroller Library - SDFileSystem 00002 * Copyright (c) 2008-2009, sford 00003 */ 00004 00005 // VERY DRAFT CODE!!! 00006 00007 #ifndef SDFILESYSTEM_H 00008 #define SDFILESYSTEM_H 00009 00010 #include "mbed.h" 00011 #include "FATFileSystem.h" 00012 00013 /* Class: SDFileSystem 00014 * Access the filesystem on an SD Card using SPI 00015 * 00016 * Example: 00017 * > SDFileSystem sd(p5, p6, p7, p12, "sd"); 00018 * > 00019 * > int main() { 00020 * > FILE *fp = fopen("/sd/myfile.txt", "w"); 00021 * > fprintf(fp, "Hello World!\n"); 00022 * > fclose(fp); 00023 * > } 00024 */ 00025 class SDFileSystem : public FATFileSystem { 00026 public: 00027 00028 /* Constructor: SDFileSystem 00029 * Create the File System for accessing an SD Card using SPI 00030 * 00031 * Variables: 00032 * mosi - SPI mosi pin connected to SD Card 00033 * miso - SPI miso pin conencted to SD Card 00034 * sclk - SPI sclk pin connected to SD Card 00035 * cs - DigitalOut pin used as SD Card chip select 00036 * name - The name used to access the filesystem 00037 */ 00038 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name); 00039 virtual int disk_initialize(); 00040 virtual int disk_write(const char *buffer, int block_number); 00041 virtual int disk_read(char *buffer, int block_number); 00042 virtual int disk_status(); 00043 virtual int disk_sync(); 00044 virtual int disk_sectors(); 00045 00046 protected: 00047 00048 int _cmd(int cmd, int arg); 00049 int _cmdx(int cmd, int arg); 00050 int _cmd8(); 00051 int _cmd58(); 00052 int initialise_card(); 00053 int initialise_card_v1(); 00054 int initialise_card_v2(); 00055 00056 00057 int _read(char *buffer, int length); 00058 int _write(const char *buffer, int length); 00059 int _sd_sectors(); 00060 int _sectors; 00061 00062 SPI _spi; 00063 DigitalOut _cs; 00064 }; 00065 00066 #endif
Generated on Thu Jul 14 2022 20:02:46 by 1.7.2