LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MassStorageClassCommon.h
Go to the documentation of this file.
1 /*
2  * @brief Common definitions and declarations for the library USB Mass Storage Class driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * Copyright(C) Dean Camera, 2011, 2012
7  * All rights reserved.
8  *
9  * @par
10  * Software that is described herein is for illustrative purposes only
11  * which provides customers with programming information regarding the
12  * LPC products. This software is supplied "AS IS" without any warranties of
13  * any kind, and NXP Semiconductors and its licensor disclaim any and
14  * all warranties, express or implied, including all implied warranties of
15  * merchantability, fitness for a particular purpose and non-infringement of
16  * intellectual property rights. NXP Semiconductors assumes no responsibility
17  * or liability for the use of the software, conveys no license or rights under any
18  * patent, copyright, mask work right, or any other intellectual property rights in
19  * or to any products. NXP Semiconductors reserves the right to make changes
20  * in the software without notification. NXP Semiconductors also makes no
21  * representation or warranty that such application will be suitable for the
22  * specified use without further testing or modification.
23  *
24  * @par
25  * Permission to use, copy, modify, and distribute this software and its
26  * documentation is hereby granted, under NXP Semiconductors' and its
27  * licensor's relevant copyrights in the software, without fee, provided that it
28  * is used in conjunction with NXP Semiconductors microcontrollers. This
29  * copyright, permission, and disclaimer notice must appear in all copies of
30  * this code.
31  */
32 
43 #ifndef _MS_CLASS_COMMON_H_
44 #define _MS_CLASS_COMMON_H_
45 
46  /* Includes: */
47  #include "../../Core/StdDescriptors.h"
48 
49  /* Enable C linkage for C++ Compilers: */
50  #if defined(__cplusplus)
51  extern "C" {
52  #endif
53 
54  /* Preprocessor Checks: */
55  #if !defined(__INCLUDE_FROM_MS_DRIVER)
56  #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.
57  #endif
58 
59  /* Macros: */
61  #define MS_CBW_SIGNATURE 0x43425355UL
62 
64  #define MS_CSW_SIGNATURE 0x53425355UL
65 
67  #define MS_COMMAND_DIR_DATA_OUT (0 << 7)
68 
70  #define MS_COMMAND_DIR_DATA_IN (1 << 7)
71 
75  #define SCSI_CMD_INQUIRY 0x12
76 
78  #define SCSI_CMD_REQUEST_SENSE 0x03
79 
81  #define SCSI_CMD_TEST_UNIT_READY 0x00
82 
84  #define SCSI_CMD_READ_CAPACITY_10 0x25
85 
87  #define SCSI_CMD_SEND_DIAGNOSTIC 0x1D
88 
90  #define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
91 
93  #define SCSI_CMD_WRITE_10 0x2A
94 
96  #define SCSI_CMD_READ_10 0x28
97 
99  #define SCSI_CMD_WRITE_6 0x0A
100 
102  #define SCSI_CMD_READ_6 0x08
103 
105  #define SCSI_CMD_VERIFY_10 0x2F
106 
108  #define SCSI_CMD_MODE_SENSE_6 0x1A
109 
111  #define SCSI_CMD_MODE_SENSE_10 0x5A
112 
113 
117  #define SCSI_SENSE_KEY_GOOD 0x00
118 
120  #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01
121 
123  #define SCSI_SENSE_KEY_NOT_READY 0x02
124 
126  #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03
127 
129  #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04
130 
132  #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05
133 
137  #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06
138 
140  #define SCSI_SENSE_KEY_DATA_PROTECT 0x07
141 
143  #define SCSI_SENSE_KEY_BLANK_CHECK 0x08
144 
146  #define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09
147 
149  #define SCSI_SENSE_KEY_COPY_ABORTED 0x0A
150 
152  #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B
153 
155  #define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D
156 
158  #define SCSI_SENSE_KEY_MISCOMPARE 0x0E
159 
160 
164  #define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION 0x00
165 
167  #define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY 0x04
168 
170  #define SCSI_ASENSE_INVALID_FIELD_IN_CDB 0x24
171 
175  #define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE 0x28
176 
178  #define SCSI_ASENSE_WRITE_PROTECTED 0x27
179 
181  #define SCSI_ASENSE_FORMAT_ERROR 0x31
182 
184  #define SCSI_ASENSE_INVALID_COMMAND 0x20
185 
187  #define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21
188 
190  #define SCSI_ASENSE_MEDIUM_NOT_PRESENT 0x3A
191 
192 
196  #define SCSI_ASENSEQ_NO_QUALIFIER 0x00
197 
199  #define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED 0x01
200 
204  #define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED 0x02
205 
207  #define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07
208 
209 
210  /* Enums: */
215  {
226  };
227 
230  {
237  };
238 
241  {
247  };
248 
249  /* Type Defines: */
256  typedef ATTR_IAR_PACKED struct
257  {
261  uint8_t Flags;
262  uint8_t LUN;
264  uint8_t SCSICommandData[16];
266 
273  typedef ATTR_IAR_PACKED struct
274  {
276  uint32_t Tag;
278  uint8_t Status;
280 
288  typedef ATTR_IAR_PACKED struct
289  {
290  uint8_t ResponseCode;
291 
292  uint8_t SegmentNumber;
293 
294  unsigned SenseKey : 4;
295  unsigned Reserved : 1;
296  unsigned ILI : 1;
297  unsigned EOM : 1;
298  unsigned FileMark : 1;
299 
300  uint8_t Information[4];
306  uint8_t SenseKeySpecific[3];
308 
317  typedef ATTR_IAR_PACKED struct
318  {
319  unsigned DeviceType : 5;
320  unsigned PeripheralQualifier : 3;
321 
322  unsigned Reserved : 7;
323  unsigned Removable : 1;
324 
325  uint8_t Version;
326 
327  unsigned ResponseDataFormat : 4;
328  unsigned Reserved2 : 1;
329  unsigned NormACA : 1;
330  unsigned TrmTsk : 1;
331  unsigned AERC : 1;
332 
333  uint8_t AdditionalLength;
334  uint8_t Reserved3[2];
335 
336  unsigned SoftReset : 1;
337  unsigned CmdQue : 1;
338  unsigned Reserved4 : 1;
339  unsigned Linked : 1;
340  unsigned Sync : 1;
341  unsigned WideBus16Bit : 1;
342  unsigned WideBus32Bit : 1;
343  unsigned RelAddr : 1;
344 
345  uint8_t VendorID[8];
346  uint8_t ProductID[16];
347  uint8_t RevisionID[4];
349 
350  /* Disable C linkage for C++ Compilers: */
351  #if defined(__cplusplus)
352  }
353  #endif
354 
355 #endif
356