Adaptation of the official mbed USBHost repository to work with the LPC4088 Display Module
Dependents: DMSupport DMSupport DMSupport DMSupport
Fork of DM_USBHost by
USBHostMSD/USBHostMSD.h@33:819bbf04163b, 2019-11-04 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Nov 04 14:30:07 2019 +0000
- Revision:
- 33:819bbf04163b
- Parent:
- 27:aa2fd412f1d3
More updates related to mbed OS 5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 8:93da8ea2708b | 1 | /* mbed USBHost Library |
samux | 8:93da8ea2708b | 2 | * Copyright (c) 2006-2013 ARM Limited |
samux | 8:93da8ea2708b | 3 | * |
samux | 8:93da8ea2708b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
samux | 8:93da8ea2708b | 5 | * you may not use this file except in compliance with the License. |
samux | 8:93da8ea2708b | 6 | * You may obtain a copy of the License at |
samux | 8:93da8ea2708b | 7 | * |
samux | 8:93da8ea2708b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
samux | 8:93da8ea2708b | 9 | * |
samux | 8:93da8ea2708b | 10 | * Unless required by applicable law or agreed to in writing, software |
samux | 8:93da8ea2708b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
samux | 8:93da8ea2708b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
samux | 8:93da8ea2708b | 13 | * See the License for the specific language governing permissions and |
samux | 8:93da8ea2708b | 14 | * limitations under the License. |
samux | 8:93da8ea2708b | 15 | */ |
mbed_official | 0:a554658735bf | 16 | |
mbed_official | 0:a554658735bf | 17 | #ifndef USBHOSTMSD_H |
mbed_official | 0:a554658735bf | 18 | #define USBHOSTMSD_H |
mbed_official | 0:a554658735bf | 19 | |
mbed_official | 0:a554658735bf | 20 | #include "USBHostConf.h" |
mbed_official | 0:a554658735bf | 21 | |
mbed_official | 0:a554658735bf | 22 | #if USBHOST_MSD |
mbed_official | 0:a554658735bf | 23 | |
mbed_official | 0:a554658735bf | 24 | #include "USBHost.h" |
mbed_official | 0:a554658735bf | 25 | #include "FATFileSystem.h" |
mbed_official | 0:a554658735bf | 26 | |
mbed_official | 24:868cbfe611a7 | 27 | /** |
samux | 1:0a457e34fa9e | 28 | * A class to communicate a USB flash disk |
mbed_official | 0:a554658735bf | 29 | */ |
mbed_official | 0:a554658735bf | 30 | class USBHostMSD : public IUSBEnumerator, public FATFileSystem { |
mbed_official | 0:a554658735bf | 31 | public: |
mbed_official | 0:a554658735bf | 32 | /** |
mbed_official | 0:a554658735bf | 33 | * Constructor |
mbed_official | 0:a554658735bf | 34 | * |
mbed_official | 0:a554658735bf | 35 | * @param rootdir mount name |
mbed_official | 0:a554658735bf | 36 | */ |
mbed_official | 0:a554658735bf | 37 | USBHostMSD(const char * rootdir); |
embeddedartists | 27:aa2fd412f1d3 | 38 | virtual ~USBHostMSD(); |
mbed_official | 0:a554658735bf | 39 | |
mbed_official | 0:a554658735bf | 40 | /** |
mbed_official | 0:a554658735bf | 41 | * Check if a MSD device is connected |
mbed_official | 0:a554658735bf | 42 | * |
mbed_official | 0:a554658735bf | 43 | * @return true if a MSD device is connected |
mbed_official | 0:a554658735bf | 44 | */ |
mbed_official | 0:a554658735bf | 45 | bool connected(); |
mbed_official | 0:a554658735bf | 46 | |
samux | 3:0f5c32575eb8 | 47 | /** |
mbed_official | 0:a554658735bf | 48 | * Try to connect to a MSD device |
mbed_official | 0:a554658735bf | 49 | * |
samux | 3:0f5c32575eb8 | 50 | * @return true if connection was successful |
mbed_official | 0:a554658735bf | 51 | */ |
mbed_official | 0:a554658735bf | 52 | bool connect(); |
mbed_official | 0:a554658735bf | 53 | |
mbed_official | 0:a554658735bf | 54 | protected: |
mbed_official | 0:a554658735bf | 55 | //From IUSBEnumerator |
mbed_official | 0:a554658735bf | 56 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
mbed_official | 0:a554658735bf | 57 | 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 |
mbed_official | 0:a554658735bf | 58 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
mbed_official | 0:a554658735bf | 59 | |
mbed_official | 0:a554658735bf | 60 | // From FATFileSystem |
mbed_official | 0:a554658735bf | 61 | virtual int disk_initialize(); |
mbed_official | 0:a554658735bf | 62 | virtual int disk_status() {return 0;}; |
mbed_official | 26:607951c26872 | 63 | virtual int disk_read(uint8_t* buffer, uint64_t sector, uint8_t count); |
mbed_official | 26:607951c26872 | 64 | virtual int disk_write(const uint8_t* buffer, uint64_t sector, uint8_t count); |
mbed_official | 0:a554658735bf | 65 | virtual int disk_sync() {return 0;}; |
mbed_official | 0:a554658735bf | 66 | virtual uint64_t disk_sectors(); |
mbed_official | 0:a554658735bf | 67 | |
mbed_official | 0:a554658735bf | 68 | private: |
mbed_official | 0:a554658735bf | 69 | USBHost * host; |
mbed_official | 0:a554658735bf | 70 | USBDeviceConnected * dev; |
mbed_official | 0:a554658735bf | 71 | bool dev_connected; |
mbed_official | 0:a554658735bf | 72 | USBEndpoint * bulk_in; |
mbed_official | 0:a554658735bf | 73 | USBEndpoint * bulk_out; |
samux | 4:b320d68e98e7 | 74 | uint8_t nb_ep; |
mbed_official | 0:a554658735bf | 75 | |
mbed_official | 0:a554658735bf | 76 | // Bulk-only CBW |
mbed_official | 13:b58a2204422f | 77 | typedef struct { |
mbed_official | 0:a554658735bf | 78 | uint32_t Signature; |
mbed_official | 0:a554658735bf | 79 | uint32_t Tag; |
mbed_official | 0:a554658735bf | 80 | uint32_t DataLength; |
mbed_official | 0:a554658735bf | 81 | uint8_t Flags; |
mbed_official | 0:a554658735bf | 82 | uint8_t LUN; |
mbed_official | 0:a554658735bf | 83 | uint8_t CBLength; |
mbed_official | 0:a554658735bf | 84 | uint8_t CB[16]; |
mbed_official | 13:b58a2204422f | 85 | } PACKED CBW; |
mbed_official | 0:a554658735bf | 86 | |
mbed_official | 0:a554658735bf | 87 | // Bulk-only CSW |
mbed_official | 13:b58a2204422f | 88 | typedef struct { |
mbed_official | 0:a554658735bf | 89 | uint32_t Signature; |
mbed_official | 0:a554658735bf | 90 | uint32_t Tag; |
mbed_official | 0:a554658735bf | 91 | uint32_t DataResidue; |
mbed_official | 0:a554658735bf | 92 | uint8_t Status; |
mbed_official | 13:b58a2204422f | 93 | } PACKED CSW; |
mbed_official | 0:a554658735bf | 94 | |
embeddedartists | 27:aa2fd412f1d3 | 95 | CBW* cbw; |
embeddedartists | 27:aa2fd412f1d3 | 96 | CSW* csw; |
mbed_official | 0:a554658735bf | 97 | |
mbed_official | 0:a554658735bf | 98 | int SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t * data, uint32_t transfer_len); |
mbed_official | 0:a554658735bf | 99 | int testUnitReady(); |
mbed_official | 0:a554658735bf | 100 | int readCapacity(); |
mbed_official | 0:a554658735bf | 101 | int inquiry(uint8_t lun, uint8_t page_code); |
mbed_official | 0:a554658735bf | 102 | int SCSIRequestSense(); |
mbed_official | 0:a554658735bf | 103 | int dataTransfer(uint8_t * buf, uint32_t block, uint8_t nbBlock, int direction); |
mbed_official | 0:a554658735bf | 104 | int checkResult(uint8_t res, USBEndpoint * ep); |
samux | 4:b320d68e98e7 | 105 | int getMaxLun(); |
mbed_official | 0:a554658735bf | 106 | |
mbed_official | 0:a554658735bf | 107 | int blockSize; |
mbed_official | 0:a554658735bf | 108 | uint64_t blockCount; |
mbed_official | 0:a554658735bf | 109 | |
mbed_official | 0:a554658735bf | 110 | int msd_intf; |
mbed_official | 0:a554658735bf | 111 | bool msd_device_found; |
mbed_official | 0:a554658735bf | 112 | bool disk_init; |
mbed_official | 24:868cbfe611a7 | 113 | |
mbed_official | 0:a554658735bf | 114 | void init(); |
mbed_official | 0:a554658735bf | 115 | |
mbed_official | 0:a554658735bf | 116 | }; |
mbed_official | 0:a554658735bf | 117 | |
mbed_official | 0:a554658735bf | 118 | #endif |
mbed_official | 0:a554658735bf | 119 | |
mbed_official | 0:a554658735bf | 120 | #endif |