A program to read out the FTSE100 in real time using a TLV320 CODEC and Ethernet connexion

Dependencies:   EthernetNetIf I2SSlave mbed TLV320

Committer:
d_worrall
Date:
Fri Aug 05 13:05:52 2011 +0000
Revision:
0:e1324d2fc338
version 2.0

Who changed what in which revision?

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