Dependencies:   mbed Servo

Committer:
eric11fr
Date:
Tue Oct 27 22:22:14 2020 +0000
Revision:
4:34a8e94c6fd5
Parent:
0:b8bade04f24f
test menu via xbee

Who changed what in which revision?

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