modify for C210 webcam and Startboard Orange.

Dependencies:   TextLCD USBHost mbed

Fork of USBHostC270_example by Norimasa Okamoto

Norimasa Okamoto さんの http://mbed.org/users/va009039/code/USBHostC270_example/ を C210 webcam と StarBoard Orange での SD カード保存用に変更。

Committer:
masato
Date:
Tue Mar 19 14:16:25 2013 +0000
Revision:
12:c827ed52021d
for C210 and StartBoard Orange

Who changed what in which revision?

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