![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
USB composite device example program, drag-and-drop flash writer.
Dependencies: SWD USBDevice mbed BaseDAP
Diff: tests/RamDisk.cpp
- Revision:
- 1:ea8e179320d7
- Parent:
- 0:2385683c867a
--- a/tests/RamDisk.cpp Tue Sep 17 04:33:44 2013 +0000 +++ b/tests/RamDisk.cpp Sat Sep 28 03:21:14 2013 +0000 @@ -1,14 +1,16 @@ -// RamDisk.cpp 2013/9/16 +// RamDisk.cpp 2013/9/21 #include "mbed.h" #include "RamDisk.h" +#include "mydebug.h" -RamDisk::RamDisk() : _head(NULL) +RamDisk::RamDisk() : _head(NULL), use_size(0) { _sectors = 128; // 64KB(512*128) } int RamDisk::read(uint8_t * data, uint32_t block) { + //DBG("block=%d", block); SectorData* p = find(block); if (p) { memcpy(data, p->data, 512); @@ -32,17 +34,23 @@ { SectorData* p = find(block); if (p) { + DBG("update block=%d", block); memcpy(p->data, data, 512); return 0; } if (is_blank(data)) { return 0; } + DBG("new block=%d", block); p = new SectorData; + TEST_ASSERT(p); p->block = block; memcpy(p->data, data, 512); p->next = _head; _head = p; + use_size += 512; + //DBG("use_size: %d", use_size); + TEST_ASSERT(use_size < (512*16)); return 0; }