wave player

Fork of FATFileSystem by mbed official

Committer:
Kojto
Date:
Thu Aug 25 09:34:29 2016 +0100
Revision:
8:c4baca9a2c3d
Parent:
7:094f84646b9f
Synchronized with git revision 4047ff95767d307

- fix _name error (getName())
- add thread safety

Who changed what in which revision?

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