![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Writing data to and from a USB stick
USBHostLite/usbhost_ms.h@0:5934350323b2, 2011-11-06 (annotated)
- Committer:
- ms523
- Date:
- Sun Nov 06 15:45:12 2011 +0000
- Revision:
- 0:5934350323b2
Working with a USB stick
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ms523 | 0:5934350323b2 | 1 | /* |
ms523 | 0:5934350323b2 | 2 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 3 | * NXP USB Host Stack |
ms523 | 0:5934350323b2 | 4 | * |
ms523 | 0:5934350323b2 | 5 | * (c) Copyright 2008, NXP SemiConductors |
ms523 | 0:5934350323b2 | 6 | * (c) Copyright 2008, OnChip Technologies LLC |
ms523 | 0:5934350323b2 | 7 | * All Rights Reserved |
ms523 | 0:5934350323b2 | 8 | * |
ms523 | 0:5934350323b2 | 9 | * www.nxp.com |
ms523 | 0:5934350323b2 | 10 | * www.onchiptech.com |
ms523 | 0:5934350323b2 | 11 | * |
ms523 | 0:5934350323b2 | 12 | * File : usbhost_ms.h |
ms523 | 0:5934350323b2 | 13 | * Programmer(s) : Ravikanth.P |
ms523 | 0:5934350323b2 | 14 | * Version : |
ms523 | 0:5934350323b2 | 15 | * |
ms523 | 0:5934350323b2 | 16 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 17 | */ |
ms523 | 0:5934350323b2 | 18 | |
ms523 | 0:5934350323b2 | 19 | #ifndef USBHOST_MS_H |
ms523 | 0:5934350323b2 | 20 | #define USBHOST_MS_H |
ms523 | 0:5934350323b2 | 21 | |
ms523 | 0:5934350323b2 | 22 | /* |
ms523 | 0:5934350323b2 | 23 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 24 | * INCLUDE HEADER FILES |
ms523 | 0:5934350323b2 | 25 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 26 | */ |
ms523 | 0:5934350323b2 | 27 | |
ms523 | 0:5934350323b2 | 28 | #include "usbhost_inc.h" |
ms523 | 0:5934350323b2 | 29 | |
ms523 | 0:5934350323b2 | 30 | /* |
ms523 | 0:5934350323b2 | 31 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 32 | * MASS STORAGE SPECIFIC DEFINITIONS |
ms523 | 0:5934350323b2 | 33 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 34 | */ |
ms523 | 0:5934350323b2 | 35 | |
ms523 | 0:5934350323b2 | 36 | #define MS_GET_MAX_LUN_REQ 0xFE |
ms523 | 0:5934350323b2 | 37 | #define MASS_STORAGE_CLASS 0x08 |
ms523 | 0:5934350323b2 | 38 | #define MASS_STORAGE_SUBCLASS_SCSI 0x06 |
ms523 | 0:5934350323b2 | 39 | #define MASS_STORAGE_PROTOCOL_BO 0x50 |
ms523 | 0:5934350323b2 | 40 | |
ms523 | 0:5934350323b2 | 41 | #define INQUIRY_LENGTH 36 |
ms523 | 0:5934350323b2 | 42 | /* |
ms523 | 0:5934350323b2 | 43 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 44 | * SCSI SPECIFIC DEFINITIONS |
ms523 | 0:5934350323b2 | 45 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 46 | */ |
ms523 | 0:5934350323b2 | 47 | |
ms523 | 0:5934350323b2 | 48 | #define CBW_SIGNATURE 0x43425355 |
ms523 | 0:5934350323b2 | 49 | #define CSW_SIGNATURE 0x53425355 |
ms523 | 0:5934350323b2 | 50 | #define CBW_SIZE 31 |
ms523 | 0:5934350323b2 | 51 | #define CSW_SIZE 13 |
ms523 | 0:5934350323b2 | 52 | #define CSW_CMD_PASSED 0x00 |
ms523 | 0:5934350323b2 | 53 | #define SCSI_CMD_REQUEST_SENSE 0x03 |
ms523 | 0:5934350323b2 | 54 | #define SCSI_CMD_TEST_UNIT_READY 0x00 |
ms523 | 0:5934350323b2 | 55 | #define SCSI_CMD_INQUIRY 0x12 |
ms523 | 0:5934350323b2 | 56 | #define SCSI_CMD_READ_10 0x28 |
ms523 | 0:5934350323b2 | 57 | #define SCSI_CMD_READ_CAPACITY 0x25 |
ms523 | 0:5934350323b2 | 58 | #define SCSI_CMD_WRITE_10 0x2A |
ms523 | 0:5934350323b2 | 59 | |
ms523 | 0:5934350323b2 | 60 | /* |
ms523 | 0:5934350323b2 | 61 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 62 | * TYPE DEFINITIONS |
ms523 | 0:5934350323b2 | 63 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 64 | */ |
ms523 | 0:5934350323b2 | 65 | |
ms523 | 0:5934350323b2 | 66 | typedef enum ms_data_dir { |
ms523 | 0:5934350323b2 | 67 | |
ms523 | 0:5934350323b2 | 68 | MS_DATA_DIR_IN = 0x80, |
ms523 | 0:5934350323b2 | 69 | MS_DATA_DIR_OUT = 0x00, |
ms523 | 0:5934350323b2 | 70 | MS_DATA_DIR_NONE = 0x01 |
ms523 | 0:5934350323b2 | 71 | |
ms523 | 0:5934350323b2 | 72 | } MS_DATA_DIR; |
ms523 | 0:5934350323b2 | 73 | |
ms523 | 0:5934350323b2 | 74 | /* |
ms523 | 0:5934350323b2 | 75 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 76 | * FUNCTION PROTOTYPES |
ms523 | 0:5934350323b2 | 77 | ************************************************************************************************************** |
ms523 | 0:5934350323b2 | 78 | */ |
ms523 | 0:5934350323b2 | 79 | |
ms523 | 0:5934350323b2 | 80 | USB_INT32S MS_BulkRecv ( USB_INT32U block_number, |
ms523 | 0:5934350323b2 | 81 | USB_INT16U num_blocks, |
ms523 | 0:5934350323b2 | 82 | volatile USB_INT08U *user_buffer); |
ms523 | 0:5934350323b2 | 83 | |
ms523 | 0:5934350323b2 | 84 | USB_INT32S MS_BulkSend ( USB_INT32U block_number, |
ms523 | 0:5934350323b2 | 85 | USB_INT16U num_blocks, |
ms523 | 0:5934350323b2 | 86 | volatile USB_INT08U *user_buffer); |
ms523 | 0:5934350323b2 | 87 | USB_INT32S MS_ParseConfiguration(void); |
ms523 | 0:5934350323b2 | 88 | USB_INT32S MS_TestUnitReady (void); |
ms523 | 0:5934350323b2 | 89 | USB_INT32S MS_ReadCapacity (USB_INT32U *numBlks, USB_INT32U *blkSize); |
ms523 | 0:5934350323b2 | 90 | USB_INT32S MS_GetMaxLUN (void); |
ms523 | 0:5934350323b2 | 91 | USB_INT32S MS_GetSenseInfo (void); |
ms523 | 0:5934350323b2 | 92 | USB_INT32S MS_Init (USB_INT32U *blkSize, USB_INT32U *numBlks, USB_INT08U *inquiryResult); |
ms523 | 0:5934350323b2 | 93 | USB_INT32S MS_Inquire (USB_INT08U *response); |
ms523 | 0:5934350323b2 | 94 | |
ms523 | 0:5934350323b2 | 95 | void Fill_MSCommand ( USB_INT32U block_number, |
ms523 | 0:5934350323b2 | 96 | USB_INT32U block_size, |
ms523 | 0:5934350323b2 | 97 | USB_INT16U num_blocks, |
ms523 | 0:5934350323b2 | 98 | MS_DATA_DIR direction, |
ms523 | 0:5934350323b2 | 99 | USB_INT08U scsi_cmd, |
ms523 | 0:5934350323b2 | 100 | USB_INT08U scsi_cmd_len); |
ms523 | 0:5934350323b2 | 101 | #endif |