This program is an example of of using the MSCUSBHost code with a raw build of ELM Chan Fat Fs. This was done to add both Long File Name Support along with proper time/date stamps (assuming you have a battery hooked up to keep time). This code exposes the Chan API (see main.cpp) and is NOT a c++ class: http://elm-chan.org/fsw/ff/00index_e.html The diskio.c file has the mapping needed to link the filesystem to the MSC stuff
USBHostLite/usbhost_ms.h@0:2dbbafe1b1fb, 2011-01-23 (annotated)
- Committer:
- emh203
- Date:
- Sun Jan 23 18:35:43 2011 +0000
- Revision:
- 0:2dbbafe1b1fb
1st test version. Test with raw mbed and Samtec USB-RA type A connector wired directly to pins.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emh203 | 0:2dbbafe1b1fb | 1 | /* |
emh203 | 0:2dbbafe1b1fb | 2 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 3 | * NXP USB Host Stack |
emh203 | 0:2dbbafe1b1fb | 4 | * |
emh203 | 0:2dbbafe1b1fb | 5 | * (c) Copyright 2008, NXP SemiConductors |
emh203 | 0:2dbbafe1b1fb | 6 | * (c) Copyright 2008, OnChip Technologies LLC |
emh203 | 0:2dbbafe1b1fb | 7 | * All Rights Reserved |
emh203 | 0:2dbbafe1b1fb | 8 | * |
emh203 | 0:2dbbafe1b1fb | 9 | * www.nxp.com |
emh203 | 0:2dbbafe1b1fb | 10 | * www.onchiptech.com |
emh203 | 0:2dbbafe1b1fb | 11 | * |
emh203 | 0:2dbbafe1b1fb | 12 | * File : usbhost_ms.h |
emh203 | 0:2dbbafe1b1fb | 13 | * Programmer(s) : Ravikanth.P |
emh203 | 0:2dbbafe1b1fb | 14 | * Version : |
emh203 | 0:2dbbafe1b1fb | 15 | * |
emh203 | 0:2dbbafe1b1fb | 16 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 17 | */ |
emh203 | 0:2dbbafe1b1fb | 18 | |
emh203 | 0:2dbbafe1b1fb | 19 | #ifndef USBHOST_MS_H |
emh203 | 0:2dbbafe1b1fb | 20 | #define USBHOST_MS_H |
emh203 | 0:2dbbafe1b1fb | 21 | |
emh203 | 0:2dbbafe1b1fb | 22 | /* |
emh203 | 0:2dbbafe1b1fb | 23 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 24 | * INCLUDE HEADER FILES |
emh203 | 0:2dbbafe1b1fb | 25 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 26 | */ |
emh203 | 0:2dbbafe1b1fb | 27 | |
emh203 | 0:2dbbafe1b1fb | 28 | #include "usbhost_inc.h" |
emh203 | 0:2dbbafe1b1fb | 29 | |
emh203 | 0:2dbbafe1b1fb | 30 | /* |
emh203 | 0:2dbbafe1b1fb | 31 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 32 | * MASS STORAGE SPECIFIC DEFINITIONS |
emh203 | 0:2dbbafe1b1fb | 33 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 34 | */ |
emh203 | 0:2dbbafe1b1fb | 35 | |
emh203 | 0:2dbbafe1b1fb | 36 | #define MS_GET_MAX_LUN_REQ 0xFE |
emh203 | 0:2dbbafe1b1fb | 37 | #define MASS_STORAGE_CLASS 0x08 |
emh203 | 0:2dbbafe1b1fb | 38 | #define MASS_STORAGE_SUBCLASS_SCSI 0x06 |
emh203 | 0:2dbbafe1b1fb | 39 | #define MASS_STORAGE_PROTOCOL_BO 0x50 |
emh203 | 0:2dbbafe1b1fb | 40 | |
emh203 | 0:2dbbafe1b1fb | 41 | #define INQUIRY_LENGTH 36 |
emh203 | 0:2dbbafe1b1fb | 42 | /* |
emh203 | 0:2dbbafe1b1fb | 43 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 44 | * SCSI SPECIFIC DEFINITIONS |
emh203 | 0:2dbbafe1b1fb | 45 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 46 | */ |
emh203 | 0:2dbbafe1b1fb | 47 | |
emh203 | 0:2dbbafe1b1fb | 48 | #define CBW_SIGNATURE 0x43425355 |
emh203 | 0:2dbbafe1b1fb | 49 | #define CSW_SIGNATURE 0x53425355 |
emh203 | 0:2dbbafe1b1fb | 50 | #define CBW_SIZE 31 |
emh203 | 0:2dbbafe1b1fb | 51 | #define CSW_SIZE 13 |
emh203 | 0:2dbbafe1b1fb | 52 | #define CSW_CMD_PASSED 0x00 |
emh203 | 0:2dbbafe1b1fb | 53 | #define SCSI_CMD_REQUEST_SENSE 0x03 |
emh203 | 0:2dbbafe1b1fb | 54 | #define SCSI_CMD_TEST_UNIT_READY 0x00 |
emh203 | 0:2dbbafe1b1fb | 55 | #define SCSI_CMD_INQUIRY 0x12 |
emh203 | 0:2dbbafe1b1fb | 56 | #define SCSI_CMD_READ_10 0x28 |
emh203 | 0:2dbbafe1b1fb | 57 | #define SCSI_CMD_READ_CAPACITY 0x25 |
emh203 | 0:2dbbafe1b1fb | 58 | #define SCSI_CMD_WRITE_10 0x2A |
emh203 | 0:2dbbafe1b1fb | 59 | |
emh203 | 0:2dbbafe1b1fb | 60 | /* |
emh203 | 0:2dbbafe1b1fb | 61 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 62 | * TYPE DEFINITIONS |
emh203 | 0:2dbbafe1b1fb | 63 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 64 | */ |
emh203 | 0:2dbbafe1b1fb | 65 | |
emh203 | 0:2dbbafe1b1fb | 66 | typedef enum ms_data_dir { |
emh203 | 0:2dbbafe1b1fb | 67 | |
emh203 | 0:2dbbafe1b1fb | 68 | MS_DATA_DIR_IN = 0x80, |
emh203 | 0:2dbbafe1b1fb | 69 | MS_DATA_DIR_OUT = 0x00, |
emh203 | 0:2dbbafe1b1fb | 70 | MS_DATA_DIR_NONE = 0x01 |
emh203 | 0:2dbbafe1b1fb | 71 | |
emh203 | 0:2dbbafe1b1fb | 72 | } MS_DATA_DIR; |
emh203 | 0:2dbbafe1b1fb | 73 | |
emh203 | 0:2dbbafe1b1fb | 74 | /* |
emh203 | 0:2dbbafe1b1fb | 75 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 76 | * FUNCTION PROTOTYPES |
emh203 | 0:2dbbafe1b1fb | 77 | ************************************************************************************************************** |
emh203 | 0:2dbbafe1b1fb | 78 | */ |
emh203 | 0:2dbbafe1b1fb | 79 | |
emh203 | 0:2dbbafe1b1fb | 80 | USB_INT32S MS_BulkRecv ( USB_INT32U block_number, |
emh203 | 0:2dbbafe1b1fb | 81 | USB_INT16U num_blocks, |
emh203 | 0:2dbbafe1b1fb | 82 | volatile USB_INT08U *user_buffer); |
emh203 | 0:2dbbafe1b1fb | 83 | |
emh203 | 0:2dbbafe1b1fb | 84 | USB_INT32S MS_BulkSend ( USB_INT32U block_number, |
emh203 | 0:2dbbafe1b1fb | 85 | USB_INT16U num_blocks, |
emh203 | 0:2dbbafe1b1fb | 86 | volatile USB_INT08U *user_buffer); |
emh203 | 0:2dbbafe1b1fb | 87 | USB_INT32S MS_ParseConfiguration(void); |
emh203 | 0:2dbbafe1b1fb | 88 | USB_INT32S MS_TestUnitReady (void); |
emh203 | 0:2dbbafe1b1fb | 89 | USB_INT32S MS_ReadCapacity (USB_INT32U *numBlks, USB_INT32U *blkSize); |
emh203 | 0:2dbbafe1b1fb | 90 | USB_INT32S MS_GetMaxLUN (void); |
emh203 | 0:2dbbafe1b1fb | 91 | USB_INT32S MS_GetSenseInfo (void); |
emh203 | 0:2dbbafe1b1fb | 92 | USB_INT32S MS_Init (USB_INT32U *blkSize, USB_INT32U *numBlks, USB_INT08U *inquiryResult); |
emh203 | 0:2dbbafe1b1fb | 93 | USB_INT32S MS_Inquire (USB_INT08U *response); |
emh203 | 0:2dbbafe1b1fb | 94 | |
emh203 | 0:2dbbafe1b1fb | 95 | void Fill_MSCommand ( USB_INT32U block_number, |
emh203 | 0:2dbbafe1b1fb | 96 | USB_INT32U block_size, |
emh203 | 0:2dbbafe1b1fb | 97 | USB_INT16U num_blocks, |
emh203 | 0:2dbbafe1b1fb | 98 | MS_DATA_DIR direction, |
emh203 | 0:2dbbafe1b1fb | 99 | USB_INT08U scsi_cmd, |
emh203 | 0:2dbbafe1b1fb | 100 | USB_INT08U scsi_cmd_len); |
emh203 | 0:2dbbafe1b1fb | 101 | #endif |