Implementation of a LocalFileSystem using S25FL216K serial flash memory. Currently only 256kB available!

Dependencies:   FATFileSystem S25FL216K

Dependents:   S25FL216K_LocalFileSystem

Fork of S25FL216K_USBFileSystem by Murat Kilivan

Committer:
mkilivan
Date:
Tue Dec 23 21:36:32 2014 +0000
Revision:
5:c8918e47c566
initial commit

Who changed what in which revision?

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