Stand-alone HMD demo system built on mbed FRDM-K64F.

Dependencies:   SDFileSystem mbed FATFileSystem

Committer:
maruishi
Date:
Tue Jul 29 11:41:59 2014 +0000
Revision:
0:9bbe50de69d8
FRDM-K64F based 3D Head-mount-display for Interface(CQ Pub)

Who changed what in which revision?

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