Bop-It Game

Dependencies:   TextLCD mbed ADXL345 VS1053b

Committer:
jdumond3
Date:
Wed Oct 19 18:04:48 2011 +0000
Revision:
0:d16ac399135a

        

Who changed what in which revision?

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