Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
USBHostMSD.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef USBHOSTMSD_H 00020 #define USBHOSTMSD_H 00021 00022 #include "USBHost.h" 00023 #include "FATFileSystem.h" 00024 00025 class USBHostMSD: public FATFileSystem { 00026 public: 00027 /* 00028 * Constructor 00029 * 00030 * @param rootdir mount name 00031 */ 00032 USBHostMSD(const char * rootdir); 00033 00034 /* 00035 * Check if a serial port device is connected 00036 * 00037 * @returns true if a serial device is connected 00038 */ 00039 bool connected(); 00040 00041 protected: 00042 virtual int disk_initialize(); 00043 virtual int disk_write(const char *buffer, int block_number); 00044 virtual int disk_read(char *buffer, int block_number); 00045 virtual int disk_sectors(); 00046 00047 private: 00048 00049 // Bulk-only CBW 00050 typedef __packed struct { 00051 uint32_t Signature; 00052 uint32_t Tag; 00053 uint32_t DataLength; 00054 uint8_t Flags; 00055 uint8_t LUN; 00056 uint8_t CBLength; 00057 uint8_t CB[16]; 00058 } CBW; 00059 00060 // Bulk-only CSW 00061 typedef __packed struct { 00062 uint32_t Signature; 00063 uint32_t Tag; 00064 uint32_t DataResidue; 00065 uint8_t Status; 00066 } CSW; 00067 00068 CBW cbw; 00069 CSW csw; 00070 00071 int SCSITransfer(uint8_t * cmd, uint8_t cmd_len, int flags, uint8_t * data, uint32_t transfer_len); 00072 int testUnitReady(); 00073 int readCapacity(); 00074 int dataTransfer(uint8_t * buf, uint32_t block, uint8_t nbBlock, int direction); 00075 00076 USBHost * host; 00077 USBDeviceConnected * dev; 00078 Endpoint * bulk_in; 00079 Endpoint * bulk_out; 00080 int blockSize; 00081 int blockCount; 00082 }; 00083 00084 #endif
Generated on Tue Jul 12 2022 17:50:57 by
