A simple demo how to use the HTTPServer with an SDCard file system

Dependencies:   mbed lwip

Committer:
rolf
Date:
Fri Nov 20 11:25:04 2009 +0000
Revision:
0:949146458785

        

Who changed what in which revision?

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