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