This program is for Star Board Orange. Wave file into SD card is read, and its DAC signal output.

Dependencies:   EthernetNetIf mbed HTTPServer

Committer:
y_notsu
Date:
Thu Nov 25 14:59:16 2010 +0000
Revision:
0:383bff20e783

        

Who changed what in which revision?

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