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