Universal Translator

Dependencies:   EthernetNetIf TextLCD mbed PS2 HTTPClient

Committer:
benglish6
Date:
Mon Feb 28 17:37:46 2011 +0000
Revision:
1:5ae213418d04
Parent:
0:c69af1faeb95

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benglish6 0:c69af1faeb95 1 /* mbed SDFileSystem Library, for providing file access to SD cards
benglish6 0:c69af1faeb95 2 * Copyright (c) 2008-2010, sford
benglish6 0:c69af1faeb95 3 *
benglish6 0:c69af1faeb95 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
benglish6 0:c69af1faeb95 5 * of this software and associated documentation files (the "Software"), to deal
benglish6 0:c69af1faeb95 6 * in the Software without restriction, including without limitation the rights
benglish6 0:c69af1faeb95 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
benglish6 0:c69af1faeb95 8 * copies of the Software, and to permit persons to whom the Software is
benglish6 0:c69af1faeb95 9 * furnished to do so, subject to the following conditions:
benglish6 0:c69af1faeb95 10 *
benglish6 0:c69af1faeb95 11 * The above copyright notice and this permission notice shall be included in
benglish6 0:c69af1faeb95 12 * all copies or substantial portions of the Software.
benglish6 0:c69af1faeb95 13 *
benglish6 0:c69af1faeb95 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
benglish6 0:c69af1faeb95 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
benglish6 0:c69af1faeb95 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
benglish6 0:c69af1faeb95 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
benglish6 0:c69af1faeb95 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
benglish6 0:c69af1faeb95 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
benglish6 0:c69af1faeb95 20 * THE SOFTWARE.
benglish6 0:c69af1faeb95 21 */
benglish6 0:c69af1faeb95 22
benglish6 0:c69af1faeb95 23 #ifndef MBED_SDFILESYSTEM_H
benglish6 0:c69af1faeb95 24 #define MBED_SDFILESYSTEM_H
benglish6 0:c69af1faeb95 25
benglish6 0:c69af1faeb95 26 #include "mbed.h"
benglish6 0:c69af1faeb95 27 #include "FATFileSystem.h"
benglish6 0:c69af1faeb95 28
benglish6 0:c69af1faeb95 29 /** Access the filesystem on an SD Card using SPI
benglish6 0:c69af1faeb95 30 *
benglish6 0:c69af1faeb95 31 * @code
benglish6 0:c69af1faeb95 32 * #include "mbed.h"
benglish6 0:c69af1faeb95 33 * #include "SDFileSystem.h"
benglish6 0:c69af1faeb95 34 *
benglish6 0:c69af1faeb95 35 * SDFileSystem sd(p5, p6, p7, p12, "sd"); // mosi, miso, sclk, cs
benglish6 0:c69af1faeb95 36 *
benglish6 0:c69af1faeb95 37 * int main() {
benglish6 0:c69af1faeb95 38 * FILE *fp = fopen("/sd/myfile.txt", "w");
benglish6 0:c69af1faeb95 39 * fprintf(fp, "Hello World!\n");
benglish6 0:c69af1faeb95 40 * fclose(fp);
benglish6 0:c69af1faeb95 41 * }
benglish6 0:c69af1faeb95 42 */
benglish6 0:c69af1faeb95 43 class SDFileSystem : public FATFileSystem {
benglish6 0:c69af1faeb95 44 public:
benglish6 0:c69af1faeb95 45
benglish6 0:c69af1faeb95 46 /** Create the File System for accessing an SD Card using SPI
benglish6 0:c69af1faeb95 47 *
benglish6 0:c69af1faeb95 48 * @param mosi SPI mosi pin connected to SD Card
benglish6 0:c69af1faeb95 49 * @param miso SPI miso pin conencted to SD Card
benglish6 0:c69af1faeb95 50 * @param sclk SPI sclk pin connected to SD Card
benglish6 0:c69af1faeb95 51 * @param cs DigitalOut pin used as SD Card chip select
benglish6 0:c69af1faeb95 52 * @param name The name used to access the virtual filesystem
benglish6 0:c69af1faeb95 53 */
benglish6 0:c69af1faeb95 54 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
benglish6 0:c69af1faeb95 55 virtual int disk_initialize();
benglish6 0:c69af1faeb95 56 virtual int disk_write(const char *buffer, int block_number);
benglish6 0:c69af1faeb95 57 virtual int disk_read(char *buffer, int block_number);
benglish6 0:c69af1faeb95 58 virtual int disk_status();
benglish6 0:c69af1faeb95 59 virtual int disk_sync();
benglish6 0:c69af1faeb95 60 virtual int disk_sectors();
benglish6 0:c69af1faeb95 61
benglish6 0:c69af1faeb95 62 protected:
benglish6 0:c69af1faeb95 63
benglish6 0:c69af1faeb95 64 int _cmd(int cmd, int arg);
benglish6 0:c69af1faeb95 65 int _cmdx(int cmd, int arg);
benglish6 0:c69af1faeb95 66 int _cmd8();
benglish6 0:c69af1faeb95 67 int _cmd58();
benglish6 0:c69af1faeb95 68 int initialise_card();
benglish6 0:c69af1faeb95 69 int initialise_card_v1();
benglish6 0:c69af1faeb95 70 int initialise_card_v2();
benglish6 0:c69af1faeb95 71
benglish6 0:c69af1faeb95 72 int _read(char *buffer, int length);
benglish6 0:c69af1faeb95 73 int _write(const char *buffer, int length);
benglish6 0:c69af1faeb95 74 int _sd_sectors();
benglish6 0:c69af1faeb95 75 int _sectors;
benglish6 0:c69af1faeb95 76
benglish6 0:c69af1faeb95 77 SPI _spi;
benglish6 0:c69af1faeb95 78 DigitalOut _cs;
benglish6 0:c69af1faeb95 79 };
benglish6 0:c69af1faeb95 80
benglish6 0:c69af1faeb95 81 #endif