Update version of EALib.

Dependencies:   FATFileSystem

Fork of EALib by IONX

Committer:
embeddedartists
Date:
Thu Sep 26 06:37:02 2013 +0000
Revision:
0:0fdadbc3d852
Child:
2:1c6134c80dc5
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:0fdadbc3d852 1 #ifndef QSPIFILESYSTEM_H
embeddedartists 0:0fdadbc3d852 2 #define QSPIFILESYSTEM_H
embeddedartists 0:0fdadbc3d852 3
embeddedartists 0:0fdadbc3d852 4 #include "mbed.h"
embeddedartists 0:0fdadbc3d852 5 #include "FileSystemLike.h"
embeddedartists 0:0fdadbc3d852 6
embeddedartists 0:0fdadbc3d852 7 /** Access the filesystem on an QSPI flash using SPIFI
embeddedartists 0:0fdadbc3d852 8 *
embeddedartists 0:0fdadbc3d852 9 * @code
embeddedartists 0:0fdadbc3d852 10 * #include "mbed.h"
embeddedartists 0:0fdadbc3d852 11 * #include "QSPIFileSystem.h"
embeddedartists 0:0fdadbc3d852 12 *
embeddedartists 0:0fdadbc3d852 13 * QSPIFileSystem qspi("qspi");
embeddedartists 0:0fdadbc3d852 14 *
embeddedartists 0:0fdadbc3d852 15 * int main() {
embeddedartists 0:0fdadbc3d852 16 * if (!qspifs.isFormatted()) {
embeddedartists 0:0fdadbc3d852 17 * qspifs.format();
embeddedartists 0:0fdadbc3d852 18 * }
embeddedartists 0:0fdadbc3d852 19 *
embeddedartists 0:0fdadbc3d852 20 * FILE *fp = fopen("/qspi/myfile.txt", "w");
embeddedartists 0:0fdadbc3d852 21 * if (fp != NULL) {
embeddedartists 0:0fdadbc3d852 22 * fprintf(fp, "Hello World!\n");
embeddedartists 0:0fdadbc3d852 23 * fclose(fp);
embeddedartists 0:0fdadbc3d852 24 * }
embeddedartists 0:0fdadbc3d852 25 * }
embeddedartists 0:0fdadbc3d852 26 * @endcode
embeddedartists 0:0fdadbc3d852 27 */
embeddedartists 0:0fdadbc3d852 28 class QSPIFileSystem : public FileSystemLike {
embeddedartists 0:0fdadbc3d852 29 public:
embeddedartists 0:0fdadbc3d852 30
embeddedartists 0:0fdadbc3d852 31 /** Create the File System for accessing a QSPI Flash
embeddedartists 0:0fdadbc3d852 32 *
embeddedartists 0:0fdadbc3d852 33 * @param name The name used to access the virtual filesystem
embeddedartists 0:0fdadbc3d852 34 */
embeddedartists 0:0fdadbc3d852 35 QSPIFileSystem(const char* name);
embeddedartists 0:0fdadbc3d852 36
embeddedartists 0:0fdadbc3d852 37 virtual FileHandle *open(const char *filename, int flags);
embeddedartists 0:0fdadbc3d852 38 virtual int remove(const char *filename);
embeddedartists 0:0fdadbc3d852 39 virtual int rename(const char *oldname, const char *newname);
embeddedartists 0:0fdadbc3d852 40 virtual DirHandle *opendir(const char *name);
embeddedartists 0:0fdadbc3d852 41 virtual int mkdir(const char *name, mode_t mode);
embeddedartists 0:0fdadbc3d852 42
embeddedartists 0:0fdadbc3d852 43 /** Creates a new file system on the QSPI flash.
embeddedartists 0:0fdadbc3d852 44 * The file system will have the specified size and will always
embeddedartists 0:0fdadbc3d852 45 * be positioned at the end of the QSPI flash. If the fsSizeInMB is
embeddedartists 0:0fdadbc3d852 46 * less than the size of the QSPI flash the lower end of the flash
embeddedartists 0:0fdadbc3d852 47 * will be left untouched.
embeddedartists 0:0fdadbc3d852 48 *
embeddedartists 0:0fdadbc3d852 49 * @param fsSizeInMB The size of the file system
embeddedartists 0:0fdadbc3d852 50 *
embeddedartists 0:0fdadbc3d852 51 * @returns
embeddedartists 0:0fdadbc3d852 52 * 0 on success,
embeddedartists 0:0fdadbc3d852 53 * -1 on failure.
embeddedartists 0:0fdadbc3d852 54 */
embeddedartists 0:0fdadbc3d852 55 int format(unsigned int fsSizeInMB = 8);
embeddedartists 0:0fdadbc3d852 56
embeddedartists 0:0fdadbc3d852 57 /** Tests if there is a file system present on the QSPI flash
embeddedartists 0:0fdadbc3d852 58 *
embeddedartists 0:0fdadbc3d852 59 * @returns
embeddedartists 0:0fdadbc3d852 60 * True if a valid file system could be found,
embeddedartists 0:0fdadbc3d852 61 * False on failure.
embeddedartists 0:0fdadbc3d852 62 */
embeddedartists 0:0fdadbc3d852 63 bool isformatted();
embeddedartists 0:0fdadbc3d852 64
embeddedartists 0:0fdadbc3d852 65 /** Retrieves the start and end addresses for the file system.
embeddedartists 0:0fdadbc3d852 66 * The pStartAddr and pEndAddr will only be assigned values if the
embeddedartists 0:0fdadbc3d852 67 * function returns true.
embeddedartists 0:0fdadbc3d852 68 *
embeddedartists 0:0fdadbc3d852 69 * @param pStartAddr Will return the start of the file system area
embeddedartists 0:0fdadbc3d852 70 * @param pEndAddr Will return the end of the file system area
embeddedartists 0:0fdadbc3d852 71 *
embeddedartists 0:0fdadbc3d852 72 * @returns
embeddedartists 0:0fdadbc3d852 73 * True if there is a file system,
embeddedartists 0:0fdadbc3d852 74 * False on failure.
embeddedartists 0:0fdadbc3d852 75 */
embeddedartists 0:0fdadbc3d852 76 bool getMemoryBoundaries(uint32_t* pStartAddr, uint32_t* pEndAddr);
embeddedartists 0:0fdadbc3d852 77 };
embeddedartists 0:0fdadbc3d852 78
embeddedartists 0:0fdadbc3d852 79 #endif
embeddedartists 0:0fdadbc3d852 80
embeddedartists 0:0fdadbc3d852 81