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