USBMSD SD card Hello World for Mbed platforms
Dependencies: mbed USBMSD_SD USBDevice
Diff: ChaNFSSD/SDFileSystem.cpp
- Revision:
- 13:32b8a767cf0e
- Parent:
- 12:a12eb1fc05f3
- Child:
- 14:757226626acb
--- a/ChaNFSSD/SDFileSystem.cpp Wed Nov 30 17:50:35 2011 +0000 +++ b/ChaNFSSD/SDFileSystem.cpp Mon Dec 05 14:34:29 2011 +0000 @@ -208,7 +208,7 @@ return 1; } - _spi.frequency(1000000); // Set to 1MHz for data transfer + _spi.frequency(5000000); // Set to 5MHz for data transfer return 0; } @@ -439,19 +439,24 @@ fprintf(stderr, "This disk tastes funny! I only know about type 0 CSD structures\n"); return 0; } - + // memory capacity = BLOCKNR * BLOCK_LEN // where // BLOCKNR = (C_SIZE+1) * MULT // MULT = 2^(C_SIZE_MULT+2) (C_SIZE_MULT < 8) // BLOCK_LEN = 2^READ_BL_LEN, (READ_BL_LEN < 12) - + int block_len = 1 << read_bl_len; int mult = 1 << (c_size_mult + 2); int blocknr = (c_size + 1) * mult; - int capacity = blocknr * block_len; - + capacity = blocknr * block_len; + int blocks = capacity / 512; return blocks; } + + +int SDFileSystem::disk_size() { + return capacity; +}