USBHOST lib for STM
Dependents: door-access-controller-dev
Revision 6:d3ac9e1c0035, committed 2017-04-26
- Comitter:
- jamike
- Date:
- Wed Apr 26 20:08:31 2017 +0000
- Parent:
- 5:fc157e6bd5a5
- Commit message:
- fix error in read and write
Changed in this revision
| USBHostMSD/USBHostMSD.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/USBHostMSD/USBHostMSD.cpp Wed Apr 26 18:11:37 2017 +0200
+++ b/USBHostMSD/USBHostMSD.cpp Wed Apr 26 20:08:31 2017 +0000
@@ -341,6 +341,7 @@
int USBHostMSD::program(const void *buffer, bd_addr_t addr, bd_size_t size)
{
uint32_t block_number, count;
+ uint8_t *buf = (uint8_t *)buffer;
if (!disk_init) {
init();
}
@@ -350,9 +351,9 @@
count = size /blockSize;
for (uint32_t b = block_number; b < block_number + count; b++) {
- if (dataTransfer((uint8_t*)buffer, b, 1, HOST_TO_DEVICE))
+ if (dataTransfer(buf, b, 1, HOST_TO_DEVICE))
return -1;
- buffer += 512;
+ buf += blockSize;
}
return 0;
}
@@ -360,6 +361,7 @@
int USBHostMSD::read(void *buffer, bd_addr_t addr, bd_size_t size)
{
uint32_t block_number, count;
+ uint8_t *buf = (uint8_t *)buffer;
if (!disk_init) {
init();
}
@@ -369,9 +371,9 @@
count = size /blockSize;
for (uint32_t b = block_number; b < block_number + count; b++) {
- if (dataTransfer((uint8_t*)buffer, b, 1, DEVICE_TO_HOST))
+ if (dataTransfer((uint8_t*)buf, b, 1, DEVICE_TO_HOST))
return -1;
- buffer += 512;
+ buf += blockSize;
}
return 0;
}