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