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