Web enabled thermostat demo using the Mission Cognition baseboard.

Dependencies:   NetServices mbed AvailableMemory

Committer:
jt
Date:
Mon Oct 03 21:45:56 2011 +0000
Revision:
0:2e82bfc9dc19
1.0

Who changed what in which revision?

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