Class that contain only FATFileSystem

Fork of USBFileSystem by Erik -

Committer:
mkilivan
Date:
Fri Dec 19 14:41:08 2014 +0000
Revision:
6:eeeea7fbb0a2
Parent:
2:9af05743d551
Remove USB part

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 2:9af05743d551 1 /* mbed Microcontroller Library
Sissors 2:9af05743d551 2 * Copyright (c) 2006-2012 ARM Limited
Sissors 2:9af05743d551 3 *
Sissors 2:9af05743d551 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
Sissors 2:9af05743d551 5 * of this software and associated documentation files (the "Software"), to deal
Sissors 2:9af05743d551 6 * in the Software without restriction, including without limitation the rights
Sissors 2:9af05743d551 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Sissors 2:9af05743d551 8 * copies of the Software, and to permit persons to whom the Software is
Sissors 2:9af05743d551 9 * furnished to do so, subject to the following conditions:
Sissors 2:9af05743d551 10 *
Sissors 2:9af05743d551 11 * The above copyright notice and this permission notice shall be included in
Sissors 2:9af05743d551 12 * all copies or substantial portions of the Software.
Sissors 2:9af05743d551 13 *
Sissors 2:9af05743d551 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Sissors 2:9af05743d551 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Sissors 2:9af05743d551 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Sissors 2:9af05743d551 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Sissors 2:9af05743d551 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Sissors 2:9af05743d551 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Sissors 2:9af05743d551 20 * SOFTWARE.
Sissors 2:9af05743d551 21 */
Sissors 2:9af05743d551 22 #ifndef MBED_FATFILESYSTEM_H
Sissors 2:9af05743d551 23 #define MBED_FATFILESYSTEM_H
Sissors 2:9af05743d551 24
Sissors 2:9af05743d551 25 #include "FileSystemLike.h"
Sissors 2:9af05743d551 26 #include "FileHandle.h"
Sissors 2:9af05743d551 27 #include "ff.h"
Sissors 2:9af05743d551 28 #include <stdint.h>
Sissors 2:9af05743d551 29
Sissors 2:9af05743d551 30 using namespace mbed;
Sissors 2:9af05743d551 31
Sissors 2:9af05743d551 32 class FATFileSystem : public FileSystemLike {
Sissors 2:9af05743d551 33 public:
Sissors 2:9af05743d551 34
Sissors 2:9af05743d551 35 FATFileSystem(const char* n);
Sissors 2:9af05743d551 36 virtual ~FATFileSystem();
Sissors 2:9af05743d551 37
Sissors 2:9af05743d551 38 static FATFileSystem * _ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array
Sissors 2:9af05743d551 39 FATFS _fs; // Work area (file system object) for logical drive
Sissors 2:9af05743d551 40 int _fsid;
Sissors 2:9af05743d551 41
Sissors 2:9af05743d551 42 virtual FileHandle *open(const char* name, int flags);
Sissors 2:9af05743d551 43 virtual int remove(const char *filename);
Sissors 2:9af05743d551 44 virtual int format();
Sissors 2:9af05743d551 45 virtual DirHandle *opendir(const char *name);
Sissors 2:9af05743d551 46 virtual int mkdir(const char *name, mode_t mode);
Sissors 2:9af05743d551 47
Sissors 2:9af05743d551 48 virtual int disk_initialize() { return 0; }
Sissors 2:9af05743d551 49 virtual int disk_status() { return 0; }
Sissors 2:9af05743d551 50 virtual int disk_read(uint8_t * buffer, uint64_t sector) = 0;
Sissors 2:9af05743d551 51 virtual int disk_write(const uint8_t * buffer, uint64_t sector) = 0;
Sissors 2:9af05743d551 52 virtual int disk_sync() { return 0; }
Sissors 2:9af05743d551 53 virtual uint64_t disk_sectors() = 0;
Sissors 2:9af05743d551 54
Sissors 2:9af05743d551 55 };
Sissors 2:9af05743d551 56
Sissors 2:9af05743d551 57 #endif