From bcaf1d5093cb8dbe4ad4e9667ee17981a0e42a6f Mon Sep 17 00:00:00 2001 From: "sc943313837@gmail.com" Date: Sat, 1 Dec 2012 08:00:57 +0000 Subject: [PATCH] Single block write data git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2463 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/drivers/usb/usbdevice/class/mstorage.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c index 5d9242f96..c2c753ec0 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.c +++ b/components/drivers/usb/usbdevice/class/mstorage.c @@ -275,7 +275,7 @@ static rt_err_t _write_10(udevice_t device, ustorage_cbw_t cbw) RT_DEBUG_LOG(RT_DEBUG_USB, ("_write_10 count 0x%x 0x%x\n", _count, geometry.sector_count)); - dcd_ep_read(device->dcd, ep_out, buffer, MIN(_size, 4096)); + dcd_ep_read(device->dcd, ep_out, write_ptr, geometry.bytes_per_sector); return RT_EOK; } @@ -417,18 +417,19 @@ static rt_err_t _ep_out_handler(udevice_t device, rt_size_t size) size, _block, _size)); _size -= size; - write_ptr += size; csw.data_reside -= size; + + rt_device_write(disk, _block, write_ptr, 1); + _block ++; if(_size == 0) - { - rt_device_write(disk, _block, buffer, _count); + { dcd_ep_write(device->dcd, ep_in, (rt_uint8_t*)&csw, SIZEOF_CSW); dcd_ep_read(device->dcd, ep_out, ep_out->buffer, SIZEOF_CBW); status = STATUS_CBW; } else { - dcd_ep_read(device->dcd, ep_out, write_ptr, MIN(_size, 4096)); + dcd_ep_read(device->dcd, ep_out, write_ptr, geometry.bytes_per_sector); } } else