FAT

Dependents:   SDFileSystem_Axelta

Committer:
gauthibit
Date:
Fri Nov 11 06:39:00 2016 +0000
Revision:
0:6547fbc0f7c0
FAT

Who changed what in which revision?

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