James Heavey / Mbed 2 deprecated 2665-Breakout-Game

Dependencies:   mbed

Committer:
jamesheavey
Date:
Tue Jan 05 01:14:11 2021 +0000
Revision:
0:92b180c8d407
test

Who changed what in which revision?

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