LCD1289Serial_Ethenet

Dependencies:   EthernetInterface FatFileSystemCpp SDFileSystem mbed-rtos mbed

Committer:
shindo
Date:
Wed Nov 07 06:42:34 2012 +0000
Revision:
0:a5367e4d8591
LCD1289Serial_Ethenet

Who changed what in which revision?

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