esemi00
Dependencies: mbed FatFileSystemCpp
MSCFileSystem.h@0:2369be4f42cd, 2021-01-20 (annotated)
- Committer:
- esemi00
- Date:
- Wed Jan 20 05:26:38 2021 +0000
- Revision:
- 0:2369be4f42cd
esemi00
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
esemi00 | 0:2369be4f42cd | 1 | /* USB Mass Storage device file system |
esemi00 | 0:2369be4f42cd | 2 | * Copyrigh (c) 2010, Igor Skochinsky |
esemi00 | 0:2369be4f42cd | 3 | * based on SDFileStorage |
esemi00 | 0:2369be4f42cd | 4 | * Copyright (c) 2008-2009, sford |
esemi00 | 0:2369be4f42cd | 5 | */ |
esemi00 | 0:2369be4f42cd | 6 | |
esemi00 | 0:2369be4f42cd | 7 | #ifndef MSCFILESYSTEM_H |
esemi00 | 0:2369be4f42cd | 8 | #define MSCFILESYSTEM_H |
esemi00 | 0:2369be4f42cd | 9 | |
esemi00 | 0:2369be4f42cd | 10 | #include "mbed.h" |
esemi00 | 0:2369be4f42cd | 11 | #include "FATFileSystem.h" |
esemi00 | 0:2369be4f42cd | 12 | |
esemi00 | 0:2369be4f42cd | 13 | /* Class: MSCFileSystem |
esemi00 | 0:2369be4f42cd | 14 | * Access the filesystem on an attached USB mass storage device (e.g. a memory stick) |
esemi00 | 0:2369be4f42cd | 15 | * |
esemi00 | 0:2369be4f42cd | 16 | * Example: |
esemi00 | 0:2369be4f42cd | 17 | * > MSCFileSystem msc("msc"); |
esemi00 | 0:2369be4f42cd | 18 | * > |
esemi00 | 0:2369be4f42cd | 19 | * > int main() { |
esemi00 | 0:2369be4f42cd | 20 | * > FILE *fp = fopen("/msc/myfile.txt", "w"); |
esemi00 | 0:2369be4f42cd | 21 | * > fprintf(fp, "Hello World!\n"); |
esemi00 | 0:2369be4f42cd | 22 | * > fclose(fp); |
esemi00 | 0:2369be4f42cd | 23 | * > } |
esemi00 | 0:2369be4f42cd | 24 | */ |
esemi00 | 0:2369be4f42cd | 25 | class MSCFileSystem : public FATFileSystem { |
esemi00 | 0:2369be4f42cd | 26 | public: |
esemi00 | 0:2369be4f42cd | 27 | |
esemi00 | 0:2369be4f42cd | 28 | /* Constructor: MSCFileSystem |
esemi00 | 0:2369be4f42cd | 29 | * Create the File System for accessing a USB mass storage device |
esemi00 | 0:2369be4f42cd | 30 | * |
esemi00 | 0:2369be4f42cd | 31 | * Parameters: |
esemi00 | 0:2369be4f42cd | 32 | * name - The name used to access the filesystem |
esemi00 | 0:2369be4f42cd | 33 | */ |
esemi00 | 0:2369be4f42cd | 34 | MSCFileSystem(const char* name); |
esemi00 | 0:2369be4f42cd | 35 | virtual int disk_initialize(); |
esemi00 | 0:2369be4f42cd | 36 | virtual int disk_write(const char *buffer, int block_number); |
esemi00 | 0:2369be4f42cd | 37 | virtual int disk_read(char *buffer, int block_number); |
esemi00 | 0:2369be4f42cd | 38 | virtual int disk_status(); |
esemi00 | 0:2369be4f42cd | 39 | virtual int disk_sync(); |
esemi00 | 0:2369be4f42cd | 40 | virtual int disk_sectors(); |
esemi00 | 0:2369be4f42cd | 41 | |
esemi00 | 0:2369be4f42cd | 42 | protected: |
esemi00 | 0:2369be4f42cd | 43 | |
esemi00 | 0:2369be4f42cd | 44 | int initialise_msc(); |
esemi00 | 0:2369be4f42cd | 45 | uint32_t _numBlks; |
esemi00 | 0:2369be4f42cd | 46 | uint32_t _blkSize; |
esemi00 | 0:2369be4f42cd | 47 | }; |
esemi00 | 0:2369be4f42cd | 48 | |
esemi00 | 0:2369be4f42cd | 49 | #endif |