RK4_euler

Dependencies:   FatFileSystem mbed

Fork of RK4_euler by hige dura

Committer:
higedura
Date:
Thu Nov 29 15:22:06 2012 +0000
Revision:
7:ec00db826804
Parent:
3:5b192b38b3bb
RK4_euler

Who changed what in which revision?

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