USB composite device example program, drag-and-drop flash writer.
Dependencies: SWD USBDevice mbed BaseDAP
RomDisk.h
00001 // RomDisk.h 2013/9/26 00002 #pragma once 00003 00004 #define ATTR_READ_ONLY 0x01 00005 #define ATTR_HIDDEN 0x02 00006 #define ATTR_SYSTEM 0x04 00007 #define ATTR_VOLUME_ID 0x08 00008 #define ATTR_DIRECTORY 0x10 00009 #define ATTR_ARCHIVE 0x20 00010 #define ATTR_LONG_NAME (ATTR_READ_ONLY|ATTR_HIDDEN|ATTR_SYSTEM|ATTR_VOLUME_ID) 00011 00012 struct DirEntry { 00013 uint8_t name[8+3]; 00014 uint8_t attr; 00015 uint8_t NTres; 00016 uint8_t cDateTime_ms; 00017 uint16_t cTime; 00018 uint16_t cDate; 00019 uint16_t aDate; 00020 uint16_t clusterHI; 00021 uint16_t mTime; 00022 uint16_t mDate; 00023 uint16_t cluster; 00024 uint32_t size; 00025 bool is_free() { 00026 return name[0] == 0xe5 || name[0] == 0x00; 00027 } 00028 bool is_file() { 00029 return is_free() == false && attr == ATTR_ARCHIVE; 00030 } 00031 int cmpDateTime(DirEntry* entry) { 00032 if (mDate > entry->mDate) { 00033 return 1; 00034 } else if (mDate < entry->mDate) { 00035 return -1; 00036 } 00037 if (mTime > entry->mTime) { 00038 return 1; 00039 } else if (mTime < entry->mTime) { 00040 return -1; 00041 } 00042 return 0; 00043 } 00044 } __attribute__((__packed__));; 00045 00046 struct SectorIndex { 00047 int block; 00048 const uint8_t* data; 00049 }; 00050 00051 extern const SectorIndex sector_index[]; // RomDiskData.cpp 00052 00053 class RomDisk { 00054 public: 00055 RomDisk(); 00056 int read(uint8_t * data, uint32_t block); 00057 int write(const uint8_t * data, uint32_t block); 00058 uint32_t sectors(); 00059 bool is_fat(uint32_t sector); 00060 bool is_rootdir(uint32_t sector); 00061 int dir_count(uint32_t sector); 00062 uint32_t cluster_to_sector(uint32_t cluster); 00063 protected: 00064 uint64_t _sectors; 00065 };
Generated on Wed Jul 13 2022 08:08:25 by 1.7.2