USBAudio example using a microphone

Dependencies:   USBDevice mbed

Committer:
samux
Date:
Mon Dec 19 15:46:17 2011 +0000
Revision:
3:e6a29c83ac52
ok we can send a music from an sdcard but readings are time to time slow...

Who changed what in which revision?

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