]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/LPCOpen/LPCUSBLib/Drivers/USB/Class/Device/MassStorageClassDevice.h
Update LPC18xx FreeRTOS+UDP demo to use LPCOpen USB and Ethernet drivers.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / LPCOpen / LPCUSBLib / Drivers / USB / Class / Device / MassStorageClassDevice.h
1 /*\r
2  * @brief Device mode driver for the library USB Mass Storage Class driver\r
3  *\r
4  * @note\r
5  * Copyright(C) NXP Semiconductors, 2012\r
6  * Copyright(C) Dean Camera, 2011, 2012\r
7  * All rights reserved.\r
8  *\r
9  * @par\r
10  * Software that is described herein is for illustrative purposes only\r
11  * which provides customers with programming information regarding the\r
12  * LPC products.  This software is supplied "AS IS" without any warranties of\r
13  * any kind, and NXP Semiconductors and its licensor disclaim any and\r
14  * all warranties, express or implied, including all implied warranties of\r
15  * merchantability, fitness for a particular purpose and non-infringement of\r
16  * intellectual property rights.  NXP Semiconductors assumes no responsibility\r
17  * or liability for the use of the software, conveys no license or rights under any\r
18  * patent, copyright, mask work right, or any other intellectual property rights in\r
19  * or to any products. NXP Semiconductors reserves the right to make changes\r
20  * in the software without notification. NXP Semiconductors also makes no\r
21  * representation or warranty that such application will be suitable for the\r
22  * specified use without further testing or modification.\r
23  *\r
24  * @par\r
25  * Permission to use, copy, modify, and distribute this software and its\r
26  * documentation is hereby granted, under NXP Semiconductors' and its\r
27  * licensor's relevant copyrights in the software, without fee, provided that it\r
28  * is used in conjunction with NXP Semiconductors microcontrollers.  This\r
29  * copyright, permission, and disclaimer notice must appear in all copies of\r
30  * this code.\r
31  */\r
32 \r
33 /** @ingroup Group_USBClassMS\r
34  *  @defgroup Group_USBClassMSDevice Mass Storage Class Device Mode Driver\r
35  *\r
36  *  @section Sec_Dependencies Module Source Dependencies\r
37  *  The following files must be built with any user project that uses this module:\r
38  *    - nxpUSBlib/Drivers/USB/Class/Device/MassStorage.c <i>(Makefile source module name: NXPUSBLIB_SRC_USBCLASS)</i>\r
39  *\r
40  *  @section Sec_ModDescription Module Description\r
41  *  Device Mode USB Class driver framework interface, for the Mass Storage USB Class driver.\r
42  *\r
43  * @{\r
44  */\r
45 \r
46 #ifndef _MS_CLASS_DEVICE_H_\r
47 #define _MS_CLASS_DEVICE_H_\r
48 \r
49 /* Includes: */\r
50                 #include "../../USB.h"\r
51                 #include "../Common/MassStorageClassCommon.h"\r
52 \r
53 /* Enable C linkage for C++ Compilers: */\r
54                 #if defined(__cplusplus)\r
55 extern "C" {\r
56                 #endif\r
57 \r
58 /* Preprocessor Checks: */\r
59                 #if !defined(__INCLUDE_FROM_MS_DRIVER)\r
60                         #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.\r
61                 #endif\r
62 \r
63 /* Public Interface - May be used in end-application: */\r
64 /* Type Defines: */\r
65 /**\r
66  * @brief Mass Storage Class Device Mode Configuration and State Structure.\r
67  *\r
68  *  Class state structure. An instance of this structure should be made for each Mass Storage interface\r
69  *  within the user application, and passed to each of the Mass Storage class driver functions as the\r
70  *  \c MSInterfaceInfo parameter. This stores each Mass Storage interface's configuration and state information.\r
71  */\r
72 typedef struct {\r
73         const struct {\r
74                 uint8_t  InterfaceNumber;                               /**< Interface number of the Mass Storage interface within the device. */\r
75 \r
76                 uint8_t  DataINEndpointNumber;                          /**< Endpoint number of the Mass Storage interface's IN data endpoint. */\r
77                 uint16_t DataINEndpointSize;                    /**< Size in bytes of the Mass Storage interface's IN data endpoint. */\r
78                 bool     DataINEndpointDoubleBank;                              /**< Indicates if the Mass Storage interface's IN data endpoint should use double banking. */\r
79 \r
80                 uint8_t  DataOUTEndpointNumber;                         /**< Endpoint number of the Mass Storage interface's OUT data endpoint. */\r
81                 uint16_t DataOUTEndpointSize;                           /**< Size in bytes of the Mass Storage interface's OUT data endpoint. */\r
82                 bool     DataOUTEndpointDoubleBank;                             /**< Indicates if the Mass Storage interface's OUT data endpoint should use double banking. */\r
83 \r
84                 uint8_t  TotalLUNs;                             /**< Total number of logical drives in the Mass Storage interface. */\r
85                 uint8_t  PortNumber;                            /**< Port number that this interface is running.*/\r
86         } Config;                               /**< Config data for the USB class interface within the device. All elements in this section\r
87                                                          *   <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
88                                                          */\r
89 \r
90         struct {\r
91                 MS_CommandBlockWrapper_t  CommandBlock;                         /**< Mass Storage class command block structure, stores the received SCSI\r
92                                                                                                                          *   command from the host which is to be processed.\r
93                                                                                                                          */\r
94                 MS_CommandStatusWrapper_t CommandStatus;                        /**< Mass Storage class command status structure, set elements to indicate\r
95                                                                                                                          *   the issued command's success or failure to the host.\r
96                                                                                                                          */\r
97                 volatile bool IsMassStoreReset;                         /**< Flag indicating that the host has requested that the Mass Storage interface be reset\r
98                                                                                                          *   and that all current Mass Storage operations should immediately abort.\r
99                                                                                                          */\r
100         } State;                        /**< State data for the USB class interface within the device. All elements in this section\r
101                                                  *   are reset to their defaults when the interface is enumerated.\r
102                                                  */\r
103 \r
104 } USB_ClassInfo_MS_Device_t;\r
105 \r
106 /* Function Prototypes: */\r
107 /**\r
108  * @brief       Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library\r
109  *  @ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
110  *  containing the given Mass Storage interface is selected.\r
111  *\r
112  * @param       MSInterfaceInfo : Pointer to a structure containing a Mass Storage Class configuration and state.\r
113  *\r
114  * @return      Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
115  */\r
116 bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
117 \r
118 /**\r
119  * @brief       Processes incoming control requests from the host, that are directed to the given Mass Storage class interface. This should be\r
120  *  linked to the library @ref EVENT_USB_Device_ControlRequest() event.\r
121  *\r
122  * @param       MSInterfaceInfo : Pointer to a structure containing a Mass Storage Class configuration and state.\r
123  * @return      Nothing\r
124  */\r
125 void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
126 \r
127 /**\r
128  * @brief       General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should\r
129  *  be called frequently in the main program loop, before the master USB management task @ref USB_USBTask().\r
130  *\r
131  * @param       MSInterfaceInfo : Pointer to a structure containing a Mass Storage configuration and state.\r
132  * @return      Nothing\r
133  */\r
134 void MS_Device_USBTask(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
135 \r
136 /**\r
137  * @brief       Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the\r
138  *  host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible\r
139  *  for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure\r
140  *  inside the Mass Storage class state structure passed as a parameter to the callback function.\r
141  *\r
142  * @param       MSInterfaceInfo : Pointer to a structure containing a Mass Storage Class configuration and state.\r
143  *\r
144  * @return      Boolean \c true if the SCSI command was successfully processed, \c false otherwise.\r
145  */\r
146 bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
147 \r
148 /* Private Interface - For use in library only: */\r
149         #if !defined(__DOXYGEN__)\r
150 /* Function Prototypes: */\r
151                         #if defined(__INCLUDE_FROM_MASSSTORAGE_DEVICE_C)\r
152 static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
153 \r
154 static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t *const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
155 \r
156                         #endif\r
157 \r
158         #endif\r
159 \r
160 /* Disable C linkage for C++ Compilers: */\r
161                 #if defined(__cplusplus)\r
162 }\r
163                 #endif\r
164 \r
165 #endif\r
166 \r
167 /** @} */\r
168 \r