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