Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MSCFileSystem.h@0:0732b16d9a92, 2011-01-06 (annotated)
- Committer:
- CE
- Date:
- Thu Jan 06 19:01:44 2011 +0000
- Revision:
- 0:0732b16d9a92
R1A
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| CE | 0:0732b16d9a92 | 1 | /* USB Mass Storage device file system |
| CE | 0:0732b16d9a92 | 2 | * Copyrigh (c) 2010, Igor Skochinsky |
| CE | 0:0732b16d9a92 | 3 | * based on SDFileStorage |
| CE | 0:0732b16d9a92 | 4 | * Copyright (c) 2008-2009, sford |
| CE | 0:0732b16d9a92 | 5 | */ |
| CE | 0:0732b16d9a92 | 6 | |
| CE | 0:0732b16d9a92 | 7 | #ifndef MSCFILESYSTEM_H |
| CE | 0:0732b16d9a92 | 8 | #define MSCFILESYSTEM_H |
| CE | 0:0732b16d9a92 | 9 | |
| CE | 0:0732b16d9a92 | 10 | #include "mbed.h" |
| CE | 0:0732b16d9a92 | 11 | #include "FATFileSystem.h" |
| CE | 0:0732b16d9a92 | 12 | |
| CE | 0:0732b16d9a92 | 13 | /* Class: MSCFileSystem |
| CE | 0:0732b16d9a92 | 14 | * Access the filesystem on an attached USB mass storage device (e.g. a memory stick) |
| CE | 0:0732b16d9a92 | 15 | * |
| CE | 0:0732b16d9a92 | 16 | * Example: |
| CE | 0:0732b16d9a92 | 17 | * > MSCFileSystem msc("msc"); |
| CE | 0:0732b16d9a92 | 18 | * > |
| CE | 0:0732b16d9a92 | 19 | * > int main() { |
| CE | 0:0732b16d9a92 | 20 | * > FILE *fp = fopen("/msc/myfile.txt", "w"); |
| CE | 0:0732b16d9a92 | 21 | * > fprintf(fp, "Hello World!\n"); |
| CE | 0:0732b16d9a92 | 22 | * > fclose(fp); |
| CE | 0:0732b16d9a92 | 23 | * > } |
| CE | 0:0732b16d9a92 | 24 | */ |
| CE | 0:0732b16d9a92 | 25 | class MSCFileSystem : public FATFileSystem { |
| CE | 0:0732b16d9a92 | 26 | public: |
| CE | 0:0732b16d9a92 | 27 | |
| CE | 0:0732b16d9a92 | 28 | /* Constructor: MSCFileSystem |
| CE | 0:0732b16d9a92 | 29 | * Create the File System for accessing a USB mass storage device |
| CE | 0:0732b16d9a92 | 30 | * |
| CE | 0:0732b16d9a92 | 31 | * Parameters: |
| CE | 0:0732b16d9a92 | 32 | * name - The name used to access the filesystem |
| CE | 0:0732b16d9a92 | 33 | */ |
| CE | 0:0732b16d9a92 | 34 | MSCFileSystem(const char* name); |
| CE | 0:0732b16d9a92 | 35 | virtual int disk_initialize(); |
| CE | 0:0732b16d9a92 | 36 | virtual int disk_write(const char *buffer, int block_number); |
| CE | 0:0732b16d9a92 | 37 | virtual int disk_read(char *buffer, int block_number); |
| CE | 0:0732b16d9a92 | 38 | virtual int disk_status(); |
| CE | 0:0732b16d9a92 | 39 | virtual int disk_sync(); |
| CE | 0:0732b16d9a92 | 40 | virtual int disk_sectors(); |
| CE | 0:0732b16d9a92 | 41 | |
| CE | 0:0732b16d9a92 | 42 | protected: |
| CE | 0:0732b16d9a92 | 43 | |
| CE | 0:0732b16d9a92 | 44 | int initialise_msc(); |
| CE | 0:0732b16d9a92 | 45 | uint32_t _numBlks; |
| CE | 0:0732b16d9a92 | 46 | uint32_t _blkSize; |
| CE | 0:0732b16d9a92 | 47 | }; |
| CE | 0:0732b16d9a92 | 48 | |
| CE | 0:0732b16d9a92 | 49 | #endif |