1 /* mbed USBHost Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include "USBHostConf.h"
25 #include "FATFileSystem.h"
28 * A class to communicate a USB flash disk
30 class USBHostMSD : public IUSBEnumerator, public FATFileSystem {
35 * @param rootdir mount name
37 USBHostMSD(const char * rootdir);
40 * Check if a MSD device is connected
42 * @return true if a MSD device is connected
47 * Try to connect to a MSD device
49 * @return true if connection was successful
55 virtual void setVidPid(uint16_t vid, uint16_t pid);
56 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
57 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
60 virtual int disk_initialize();
61 virtual int disk_status() {return 0;};
62 virtual int disk_read(uint8_t* buffer, uint64_t sector, uint8_t count);
63 virtual int disk_write(const uint8_t* buffer, uint64_t sector, uint8_t count);
64 virtual int disk_sync() {return 0;};
65 virtual uint64_t disk_sectors();
69 USBDeviceConnected * dev;
71 USBEndpoint * bulk_in;
72 USBEndpoint * bulk_out;
97 int SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t * data, uint32_t transfer_len);
100 int inquiry(uint8_t lun, uint8_t page_code);
101 int SCSIRequestSense();
102 int dataTransfer(uint8_t * buf, uint32_t block, uint8_t nbBlock, int direction);
103 int checkResult(uint8_t res, USBEndpoint * ep);
110 bool msd_device_found;