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.
Dependencies: FatFileSystem TB6612FNG2 mbed
msc/msc.h@0:de03cbbcd0ff, 2015-11-30 (annotated)
- Committer:
- mbed_Cookbook_SE
- Date:
- Mon Nov 30 09:32:15 2015 +0000
- Revision:
- 0:de03cbbcd0ff
??
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 1 | #ifndef MSC_H |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 2 | #define MSC_H |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 3 | #include "UsbHostMgr.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 4 | #include "UsbEndpoint.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 5 | #include "UsbBaseClass.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 6 | #include "FATFileSystem.h" |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 7 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 8 | #define SCSI_CMD_REQUEST_SENSE 0x03 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 9 | #define SCSI_CMD_TEST_UNIT_READY 0x00 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 10 | #define SCSI_CMD_INQUIRY 0x12 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 11 | #define SCSI_CMD_READ_10 0x28 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 12 | #define SCSI_CMD_READ_CAPACITY 0x25 |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 13 | #define SCSI_CMD_WRITE_10 0x2A |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 14 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 15 | #pragma pack(push,1) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 16 | typedef struct stcbw { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 17 | uint32_t dCBWSignature; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 18 | uint32_t dCBWTag; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 19 | uint32_t dCBWDataTraansferLength; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 20 | uint8_t bmCBWFlags; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 21 | uint8_t bCBWLUN; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 22 | uint8_t bCBWCBLength; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 23 | uint8_t CBWCB[16]; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 24 | } CBW; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 25 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 26 | typedef struct stcsw { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 27 | uint32_t dCSWSignature; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 28 | uint32_t dCSWTag; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 29 | uint32_t dCSWDataResidue; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 30 | uint8_t bCSWStatus; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 31 | } CSW; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 32 | #pragma pack(pop) |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 33 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 34 | class msc : public FATFileSystem, public UsbBaseClass { |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 35 | public: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 36 | msc(const char* name = NULL, int drive = 0); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 37 | virtual int disk_initialize(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 38 | virtual int disk_write(const char *buffer, int block_number); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 39 | virtual int disk_read(char *buffer, int block_number); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 40 | virtual int disk_status(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 41 | virtual int disk_sync(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 42 | virtual int disk_sectors(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 43 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 44 | int setup(int timeout = 9000); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 45 | void _test(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 46 | private: |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 47 | int ParseConfiguration(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 48 | int BulkOnlyMassStorageReset(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 49 | int GetMaxLUN(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 50 | int ReadCapacity(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 51 | int GetSenseInfo(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 52 | int TestUnitReady(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 53 | int Inquire(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 54 | int MS_BulkRecv(uint32_t block_number, int num_blocks, uint8_t* user_buffer); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 55 | int MS_BulkSend(uint32_t block_number, int num_blocks, uint8_t* user_buffer); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 56 | int CommandTransport(const uint8_t* cdb, int size); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 57 | int StatusTransport(); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 58 | int _bulkRecv(uint8_t* buf, int size); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 59 | int _bulkSend(uint8_t* buf, int size); |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 60 | const char* m_name; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 61 | int m_drive; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 62 | uint32_t m_numBlocks; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 63 | int m_BlockSize; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 64 | int m_lun; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 65 | int m_MaxLUN; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 66 | int m_interface; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 67 | uint32_t m_tag; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 68 | CBW m_CBW; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 69 | CSW m_CSW; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 70 | UsbDevice* m_pDev; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 71 | UsbEndpoint* m_pEpBulkIn; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 72 | UsbEndpoint* m_pEpBulkOut; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 73 | }; |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 74 | |
| mbed_Cookbook_SE | 0:de03cbbcd0ff | 75 | #endif // MSC_H |