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.
Dependents: mini_piano_player play_wav BlueCrutch FTHR_USBMSD_Demo_27
Fork of USBMSD_SD by
Diff: USBMSD_SD.cpp
- Revision:
- 3:cce1e689c548
- Parent:
- 2:055119ccf5a7
--- a/USBMSD_SD.cpp Mon Jan 21 10:40:05 2013 +0000
+++ b/USBMSD_SD.cpp Wed Nov 16 18:24:52 2016 +0000
@@ -222,25 +222,33 @@
return 0;
}
-int USBMSD_SD::disk_write(const uint8_t *buffer, uint64_t block_number) {
- // set write address for single block (CMD24)
- if (_cmd(24, block_number * cdv) != 0) {
- return 1;
+int USBMSD_SD::disk_write(const uint8_t* buffer, uint64_t block_number, uint8_t count) {
+ for (uint64_t b = block_number; b < block_number + count; b++) {
+ // set write address for single block (CMD24)
+ if (_cmd(24, b * cdv) != 0) {
+ return 1;
+ }
+
+ // send the data block
+ _write(buffer, 512);
+ buffer += 512;
}
- // send the data block
- _write(buffer, 512);
return 0;
}
-int USBMSD_SD::disk_read(uint8_t *buffer, uint64_t block_number) {
- // set read address for single block (CMD17)
- if (_cmd(17, block_number * cdv) != 0) {
- return 1;
+int USBMSD_SD::disk_read(uint8_t* buffer, uint64_t block_number, uint8_t count) {
+ for (uint64_t b = block_number; b < block_number + count; b++) {
+ // set read address for single block (CMD17)
+ if (_cmd(17, b * cdv) != 0) {
+ return 1;
+ }
+
+ // receive the data
+ _read(buffer, 512);
+ buffer += 512;
}
-
- // receive the data
- _read(buffer, 512);
+
return 0;
}
