Wave-Player with TLV320

Dependencies:   FatFileSystemCpp I2SSlave TLV320 mbed

Committer:
HB9GAA
Date:
Wed Dec 09 20:58:55 2015 +0000
Revision:
0:3087f1924901
Wave-Player with TLV320

Who changed what in which revision?

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