LINKED LIST TEST on mbed

Dependencies:   mbed

Committer:
lynxeyed_atsu
Date:
Sat Feb 26 03:55:12 2011 +0000
Revision:
0:e8bfffbb3ab6

        

Who changed what in which revision?

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