actualizacion no funciona
Dependencies: FATFileSystem mbed-rtos
Dependents: Proyect_Patric_electronic_door_MSC_Ok_ESP
Fork of USBHost by
USBHostMSD/USBHostMSD.h@3:0f5c32575eb8, 2013-03-06 (annotated)
- Committer:
- samux
- Date:
- Wed Mar 06 17:50:07 2013 +0000
- Revision:
- 3:0f5c32575eb8
- Parent:
- 1:0a457e34fa9e
- Child:
- 4:b320d68e98e7
update doxygen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:a554658735bf | 1 | /* Copyright (c) 2010-2012 mbed.org, MIT License |
mbed_official | 0:a554658735bf | 2 | * |
mbed_official | 0:a554658735bf | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
mbed_official | 0:a554658735bf | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
mbed_official | 0:a554658735bf | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
mbed_official | 0:a554658735bf | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
mbed_official | 0:a554658735bf | 7 | * Software is furnished to do so, subject to the following conditions: |
mbed_official | 0:a554658735bf | 8 | * |
mbed_official | 0:a554658735bf | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
mbed_official | 0:a554658735bf | 10 | * substantial portions of the Software. |
mbed_official | 0:a554658735bf | 11 | * |
mbed_official | 0:a554658735bf | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
mbed_official | 0:a554658735bf | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
mbed_official | 0:a554658735bf | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
mbed_official | 0:a554658735bf | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mbed_official | 0:a554658735bf | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
mbed_official | 0:a554658735bf | 17 | */ |
mbed_official | 0:a554658735bf | 18 | |
mbed_official | 0:a554658735bf | 19 | #ifndef USBHOSTMSD_H |
mbed_official | 0:a554658735bf | 20 | #define USBHOSTMSD_H |
mbed_official | 0:a554658735bf | 21 | |
mbed_official | 0:a554658735bf | 22 | #include "USBHostConf.h" |
mbed_official | 0:a554658735bf | 23 | |
mbed_official | 0:a554658735bf | 24 | #if USBHOST_MSD |
mbed_official | 0:a554658735bf | 25 | |
mbed_official | 0:a554658735bf | 26 | #include "USBHost.h" |
mbed_official | 0:a554658735bf | 27 | #include "FATFileSystem.h" |
mbed_official | 0:a554658735bf | 28 | |
mbed_official | 0:a554658735bf | 29 | /** |
samux | 1:0a457e34fa9e | 30 | * A class to communicate a USB flash disk |
mbed_official | 0:a554658735bf | 31 | */ |
mbed_official | 0:a554658735bf | 32 | class USBHostMSD : public IUSBEnumerator, public FATFileSystem { |
mbed_official | 0:a554658735bf | 33 | public: |
mbed_official | 0:a554658735bf | 34 | /** |
mbed_official | 0:a554658735bf | 35 | * Constructor |
mbed_official | 0:a554658735bf | 36 | * |
mbed_official | 0:a554658735bf | 37 | * @param rootdir mount name |
mbed_official | 0:a554658735bf | 38 | */ |
mbed_official | 0:a554658735bf | 39 | USBHostMSD(const char * rootdir); |
mbed_official | 0:a554658735bf | 40 | |
mbed_official | 0:a554658735bf | 41 | /** |
mbed_official | 0:a554658735bf | 42 | * Check if a MSD device is connected |
mbed_official | 0:a554658735bf | 43 | * |
mbed_official | 0:a554658735bf | 44 | * @return true if a MSD device is connected |
mbed_official | 0:a554658735bf | 45 | */ |
mbed_official | 0:a554658735bf | 46 | bool connected(); |
mbed_official | 0:a554658735bf | 47 | |
samux | 3:0f5c32575eb8 | 48 | /** |
mbed_official | 0:a554658735bf | 49 | * Try to connect to a MSD device |
mbed_official | 0:a554658735bf | 50 | * |
samux | 3:0f5c32575eb8 | 51 | * @return true if connection was successful |
mbed_official | 0:a554658735bf | 52 | */ |
mbed_official | 0:a554658735bf | 53 | bool connect(); |
mbed_official | 0:a554658735bf | 54 | |
mbed_official | 0:a554658735bf | 55 | protected: |
mbed_official | 0:a554658735bf | 56 | //From IUSBEnumerator |
mbed_official | 0:a554658735bf | 57 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
mbed_official | 0:a554658735bf | 58 | 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 | 59 | 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 | 60 | |
mbed_official | 0:a554658735bf | 61 | // From FATFileSystem |
mbed_official | 0:a554658735bf | 62 | virtual int disk_initialize(); |
mbed_official | 0:a554658735bf | 63 | virtual int disk_status() {return 0;}; |
mbed_official | 0:a554658735bf | 64 | virtual int disk_read(uint8_t * buffer, uint64_t sector); |
mbed_official | 0:a554658735bf | 65 | virtual int disk_write(const uint8_t * buffer, uint64_t sector); |
mbed_official | 0:a554658735bf | 66 | virtual int disk_sync() {return 0;}; |
mbed_official | 0:a554658735bf | 67 | virtual uint64_t disk_sectors(); |
mbed_official | 0:a554658735bf | 68 | |
mbed_official | 0:a554658735bf | 69 | private: |
mbed_official | 0:a554658735bf | 70 | USBHost * host; |
mbed_official | 0:a554658735bf | 71 | USBDeviceConnected * dev; |
mbed_official | 0:a554658735bf | 72 | bool dev_connected; |
mbed_official | 0:a554658735bf | 73 | USBEndpoint * bulk_in; |
mbed_official | 0:a554658735bf | 74 | USBEndpoint * bulk_out; |
mbed_official | 0:a554658735bf | 75 | |
mbed_official | 0:a554658735bf | 76 | // Bulk-only CBW |
mbed_official | 0:a554658735bf | 77 | typedef __packed 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 | 0:a554658735bf | 85 | } CBW; |
mbed_official | 0:a554658735bf | 86 | |
mbed_official | 0:a554658735bf | 87 | // Bulk-only CSW |
mbed_official | 0:a554658735bf | 88 | typedef __packed 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 | 0:a554658735bf | 93 | } CSW; |
mbed_official | 0:a554658735bf | 94 | |
mbed_official | 0:a554658735bf | 95 | CBW cbw; |
mbed_official | 0:a554658735bf | 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); |
mbed_official | 0:a554658735bf | 105 | |
mbed_official | 0:a554658735bf | 106 | int blockSize; |
mbed_official | 0:a554658735bf | 107 | uint64_t blockCount; |
mbed_official | 0:a554658735bf | 108 | |
mbed_official | 0:a554658735bf | 109 | int msd_intf; |
mbed_official | 0:a554658735bf | 110 | bool msd_device_found; |
mbed_official | 0:a554658735bf | 111 | bool disk_init; |
mbed_official | 0:a554658735bf | 112 | |
mbed_official | 0:a554658735bf | 113 | void init(); |
mbed_official | 0:a554658735bf | 114 | |
mbed_official | 0:a554658735bf | 115 | }; |
mbed_official | 0:a554658735bf | 116 | |
mbed_official | 0:a554658735bf | 117 | #endif |
mbed_official | 0:a554658735bf | 118 | |
mbed_official | 0:a554658735bf | 119 | #endif |
mbed_official | 0:a554658735bf | 120 |