mX mbed BaseBoard audio

Dependencies:   mbed

Committer:
ashwin_athani
Date:
Wed Dec 08 06:21:06 2010 +0000
Revision:
0:6c621d41bf07

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashwin_athani 0:6c621d41bf07 1 /* mbed Microcontroller Library - SDFileSystem
ashwin_athani 0:6c621d41bf07 2 * Copyright (c) 2008-2009, sford
ashwin_athani 0:6c621d41bf07 3 */
ashwin_athani 0:6c621d41bf07 4
ashwin_athani 0:6c621d41bf07 5 #ifndef SDFILESYSTEM_H
ashwin_athani 0:6c621d41bf07 6 #define SDFILESYSTEM_H
ashwin_athani 0:6c621d41bf07 7
ashwin_athani 0:6c621d41bf07 8 #include "mbed.h"
ashwin_athani 0:6c621d41bf07 9 #include "FATFileSystem.h"
ashwin_athani 0:6c621d41bf07 10
ashwin_athani 0:6c621d41bf07 11 /* Class: SDFileSystem
ashwin_athani 0:6c621d41bf07 12 * Access the filesystem on an SD Card using SPI
ashwin_athani 0:6c621d41bf07 13 *
ashwin_athani 0:6c621d41bf07 14 * Example:
ashwin_athani 0:6c621d41bf07 15 * > SDFileSystem sd(p5, p6, p7, p12, "sd");
ashwin_athani 0:6c621d41bf07 16 * >
ashwin_athani 0:6c621d41bf07 17 * > int main() {
ashwin_athani 0:6c621d41bf07 18 * > FILE *fp = fopen("/sd/myfile.txt", "w");
ashwin_athani 0:6c621d41bf07 19 * > fprintf(fp, "Hello World!\n");
ashwin_athani 0:6c621d41bf07 20 * > fclose(fp);
ashwin_athani 0:6c621d41bf07 21 * > }
ashwin_athani 0:6c621d41bf07 22 */
ashwin_athani 0:6c621d41bf07 23 class SDFileSystem : public FATFileSystem {
ashwin_athani 0:6c621d41bf07 24 public:
ashwin_athani 0:6c621d41bf07 25
ashwin_athani 0:6c621d41bf07 26 /* Constructor: SDFileSystem
ashwin_athani 0:6c621d41bf07 27 * Create the File System for accessing an SD Card using SPI
ashwin_athani 0:6c621d41bf07 28 *
ashwin_athani 0:6c621d41bf07 29 * Variables:
ashwin_athani 0:6c621d41bf07 30 * mosi - SPI mosi pin connected to SD Card
ashwin_athani 0:6c621d41bf07 31 * miso - SPI miso pin conencted to SD Card
ashwin_athani 0:6c621d41bf07 32 * sclk - SPI sclk pin connected to SD Card
ashwin_athani 0:6c621d41bf07 33 * cs - DigitalOut pin used as SD Card chip select
ashwin_athani 0:6c621d41bf07 34 * name - The name used to access the filesystem
ashwin_athani 0:6c621d41bf07 35 */
ashwin_athani 0:6c621d41bf07 36 SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name);
ashwin_athani 0:6c621d41bf07 37 virtual int disk_initialize();
ashwin_athani 0:6c621d41bf07 38 virtual int disk_write(const char *buffer, int block_number);
ashwin_athani 0:6c621d41bf07 39 virtual int disk_read(char *buffer, int block_number);
ashwin_athani 0:6c621d41bf07 40 virtual int disk_status();
ashwin_athani 0:6c621d41bf07 41 virtual int disk_sync();
ashwin_athani 0:6c621d41bf07 42 virtual int disk_sectors();
ashwin_athani 0:6c621d41bf07 43
ashwin_athani 0:6c621d41bf07 44 protected:
ashwin_athani 0:6c621d41bf07 45
ashwin_athani 0:6c621d41bf07 46 int _cmd(int cmd, int arg);
ashwin_athani 0:6c621d41bf07 47 int _read(char *buffer, int length);
ashwin_athani 0:6c621d41bf07 48 int _write(const char *buffer, int length);
ashwin_athani 0:6c621d41bf07 49 int _sd_sectors();
ashwin_athani 0:6c621d41bf07 50 int _sectors;
ashwin_athani 0:6c621d41bf07 51
ashwin_athani 0:6c621d41bf07 52 SPI _spi;
ashwin_athani 0:6c621d41bf07 53 DigitalOut _cs;
ashwin_athani 0:6c621d41bf07 54 };
ashwin_athani 0:6c621d41bf07 55
ashwin_athani 0:6c621d41bf07 56 #endif