[ FORK ] USBFileSytem; fork from sissors/USBFileSystem

Dependents:   USBMSD_CDC_11U35test

Fork of USBFileSystem by Erik -

Committer:
k4zuki
Date:
Tue Apr 21 09:14:07 2015 +0000
Revision:
9:98a97b7d56a8
Parent:
7:da1f3328a496
update USBDevice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 7:da1f3328a496 1 /* mbed Microcontroller Library
Sissors 7:da1f3328a496 2 * Copyright (c) 2006-2012 ARM Limited
Sissors 7:da1f3328a496 3 *
Sissors 7:da1f3328a496 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
Sissors 7:da1f3328a496 5 * of this software and associated documentation files (the "Software"), to deal
Sissors 7:da1f3328a496 6 * in the Software without restriction, including without limitation the rights
Sissors 7:da1f3328a496 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Sissors 7:da1f3328a496 8 * copies of the Software, and to permit persons to whom the Software is
Sissors 7:da1f3328a496 9 * furnished to do so, subject to the following conditions:
Sissors 7:da1f3328a496 10 *
Sissors 7:da1f3328a496 11 * The above copyright notice and this permission notice shall be included in
Sissors 7:da1f3328a496 12 * all copies or substantial portions of the Software.
Sissors 7:da1f3328a496 13 *
Sissors 7:da1f3328a496 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Sissors 7:da1f3328a496 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Sissors 7:da1f3328a496 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Sissors 7:da1f3328a496 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Sissors 7:da1f3328a496 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Sissors 7:da1f3328a496 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Sissors 7:da1f3328a496 20 * SOFTWARE.
Sissors 7:da1f3328a496 21 */
Sissors 7:da1f3328a496 22 #ifndef MBED_FATFILESYSTEM_H
Sissors 7:da1f3328a496 23 #define MBED_FATFILESYSTEM_H
Sissors 7:da1f3328a496 24
Sissors 7:da1f3328a496 25 #include "FileSystemLike.h"
Sissors 7:da1f3328a496 26 #include "FileHandle.h"
Sissors 7:da1f3328a496 27 #include "ff.h"
Sissors 7:da1f3328a496 28 #include <stdint.h>
Sissors 7:da1f3328a496 29
Sissors 7:da1f3328a496 30 using namespace mbed;
Sissors 7:da1f3328a496 31
Sissors 7:da1f3328a496 32 /**
Sissors 7:da1f3328a496 33 * FATFileSystem based on ChaN's Fat Filesystem library v0.8
Sissors 7:da1f3328a496 34 */
Sissors 7:da1f3328a496 35 class FATFileSystem : public FileSystemLike {
Sissors 7:da1f3328a496 36 public:
Sissors 7:da1f3328a496 37
Sissors 7:da1f3328a496 38 FATFileSystem(const char* n);
Sissors 7:da1f3328a496 39 virtual ~FATFileSystem();
Sissors 7:da1f3328a496 40
Sissors 7:da1f3328a496 41 static FATFileSystem * _ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array
Sissors 7:da1f3328a496 42 FATFS _fs; // Work area (file system object) for logical drive
Sissors 7:da1f3328a496 43 int _fsid;
Sissors 7:da1f3328a496 44
Sissors 7:da1f3328a496 45 /**
Sissors 7:da1f3328a496 46 * Opens a file on the filesystem
Sissors 7:da1f3328a496 47 */
Sissors 7:da1f3328a496 48 virtual FileHandle *open(const char* name, int flags);
Sissors 7:da1f3328a496 49
Sissors 7:da1f3328a496 50 /**
Sissors 7:da1f3328a496 51 * Removes a file path
Sissors 7:da1f3328a496 52 */
Sissors 7:da1f3328a496 53 virtual int remove(const char *filename);
Sissors 7:da1f3328a496 54
Sissors 7:da1f3328a496 55 /**
Sissors 7:da1f3328a496 56 * Renames a file
Sissors 7:da1f3328a496 57 */
Sissors 7:da1f3328a496 58 virtual int rename(const char *oldname, const char *newname);
Sissors 7:da1f3328a496 59
Sissors 7:da1f3328a496 60 /**
Sissors 7:da1f3328a496 61 * Formats a logical drive, FDISK artitioning rule, 512 bytes per cluster
Sissors 7:da1f3328a496 62 */
Sissors 7:da1f3328a496 63 virtual int format();
Sissors 7:da1f3328a496 64
Sissors 7:da1f3328a496 65 /**
Sissors 7:da1f3328a496 66 * Opens a directory on the filesystem
Sissors 7:da1f3328a496 67 */
Sissors 7:da1f3328a496 68 virtual DirHandle *opendir(const char *name);
Sissors 7:da1f3328a496 69
Sissors 7:da1f3328a496 70 /**
Sissors 7:da1f3328a496 71 * Creates a directory path
Sissors 7:da1f3328a496 72 */
Sissors 7:da1f3328a496 73 virtual int mkdir(const char *name, mode_t mode);
Sissors 7:da1f3328a496 74
Sissors 7:da1f3328a496 75 /**
Sissors 7:da1f3328a496 76 * Mounts the filesystem
Sissors 7:da1f3328a496 77 */
Sissors 7:da1f3328a496 78 virtual int mount();
Sissors 7:da1f3328a496 79
Sissors 7:da1f3328a496 80 /**
Sissors 7:da1f3328a496 81 * Unmounts the filesystem
Sissors 7:da1f3328a496 82 */
Sissors 7:da1f3328a496 83 virtual int unmount();
Sissors 7:da1f3328a496 84
Sissors 7:da1f3328a496 85 virtual int disk_initialize() { return 0; }
Sissors 7:da1f3328a496 86 virtual int disk_status() { return 0; }
Sissors 7:da1f3328a496 87 virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count) = 0;
Sissors 7:da1f3328a496 88 virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count) = 0;
Sissors 7:da1f3328a496 89 virtual int disk_sync() { return 0; }
Sissors 7:da1f3328a496 90 virtual uint64_t disk_sectors() = 0;
Sissors 7:da1f3328a496 91
Sissors 7:da1f3328a496 92 };
Sissors 7:da1f3328a496 93
Sissors 7:da1f3328a496 94 #endif