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