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.
Dependencies: USBDevice USBMSD_SD mbed
Fork of USBMSD_SD_HelloWorld_Mbed by
Diff: USBMSD/USBMSD.cpp
- Revision:
- 8:534fd41d8cc7
- Parent:
- 7:6494da2a5c60
- Child:
- 9:9c343b9ee6d8
--- a/USBMSD/USBMSD.cpp Mon Nov 14 12:08:32 2011 +0000
+++ b/USBMSD/USBMSD.cpp Mon Nov 14 17:50:02 2011 +0000
@@ -80,22 +80,27 @@
bool USBMSD::connect() {
//disk initialization
- diskInit();
+ disk_initialize();
+
+ //set_status(1 << 1);
// get block size
- BlockSize = blockSize();
+ BlockSize = 512;
if (BlockSize != 0) {
page = (uint8_t *)malloc(BlockSize * sizeof(uint8_t));
if (page == NULL)
return false;
}
- //get memory size
- MemorySize = memorySize();
+ //get number of blocks
+ BlockCount = disk_sectors();
+
+ MemorySize = BlockCount * 512;
if (!MemorySize) {
return false;
}
- BlockCount = MemorySize/BlockSize;
+ printf("block count: %d\r\n", BlockCount);
+ printf("mem size: %d\r\n", MemorySize);
//connect the device
USBDevice::connect();
@@ -197,7 +202,7 @@
// if the array is filled, write it in memory
if (!((addr + size)%BlockSize))
- blockWrite(page, addr/BlockSize);
+ disk_write((const char *)page, addr/BlockSize);
addr += size;
length -= size;
@@ -220,7 +225,7 @@
// beginning of a new block -> load a whole block in RAM
if (!(addr%BlockSize))
- blockRead(page, addr/BlockSize);
+ disk_read((char *)page, addr/BlockSize);
// info are in RAM -> no need to re-read memory
for (n = 0; n < size; n++) {
@@ -464,7 +469,7 @@
// we read an entire block
if (!(addr%BlockSize))
- blockRead(page, addr/BlockSize);
+ disk_read((char *)page, addr/BlockSize);
// write data which are in RAM
writeNB(EPBULK_IN, &page[addr%BlockSize], n, MAX_PACKET_SIZE_EPBULK);
