diff options
| author | Cliff Chen <[email protected]> | 2020-03-16 10:22:37 +0800 |
|---|---|---|
| committer | Cliff Chen <[email protected]> | 2020-03-16 10:50:34 +0800 |
| commit | 1c68bd9d3cef3e6a935e520de57cb0acfc2c0a5e (patch) | |
| tree | 54aa10cc60ea0baaa45edfdfde1ba0e49b42de41 /components/drivers | |
| parent | a7bcf90d78970f9a5e221133653331df158e9548 (diff) | |
Support msc mode automatic switching
Signed-off-by: Cliff Chen <[email protected]>
Diffstat (limited to 'components/drivers')
| -rw-r--r-- | components/drivers/usb/usbdevice/class/mstorage.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c index 6a6e92415b..43fb25afe4 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.c +++ b/components/drivers/usb/usbdevice/class/mstorage.c @@ -16,6 +16,10 @@ #include "drivers/usb_device.h" #include "mstorage.h" +#ifdef RT_USING_DFS_MNTTABLE +#include "dfs_fs.h" +#endif + #ifdef RT_USB_DEVICE_MSTORAGE enum STAT @@ -955,7 +959,7 @@ 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; + data = (struct mstorage*)func->user_data; data->disk = rt_device_find(RT_USB_MSTORAGE_DISK_NAME); if(data->disk == RT_NULL) @@ -964,6 +968,10 @@ static rt_err_t _function_enable(ufunction_t func) return -RT_ERROR; } +#ifdef RT_USING_DFS_MNTTABLE + dfs_unmount_device(data->disk); +#endif + if(rt_device_open(data->disk, RT_DEVICE_OFLAG_RDWR) != RT_EOK) { rt_kprintf("disk open error\n"); @@ -1029,6 +1037,9 @@ static rt_err_t _function_disable(ufunction_t func) if(data->disk != RT_NULL) { rt_device_close(data->disk); +#ifdef RT_USING_DFS_MNTTABLE + dfs_mount_device(data->disk); +#endif data->disk = RT_NULL; } |
