| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
MassStorageClassHost.h
Go to the documentation of this file.
1 /*
2 * @brief Host mode driver 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
46 #ifndef __MS_CLASS_HOST_H__
47 #define __MS_CLASS_HOST_H__
48
49 /* Includes: */
50 #include "../../USB.h"
51 #include "../Common/MassStorageClassCommon.h"
52
53 /* Enable C linkage for C++ Compilers: */
54 #if defined(__cplusplus)
55 extern "C" {
56 #endif
57
58 /* Preprocessor Checks: */
59 #if !defined(__INCLUDE_FROM_MS_DRIVER)
60 #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.
61 #endif
62
63 /* Public Interface - May be used in end-application: */
64 /* Macros: */
66 #define MS_ERROR_LOGICAL_CMD_FAILED 0x80
67
68 /* Type Defines: */
75 typedef struct
76 {
77 struct
78 {
79 uint8_t DataINPipeNumber;
80 bool DataINPipeDoubleBank;
82 uint8_t DataOUTPipeNumber;
83 bool DataOUTPipeDoubleBank;
84 uint8_t PortNumber;
86 } Config;
89 struct
90 {
91 bool IsActive;
95 uint8_t InterfaceNumber;
97 uint16_t DataINPipeSize;
98 uint16_t DataOUTPipeSize;
100 uint32_t TransactionTag;
101 } State;
105 } USB_ClassInfo_MS_Host_t;
106
113 typedef struct
114 {
115 uint32_t Blocks;
116 uint32_t BlockSize;
117 } SCSI_Capacity_t;
118
119 /* Enums: */
120 enum MS_Host_EnumerationFailure_ErrorCodes_t
121 {
122 MS_ENUMERROR_NoError = 0,
123 MS_ENUMERROR_InvalidConfigDescriptor = 1,
124 MS_ENUMERROR_NoCompatibleInterfaceFound = 2,
125 MS_ENUMERROR_PipeConfigurationFailed = 3,
126 };
127
128 /* Function Prototypes: */
141 uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
142 uint16_t ConfigDescriptorSize,
143 void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);
144
153 uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
154
168 uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
169 uint8_t* const MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
170
183 uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
184 const uint8_t LUNIndex,
185 SCSI_Inquiry_Response_t* const InquiryData) ATTR_NON_NULL_PTR_ARG(1)
186 ATTR_NON_NULL_PTR_ARG(3);
187
195 uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
196 const uint8_t LUNIndex) ATTR_NON_NULL_PTR_ARG(1);
197
209 uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
210 const uint8_t LUNIndex,
211 SCSI_Capacity_t* const DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1)
212 ATTR_NON_NULL_PTR_ARG(3);
213
226 uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
227 const uint8_t LUNIndex,
228 SCSI_Request_Sense_Response_t* const SenseData) ATTR_NON_NULL_PTR_ARG(1)
229 ATTR_NON_NULL_PTR_ARG(3);
230
243 uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
244 const uint8_t LUNIndex,
245 const bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1);
246
261 uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
262 const uint8_t LUNIndex,
263 const uint32_t BlockAddress,
264 const uint8_t Blocks,
265 const uint16_t BlockSize,
266 void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);
267
282 uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
283 const uint8_t LUNIndex,
284 const uint32_t BlockAddress,
285 const uint8_t Blocks,
286 const uint16_t BlockSize,
287 const void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);
288
289 /* Inline Functions: */
297 static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;
298 static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)
299 {
300 (void)MSInterfaceInfo;
301 }
302
303 /* Private Interface - For use in library only: */
304 #if !defined(__DOXYGEN__)
305 /* Macros: */
306 #define MS_COMMAND_DATA_TIMEOUT_MS 10000
307
308 /* Function Prototypes: */
309 #if defined(__INCLUDE_FROM_MASSSTORAGE_HOST_C)
310 static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
311 MS_CommandBlockWrapper_t* const SCSICommandBlock,
312 const void* const BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
313 static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
314 static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
315 MS_CommandBlockWrapper_t* const SCSICommandBlock,
316 void* BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
317 static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
318 MS_CommandStatusWrapper_t* const SCSICommandStatus)
319 ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
320
321 static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)
322 ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
323 static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor)
324 ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);
325 #endif
326 #endif
327
328 /* Disable C linkage for C++ Compilers: */
329 #if defined(__cplusplus)
330 }
331 #endif
332
333 #endif
334