summaryrefslogtreecommitdiff
path: root/components/drivers/usb/usbdevice
diff options
context:
space:
mode:
authorZYH <[email protected]>2017-12-21 21:26:40 +0800
committerZYH <[email protected]>2017-12-21 21:26:40 +0800
commit92f5b437f77a444f01ef78e258f1fe6c96b656a6 (patch)
treefd7b1151d55fc0c694d94ff68e53f48c8f15c70e /components/drivers/usb/usbdevice
parentac278da0aa10f23b4746fccc4f36e92953d6bdf8 (diff)
[USB Device]fix an error on msc
Diffstat (limited to 'components/drivers/usb/usbdevice')
-rw-r--r--components/drivers/usb/usbdevice/class/mstorage.c8
-rw-r--r--components/drivers/usb/usbdevice/core/core.c3
2 files changed, 8 insertions, 3 deletions
diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c
index eeff755e2e..d4caf44166 100644
--- a/components/drivers/usb/usbdevice/class/mstorage.c
+++ b/components/drivers/usb/usbdevice/class/mstorage.c
@@ -954,7 +954,6 @@ static rt_err_t _function_enable(ufunction_t func)
{
struct mstorage *data;
RT_ASSERT(func != RT_NULL);
-
RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function enabled\n"));
data = (struct mstorage*)func->user_data;
@@ -1027,7 +1026,12 @@ static rt_err_t _function_disable(ufunction_t func)
rt_free(data->ep_out->buffer);
data->ep_out->buffer = RT_NULL;
}
-
+ if(data->disk != RT_NULL)
+ {
+ rt_device_close(data->disk);
+ data->disk = RT_NULL;
+ }
+
data->status = STAT_CBW;
return RT_EOK;
diff --git a/components/drivers/usb/usbdevice/core/core.c b/components/drivers/usb/usbdevice/core/core.c
index 15ab31e9f7..1b7f03b006 100644
--- a/components/drivers/usb/usbdevice/core/core.c
+++ b/components/drivers/usb/usbdevice/core/core.c
@@ -2144,8 +2144,9 @@ static void rt_usbd_thread_entry(void* parameter)
break;
case USB_MSG_RESET:
RT_DEBUG_LOG(RT_DEBUG_USB, ("reset %d\n", device->state));
- if (device->state == USB_STATE_ADDRESS)
+ if (device->state == USB_STATE_ADDRESS || device->state == USB_STATE_CONFIGURED)
_stop_notify(device);
+ device->state = USB_STATE_NOTATTACHED;
break;
case USB_MSG_PLUG_IN:
device->state = USB_STATE_ATTACHED;