Just a \"collage\" of some existing examples to test the web capabilities of the mBed

Dependencies:   EthernetNetIf NTPClient_NetServices mbed HTTPServer

Committer:
guiott
Date:
Thu Feb 17 13:13:13 2011 +0000
Revision:
0:bf8b2e1459d0

        

Who changed what in which revision?

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