SDFileSystem, included for backwards compatibility.

Committer:
root@mbed.org
Date:
Tue May 08 15:20:54 2012 +0100
Revision:
0:6afe57e15f1a
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
root@mbed.org 0:6afe57e15f1a 1 /* mbed Microcontroller Library - SDFileSystem
root@mbed.org 0:6afe57e15f1a 2 * Copyright (c) 2008-2009, sford
root@mbed.org 0:6afe57e15f1a 3 */
root@mbed.org 0:6afe57e15f1a 4
root@mbed.org 0:6afe57e15f1a 5 #ifndef SDFILESYSTEM_H
root@mbed.org 0:6afe57e15f1a 6 #define SDFILESYSTEM_H
root@mbed.org 0:6afe57e15f1a 7
root@mbed.org 0:6afe57e15f1a 8 #include "mbed.h"
root@mbed.org 0:6afe57e15f1a 9 #include "FATFileSystem.h"
root@mbed.org 0:6afe57e15f1a 10
root@mbed.org 0:6afe57e15f1a 11 /* Class: SDFileSystem
root@mbed.org 0:6afe57e15f1a 12 * Access the filesystem on an SD Card using SPI
root@mbed.org 0:6afe57e15f1a 13 *
root@mbed.org 0:6afe57e15f1a 14 * Example:
root@mbed.org 0:6afe57e15f1a 15 * > SDFileSystem sd(p5, p6, p7, p12, "sd");
root@mbed.org 0:6afe57e15f1a 16 * >
root@mbed.org 0:6afe57e15f1a 17 * > int main() {
root@mbed.org 0:6afe57e15f1a 18 * > FILE *fp = fopen("/sd/myfile.txt", "w");
root@mbed.org 0:6afe57e15f1a 19 * > fprintf(fp, "Hello World!\n");
root@mbed.org 0:6afe57e15f1a 20 * > fclose(fp);
root@mbed.org 0:6afe57e15f1a 21 * > }
root@mbed.org 0:6afe57e15f1a 22 */
root@mbed.org 0:6afe57e15f1a 23 class SDFileSystem : public FATFileSystem {
root@mbed.org 0:6afe57e15f1a 24 public:
root@mbed.org 0:6afe57e15f1a 25
root@mbed.org 0:6afe57e15f1a 26 /* Constructor: SDFileSystem
root@mbed.org 0:6afe57e15f1a 27 * Create the File System for accessing an SD Card using SPI
root@mbed.org 0:6afe57e15f1a 28 *
root@mbed.org 0:6afe57e15f1a 29 * Variables:
root@mbed.org 0:6afe57e15f1a 30 * mosi - SPI mosi pin connected to SD Card
root@mbed.org 0:6afe57e15f1a 31 * miso - SPI miso pin conencted to SD Card
root@mbed.org 0:6afe57e15f1a 32 * sclk - SPI sclk pin connected to SD Card
root@mbed.org 0:6afe57e15f1a 33 * cs - DigitalOut pin used as SD Card chip select
root@mbed.org 0:6afe57e15f1a 34 * name - The name used to access the filesystem
root@mbed.org 0:6afe57e15f1a 35 */
root@mbed.org 0:6afe57e15f1a 36 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
root@mbed.org 0:6afe57e15f1a 37 virtual int disk_initialize();
root@mbed.org 0:6afe57e15f1a 38 virtual int disk_write(const char *buffer, int block_number);
root@mbed.org 0:6afe57e15f1a 39 virtual int disk_read(char *buffer, int block_number);
root@mbed.org 0:6afe57e15f1a 40 virtual int disk_status();
root@mbed.org 0:6afe57e15f1a 41 virtual int disk_sync();
root@mbed.org 0:6afe57e15f1a 42 virtual int disk_sectors();
root@mbed.org 0:6afe57e15f1a 43
root@mbed.org 0:6afe57e15f1a 44 protected:
root@mbed.org 0:6afe57e15f1a 45
root@mbed.org 0:6afe57e15f1a 46 int _cmd(int cmd, int arg);
root@mbed.org 0:6afe57e15f1a 47 int _read(char *buffer, int length);
root@mbed.org 0:6afe57e15f1a 48 int _write(const char *buffer, int length);
root@mbed.org 0:6afe57e15f1a 49 int _sd_sectors();
root@mbed.org 0:6afe57e15f1a 50 int _sectors;
root@mbed.org 0:6afe57e15f1a 51
root@mbed.org 0:6afe57e15f1a 52 SPI _spi;
root@mbed.org 0:6afe57e15f1a 53 DigitalOut _cs;
root@mbed.org 0:6afe57e15f1a 54 };
root@mbed.org 0:6afe57e15f1a 55
root@mbed.org 0:6afe57e15f1a 56 #endif